mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
+1
@@ -66,6 +66,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode FILE_ADD_ERR = new ErrorCode(1_002_029_012, "文件已经存在是否强制保存");
|
||||
ErrorCode FILE_UPLOAD_ERR = new ErrorCode(1_002_029_012, "文件内容为空");
|
||||
ErrorCode ORDER_STATUS_CONFLICT = new ErrorCode(1_002_029_006, "生产单状态冲突,禁止投入生产");
|
||||
ErrorCode ORDER_READ_ERR = new ErrorCode(1_002_029_006, "订单列表获取失败,请刷新重试");
|
||||
|
||||
ErrorCode SOURCE_NOT_EXITS_ERROR = new ErrorCode(1_002_029_013, "源数据查询失败");
|
||||
ErrorCode ORDER_CAN_NOT_DELETE = new ErrorCode(1_002_029_013, "存在状态不符合强制删除的生产单,禁止删除");
|
||||
|
||||
+29
-5
@@ -26,6 +26,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
@@ -224,7 +225,7 @@ public class OrderController {
|
||||
throws InterruptedException, ExecutionException {
|
||||
|
||||
Long organId = SecurityFrameworkUtils.getLoginUser().getOrganId();
|
||||
String token = apiDataAchieve.getApiToken(organId);
|
||||
String token = apiDataAchieve.getApiToken(organId).get().getJSONObject("info").getString("access_token");
|
||||
JSONObject dataPlates = apiDataAchieve.getApiPlateProData(token, orderNo).get();
|
||||
if (!dataPlates.getString("err_code").equals("0")) {
|
||||
throw exception(PLATE_PLAN_DATA_ERROR);
|
||||
@@ -273,11 +274,11 @@ public class OrderController {
|
||||
System.err.println(excelReadUtil.isErr());
|
||||
// 判断是否读取有误
|
||||
if (excelReadUtil.isErr() == -1) { // 文件为空
|
||||
ExcelWriterUtil.writeErr(response, "生产单内容为空", orderService.getSavePath() + File.separator + "错误文件.xlsx");
|
||||
ExcelWriterUtil.writeErr(response, "生产单内容为空", orderService.getSavePath() + File.separator + "order_err.xlsx");
|
||||
return;
|
||||
} else if (excelReadUtil.isErr() > 0) {
|
||||
// 返回文件
|
||||
ExcelWriterUtil.write(response, (Map<Object, Object>) map.get("order"), (List<OrderPlateImportExcelVO>) map.get("plate"), orderService.getSavePath() + File.separator + "生产单Excel导入错误导出模板.xlsx");
|
||||
ExcelWriterUtil.write(response, (Map<Object, Object>) map.get("order"), (List<OrderPlateImportExcelVO>) map.get("plate"), orderService.getSavePath() + File.separator + "order_add_excel_err.xlsx");
|
||||
return;
|
||||
} else {
|
||||
// 获取数据
|
||||
@@ -293,7 +294,7 @@ public class OrderController {
|
||||
err += orderDO.getCustomOrderNo() + "-自定义生产单号已存在;";
|
||||
}
|
||||
if (!err.equals("")) {
|
||||
ExcelWriterUtil.writeErr(response, err, orderService.getSavePath() + File.separator + "错误文件.xlsx");
|
||||
ExcelWriterUtil.writeErr(response, err, orderService.getSavePath() + File.separator + "order_err.xlsx");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -304,7 +305,7 @@ public class OrderController {
|
||||
}
|
||||
orderService.importExcelData(orderDO, list);
|
||||
} catch (Exception e) {
|
||||
ExcelWriterUtil.writeErr(response, "系统出现未知错误,请下载模板,按照模板重新上传文件", orderService.getSavePath() + File.separator + "错误文件.xlsx");
|
||||
ExcelWriterUtil.writeErr(response, "系统出现未知错误,请下载模板,按照模板重新上传文件", orderService.getSavePath() + File.separator + "order_err.xlsx");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,4 +342,27 @@ public class OrderController {
|
||||
|
||||
return success(orderService.getPrintDataMap(orderId, type, response));
|
||||
}
|
||||
|
||||
// 获取api订单接口
|
||||
@GetMapping("/getApiOrder")
|
||||
@Operation(summary = "获取api订单接口")
|
||||
@Parameters({
|
||||
@Parameter(name = "startTime", description = "开始时间", required = false),
|
||||
@Parameter(name = "endTime", description = "结束时间", required = false),
|
||||
@Parameter(name = "orderNo", description = "订单号", required = false),
|
||||
@Parameter(name = "customOrderNo", description = "自定义单号", required = false)
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('production:manager-list:detail')")
|
||||
public CommonResult<List<ApiOrderRespVO>> getApiOrder(@RequestParam(value = "startTime", required = false) String startTime,
|
||||
@RequestParam(value = "endTime", required = false) String endTime,
|
||||
@RequestParam(value = "orderNo", required = false) String orderNo,
|
||||
@RequestParam(value = "customOrderNo", required = false) String customOrderNo)
|
||||
throws ExecutionException, InterruptedException {
|
||||
Long organId = SecurityFrameworkUtils.getLoginUser().getOrganId();
|
||||
JSONObject oauth = apiDataAchieve.getApiToken(organId).get();
|
||||
String token = oauth.getJSONObject("info").getString("access_token");
|
||||
String shopId = oauth.getJSONObject("info").getString("shop_id");
|
||||
JSONObject orderList = apiDataAchieve.getApiOrderList(token,shopId,startTime,endTime,orderNo,customOrderNo).get();
|
||||
return success(orderService.getApiOrderList(orderList));
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.cf.imes.module.executor.controller.admin.order.vo.order;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
@Schema(description = "管理后台 - api生产单获取列表")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString(callSuper = true)
|
||||
public class ApiOrderRespVO {
|
||||
|
||||
@Schema(description = "订单编号")
|
||||
private String order_no;
|
||||
|
||||
@Schema(description = "自定义单号")
|
||||
private String custom_order_no;
|
||||
|
||||
@Schema(description = "门店名称")
|
||||
private String store_name;
|
||||
|
||||
@Schema(description = "门店电话")
|
||||
private String store_phone;
|
||||
|
||||
@Schema(description = "客户名称")
|
||||
private String cosignee_name;
|
||||
|
||||
@Schema(description = "客户电话")
|
||||
private String cosignee_phone;
|
||||
|
||||
@Schema(description = "客户地址")
|
||||
private String cosignee_address;
|
||||
|
||||
@Schema(description = "订单开始时间")
|
||||
private String start_date;
|
||||
|
||||
@Schema(description = "订单结束时间")
|
||||
private String end_date;
|
||||
|
||||
@Schema(description = "订单状态")
|
||||
private String order_state;
|
||||
|
||||
@Schema(description = "平台状态")
|
||||
private String submit_state;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String comments;
|
||||
|
||||
@Schema(description = "业务员标识")
|
||||
private String staff_id;
|
||||
|
||||
@Schema(description = "业务员昵称")
|
||||
private String nick_name;
|
||||
|
||||
@Schema(description = "拆单员标识")
|
||||
private String cd_user;
|
||||
|
||||
@Schema(description = "拆单员昵称")
|
||||
private String cd_nick_name;
|
||||
}
|
||||
+3
@@ -25,6 +25,9 @@ public class OrderPageReqVO extends PageParam {
|
||||
@Schema(description = "父单号")
|
||||
private Long parentNo;
|
||||
|
||||
@Schema(description = "源生产单号")
|
||||
private String apiOrderId;
|
||||
|
||||
@Schema(description = "生产单日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] orderDate;
|
||||
|
||||
+4
@@ -19,6 +19,10 @@ public class OrderRespVO {
|
||||
@ExcelProperty("父单号")
|
||||
private Long parentNo;
|
||||
|
||||
@Schema(description = "源生产单号")
|
||||
@ExcelProperty("父单号")
|
||||
private String apiOrderId;
|
||||
|
||||
@Schema(description = "生产单日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("交付日期")
|
||||
private LocalDateTime orderDate;
|
||||
|
||||
+3
@@ -18,6 +18,9 @@ public class OrderSaveReqVO {
|
||||
@Schema(description = "父单号")
|
||||
private Long parentNo;
|
||||
|
||||
@Schema(description = "源生产单号")
|
||||
private String apiOrderId;
|
||||
|
||||
@Schema(description = "生产单日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "交付日期不能为空")
|
||||
private LocalDateTime orderDate;
|
||||
|
||||
+4
@@ -37,6 +37,10 @@ public class OrderDO extends BaseDO {
|
||||
* 父单号
|
||||
*/
|
||||
private Long parentNo;
|
||||
/**
|
||||
* 源生产单号
|
||||
*/
|
||||
private String apiOrderId;
|
||||
/**
|
||||
* 生产单日期
|
||||
*/
|
||||
|
||||
+3
@@ -33,6 +33,7 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
|
||||
.eqIfPresent(OrderDO::getParentNo, reqVO.getParentNo())
|
||||
.likeIfPresent(OrderDO::getId, reqVO.getId() == null ? null : String.valueOf(reqVO.getId()))
|
||||
.betweenIfPresent(OrderDO::getDeliveryDate, reqVO.getDeliveryDate())
|
||||
.eqIfPresent(OrderDO::getApiOrderId, reqVO.getApiOrderId())
|
||||
.betweenIfPresent(OrderDO::getOrderDate, reqVO.getOrderDate())
|
||||
.eqIfPresent(OrderDO::getOrderType, reqVO.getOrderType())
|
||||
.eqIfPresent(OrderDO::getOrderSort, reqVO.getOrderSort())
|
||||
@@ -60,6 +61,7 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
|
||||
case "customOrderNo" -> query.orderByAsc(OrderDO::getCustomOrderNo);
|
||||
case "orderDate" -> query.orderByAsc(OrderDO::getOrderDate);
|
||||
case "deliveryDate" -> query.orderByAsc(OrderDO::getDeliveryDate);
|
||||
case "apiOrderId" -> query.orderByAsc(OrderDO::getApiOrderId);
|
||||
}
|
||||
}else if (reqVO.getOrder().equals("descend")) {
|
||||
switch (reqVO.getField()) {
|
||||
@@ -67,6 +69,7 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
|
||||
case "customOrderNo" -> query.orderByDesc(OrderDO::getCustomOrderNo);
|
||||
case "orderDate" -> query.orderByDesc(OrderDO::getOrderDate);
|
||||
case "deliveryDate" -> query.orderByDesc(OrderDO::getDeliveryDate);
|
||||
case "apiOrderId" -> query.orderByDesc(OrderDO::getApiOrderId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -3,6 +3,7 @@ package com.cf.imes.module.executor.service.order;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.*;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderBodyRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderRoomBodyRespVO;
|
||||
@@ -15,6 +16,7 @@ import org.springframework.boot.system.ApplicationHome;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -167,5 +169,7 @@ public interface OrderService {
|
||||
*/
|
||||
Boolean customOrderNoIsExists(String customOrderNo);
|
||||
|
||||
|
||||
/**查找api单号列表
|
||||
*/
|
||||
List<ApiOrderRespVO> getApiOrderList(JSONObject orderList);
|
||||
}
|
||||
+38
@@ -2,6 +2,8 @@ package com.cf.imes.module.executor.service.order;
|
||||
|
||||
import cn.smallbun.screw.core.util.CollectionUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
|
||||
@@ -143,6 +145,8 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
private static final int RANDOM_NUMBER_MAX = 10;
|
||||
|
||||
private static final String SUBMIT_STATE = "1"; // 空订单
|
||||
|
||||
@Override
|
||||
public Long createOrder(OrderSaveReqVO createReqVO) {
|
||||
//校验手机号是否合法
|
||||
@@ -543,6 +547,40 @@ public class OrderServiceImpl implements OrderService {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApiOrderRespVO> getApiOrderList(JSONObject orderList) {
|
||||
List<ApiOrderRespVO> apiOrderRespVOS = new ArrayList<>();
|
||||
JSONArray jsonArray = orderList.getJSONArray("data");
|
||||
if (jsonArray != null && jsonArray.size() > 0){
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
int index = jsonObject.getString("order_no").indexOf("@N");
|
||||
String order_no = jsonObject.getString("order_no").substring(index + "@N".length());
|
||||
ApiOrderRespVO apiOrderRespVO = JSON.parseObject(jsonObject.toJSONString(), ApiOrderRespVO.class).setOrder_no(order_no);
|
||||
|
||||
// 判断是否已经导入
|
||||
if (validateOrderNoExists(apiOrderRespVO.getOrder_no(), OrganContextHolder.getOrganId())){
|
||||
if (!apiOrderRespVO.getOrder_state().equals(SUBMIT_STATE)){
|
||||
apiOrderRespVOS.add(apiOrderRespVO);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return apiOrderRespVOS;
|
||||
}
|
||||
|
||||
// 判断是否已经导入
|
||||
private Boolean validateOrderNoExists(String orderNo, Long organId) {
|
||||
if (orderMapper.selectCount(new LambdaQueryWrapper<OrderDO>()
|
||||
.eq(OrderDO::getApiOrderId, orderNo)
|
||||
.eq(OrderDO::getDeleted, false)
|
||||
.eq(OrderDO::getOrganId, organId)) > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 业务员是否存在
|
||||
private void validateSalesmanOrderNoExists(String salesman, Long organId) {
|
||||
if (adminUserApi.validateUser(salesman, organId).getData() == null) {
|
||||
|
||||
+85
-3
@@ -33,7 +33,7 @@ public class ApiDataAchieve {
|
||||
private static final int PARTS_PAGE_MAX = 100;
|
||||
|
||||
// 获得token数据
|
||||
public String getApiToken(Long organId) {
|
||||
public Future<JSONObject> getApiToken(Long organId) {
|
||||
JSONObject app = applicationApi.getApplicationByOrganId(organId);
|
||||
String appId = app.getString("appId");
|
||||
String appSecret = app.getString("appSecret");
|
||||
@@ -42,8 +42,8 @@ public class ApiDataAchieve {
|
||||
if (!json.getString("err_msg").equals("success")) {
|
||||
throw exception(APP_TOKEN_ERROR);
|
||||
}
|
||||
String token = json.getJSONObject("info").getString("access_token");
|
||||
return token;
|
||||
// String token = json.getJSONObject("info").getString("access_token");
|
||||
return new AsyncResult<>(json);
|
||||
}
|
||||
|
||||
// 获取板件生产数据信息
|
||||
@@ -167,6 +167,41 @@ public class ApiDataAchieve {
|
||||
return new AsyncResult<>(block);
|
||||
}
|
||||
|
||||
// 订单列表
|
||||
public Future<JSONObject> getApiOrderList(String token,String shopId,String createDateMin, String createDateMax, String orderNo, String customOrderNo) {
|
||||
JSONObject jsonOrders = new JSONObject();
|
||||
if (createDateMin != null){
|
||||
jsonOrders.put("create_date_min", createDateMin);
|
||||
}
|
||||
if (createDateMax != null) {
|
||||
jsonOrders.put("create_date_max", createDateMax);
|
||||
}
|
||||
|
||||
jsonOrders.put("curr_page", 1);
|
||||
jsonOrders.put("page_count", PARTS_PAGE_MAX);
|
||||
|
||||
if (orderNo != null) {
|
||||
jsonOrders.put("order_no", shopId + "@N" +orderNo);
|
||||
}
|
||||
if (customOrderNo != null){
|
||||
jsonOrders.put("custom_order_no", customOrderNo);
|
||||
}
|
||||
|
||||
JSONObject orders = apiDataProduction.getApiOrderList(token, jsonOrders);
|
||||
System.out.println(" jsonOrders " + jsonOrders);
|
||||
System.out.println(" orders " + orders);
|
||||
if (!orders.getString("err_code").equals("0")) {
|
||||
throw exception(ORDER_READ_ERR);
|
||||
}
|
||||
JSONObject order = new JSONObject();
|
||||
int countPage = divideWithPlusOne(orders.getInteger("count"), PARTS_PAGE_MAX);
|
||||
for (int i = 1; i <= countPage; i++) {
|
||||
jsonOrders.put("curr_page", i);
|
||||
JSONObject value = apiDataProduction.getApiOrderList(token, jsonOrders);
|
||||
order = mergeData(order, value);
|
||||
}
|
||||
return new AsyncResult<>(order);
|
||||
}
|
||||
|
||||
public JSONObject mergeJSONObjects(JSONObject object1, JSONObject object2) {
|
||||
|
||||
@@ -203,5 +238,52 @@ public class ApiDataAchieve {
|
||||
return mergedObj;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int divideWithPlusOne(int dividend, int divisor) {
|
||||
// 首先检查除数是否为0,避免除以0的异常
|
||||
if (divisor == 0) {
|
||||
throw new IllegalArgumentException("除数不能为0");
|
||||
}
|
||||
|
||||
// 计算商和余数
|
||||
int quotient = dividend / divisor; // 商
|
||||
int remainder = dividend % divisor; // 余数
|
||||
|
||||
// 如果余数不为0,则商加一
|
||||
if (remainder != 0) {
|
||||
quotient++;
|
||||
}
|
||||
|
||||
return quotient;
|
||||
}
|
||||
|
||||
public JSONObject mergeData(JSONObject object1, JSONObject object2) {
|
||||
|
||||
// 创建新对象
|
||||
JSONObject mergedObj = new JSONObject();
|
||||
// 合并 List 属性
|
||||
JSONArray mergedList = new JSONArray();
|
||||
JSONArray list1 = null;
|
||||
if (object1.getJSONArray("data") != null) {
|
||||
list1 = object1.getJSONArray("data");
|
||||
if (list1 != null) {
|
||||
for (int i = 0; i < list1.size(); i++) {
|
||||
mergedList.add(list1.getJSONObject(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
JSONArray list2 = object2.getJSONArray("data");
|
||||
if (list2 != null) {
|
||||
for (int i = 0; i < list2.size(); i++) {
|
||||
mergedList.add(list2.getJSONObject(i));
|
||||
}
|
||||
}
|
||||
|
||||
mergedObj.put("data", mergedList);
|
||||
// System.out.println(mergedObj);
|
||||
return mergedObj;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -40,4 +40,8 @@ public interface ApiDataProduction {
|
||||
// 板件数据
|
||||
@RequestMapping(value = "/Api-erpOrders-getBlocks",method = RequestMethod.POST)
|
||||
JSONObject getApiBlocksMessage(@RequestParam("token") String token, @RequestBody JSONObject json);
|
||||
|
||||
// 订单列表
|
||||
@RequestMapping(value = "/Api-erpOrders-orderList",method = RequestMethod.POST)
|
||||
JSONObject getApiOrderList(@RequestParam("token") String token, @RequestBody JSONObject json);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user