新火炬后端单体项目初始化代码
zhangherong
3 天以前 d4a7b1faad635b4817891185a4f471595db2eece
src/main/java/org/jeecg/modules/mes/job/ProductionOrderSyncCreationJob.java
@@ -1,6 +1,8 @@
package org.jeecg.modules.mes.job;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.modules.lsw.service.ILswMaterialService;
import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecg.modules.mdc.util.ThrowableUtil;
import org.jeecg.modules.mes.entity.MesProductionOrder;
@@ -22,6 +24,7 @@
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
@@ -33,7 +36,8 @@
@Slf4j
public class ProductionOrderSyncCreationJob implements Job {
    //工厂编码(新火炬 2301)
    private static final String FACTORY_CODE = "2301";
    @Value("${xhj.factoryCode:2301}")
    private String FACTORY_CODE;
    /**
     * 订单类型
     * 标准生产订单 Z001
@@ -42,7 +46,8 @@
     * 试制生产订单(新火炬)  Z011
     * 拆零生产订单(新火炬)  2012
     */
    private static final String ORDER_TYPE_CODE = "Z001";
    @Value("${xhj.orderType:Z001}")
    private String ORDER_TYPE_CODE;
    /**
     * 生产调度员
     * 001 一分厂调度员
@@ -57,19 +62,16 @@
     * 010 六厂调度员
     * 012 八分厂调度员
     */
    private static final String PRODUCTION_MANAGER = "010";
    @Value("${xhj.productionManager:012}")
    private String PRODUCTION_MANAGER;
    /**
     * 生产订单状态,实际上,只有REL状态的工单才可以进行操作
     * CRTD 新建
     * REL 下达
     * TECO 关闭
     */
    private static final String ORDER_STATUS = "REL";
    /**
     * 请求成功编码
     */
    private static final String SUCCESS_CODE = "S";
    @Value("${xhj.orderStatus:REL}")
    private String ORDER_STATUS;
    @Autowired
    private ProductionOrderSync productionOrderSync;
@@ -87,6 +89,8 @@
    private ISysQuartzLogService sysQuartzLogService;
    @Autowired
    private IQuartzJobService quartzJobService;
    @Autowired
    private ILswMaterialService lswMaterialService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
@@ -117,7 +121,7 @@
        try {
            //调用SAP接口获取生产订单
            Map<String, Object> productionOrderMap = productionOrderSync.syncProductionOrder(request);
            if (productionOrderMap == null || !SUCCESS_CODE.equals(productionOrderMap.get("ztype"))) {
            if (productionOrderMap == null || !CommonConstant.SAP_SUCCESS_CODE.equals(productionOrderMap.get("ztype"))) {
                log.error("未同步到订单信息!日期:{}", LocalDateTime.now());
                return;
            }
@@ -133,7 +137,7 @@
            String orderCodes = String.join(",", orderMap.keySet());
            //订单BOM同步
            Map<String, Object> orderBomMap = orderBomSync.syncOrderBom(FACTORY_CODE, orderCodes);
            if (orderBomMap == null || !SUCCESS_CODE.equals(orderBomMap.get("ztype"))) {
            if (orderBomMap == null || !CommonConstant.SAP_SUCCESS_CODE.equals(orderBomMap.get("ztype"))) {
                log.error("未同步到订单BOM信息!日期:{}", LocalDateTime.now());
                return;
            }
@@ -144,15 +148,22 @@
                log.error("返回类型错误, class:{}", result == null ? null : result.getClass());
                return;
            }
            //订单BOM数据处理
            List<OrderBomDTO> orderBomDTOList = (List<OrderBomDTO>) result;
            b = processBillMaterialsService.saveOrUpdateOrderBom(orderMap, orderBomDTOList);
            if (!b) {
                log.error("保存订单BOM失败,日期:{}", LocalDateTime.now());
                return;
            }
            //物料数据处理
            b = lswMaterialService.saveOrUpdateMaterial(orderMap, orderBomDTOList);
            if (!b) {
                log.error("保存物料失败,日期:{}", LocalDateTime.now());
                return;
            }
            //订单工序同步
            Map<String, Object> orderProcessMap = orderProcessSync.syncOrderProcess(FACTORY_CODE, orderCodes);
            if (orderBomMap == null || !SUCCESS_CODE.equals(orderProcessMap.get("ztype"))) {
            if (orderBomMap == null || !CommonConstant.SAP_SUCCESS_CODE.equals(orderProcessMap.get("ztype"))) {
                log.error("未同步到订单工序信息!日期:{}", LocalDateTime.now());
                return;
            }