zouyu
2023-11-15 27879ae8c1df7ff014858456b17996cf62d34f9b
mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/CustomerOrderServiceImpl.java
@@ -28,6 +28,7 @@
import com.chinaztt.mes.basic.entity.Part;
import com.chinaztt.mes.basic.mapper.PartMapper;
import com.chinaztt.mes.basic.mapper.StaffMapper;
import com.chinaztt.mes.basic.mapper.UserServiceMapper;
import com.chinaztt.mes.basic.util.RedisUtils;
import com.chinaztt.mes.common.handler.StateMachineHandler;
import com.chinaztt.mes.common.numgen.NumberGenerator;
@@ -36,6 +37,7 @@
import com.chinaztt.mes.common.oa.OAResult;
import com.chinaztt.mes.common.util.StateResult;
import com.chinaztt.mes.common.util.WechatMsgTips;
import com.chinaztt.mes.common.util.easyexcel.EasyExcelUtils;
import com.chinaztt.mes.common.wechat.WechatProperty;
import com.chinaztt.mes.plan.dto.*;
import com.chinaztt.mes.plan.entity.*;
@@ -50,6 +52,8 @@
import com.chinaztt.mes.plan.util.CustomerOrderClientConfigure;
import com.chinaztt.mes.plan.util.CustomerOrderUnitWhiteListConfig;
import com.chinaztt.mes.plan.util.CustomerOrderUtil;
import com.chinaztt.mes.plan.util.FileSaveUtil;
import com.chinaztt.mes.plan.vo.CustomerOrderVO1;
import com.chinaztt.mes.quality.dto.CustomOrderSyncDTO;
import com.chinaztt.mes.technology.entity.*;
import com.chinaztt.mes.technology.mapper.*;
@@ -95,6 +99,7 @@
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
@@ -176,6 +181,7 @@
   private WechatProperty wechatProperty;
   private UserServiceMapper userServiceMapper;
   private final OssProperties ossProperties;
   private final OssTemplate minioTemplate;
@@ -183,6 +189,14 @@
   private final static String MO_RETURN_STAFF = "MO_RETURN_STAFF";
   private Environment environment;
   private final static String OTC_MAIN_STATUS_CANCEL = "已取消";
   private final static String OTC_MAIN_STATUS_TRANSMIT = "已下达";
   private final static String AFFILIATED_CONTRACT = "中天注塑厂";
   @Override
   public void otcDownload(Long id, HttpServletResponse response) {
@@ -208,9 +222,12 @@
   @Override
   public IPage getCustomerOrderPage(Page page, QueryWrapper<CustomerOrder> planCustomerOrder, String type) {
      IPage iPage = baseMapper.getCustomerOrderPage(page, planCustomerOrder, type);
      return iPage;
      //ZttUser currentUser = SecurityUtils.getUser();
      ////获取员工id
      //Long staffId = userServiceMapper.selectById(currentUser.getId()).getStaffId();
      return customerOrderMapper.getCustomerOrderPage(page, planCustomerOrder);
   }
   @Override
   public boolean changeMarkPlanned(List<Long> ids, String coState) {
@@ -322,39 +339,25 @@
   @Override
   public CustomerOrderDTO getCustomerOrderById(Long id) {
      CustomerOrder newCustomerOrder = baseMapper.selectById(id);
      Customer customer = customerMapper.selectById(newCustomerOrder.getCustomerId());
      CustomerOrderDTO customerOrderDTO = new CustomerOrderDTO();
      BeanUtils.copyProperties(newCustomerOrder, customerOrderDTO);
      customerOrderDTO.setComment(customer.getComment());
      //获取字段和列名
      List<OrderParamDTO> orderParamList = orderParamMapper.getAllOrder();
      customerOrderDTO.setOrderParamList(orderParamList);
      //拼接crosstab所需要的验证数据
      //      OrderParam orderParam = orderParamMapper.getParam();
      //获取客户订单和绑定的订单参数
      JSONObject customerOrderList = baseMapper.getCustomerOrderByIdnew(id);
      customerOrderDTO.setCustomerOrderList(customerOrderList);
      List<JSONObject> list = new ArrayList<>();
      customerOrderDTO.setCustomerOrderAttachmentList(list);
      // 获取工单所需物料
      List<OperationTaskProduce> operationTaskProduceList = operationTaskProduceMapper.selectList(Wrappers.<OperationTaskProduce>lambdaQuery()
            .eq(OperationTaskProduce::getCustomerOrderId, id).orderByAsc(OperationTaskProduce::getSort));
      customerOrderDTO.setOutPutBatchList(operationTaskProduceList);
      if (newCustomerOrder.getTechnologyDocumentId() != null) {
         Document document = documentMapper.selectById(newCustomerOrder.getTechnologyDocumentId());
   public CustomerOrderVO1 getCustomerOrderById(Long id) {
      CustomerOrderVO1 customerOrderVO1 = new CustomerOrderVO1();
      //销售产品单(客户行表)
      CustomerOrder customerOrder = baseMapper.selectById(id);
      BeanUtils.copyProperties(customerOrder, customerOrderVO1);
      //客户主表
      Customer customer = customerMapper.selectById(customerOrder.getCustomerId());
      BeanUtils.copyProperties(customer,customerOrderVO1);
      if (customerOrder.getTechnologyDocumentId() != null) {
         Document document = documentMapper.selectById(customerOrder.getTechnologyDocumentId());
         if (document != null) {
            customerOrderDTO.setDocNumber(document.getNumber());
            //工艺文件编号
            customerOrderVO1.setDocNumber(document.getNumber());
            //工艺文件名称
            customerOrderVO1.setDocName(document.getName());
         }
      }
      List<OrderProcessConfigFileDTO> configFiles =
            orderProcessConfigFileMapper.getProcessConfigFiles(newCustomerOrder.getCustomerOrderNo(),
                  newCustomerOrder.getOtcLineNo());
      customerOrderDTO.setConfigFiles(configFiles);
      ProcessConfigDTO processConfigdto = processConfigService.getProcessConfig(id);
      customerOrderDTO.setProcessConfigDTO(processConfigdto);
      return customerOrderDTO;
      customerOrderVO1.setId(id);
      return customerOrderVO1;
   }
   @Override
@@ -663,26 +666,13 @@
    * @return
    */
   @Override
   @Transactional(rollbackFor = Exception.class)
   public R otcCustomerOrderSync(String selectTime, String pathCode) {
      try {
         if (StringUtils.isBlank(selectTime)) {
            return R.failed("缺少查询时间");
         }
         //DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         //LocalDateTime startDate = LocalDateTime.parse(selectTime, formatter);
         //Long days = LocalDate.now().toEpochDay() - startDate.toLocalDate().toEpochDay();
         //if (days > 30) {
         //   return R.failed("超出查询时间范围");
         //}
         String token = customerOrderUtil.getToken();
         //if (pathCode.equals("0")) {
         //   return addCustomerFromOtc(selectTime, token);
         //} else if (pathCode.equals("1")) {
         //   return addCustomerFromOtcForJointStockCompany(selectTime, token);
         //} else {
         //   throw new RuntimeException("路径请求码 = 【" + pathCode + "】非法");
         //}
         return addCustomerFromOtc(selectTime, token);
      } catch (Exception e) {
         return R.failed(e.getMessage());
@@ -727,7 +717,7 @@
               //所属工厂
               String affiliatedContract=customerJSONObject.getString("affiliatedContract");
               //只拉取所属公司为中天海洋系统有限公司的数据
               if (!"中天材料厂".equals(affiliatedContract)){
               if (!AFFILIATED_CONTRACT.equals(affiliatedContract)){
                  continue;
               }
               // 不在这几个状态中的数据就跳过
@@ -739,14 +729,14 @@
                  customer = new Customer();
               }
               //如果OTC中主表状态是取消那就跳过或者删除已经同步的数据
               if ("已取消".equals(otcMainStatus)) {
               if (OTC_MAIN_STATUS_CANCEL.equals(otcMainStatus)) {
                  if (customer.getId() != null) {
                     customerMapper.deleteById(customer.getId());
                     baseMapper.delete(Wrappers.<CustomerOrder>lambdaQuery().eq(CustomerOrder::getCustomerId, customer.getId()));
                  }
                  continue;
               }
               if (!"已下达".equals(otcMainStatus)) {//null == affiliatedCompany || !Arrays.asList("已下达").contains(otcMainStatus) /*|| affiliatedCompany.equals("江苏中天科技股份有限公司")*/) {
               if (!OTC_MAIN_STATUS_TRANSMIT.equals(otcMainStatus)) {//null == affiliatedCompany || !Arrays.asList("已下达").contains(otcMainStatus) /*|| affiliatedCompany.equals("江苏中天科技股份有限公司")*/) {
                  continue;//只获取OTC中已审核及已下达的订单,
               }
               //客户编号
@@ -804,6 +794,146 @@
      }
   }
   /**
    * 添加子表信息
    *
    * @param customer
    * @param otcMainStatus
    * @throws Exception
    */
   private int addCustomerOrderFromOtc(JSONObject customerJSONObject, Customer customer, String token, List<OrderParam> orderParamList, String otcMainStatus) {
      Map<String, String> productTypeGroupMap = customerOrderUnitWhiteListConfig.getProductTypeGroupMap();
      int num = 0;
      try {
         Map<String, Object> map = new HashMap<>();
         map.put("orderNo", customer.getContractNo());
         map.put("selectTime", "1899-12-31 23:59:59");
         JSONObject result = JSONObject.parseObject(HttpRequest.get(customerOrderClientConfigure.getOtcHost() + customerOrderClientConfigure.getOtcCustomerOrderUrl())
               .contentType("application/json")
               .header("Authorization", "Bearer " + token).form(map).execute().body());
         if (result.getInteger("code") == 0) {
            JSONArray jsonArray = result.getJSONArray("data");
            for (Object obj : jsonArray) {
               JSONObject customerOrderJSONObject = JSONObject.parseObject(obj.toString());
               String otcLoneId = customerOrderJSONObject.getLong("id").toString();
               //OTC的订单状态
               String otcOrderStatus = customerOrderJSONObject.getString("lineStatus").toString();
               CustomerOrder customerOrder = baseMapper.selectOne(Wrappers.<CustomerOrder>lambdaQuery()
                     .eq(CustomerOrder::getOtcLineNo, otcLoneId));
               if (customerOrder == null) {
                  customerOrder = new CustomerOrder();
               }
               //如果这个单子在OTC中取消状态 那就删除
               if (otcOrderStatus.equals("已取消")) {
                  if (customerOrder.getId() != null) {
                     baseMapper.deleteById(customerOrder.getId());
                  }
                  continue;
               }
               //OTC合同号主表id
               customerOrder.setOtcOrderId(customerOrderJSONObject.getLong("orderId"));
               //otc行号
               customerOrder.setOtcLineNo(otcLoneId);
               //零件号
               customerOrder.setPartNo(customerOrderJSONObject.getString("partNo"));
               //来源 0:自动
               customerOrder.setSourceId("0");
               //合同号
               customerOrder.setCustomerOrderNo(customer.getContractNo());
               //客户号
               customerOrder.setCustomerNo(customer.getCustomerNo());
               //客户名称
               customerOrder.setCustomerName(customer.getCustomerName());
               //工程名称
               customerOrder.setEntityName(customer.getEntityName());
               //数量
               customerOrder.setBuyQtyDue(customerOrderJSONObject.getBigDecimal("quantity"));
               //OTC单位
               customerOrder.setOtcUnit(customerOrderJSONObject.getString("unit"));
               //期望交货日期
               customerOrder.setWantedDeliveryDate(customer.getDeliveryDate());
               //主表id
               customerOrder.setCustomerId(customer.getId());
               //电压等级
               customerOrder.setVoltAgeClass(customerOrderJSONObject.getString("voltageLevel"));
               //外呼颜色
               customerOrder.setOuterColor(customerOrderJSONObject.getString("outerSheathColor"));
               //客户零件名称
               customerOrder.setProductName(customerOrderJSONObject.getString("productName"));
               //客户零件规格
               customerOrder.setCustomerPartSpec(customerOrderJSONObject.getString("specificationModel"));
               //订单版本
               customerOrder.setVersion(customerOrderJSONObject.getInteger("version"));
               //事业部
               customerOrder.setDivision(customerOrderJSONObject.getString("division"));
               //印字类型
               customerOrder.setPrintType(customerOrderJSONObject.getString("printType"));
               //印字内容
               customerOrder.setPrintContent(customerOrderJSONObject.getString("printContent"));
               //印字要求
               customerOrder.setPrintingRequirements(customerOrderJSONObject.getString("printingRequirements"));
               //包装要求
               customerOrder.setPackageRequire(customerOrderJSONObject.getString("packageRequire"));
               //质量要求
               customerOrder.setQualityRequire(customerOrderJSONObject.getString("qualityRequire"));
               //生产需求说明
               customerOrder.setOtherProductRequire(customerOrderJSONObject.getString("otherProductRequire"));
               //系统
               customerOrder.setDivisionSystem(customerOrderJSONObject.getString("divisionSystem"));
               //收货地址
               customerOrder.setShippingAddress(customerOrderJSONObject.getString("shippingAddress"));
               //业务员
               customerOrder.setSalesmanName(customer.getSalesMan());
               //盘长要求
               customerOrder.setLengthRequirement(customerOrderJSONObject.getString("lengthRequirement"));
               //产品备注Ï
               customerOrder.setRemark(customerOrderJSONObject.getString("orderComment"));
               //产品类型
               customerOrder.setProductType(customerOrderJSONObject.getString("productType"));
               //产品分组
               customerOrder.setProductGroup(productTypeGroupMap.get(customerOrderJSONObject.getString("productType")));
               //采集性质
               customerOrder.setCentralizedMiningProperty(customerJSONObject.getString("centralizedMiningProperty"));
               //最终客户名称
               customerOrder.setFinalCustomerName(customerJSONObject.getString("finalCustomerName"));
               //销售件描述
               customerOrder.setSalesPartName(customerOrderJSONObject.getString("partDesc"));
               if (customerOrder.getId() == null) {
                  // 零件是否推送
                  customerOrder.setOtcPartSync(false);
                  // 默认为N 数据字典为:N:普通,S:样品,D:研发
                  customerOrder.setManufactureAttr("N");
                  //是否关联工艺文件为否
                  customerOrder.setIsDocument(false);
                  //状态为 如果采集性质 非采集和 省采集  状态位编辑  否则为 零件待选
                  if (customerOrder.getCentralizedMiningProperty().equals("非集采") || customerOrder.getCentralizedMiningProperty().equals("省集采")) {
                     customerOrder.setCoState(CustomerOrderStateStringValues.UNIEDIT);
                  } else {
                     customerOrder.setCoState(CustomerOrderStateStringValues.PARTUNCHECKED);
                  }
                  if (org.apache.commons.lang3.StringUtils.equals("已下达", otcMainStatus)) {
                     customerOrder.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
                     customerOrder.setOtcPartSync(Boolean.TRUE);
                  }
                  // 如果状态为零件待选,且零件号不为空,更新状态
                  if (StrUtil.isNotBlank(customerOrder.getPartNo()) && CustomerOrderStateStringValues.PARTUNCHECKED.equals(customerOrder.getCoState())) {
                     customerOrder.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
                     customerOrder.setOtcPartSync(Boolean.TRUE);
                  }
                  //审核状态为 01draft 草稿
                  customerOrder.setIsAudit(AuditStateStringValues.DRAFT);
                  baseMapper.insert(customerOrder);
               }
               addCustomerPara(customerJSONObject, customerOrderJSONObject, customerOrder, orderParamList);
               num += 1;
            }
         }
      } catch (Exception e) {
         throw new RuntimeException("订单行数据获取失败,原因:" + e.getMessage());
      }
      return num;
   }
   ///**
   // * 添加主表信息
@@ -918,139 +1048,139 @@
    * @param otcMainStatus
    * @throws Exception
    */
   private int addCustomerOrderFromOtc(JSONObject customerJSONObject, Customer customer, String token, List<OrderParam> orderParamList, String otcMainStatus) {
      Map<String, String> productTypeGroupMap = customerOrderUnitWhiteListConfig.getProductTypeGroupMap();
      int num = 0;
      try {
         Map<String, Object> map = new HashMap<>();
         map.put("orderNo", customer.getContractNo());
         map.put("selectTime", "1899-12-31 23:59:59");
         JSONObject result = JSONObject.parseObject(HttpRequest.get(customerOrderClientConfigure.getOtcHost() + customerOrderClientConfigure.getOtcCustomerOrderUrl())
               .contentType("application/json")
               .header("Authorization", "Bearer " + token).form(map).execute().body());
         if (result.getInteger("code") == 0) {
            JSONArray jsonArray = result.getJSONArray("data");
            for (Object obj : jsonArray) {
               JSONObject customerOrderJSONObject = JSONObject.parseObject(obj.toString());
               String otcLoneId = customerOrderJSONObject.getLong("id").toString();
               //OTC的订单状态
               String otcOrderStatus = customerOrderJSONObject.getString("lineStatus").toString();
               CustomerOrder customerOrder = baseMapper.selectOne(Wrappers.<CustomerOrder>lambdaQuery()
                     .eq(CustomerOrder::getOtcLineNo, otcLoneId));
               if (customerOrder == null) {
                  customerOrder = new CustomerOrder();
               }
               //如果这个单子在OTC中取消状态 那就删除
               if (otcOrderStatus.equals("已取消")) {
                  if (customerOrder.getId() != null) {
                     baseMapper.deleteById(customerOrder.getId());
                  }
                  continue;
               }
               //OTC合同号主表id
               customerOrder.setOtcOrderId(customerOrderJSONObject.getLong("orderId"));
               //otc行号
               customerOrder.setOtcLineNo(otcLoneId);
               //零件号
               customerOrder.setSalesPartNo(customerOrderJSONObject.getString("partNo"));
               //来源
               customerOrder.setSourceId("OTC");
               //合同号
               customerOrder.setCustomerOrderNo(customer.getContractNo());
               //客户号
               customerOrder.setCustomerNo(customer.getCustomerNo());
               //客户名称
               customerOrder.setCustomerName(customer.getCustomerName());
               //销售数量原先OTC的单位
               customerOrder.setOtcQuantity(customerOrderJSONObject.getBigDecimal("quantity"));
               //OTC单位
               customerOrder.setOtcUnit(customerOrderJSONObject.getString("unit"));
               //期望交货日期
               customerOrder.setWantedDeliveryDate(customer.getDeliveryDate());
               //主表id
               customerOrder.setCustomerId(customer.getId());
               //电压等级
               customerOrder.setVoltAgeClass(customerOrderJSONObject.getString("voltageLevel"));
               //外呼颜色
               customerOrder.setOuterColor(customerOrderJSONObject.getString("outerSheathColor"));
               //客户零件名称
               customerOrder.setProductName(customerOrderJSONObject.getString("productName"));
               //客户零件规格
               customerOrder.setCustomerPartSpec(customerOrderJSONObject.getString("specificationModel"));
               //订单版本
               customerOrder.setVersion(customerOrderJSONObject.getInteger("version"));
               //事业部
               customerOrder.setDivision(customerOrderJSONObject.getString("division"));
               //印字类型
               customerOrder.setPrintType(customerOrderJSONObject.getString("printType"));
               //印字内容
               customerOrder.setPrintContent(customerOrderJSONObject.getString("printContent"));
               //印字要求
               customerOrder.setPrintingRequirements(customerOrderJSONObject.getString("printingRequirements"));
               //包装要求
               customerOrder.setPackageRequire(customerOrderJSONObject.getString("packageRequire"));
               //质量要求
               customerOrder.setQualityRequire(customerOrderJSONObject.getString("qualityRequire"));
               //生产需求说明
               customerOrder.setOtherProductRequire(customerOrderJSONObject.getString("otherProductRequire"));
               //系统
               customerOrder.setDivisionSystem(customerOrderJSONObject.getString("divisionSystem"));
               //收货地址
               customerOrder.setShippingAddress(customerOrderJSONObject.getString("shippingAddress"));
               //业务员
               customerOrder.setSalesmanName(customer.getSalesMan());
               //盘长要求
               customerOrder.setLengthRequirement(customerOrderJSONObject.getString("lengthRequirement"));
               //备注Ï
               customerOrder.setRemark(customerOrderJSONObject.getString("comment"));
               //产品类型
               customerOrder.setProductType(customerOrderJSONObject.getString("productType"));
               //产品分组
               customerOrder.setProductGroup(productTypeGroupMap.get(customerOrderJSONObject.getString("productType")));
               //采集性质
               customerOrder.setCentralizedMiningProperty(customerJSONObject.getString("centralizedMiningProperty"));
               //最终客户名称
               customerOrder.setFinalCustomerName(customerJSONObject.getString("finalCustomerName"));
               //销售件描述
               customerOrder.setSalesPartName(customerOrderJSONObject.getString("partDesc"));
               if (customerOrder.getId() == null) {
                  // 零件是否推送
                  customerOrder.setOtcPartSync(false);
                  // 默认为N 数据字典为:N:普通,S:样品,D:研发
                  customerOrder.setManufactureAttr("N");
                  //是否关联工艺文件为否
                  customerOrder.setIsDocument(false);
                  //状态为 如果采集性质 非采集和 省采集  状态位编辑  否则为 零件待选
                  if (customerOrder.getCentralizedMiningProperty().equals("非集采") || customerOrder.getCentralizedMiningProperty().equals("省集采")) {
                     customerOrder.setCoState(CustomerOrderStateStringValues.UNIEDIT);
                  } else {
                     customerOrder.setCoState(CustomerOrderStateStringValues.PARTUNCHECKED);
                  }
                  if (org.apache.commons.lang3.StringUtils.equals("已下达", otcMainStatus)) {
                     customerOrder.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
                     customerOrder.setOtcPartSync(Boolean.TRUE);
                  }
                  //审核状态为 01draft 草稿
                  customerOrder.setIsAudit(AuditStateStringValues.DRAFT);
                  baseMapper.insert(customerOrder);
               } else {
                  // 如果状态为零件待选,且销售件号不为空,更新状态
                  if (StrUtil.isNotBlank(customerOrder.getSalesPartNo()) && CustomerOrderStateStringValues.PARTUNCHECKED.equals(customerOrder.getCoState())) {
                     customerOrder.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
                     customerOrder.setOtcPartSync(Boolean.TRUE);
                  }
                  baseMapper.updateById(customerOrder);
               }
               addCustomerPara(customerJSONObject, customerOrderJSONObject, customerOrder, orderParamList);
               num += 1;
            }
         }
      } catch (Exception e) {
         throw new RuntimeException("订单行数据获取失败,原因:" + e.getMessage());
      }
      return num;
   }
   //private int addCustomerOrderFromOtc(JSONObject customerJSONObject, Customer customer, String token, List<OrderParam> orderParamList, String otcMainStatus) {
   //   Map<String, String> productTypeGroupMap = customerOrderUnitWhiteListConfig.getProductTypeGroupMap();
   //   int num = 0;
   //   try {
   //      Map<String, Object> map = new HashMap<>();
   //      map.put("orderNo", customer.getContractNo());
   //      map.put("selectTime", "1899-12-31 23:59:59");
   //      JSONObject result = JSONObject.parseObject(HttpRequest.get(customerOrderClientConfigure.getOtcHost() + customerOrderClientConfigure.getOtcCustomerOrderUrl())
   //            .contentType("application/json")
   //            .header("Authorization", "Bearer " + token).form(map).execute().body());
   //      if (result.getInteger("code") == 0) {
   //         JSONArray jsonArray = result.getJSONArray("data");
   //         for (Object obj : jsonArray) {
   //            JSONObject customerOrderJSONObject = JSONObject.parseObject(obj.toString());
   //            String otcLoneId = customerOrderJSONObject.getLong("id").toString();
   //            //OTC的订单状态
   //            String otcOrderStatus = customerOrderJSONObject.getString("lineStatus").toString();
   //            CustomerOrder customerOrder = baseMapper.selectOne(Wrappers.<CustomerOrder>lambdaQuery()
   //                  .eq(CustomerOrder::getOtcLineNo, otcLoneId));
   //            if (customerOrder == null) {
   //               customerOrder = new CustomerOrder();
   //            }
   //            //如果这个单子在OTC中取消状态 那就删除
   //            if (otcOrderStatus.equals("已取消")) {
   //               if (customerOrder.getId() != null) {
   //                  baseMapper.deleteById(customerOrder.getId());
   //               }
   //               continue;
   //            }
   //            //OTC合同号主表id
   //            customerOrder.setOtcOrderId(customerOrderJSONObject.getLong("orderId"));
   //            //otc行号
   //            customerOrder.setOtcLineNo(otcLoneId);
   //            //零件号
   //            customerOrder.setSalesPartNo(customerOrderJSONObject.getString("partNo"));
   //            //来源
   //            customerOrder.setSourceId("OTC");
   //            //合同号
   //            customerOrder.setCustomerOrderNo(customer.getContractNo());
   //            //客户号
   //            customerOrder.setCustomerNo(customer.getCustomerNo());
   //            //客户名称
   //            customerOrder.setCustomerName(customer.getCustomerName());
   //            //销售数量原先OTC的单位
   //            customerOrder.setOtcQuantity(customerOrderJSONObject.getBigDecimal("quantity"));
   //            //OTC单位
   //            customerOrder.setOtcUnit(customerOrderJSONObject.getString("unit"));
   //            //期望交货日期
   //            customerOrder.setWantedDeliveryDate(customer.getDeliveryDate());
   //            //主表id
   //            customerOrder.setCustomerId(customer.getId());
   //            //电压等级
   //            customerOrder.setVoltAgeClass(customerOrderJSONObject.getString("voltageLevel"));
   //            //外呼颜色
   //            customerOrder.setOuterColor(customerOrderJSONObject.getString("outerSheathColor"));
   //            //客户零件名称
   //            customerOrder.setProductName(customerOrderJSONObject.getString("productName"));
   //            //客户零件规格
   //            customerOrder.setCustomerPartSpec(customerOrderJSONObject.getString("specificationModel"));
   //            //订单版本
   //            customerOrder.setVersion(customerOrderJSONObject.getInteger("version"));
   //            //事业部
   //            customerOrder.setDivision(customerOrderJSONObject.getString("division"));
   //            //印字类型
   //            customerOrder.setPrintType(customerOrderJSONObject.getString("printType"));
   //            //印字内容
   //            customerOrder.setPrintContent(customerOrderJSONObject.getString("printContent"));
   //            //印字要求
   //            customerOrder.setPrintingRequirements(customerOrderJSONObject.getString("printingRequirements"));
   //            //包装要求
   //            customerOrder.setPackageRequire(customerOrderJSONObject.getString("packageRequire"));
   //            //质量要求
   //            customerOrder.setQualityRequire(customerOrderJSONObject.getString("qualityRequire"));
   //            //生产需求说明
   //            customerOrder.setOtherProductRequire(customerOrderJSONObject.getString("otherProductRequire"));
   //            //系统
   //            customerOrder.setDivisionSystem(customerOrderJSONObject.getString("divisionSystem"));
   //            //收货地址
   //            customerOrder.setShippingAddress(customerOrderJSONObject.getString("shippingAddress"));
   //            //业务员
   //            customerOrder.setSalesmanName(customer.getSalesMan());
   //            //盘长要求
   //            customerOrder.setLengthRequirement(customerOrderJSONObject.getString("lengthRequirement"));
   //            //备注Ï
   //            customerOrder.setRemark(customerOrderJSONObject.getString("comment"));
   //            //产品类型
   //            customerOrder.setProductType(customerOrderJSONObject.getString("productType"));
   //            //产品分组
   //            customerOrder.setProductGroup(productTypeGroupMap.get(customerOrderJSONObject.getString("productType")));
   //            //采集性质
   //            customerOrder.setCentralizedMiningProperty(customerJSONObject.getString("centralizedMiningProperty"));
   //            //最终客户名称
   //            customerOrder.setFinalCustomerName(customerJSONObject.getString("finalCustomerName"));
   //            //销售件描述
   //            customerOrder.setSalesPartName(customerOrderJSONObject.getString("partDesc"));
   //
   //            if (customerOrder.getId() == null) {
   //               // 零件是否推送
   //               customerOrder.setOtcPartSync(false);
   //               // 默认为N 数据字典为:N:普通,S:样品,D:研发
   //               customerOrder.setManufactureAttr("N");
   //               //是否关联工艺文件为否
   //               customerOrder.setIsDocument(false);
   //               //状态为 如果采集性质 非采集和 省采集  状态位编辑  否则为 零件待选
   //               if (customerOrder.getCentralizedMiningProperty().equals("非集采") || customerOrder.getCentralizedMiningProperty().equals("省集采")) {
   //                  customerOrder.setCoState(CustomerOrderStateStringValues.UNIEDIT);
   //               } else {
   //                  customerOrder.setCoState(CustomerOrderStateStringValues.PARTUNCHECKED);
   //               }
   //               if (org.apache.commons.lang3.StringUtils.equals("已下达", otcMainStatus)) {
   //                  customerOrder.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
   //                  customerOrder.setOtcPartSync(Boolean.TRUE);
   //               }
   //               //审核状态为 01draft 草稿
   //               customerOrder.setIsAudit(AuditStateStringValues.DRAFT);
   //               baseMapper.insert(customerOrder);
   //            } else {
   //               // 如果状态为零件待选,且销售件号不为空,更新状态
   //               if (StrUtil.isNotBlank(customerOrder.getSalesPartNo()) && CustomerOrderStateStringValues.PARTUNCHECKED.equals(customerOrder.getCoState())) {
   //                  customerOrder.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
   //                  customerOrder.setOtcPartSync(Boolean.TRUE);
   //               }
   //               baseMapper.updateById(customerOrder);
   //            }
   //            addCustomerPara(customerJSONObject, customerOrderJSONObject, customerOrder, orderParamList);
   //            num += 1;
   //         }
   //      }
   //   } catch (Exception e) {
   //      throw new RuntimeException("订单行数据获取失败,原因:" + e.getMessage());
   //   }
   //   return num;
   //}
   /**
    * @param jsonObjMain    主表的jsonObj
@@ -1746,15 +1876,14 @@
   @Override
   public R uploadProcessConfigFile(MultipartFile file, String orderNumber, String lineNumber) {
      String fileName = IdUtil.simpleUUID() + StrUtil.DOT + FileUtil.extName(file.getOriginalFilename());
      String fileName = FileUtil.extName(file.getOriginalFilename());
      try {
         minioTemplate.putObject(ossProperties.getBucketName(), fileName, file.getInputStream());
         OrderProcessConfigFile configFile = new OrderProcessConfigFile();
         configFile.setFileName(fileName);
         configFile.setOriginalFileName(file.getOriginalFilename());
         configFile.setOrderNumber(orderNumber);
         configFile.setLineNumber(lineNumber);
         configFile.setBucketName(ossProperties.getBucketName());
         configFile.setBucketName(FileSaveUtil.StoreFile(file));
         orderProcessConfigFileMapper.insert(configFile);
         ProcessConfigFileOrderMapping mapping = ProcessConfigFileOrderMapping.builder().configFileId(configFile.getId())
               .orderNumber(orderNumber).lineNumber(lineNumber).build();
@@ -1781,7 +1910,9 @@
   @Override
   public void getFile(String bucket, String fileName, HttpServletResponse response) {
      try (InputStream inputStream = minioTemplate.getObject(bucket, fileName)) {
      try {
         String path = FileSaveUtil.FILE_PATH + bucket;
         InputStream inputStream = new FileInputStream(path);
         response.setContentType("application/octet-stream; charset=UTF-8");
         IoUtil.copy(inputStream, response.getOutputStream());
      } catch (Exception e) {