|
@@ -22,9 +22,12 @@ import com.zkqy.amichi.mapper.ProductionCardFlowMapper;
|
|
|
import com.zkqy.amichi.mapper.ProductionPlanningManagementMapper;
|
|
|
import com.zkqy.amichi.utils.AmichiCommissionNumberGenerator;
|
|
|
import com.zkqy.common.core.domain.AjaxResult;
|
|
|
+import com.zkqy.common.core.redis.RedisCache;
|
|
|
import com.zkqy.common.utils.DateUtils;
|
|
|
import com.zkqy.common.utils.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.format.annotation.DateTimeFormat;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.zkqy.amichi.jd.mapper.JdProductionOrderMapper;
|
|
@@ -57,6 +60,12 @@ public class JdProductionOrderServiceImpl implements JdProductionOrderService
|
|
|
@Autowired
|
|
|
private JdMaterialInfoServiceImpl jdMaterialInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StringRedisTemplate stringRedisTemplate;
|
|
|
+
|
|
|
/**
|
|
|
* 查询金蝶-生产订单信息
|
|
|
*
|
|
@@ -131,61 +140,171 @@ public class JdProductionOrderServiceImpl implements JdProductionOrderService
|
|
|
return jdProductionOrderMapper.deleteJdProductionOrderById(id);
|
|
|
}
|
|
|
|
|
|
-// @Override
|
|
|
-// public AjaxResult jdProductionOrderPull(JdProductionOrder jdProductionOrder) {
|
|
|
-// //1、查询开始同步的单据编号 String s="MO051961";
|
|
|
-// String s = jdProductionOrderMapper.selectJdProductionOrderMaxId();
|
|
|
-// //2、大于这个编号的所有订单全部拉取回来
|
|
|
-// //2.1、new金蝶jdk工具类
|
|
|
-// K3CloudApi api = new K3CloudApi();
|
|
|
-// //2.2、
|
|
|
-// HashMap<String,Object > stringHashMap=new HashMap();
|
|
|
-// stringHashMap.put("FormId","PRD_MO");
|
|
|
-// List<String> stringList=new ArrayList<>();
|
|
|
-// stringList.add("FBillNo");
|
|
|
-// stringList.add("FBillType");
|
|
|
-// stringList.add("FDate");
|
|
|
-// stringList.add("FDocumentStatus");
|
|
|
-// stringList.add("FProductType");
|
|
|
-// stringList.add("FMaterialId");
|
|
|
-// stringList.add("FWorkShopID0");
|
|
|
-// stringList.add("FQty");
|
|
|
-// stringList.add("FStatus");
|
|
|
-// stringList.add("FSaleOrderNo");
|
|
|
-// stringList.add("FPickMtrlStatus");
|
|
|
-// stringHashMap.put("FieldKeys",stringList.stream().collect(Collectors.joining(",")));
|
|
|
-// HashMap gl=new HashMap();
|
|
|
-// gl.put("FieldName","FBillNo");
|
|
|
-// gl.put("Compare","72");
|
|
|
-// gl.put("Value",s);
|
|
|
-// gl.put("Left","");
|
|
|
-// gl.put("Right","");
|
|
|
-// gl.put("Logic","0");
|
|
|
-// List<Map> mapList=new ArrayList<>();
|
|
|
-// mapList.add(gl);
|
|
|
-// stringHashMap.put("FilterString",mapList);
|
|
|
-// String jsonString = JSON.toJSONString(stringHashMap);
|
|
|
-// try {
|
|
|
-// String resultJson = String.valueOf(api.executeBillQuery(jsonString));
|
|
|
-// List<JdProductionOrder> arrayLists = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
-// int i = jdProductionOrderMapper.insertBatchJdProductionOrder(arrayLists);
|
|
|
-// if(i>0){
|
|
|
-// return AjaxResult.success("数据拉去成功");
|
|
|
-// }
|
|
|
-// } catch (Exception e) {
|
|
|
-// throw new RuntimeException(e);
|
|
|
-// }
|
|
|
-// return AjaxResult.error("数据拉取失败");
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 普通订单拉取数据
|
|
|
+ * @return
|
|
|
+ *
|
|
|
+ * 条件:所有开工数据
|
|
|
+ * 物料编码不等于焊接
|
|
|
+ * 拉取普通订单ERP数据
|
|
|
+ */
|
|
|
@Override
|
|
|
public AjaxResult jdProductionOrderPull() {
|
|
|
- AjaxResult ajaxResult = this.jdProductionOrderPullTwo();
|
|
|
- return ajaxResult;
|
|
|
+ Boolean aTrue = stringRedisTemplate.opsForValue().setIfAbsent("fjqy:ptd:pulled", "true");
|
|
|
+ if (aTrue) {
|
|
|
+ AjaxResult ajaxResult = jdMaterialInfoService.pullMaterialBaseInfo();
|
|
|
+ //金蝶工具key
|
|
|
+ K3CloudApi api = new K3CloudApi();
|
|
|
+ //定义查询条件
|
|
|
+ String query = "{\n" +
|
|
|
+ " \"FormId\": \"PRD_MO\",\n" +
|
|
|
+ " \"FieldKeys\": \"FDescription,F_PONP_teshuyaoqiu,FBillNo,FBillType,FDate,FDocumentStatus," +
|
|
|
+ "FProductType,FMaterialId,FWorkShopID0,FQty,FStatus,FSaleOrderNo,FPickMtrlStatus," +
|
|
|
+ "FMaterialId.FNumber,FMaterialName,F_PONP_BaseProperty,FSpecification,FUnitId.FName,F_PONP_yanse,F_PONP_mingpai,F_PONP_hegezheng.FDataValue," +
|
|
|
+ "F_PONP_shuomingshu.FDataValue,F_PONP_KaiGuanXiang,F_PONP_baozhuangxiang,F_PONP_GongLv,FPlanFinishDate,FPlanStartDate,F_PONP_XQRQ,FPlanStartDate,FPlanFinishDate\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FMaterialId.FNumber\",\"Compare\":\"34\",\"Value\":\"焊\",\"Right\":\"\",\"Logic\":0},{\"Left\":\"\",\"FieldName\":\"FStatus\",\"Compare\":\"105\",\"Value\":\"4\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 5000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ //
|
|
|
+ try {
|
|
|
+ //查询结果
|
|
|
+ String resultJson = api.billQuery(query);
|
|
|
+ //生产信息
|
|
|
+ List<JdProductionOrder> jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
+ //查询系统中的订单信息
|
|
|
+ ProductionPlanningManagement productionPlanningManagement1 = new ProductionPlanningManagement();
|
|
|
+ productionPlanningManagement1.setIsWeldSheet("1");
|
|
|
+ List<ProductionPlanningManagement> productionPlanningManagements = productionPlanningManagementMapper.selectProductionPlanningManagementList(productionPlanningManagement1);
|
|
|
+ List<String> collectTwo = productionPlanningManagements.stream().map(ProductionPlanningManagement::getOrderNumber).collect(Collectors.toSet())
|
|
|
+ .stream().collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, List<JdProductionOrder>> groupedByDemandDocument = jdProductionOrders.stream()
|
|
|
+ .filter(item -> !collectTwo.contains(item.getDemandDocument()))
|
|
|
+ .collect(Collectors.groupingBy(JdProductionOrder::getDemandDocument));
|
|
|
+
|
|
|
+ if (groupedByDemandDocument.size() > 0) {
|
|
|
+ //订单循环
|
|
|
+ groupedByDemandDocument.forEach((k, v) -> {
|
|
|
+ ProductionPlanningManagement productionPlanningManagement = new ProductionPlanningManagement();
|
|
|
+ //编号订单号
|
|
|
+ productionPlanningManagement.setOrderNumber(k);
|
|
|
+ //计划编号
|
|
|
+ String planNumnber = generator.generateCommissionNumber();
|
|
|
+ productionPlanningManagement.setPlanNumber(planNumnber);
|
|
|
+ productionPlanningManagement.setPlanType("0"); //待生产
|
|
|
+ productionPlanningManagement.setTaskStatus("4");//待排产
|
|
|
+ productionPlanningManagement.setIsWeldSheet("1");//焊接订单
|
|
|
+ if (StringUtils.isNotNull(v.get(0).getCompletionTime())) {
|
|
|
+ productionPlanningManagement.setCompletionTime(v.get(0).getCompletionTime());//完成时间
|
|
|
+ }
|
|
|
+ //备注
|
|
|
+ if (StringUtils.isNotNull(v.get(0).getRemark())) {
|
|
|
+ productionPlanningManagement.setRemark(v.get(0).getRemark()); //备注
|
|
|
+ }
|
|
|
+ //单据类型
|
|
|
+ if (StringUtils.isNotNull(v.get(0).getDocumentTyep())) {
|
|
|
+ productionPlanningManagement.setOrderType(v.get(0).getDocumentTyep()); //单据类型
|
|
|
+ }
|
|
|
+ //订单的创建时间
|
|
|
+ productionPlanningManagement.setCreationtimeString(v.get(0).getCreationtimeString());//单据的创建时间
|
|
|
+ //特殊要求
|
|
|
+ if (StringUtils.isNotNull(v.get(0).getTsyq())) {
|
|
|
+ productionPlanningManagement.setSpecialRequirements(v.get(0).getTsyq());//特殊要求
|
|
|
+ }
|
|
|
+
|
|
|
+ //编号订单号
|
|
|
+ List<Map> mapList = this.jdSalesOrderInfoS(k);//订单详情信息
|
|
|
+ String fDeliveryDate;
|
|
|
+ if (mapList.size() > 0) {
|
|
|
+ fDeliveryDate = mapList.get(0).get("FDeliveryDate").toString();
|
|
|
+ } else {
|
|
|
+ fDeliveryDate = "";
|
|
|
+ }
|
|
|
+ //拿到了关于这个订单的销售订单
|
|
|
+ if (mapList.size() > 0) {
|
|
|
+ if (StringUtils.isNotNull(mapList.get(0).get("F.PONP.Text"))) {
|
|
|
+ productionPlanningManagement.setContractNumber(mapList.get(0).get("F.PONP.Text").toString());
|
|
|
+ }
|
|
|
+ productionPlanningManagement.setCompletionTime(fDeliveryDate);
|
|
|
+ //======处理基本的订单信息
|
|
|
+ productionPlanningManagementMapper.insertProductionPlanningManagement(productionPlanningManagement);
|
|
|
+ v.forEach(a -> {
|
|
|
+ PlanTaskDetails planTaskDetails = new PlanTaskDetails();
|
|
|
+ planTaskDetails.setDemandDocument(a.getDocumentNumber());//需求单据号
|
|
|
+ planTaskDetails.setPlanId(productionPlanningManagement.getId());//计划id
|
|
|
+ planTaskDetails.setMaterialId(a.getMaterialCode());//原材料编码
|
|
|
+ planTaskDetails.setMaterialName(a.getMaterialName());//名称
|
|
|
+ planTaskDetails.setQuantity(a.getQuantity());//数量
|
|
|
+ //planTaskDetails.setTimeOfRequest(a.getCompletionTime());//要货时间
|
|
|
+ planTaskDetails.setModelNumber(a.getModelNumber());//型号
|
|
|
+ planTaskDetails.setSpecification(a.getSpecification());//规格
|
|
|
+ planTaskDetails.setMaterialUnit(a.getUnit());//单位
|
|
|
+ planTaskDetails.setPower(a.getGl());//功率
|
|
|
+ planTaskDetails.setVoltage(a.getDianYaPinLv());//电压频率
|
|
|
+ planTaskDetails.setColour(a.getYanse());//颜色
|
|
|
+ planTaskDetails.setMingpai(a.getMingpai());//铭牌
|
|
|
+ planTaskDetails.setShuomingshu(a.getShuomingshu());//说明书
|
|
|
+ planTaskDetails.setHegezheng(a.getHegezheng());//合格证
|
|
|
+ planTaskDetails.setBaozhuangxiang(a.getBaozhuangxiang());//包装箱
|
|
|
+ planTaskDetails.setSwitchBox(a.getKaiguanxiang());//开关箱
|
|
|
+ planTaskDetails.setScheduledCommencement(a.getFPlanStartDate()); //计划开始时间
|
|
|
+ planTaskDetails.setScheduledCompletion(a.getFPlanFinishDate()); //计划完工时间
|
|
|
+ planTaskDetails.setRemark(a.getRemark());
|
|
|
+ if (StringUtils.isNotNull(a.getDocumentDate())) {
|
|
|
+ // SimpleDateFormat formatter1= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ // String formattedDate = formatter1.format(a.getDocumentDate());
|
|
|
+ planTaskDetails.setTimeOfRequest(a.getDocumentDate());
|
|
|
+ }
|
|
|
+
|
|
|
+ planTaskDetailsMapper.insertPlanTaskDetails(planTaskDetails);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //处理订单序列号问题
|
|
|
+ groupedByDemandDocument.forEach((k, v) -> {
|
|
|
+ String stringQuery = "{\n" +
|
|
|
+ " \"FormId\": \"PRD_MO\",\n" +
|
|
|
+ " \"FieldKeys\": \"FBillNo,FSNQty1,FSaleOrderNo,FSerialNo\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FMaterialId.FNumber\",\"Compare\":\"34\",\"Value\":\"焊\",\"Right\":\"\",\"Logic\":0},{\"Left\":\"\",\"FieldName\":\"FStatus\",\"Compare\":\"105\",\"Value\":\"4\",\"Right\":\"\",\"Logic\":0},{\"Left\":\"\",\"FieldName\":\"FSaleOrderNo\",\"Compare\":\"67\",\"Value\":\"" + k + "\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 2000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ try {
|
|
|
+ String xlhString = api.billQuery(stringQuery);
|
|
|
+ if (!xlhString.equals("[]")) {
|
|
|
+ List<ProductionCardFlowVo> mapList1 = JSON.parseArray(xlhString, ProductionCardFlowVo.class);
|
|
|
+ int i = productionCardFlowMapper.insertProductionCardFlowBatchVo(mapList1);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ stringRedisTemplate.delete("fjqy:ptd:pulled");
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ stringRedisTemplate.delete("fjqy:ptd:pulled");
|
|
|
+ return AjaxResult.success("拉取成功");
|
|
|
+ } else {
|
|
|
+ return AjaxResult.success("定时任务正在执行请稍后在拉去");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 普通订单拉取斯销售订单数据
|
|
|
+ * @return
|
|
|
+ */
|
|
|
List<Map> jdSalesOrderInfoS(String orderNumber){
|
|
|
K3CloudApi api = new K3CloudApi();
|
|
|
//查询内容
|
|
@@ -247,7 +366,6 @@ public class JdProductionOrderServiceImpl implements JdProductionOrderService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 生产序列号
|
|
|
* @return
|
|
@@ -307,591 +425,163 @@ public class JdProductionOrderServiceImpl implements JdProductionOrderService
|
|
|
}
|
|
|
|
|
|
|
|
|
-// /**
|
|
|
-// * 物料编码不等于焊接
|
|
|
-// * 条件:所有开工数据
|
|
|
-// *
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-//public AjaxResult jdProductionOrderPullTwo(){
|
|
|
-// //金蝶工具key
|
|
|
-// K3CloudApi api = new K3CloudApi();
|
|
|
-// //定义查询条件
|
|
|
-// String query="{\n" +
|
|
|
-// " \"FormId\": \"PRD_MO\",\n" +
|
|
|
-// " \"FieldKeys\": \"FDescription,F_PONP_teshuyaoqiu,FBillNo,FBillType,FDate,FDocumentStatus," +
|
|
|
-// "FProductType,FMaterialId,FWorkShopID0,FQty,FStatus,,FSaleOrderNo,FPickMtrlStatus," +
|
|
|
-// "FMaterialId.FNumber,FMaterialName,F_PONP_BaseProperty,FSpecification,FUnitId.FName,F_PONP_yanse,F_PONP_mingpai,F_PONP_hegezheng.FDataValue," +
|
|
|
-// "F_PONP_shuomingshu.FDataValue,F_PONP_KaiGuanXiang,F_PONP_baozhuangxiang,F_PONP_GongLv,FPlanFinishDate,FPlanStartDate\",\n" +
|
|
|
-// " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FMaterialId.FNumber\",\"Compare\":\"34\",\"Value\":\"焊\",\"Right\":\"\",\"Logic\":0},{\"Left\":\"\",\"FieldName\":\"FStatus\",\"Compare\":\"105\",\"Value\":\"4\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
-// " \"OrderString\": \"\",\n" +
|
|
|
-// " \"TopRowCount\": 0,\n" +
|
|
|
-// " \"StartRow\": 0,\n" +
|
|
|
-// " \"Limit\": 8000,\n" +
|
|
|
-// " \"SubSystemId\": \"\"\n" +
|
|
|
-// "}";
|
|
|
-////
|
|
|
-// try {
|
|
|
-// //查询结果
|
|
|
-// String resultJson = api.billQuery(query);
|
|
|
-// //生产信息
|
|
|
-// List<JdProductionOrder> jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
-// //单据编号去重
|
|
|
-//// List<String> collectOne = jdProductionOrders.stream().map(JdProductionOrder::getDemandDocument).collect(Collectors.toSet())
|
|
|
-//// .stream().collect(Collectors.toList());
|
|
|
-//
|
|
|
-// //查询系统中的订单信息
|
|
|
-// ProductionPlanningManagement productionPlanningManagement1=new ProductionPlanningManagement();
|
|
|
-// productionPlanningManagement1.setIsWeldSheet("1");
|
|
|
-// List<ProductionPlanningManagement> productionPlanningManagements = productionPlanningManagementMapper.selectProductionPlanningManagementList(productionPlanningManagement1);
|
|
|
-//
|
|
|
-// List<String> collectTwo = productionPlanningManagements.stream().map(ProductionPlanningManagement::getOrderNumber).collect(Collectors.toSet())
|
|
|
-// .stream().collect(Collectors.toList());
|
|
|
-//
|
|
|
-//// List<String> cj= collectOne.stream().filter(item -> !collectTwo.contains(item)).collect(Collectors.toList());
|
|
|
-// //分组
|
|
|
-// // 按照订单号分组并去重
|
|
|
-//// Map<String, JdProductionOrder> groupedByDemandDocument = jdProductionOrders.stream().filter(item->!collectTwo.contains(item.getDemandDocument()))
|
|
|
-//// .collect(Collectors.toMap(
|
|
|
-//// JdProductionOrder::getDemandDocument,
|
|
|
-//// order -> order,
|
|
|
-//// (existing, replacement) -> existing // 保留第一个出现的订单
|
|
|
-//// ));
|
|
|
-// Map<String, List<JdProductionOrder>> groupedByDemandDocument = jdProductionOrders.stream()
|
|
|
-// .filter(item -> !collectTwo.contains(item.getDemandDocument()))
|
|
|
-// .collect(Collectors.groupingBy(JdProductionOrder::getDemandDocument));
|
|
|
-// if(groupedByDemandDocument.size()>0){
|
|
|
-// //订单循环
|
|
|
-// groupedByDemandDocument.forEach((k,v)->{
|
|
|
-// //计划编号
|
|
|
-// String planNumnber = generator.generateCommissionNumber();
|
|
|
-// //编号订单号
|
|
|
-// List<Map> mapList = this.jdSalesOrderInfoS(k);//订单详情信息
|
|
|
-// System.err.println(mapList.size());
|
|
|
-// //拿到了关于这个订单的销售订单
|
|
|
-// if(mapList.size()>0){
|
|
|
-// //编号订单号
|
|
|
-// String fBillNo = mapList.get(0).get("FBillNo").toString();//单据编号
|
|
|
-// //合同号
|
|
|
-// String F_PONP_Text = mapList.get(0).get("F.PONP.Text").toString();
|
|
|
-// //下单时间
|
|
|
-// String FDate = mapList.get(0).get("FCreateDate").toString();//日期
|
|
|
-// String F_PONP_Datetime;
|
|
|
-// if(mapList.get(0).get("F_PONP_DATETIME")!=null){
|
|
|
-// //要货日期
|
|
|
-// F_PONP_Datetime = mapList.get(0).get("F_PONP_DATETIME").toString();//要货日期
|
|
|
-// } else if(mapList.get(0).get("FDeliveryDate")!=null){
|
|
|
-// F_PONP_Datetime =mapList.get(0).get("FDeliveryDate").toString();//要货日期;
|
|
|
-// }else {
|
|
|
-// F_PONP_Datetime="";
|
|
|
-// }
|
|
|
-// ProductionPlanningManagement productionPlanningManagement=new ProductionPlanningManagement();
|
|
|
-// productionPlanningManagement.setPlanNumber(planNumnber);
|
|
|
-// productionPlanningManagement.setOrderNumber(fBillNo);
|
|
|
-// productionPlanningManagement.setContractNumber(F_PONP_Text);
|
|
|
-// if(StringUtils.isNotNull(v.get(0).getBz())){ //备注
|
|
|
-// productionPlanningManagement.setRemark(v.get(0).getBz());
|
|
|
-// }
|
|
|
-// productionPlanningManagement.setCreationtimeString(FDate);
|
|
|
-// productionPlanningManagement.setCompletionTime(F_PONP_Datetime);
|
|
|
-// if(StringUtils.isNotNull(v.get(0).getTsyq())){
|
|
|
-// productionPlanningManagement.setSpecialRequirements(v.get(0).getTsyq()); //特殊要求
|
|
|
-// }
|
|
|
-// productionPlanningManagement.setPlanType("0"); //待生产
|
|
|
-// productionPlanningManagement.setTaskStatus("2");//待排产
|
|
|
-// productionPlanningManagement.setIsWeldSheet("1"); //普通订单
|
|
|
-// //======处理基本的订单信息
|
|
|
-// productionPlanningManagementMapper.insertProductionPlanningManagement(productionPlanningManagement);
|
|
|
-// mapList.forEach(a->{
|
|
|
-// PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
-// List<JdProductionOrder> collect1 = jdProductionOrders.stream().filter(c -> c.getDemandDocument().equals(k) && c.getMaterialCode().equals(a.get("FMaterialId.FNumber").toString())).collect(Collectors.toList());
|
|
|
-// if(collect1.size()<=0){
|
|
|
-// System.out.println(k);
|
|
|
-// System.out.println(a.get("FMaterialId.FNumber").toString());
|
|
|
-// }
|
|
|
-// if(collect1.size()>0){
|
|
|
-// //需求单据(处理详情信息没有需求单据的问题)
|
|
|
-// planTaskDetails.setDemandDocument(collect1.get(0).getDocumentNumber()); //需求单据
|
|
|
-// //颜色
|
|
|
-// planTaskDetails.setColour(collect1.get(0).getYanse());
|
|
|
-// //铭牌
|
|
|
-// planTaskDetails.setMingpai(collect1.get(0).getMingpai());
|
|
|
-// //合格证
|
|
|
-// planTaskDetails.setHegezheng(collect1.get(0).getHegezheng());
|
|
|
-// //说明书
|
|
|
-// planTaskDetails.setShuomingshu(collect1.get(0).getShuomingshu());
|
|
|
-// //包装箱
|
|
|
-// planTaskDetails.setBaozhuangxiang(collect1.get(0).getBaozhuangxiang());
|
|
|
-// //开关箱子
|
|
|
-// planTaskDetails.setSwitchBox(collect1.get(0).getKaiguanxiang());
|
|
|
-// //功率
|
|
|
-// planTaskDetails.setPower(collect1.get(0).getGl());
|
|
|
-// }
|
|
|
-// planTaskDetails.setPlanId(productionPlanningManagement.getId());//计划id
|
|
|
-// planTaskDetails.setMaterialId(a.get("FMaterialId.FNumber").toString());//原材料编码
|
|
|
-// planTaskDetails.setMaterialName(a.get("FMaterialName").toString());//名称
|
|
|
-// planTaskDetails.setQuantity(a.get("FQty").toString());//数量
|
|
|
-// planTaskDetails.setTimeOfRequest(F_PONP_Datetime);
|
|
|
-// planTaskDetails.setCustomerModel(a.get("F.PONP.Text1").toString());//客户型号
|
|
|
-// planTaskDetails.setModelNumber(a.get("F.PONP.BaseProperty").toString());//型号
|
|
|
-// planTaskDetails.setSpecification(a.get("FMaterialModel").toString());//规格
|
|
|
-// planTaskDetails.setMaterialUnit(a.get("FUnitID.FName").toString());//单位
|
|
|
-//
|
|
|
-//// planTaskDetails.setColour(a.get("F.PONP.yanse").toString()); //颜色
|
|
|
-//// planTaskDetails.setMingpai(a.get("F.PONP.mingpai").toString()); //铭牌
|
|
|
-//// planTaskDetails.setHegezheng(a.get("F.PONP.hegezheng.FDataValue").toString()); //合格证
|
|
|
-//// planTaskDetails.setShuomingshu(a.get("F.PONP.shuomingshu.FDataValue").toString()); //说明书
|
|
|
-//// planTaskDetails.setBaozhuangxiang(a.get("F.PONP.baozhuangxiang").toString()); //包装箱
|
|
|
-//// planTaskDetails.setSwitchBox(a.get("F.PONP.Text5").toString()); //开关箱
|
|
|
-// planTaskDetailsMapper.insertPlanTaskDetails(planTaskDetails);
|
|
|
-// });
|
|
|
-// }
|
|
|
-// });
|
|
|
-// //处理订单序列号问题
|
|
|
-// groupedByDemandDocument.forEach((k,v)->{
|
|
|
-//// String documentNumber = item.getDocumentNumber();//需求单据编号
|
|
|
-// String stringQuery="{\n" +
|
|
|
-// " \"FormId\": \"PRD_MO\",\n" +
|
|
|
-// " \"FieldKeys\": \"FBillNo,FSNQty1,FSaleOrderNo,FSerialNo\",\n" +
|
|
|
-// " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FMaterialId.FNumber\",\"Compare\":\"34\",\"Value\":\"焊\",\"Right\":\"\",\"Logic\":0},{\"Left\":\"\",\"FieldName\":\"FStatus\",\"Compare\":\"105\",\"Value\":\"4\",\"Right\":\"\",\"Logic\":0},{\"Left\":\"\",\"FieldName\":\"FSaleOrderNo\",\"Compare\":\"67\",\"Value\":\""+k+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
-// " \"OrderString\": \"\",\n" +
|
|
|
-// " \"TopRowCount\": 0,\n" +
|
|
|
-// " \"StartRow\": 0,\n" +
|
|
|
-// " \"Limit\": 2000,\n" +
|
|
|
-// " \"SubSystemId\": \"\"\n" +
|
|
|
-// "}";
|
|
|
-// try {
|
|
|
-// String xlhString = api.billQuery(stringQuery);
|
|
|
-// if(!xlhString.equals("[]")){
|
|
|
-// List<ProductionCardFlowVo> mapList1 = JSON.parseArray(xlhString, ProductionCardFlowVo.class);
|
|
|
-// int i = productionCardFlowMapper.insertProductionCardFlowBatchVo(mapList1);
|
|
|
-// }
|
|
|
-// } catch (Exception e) {
|
|
|
-// throw new RuntimeException(e);
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
-// } catch (Exception e) {
|
|
|
-// throw new RuntimeException(e);
|
|
|
-// }
|
|
|
-// return AjaxResult.success();
|
|
|
-//}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
- * 物料编码不等于焊接
|
|
|
- * 条件:所有开工数据
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- public AjaxResult jdProductionOrderPullTwo(){
|
|
|
- AjaxResult ajaxResult = jdMaterialInfoService.pullMaterialBaseInfo();
|
|
|
- //金蝶工具key
|
|
|
- K3CloudApi api = new K3CloudApi();
|
|
|
- //定义查询条件
|
|
|
- String query="{\n" +
|
|
|
- " \"FormId\": \"PRD_MO\",\n" +
|
|
|
- " \"FieldKeys\": \"FDescription,F_PONP_teshuyaoqiu,FBillNo,FBillType,FDate,FDocumentStatus," +
|
|
|
- "FProductType,FMaterialId,FWorkShopID0,FQty,FStatus,FSaleOrderNo,FPickMtrlStatus," +
|
|
|
- "FMaterialId.FNumber,FMaterialName,F_PONP_BaseProperty,FSpecification,FUnitId.FName,F_PONP_yanse,F_PONP_mingpai,F_PONP_hegezheng.FDataValue," +
|
|
|
- "F_PONP_shuomingshu.FDataValue,F_PONP_KaiGuanXiang,F_PONP_baozhuangxiang,F_PONP_GongLv,FPlanFinishDate,FPlanStartDate,F_PONP_XQRQ,FPlanStartDate,FPlanFinishDate\",\n" +
|
|
|
- " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FMaterialId.FNumber\",\"Compare\":\"34\",\"Value\":\"焊\",\"Right\":\"\",\"Logic\":0},{\"Left\":\"\",\"FieldName\":\"FStatus\",\"Compare\":\"105\",\"Value\":\"4\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
- " \"OrderString\": \"\",\n" +
|
|
|
- " \"TopRowCount\": 0,\n" +
|
|
|
- " \"StartRow\": 0,\n" +
|
|
|
- " \"Limit\": 5000,\n" +
|
|
|
- " \"SubSystemId\": \"\"\n" +
|
|
|
- "}";
|
|
|
-//
|
|
|
- try {
|
|
|
- //查询结果
|
|
|
- String resultJson = api.billQuery(query);
|
|
|
- //生产信息
|
|
|
- List<JdProductionOrder> jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
- //查询系统中的订单信息
|
|
|
- ProductionPlanningManagement productionPlanningManagement1=new ProductionPlanningManagement();
|
|
|
- productionPlanningManagement1.setIsWeldSheet("1");
|
|
|
- List<ProductionPlanningManagement> productionPlanningManagements = productionPlanningManagementMapper.selectProductionPlanningManagementList(productionPlanningManagement1);
|
|
|
- List<String> collectTwo = productionPlanningManagements.stream().map(ProductionPlanningManagement::getOrderNumber).collect(Collectors.toSet())
|
|
|
- .stream().collect(Collectors.toList());
|
|
|
-
|
|
|
-
|
|
|
- Map<String, List<JdProductionOrder>> groupedByDemandDocument = jdProductionOrders.stream()
|
|
|
- .filter(item -> !collectTwo.contains(item.getDemandDocument()))
|
|
|
- .collect(Collectors.groupingBy(JdProductionOrder::getDemandDocument));
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- if(groupedByDemandDocument.size()>0){
|
|
|
- //订单循环
|
|
|
- groupedByDemandDocument.forEach((k,v)->{
|
|
|
- ProductionPlanningManagement productionPlanningManagement=new ProductionPlanningManagement();
|
|
|
- //编号订单号
|
|
|
- productionPlanningManagement.setOrderNumber(k);
|
|
|
- //计划编号
|
|
|
- String planNumnber = generator.generateCommissionNumber();
|
|
|
- productionPlanningManagement.setPlanNumber(planNumnber);
|
|
|
- //计算订单的最大完成时间
|
|
|
-// Optional<LocalDateTime> maxCompletionTime = v.stream()
|
|
|
-// .map(item -> LocalDateTime.parse(item.getCompletionTime(), DateTimeFormatter.ISO_LOCAL_DATE_TIME))
|
|
|
-// .max(Comparator.naturalOrder());
|
|
|
-// maxCompletionTime.ifPresent(maxTime ->{
|
|
|
-// System.out.println("最大的时间: " + maxTime);
|
|
|
-// String format1 = maxTime.format(formatter);
|
|
|
-// productionPlanningManagement.setCompletionTime(format1);//订单的最大完成时间
|
|
|
-// });
|
|
|
- productionPlanningManagement.setPlanType("0"); //待生产
|
|
|
- productionPlanningManagement.setTaskStatus("4");//待排产
|
|
|
- productionPlanningManagement.setIsWeldSheet("1");//焊接订单
|
|
|
- if(StringUtils.isNotNull(v.get(0).getCompletionTime())){
|
|
|
- productionPlanningManagement.setCompletionTime(v.get(0).getCompletionTime());//完成时间
|
|
|
- }
|
|
|
- //备注
|
|
|
- if(StringUtils.isNotNull(v.get(0).getRemark())){
|
|
|
- productionPlanningManagement.setRemark(v.get(0).getRemark()); //备注
|
|
|
- }
|
|
|
- //单据类型
|
|
|
- if(StringUtils.isNotNull(v.get(0).getDocumentTyep())){
|
|
|
- productionPlanningManagement.setOrderType(v.get(0).getDocumentTyep()); //单据类型
|
|
|
- }
|
|
|
- //订单的创建时间
|
|
|
- productionPlanningManagement.setCreationtimeString(v.get(0).getCreationtimeString());//单据的创建时间
|
|
|
- //特殊要求
|
|
|
- if(StringUtils.isNotNull(v.get(0).getTsyq())){
|
|
|
- productionPlanningManagement.setSpecialRequirements(v.get(0).getTsyq());//特殊要求
|
|
|
- }
|
|
|
-
|
|
|
- //编号订单号
|
|
|
- List<Map> mapList = this.jdSalesOrderInfoS(k);//订单详情信息
|
|
|
- String fDeliveryDate;
|
|
|
- if(mapList.size()>0){
|
|
|
- fDeliveryDate = mapList.get(0).get("FDeliveryDate").toString();
|
|
|
- } else {
|
|
|
- fDeliveryDate = "";
|
|
|
- }
|
|
|
- //拿到了关于这个订单的销售订单
|
|
|
- if(mapList.size()>0){
|
|
|
- if(StringUtils.isNotNull(mapList.get(0).get("F.PONP.Text"))){
|
|
|
- productionPlanningManagement.setContractNumber(mapList.get(0).get("F.PONP.Text").toString());
|
|
|
- }
|
|
|
- productionPlanningManagement.setCompletionTime(fDeliveryDate);
|
|
|
- //======处理基本的订单信息
|
|
|
- productionPlanningManagementMapper.insertProductionPlanningManagement(productionPlanningManagement);
|
|
|
- v.forEach(a->{
|
|
|
- PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
- planTaskDetails.setDemandDocument(a.getDocumentNumber());//需求单据号
|
|
|
- planTaskDetails.setPlanId(productionPlanningManagement.getId());//计划id
|
|
|
- planTaskDetails.setMaterialId(a.getMaterialCode());//原材料编码
|
|
|
- planTaskDetails.setMaterialName(a.getMaterialName());//名称
|
|
|
- planTaskDetails.setQuantity(a.getQuantity());//数量
|
|
|
-// planTaskDetails.setTimeOfRequest(a.getCompletionTime());//要货时间
|
|
|
- planTaskDetails.setModelNumber(a.getModelNumber());//型号
|
|
|
- planTaskDetails.setSpecification(a.getSpecification());//规格
|
|
|
- planTaskDetails.setMaterialUnit(a.getUnit());//单位
|
|
|
- planTaskDetails.setPower(a.getGl());//功率
|
|
|
- planTaskDetails.setVoltage(a.getDianYaPinLv());//电压频率
|
|
|
- planTaskDetails.setColour(a.getYanse());//颜色
|
|
|
- planTaskDetails.setMingpai(a.getMingpai());//铭牌
|
|
|
- planTaskDetails.setShuomingshu(a.getShuomingshu());//说明书
|
|
|
- planTaskDetails.setHegezheng(a.getHegezheng());//合格证
|
|
|
- planTaskDetails.setBaozhuangxiang(a.getBaozhuangxiang());//包装箱
|
|
|
- planTaskDetails.setSwitchBox(a.getKaiguanxiang());//开关箱
|
|
|
- planTaskDetails.setScheduledCommencement(a.getFPlanStartDate()); //计划开始时间
|
|
|
- planTaskDetails.setScheduledCompletion(a.getFPlanFinishDate()); //计划完工时间
|
|
|
- planTaskDetails.setRemark(a.getRemark());
|
|
|
- if(StringUtils.isNotNull(a.getDocumentDate())){
|
|
|
- SimpleDateFormat formatter1= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- String formattedDate = formatter1.format(a.getDocumentDate());
|
|
|
- planTaskDetails.setTimeOfRequest(formattedDate);
|
|
|
- }
|
|
|
-
|
|
|
- planTaskDetailsMapper.insertPlanTaskDetails(planTaskDetails);
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- //处理订单序列号问题
|
|
|
- groupedByDemandDocument.forEach((k,v)->{
|
|
|
- String stringQuery="{\n" +
|
|
|
- " \"FormId\": \"PRD_MO\",\n" +
|
|
|
- " \"FieldKeys\": \"FBillNo,FSNQty1,FSaleOrderNo,FSerialNo\",\n" +
|
|
|
- " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FMaterialId.FNumber\",\"Compare\":\"34\",\"Value\":\"焊\",\"Right\":\"\",\"Logic\":0},{\"Left\":\"\",\"FieldName\":\"FStatus\",\"Compare\":\"105\",\"Value\":\"4\",\"Right\":\"\",\"Logic\":0},{\"Left\":\"\",\"FieldName\":\"FSaleOrderNo\",\"Compare\":\"67\",\"Value\":\""+k+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
- " \"OrderString\": \"\",\n" +
|
|
|
- " \"TopRowCount\": 0,\n" +
|
|
|
- " \"StartRow\": 0,\n" +
|
|
|
- " \"Limit\": 2000,\n" +
|
|
|
- " \"SubSystemId\": \"\"\n" +
|
|
|
- "}";
|
|
|
- try {
|
|
|
- String xlhString = api.billQuery(stringQuery);
|
|
|
- if(!xlhString.equals("[]")){
|
|
|
- List<ProductionCardFlowVo> mapList1 = JSON.parseArray(xlhString, ProductionCardFlowVo.class);
|
|
|
- int i = productionCardFlowMapper.insertProductionCardFlowBatchVo(mapList1);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- return AjaxResult.success();
|
|
|
- }
|
|
|
- /**
|
|
|
- * 拉取焊接
|
|
|
+ * 拉取焊接订单ERP数据
|
|
|
*/
|
|
|
@Override
|
|
|
public AjaxResult pullWeldProductionOrder(){
|
|
|
- //金蝶工具key
|
|
|
- K3CloudApi api = new K3CloudApi();
|
|
|
- // 获取当前时间
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
- System.out.println("当前时间: " + now);
|
|
|
- // 减去三个月
|
|
|
- LocalDateTime threeMonthsAgo = now.minusMonths(3);
|
|
|
- System.out.println("三个月前的时间: " + threeMonthsAgo);
|
|
|
- LocalDateTime localDateTime1 = threeMonthsAgo.withMinute(0).withSecond(0).withNano(0);
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- String format = localDateTime1.format(formatter);
|
|
|
- //定义查询条件
|
|
|
- String query="{\n" +
|
|
|
- " \"FormId\": \"PRD_MO\",\n" +
|
|
|
- " \"FieldKeys\": \"FDescription,F_PONP_teshuyaoqiu,FBillNo,FBillType,FDate,FDocumentStatus," +
|
|
|
- "FProductType,FMaterialId,FWorkShopID0,FQty,FStatus,,FSaleOrderNo,FPickMtrlStatus," +
|
|
|
- "FMaterialId.FNumber,FMaterialName,F_PONP_BaseProperty,FSpecification,FUnitId.FName,F_PONP_yanse,F_PONP_mingpai,F_PONP_hegezheng.FDataValue," +
|
|
|
- "F_PONP_shuomingshu.FDataValue,F_PONP_KaiGuanXiang,F_PONP_baozhuangxiang,F_PONP_GongLv,F_PONP_XQRQ,FDate,FPlanStartDate,FPlanFinishDate\",\n" +
|
|
|
- " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FMaterialId.FNumber\",\"Compare\":\"17\",\"Value\":\"焊\",\"Right\":\"\",\"Logic\":0}," +
|
|
|
- "{\"Left\":\"\",\"FieldName\":\"FCreateDate\",\"Compare\":\"39\",\"Value\":\""+format+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
- " \"OrderString\": \"\",\n" +
|
|
|
- " \"TopRowCount\": 0,\n" +
|
|
|
- " \"StartRow\": 0,\n" +
|
|
|
- " \"Limit\": 5000,\n" +
|
|
|
- " \"SubSystemId\": \"\"\n" +
|
|
|
- "}";
|
|
|
- int startRow = 0; // 起始行号
|
|
|
- int limit = 5000; // 每次查询的数量
|
|
|
- // 更新查询条件中的起始行号
|
|
|
- //查询条件
|
|
|
- Map<String, Object> map = JSON.parseObject(query, Map.class);
|
|
|
- List<JdProductionOrder> jdProductionOrders;
|
|
|
- boolean flag = true;
|
|
|
- try {
|
|
|
- do {
|
|
|
+ Boolean aTrue = stringRedisTemplate.opsForValue().setIfAbsent("fjqy:hjd:pulled", "true");
|
|
|
+ if (aTrue) {
|
|
|
+ //金蝶工具key
|
|
|
+ K3CloudApi api = new K3CloudApi();
|
|
|
+ // 获取当前时间
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ System.out.println("当前时间: " + now);
|
|
|
+ // 减去三个月
|
|
|
+ LocalDateTime threeMonthsAgo = now.minusMonths(3);
|
|
|
+ System.out.println("三个月前的时间: " + threeMonthsAgo);
|
|
|
+ LocalDateTime localDateTime1 = threeMonthsAgo.withMinute(0).withSecond(0).withNano(0);
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String format = localDateTime1.format(formatter);
|
|
|
+ //定义查询条件
|
|
|
+ String query="{\n" +
|
|
|
+ " \"FormId\": \"PRD_MO\",\n" +
|
|
|
+ " \"FieldKeys\": \"FDescription,F_PONP_teshuyaoqiu,FBillNo,FBillType,FDate,FDocumentStatus," +
|
|
|
+ "FProductType,FMaterialId,FWorkShopID0,FQty,FStatus,,FSaleOrderNo,FPickMtrlStatus," +
|
|
|
+ "FMaterialId.FNumber,FMaterialName,F_PONP_BaseProperty,FSpecification,FUnitId.FName,F_PONP_yanse,F_PONP_mingpai,F_PONP_hegezheng.FDataValue," +
|
|
|
+ "F_PONP_shuomingshu.FDataValue,F_PONP_KaiGuanXiang,F_PONP_baozhuangxiang,F_PONP_GongLv,F_PONP_XQRQ,FDate,FPlanStartDate,FPlanFinishDate\",\n" +
|
|
|
+ " \"FilterString\": [{\"Left\":\"\",\"FieldName\":\"FMaterialId.FNumber\",\"Compare\":\"17\",\"Value\":\"焊\",\"Right\":\"\",\"Logic\":0}," +
|
|
|
+ "{\"Left\":\"\",\"FieldName\":\"FCreateDate\",\"Compare\":\"39\",\"Value\":\""+format+"\",\"Right\":\"\",\"Logic\":0}],\n" +
|
|
|
+ " \"OrderString\": \"\",\n" +
|
|
|
+ " \"TopRowCount\": 0,\n" +
|
|
|
+ " \"StartRow\": 0,\n" +
|
|
|
+ " \"Limit\": 5000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ int startRow = 0; // 起始行号
|
|
|
+ int limit = 5000; // 每次查询的数量
|
|
|
// 更新查询条件中的起始行号
|
|
|
- map.put("StartRow", startRow);
|
|
|
- //查询结果
|
|
|
- String resultJson = api.billQuery(JSON.toJSONString(map));
|
|
|
- if (resultJson.isEmpty()||resultJson.equals("[]")) {
|
|
|
- // 处理空结果的情况
|
|
|
- flag = false;
|
|
|
- }else {
|
|
|
- //生产信息
|
|
|
- jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
- //查询系统中的订单信息
|
|
|
- ProductionPlanningManagement productionPlanningManagement1=new ProductionPlanningManagement();
|
|
|
- productionPlanningManagement1.setIsWeldSheet("2");
|
|
|
- List<ProductionPlanningManagement> productionPlanningManagements = productionPlanningManagementMapper.selectProductionPlanningManagementList(productionPlanningManagement1);
|
|
|
-
|
|
|
- List<String> collectTwo = productionPlanningManagements.stream().map(ProductionPlanningManagement::getOrderNumber).collect(Collectors.toSet())
|
|
|
- .stream().collect(Collectors.toList());
|
|
|
- // 过滤掉 collectTwo 中包含的需求文档编号,并按 demandDocument 分组
|
|
|
- Map<String, List<JdProductionOrder>> groupedByDemandDocument = jdProductionOrders.stream()
|
|
|
- .filter(item -> !collectTwo.contains(item.getDemandDocument()))
|
|
|
- .collect(Collectors.groupingBy(JdProductionOrder::getDemandDocument));
|
|
|
- if(groupedByDemandDocument.size()>0){
|
|
|
- //订单循环
|
|
|
- groupedByDemandDocument.forEach((k,v)->{
|
|
|
- //计划编号
|
|
|
- String planNumnber = generator.generateCommissionNumber();
|
|
|
- //订单号
|
|
|
- ProductionPlanningManagement productionPlanningManagement=new ProductionPlanningManagement();
|
|
|
- productionPlanningManagement.setOrderNumber(k); //订单编号
|
|
|
- productionPlanningManagement.setPlanNumber(planNumnber);//计划号
|
|
|
- productionPlanningManagement.setPlanType("0"); //待生产
|
|
|
- productionPlanningManagement.setTaskStatus("4");//待排产
|
|
|
- productionPlanningManagement.setIsWeldSheet("2");//焊接订单
|
|
|
-// //计算订单的最大完成时间
|
|
|
-// Optional<LocalDateTime> maxCompletionTime = v.stream()
|
|
|
-// .map(item -> LocalDateTime.parse(item.getCompletionTime(), DateTimeFormatter.ISO_LOCAL_DATE_TIME))
|
|
|
-// .max(Comparator.naturalOrder());
|
|
|
-// maxCompletionTime.ifPresent(maxTime ->{
|
|
|
-// System.out.println("最大的时间: " + maxTime);
|
|
|
-// String format1 = maxTime.format(formatter);
|
|
|
-// productionPlanningManagement.setCompletionTime(format1);//订单的最大完成时间
|
|
|
-// });
|
|
|
- //备注
|
|
|
- if(StringUtils.isNotNull(v.get(0).getRemark())){
|
|
|
- productionPlanningManagement.setRemark(v.get(0).getRemark()); //备注
|
|
|
- }
|
|
|
- //订单的创建时间
|
|
|
- productionPlanningManagement.setCreationtimeString(v.get(0).getCreationtimeString());//单据的创建时间
|
|
|
- //特殊要求
|
|
|
- if(StringUtils.isNotNull(v.get(0).getTsyq())){
|
|
|
- productionPlanningManagement.setSpecialRequirements(v.get(0).getTsyq());//特殊要求
|
|
|
- }
|
|
|
- //单据类型
|
|
|
- if(StringUtils.isNotNull(v.get(0).getDocumentTyep())){
|
|
|
- productionPlanningManagement.setOrderType(v.get(0).getDocumentTyep()); //单据类型
|
|
|
- }
|
|
|
+ //查询条件
|
|
|
+ Map<String, Object> map = JSON.parseObject(query, Map.class);
|
|
|
+ List<JdProductionOrder> jdProductionOrders;
|
|
|
+ boolean flag = true;
|
|
|
+ try {
|
|
|
+ do {
|
|
|
+ // 更新查询条件中的起始行号
|
|
|
+ map.put("StartRow", startRow);
|
|
|
+ //查询结果
|
|
|
+ String resultJson = api.billQuery(JSON.toJSONString(map));
|
|
|
+ if (resultJson.isEmpty()||resultJson.equals("[]")) {
|
|
|
+ // 处理空结果的情况
|
|
|
+ flag = false;
|
|
|
+ }else {
|
|
|
+ //生产信息
|
|
|
+ jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
+ //查询系统中的订单信息
|
|
|
+ ProductionPlanningManagement productionPlanningManagement1=new ProductionPlanningManagement();
|
|
|
+ productionPlanningManagement1.setIsWeldSheet("2");
|
|
|
+ List<ProductionPlanningManagement> productionPlanningManagements = productionPlanningManagementMapper.selectProductionPlanningManagementList(productionPlanningManagement1);
|
|
|
+
|
|
|
+ List<String> collectTwo = productionPlanningManagements.stream().map(ProductionPlanningManagement::getOrderNumber).collect(Collectors.toSet())
|
|
|
+ .stream().collect(Collectors.toList());
|
|
|
+ // 过滤掉 collectTwo 中包含的需求文档编号,并按 demandDocument 分组
|
|
|
+ Map<String, List<JdProductionOrder>> groupedByDemandDocument = jdProductionOrders.stream()
|
|
|
+ .filter(item -> !collectTwo.contains(item.getDemandDocument()))
|
|
|
+ .collect(Collectors.groupingBy(JdProductionOrder::getDemandDocument));
|
|
|
+ if(groupedByDemandDocument.size()>0){
|
|
|
+ //订单循环
|
|
|
+ groupedByDemandDocument.forEach((k,v)->{
|
|
|
+ //计划编号
|
|
|
+ String planNumnber = generator.generateCommissionNumber();
|
|
|
+ //订单号
|
|
|
+ ProductionPlanningManagement productionPlanningManagement=new ProductionPlanningManagement();
|
|
|
+ productionPlanningManagement.setOrderNumber(k); //订单编号
|
|
|
+ productionPlanningManagement.setPlanNumber(planNumnber);//计划号
|
|
|
+ productionPlanningManagement.setPlanType("0"); //待生产
|
|
|
+ productionPlanningManagement.setTaskStatus("4");//待排产
|
|
|
+ productionPlanningManagement.setIsWeldSheet("2");//焊接订单
|
|
|
+ //备注
|
|
|
+ if(StringUtils.isNotNull(v.get(0).getRemark())){
|
|
|
+ productionPlanningManagement.setRemark(v.get(0).getRemark()); //备注
|
|
|
+ }
|
|
|
+ //订单的创建时间
|
|
|
+ productionPlanningManagement.setCreationtimeString(v.get(0).getCreationtimeString());//单据的创建时间
|
|
|
+ //特殊要求
|
|
|
+ if(StringUtils.isNotNull(v.get(0).getTsyq())){
|
|
|
+ productionPlanningManagement.setSpecialRequirements(v.get(0).getTsyq());//特殊要求
|
|
|
+ }
|
|
|
+ //单据类型
|
|
|
+ if(StringUtils.isNotNull(v.get(0).getDocumentTyep())){
|
|
|
+ productionPlanningManagement.setOrderType(v.get(0).getDocumentTyep()); //单据类型
|
|
|
+ }
|
|
|
|
|
|
- //编号订单号
|
|
|
- List<Map> mapList = this.jdSalesOrderInfoS(k);//订单详情信息
|
|
|
- String fDeliveryDate;
|
|
|
- if(mapList.size()>0){
|
|
|
- fDeliveryDate = mapList.get(0).get("FDeliveryDate").toString();
|
|
|
- } else {
|
|
|
- fDeliveryDate = "";
|
|
|
- }
|
|
|
- //拿到了关于这个订单的销售订单
|
|
|
- if(mapList.size()>0){
|
|
|
- if(StringUtils.isNotNull(mapList.get(0).get("F.PONP.Text"))){
|
|
|
- productionPlanningManagement.setContractNumber(mapList.get(0).get("F.PONP.Text").toString());
|
|
|
- }
|
|
|
- productionPlanningManagement.setCompletionTime(fDeliveryDate);
|
|
|
- //======处理基本的订单信息
|
|
|
- productionPlanningManagementMapper.insertProductionPlanningManagement(productionPlanningManagement);
|
|
|
- v.forEach(a->{
|
|
|
- PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
- planTaskDetails.setDemandDocument(a.getDocumentNumber());//需求单据号
|
|
|
- planTaskDetails.setPlanId(productionPlanningManagement.getId());//计划id
|
|
|
- planTaskDetails.setMaterialId(a.getMaterialCode());//原材料编码
|
|
|
- planTaskDetails.setMaterialName(a.getMaterialName());//名称
|
|
|
- planTaskDetails.setQuantity(a.getQuantity());//数量
|
|
|
-// planTaskDetails.setTimeOfRequest(a.getCompletionTime());//要货时间
|
|
|
- planTaskDetails.setModelNumber(a.getModelNumber());//型号
|
|
|
- planTaskDetails.setSpecification(a.getSpecification());//规格
|
|
|
- planTaskDetails.setMaterialUnit(a.getUnit());//单位
|
|
|
- planTaskDetails.setPower(a.getGl());//功率
|
|
|
- planTaskDetails.setVoltage(a.getDianYaPinLv());//电压频率
|
|
|
- planTaskDetails.setColour(a.getYanse());//颜色
|
|
|
- planTaskDetails.setMingpai(a.getMingpai());//铭牌
|
|
|
- planTaskDetails.setShuomingshu(a.getShuomingshu());//说明书
|
|
|
- planTaskDetails.setHegezheng(a.getHegezheng());//合格证
|
|
|
- planTaskDetails.setBaozhuangxiang(a.getBaozhuangxiang());//包装箱
|
|
|
- planTaskDetails.setSwitchBox(a.getKaiguanxiang());//开关箱
|
|
|
- planTaskDetails.setScheduledCommencement(a.getFPlanStartDate()); //计划开始时间
|
|
|
- planTaskDetails.setScheduledCompletion(a.getFPlanFinishDate()); //计划完工时间
|
|
|
- planTaskDetails.setRemark(a.getRemark());
|
|
|
- if(StringUtils.isNotNull(a.getDocumentDate())){
|
|
|
- SimpleDateFormat formatter1= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- String formattedDate = formatter1.format(a.getDocumentDate());
|
|
|
- planTaskDetails.setTimeOfRequest(formattedDate);//单据日期
|
|
|
+ //编号订单号
|
|
|
+ List<Map> mapList = this.jdSalesOrderInfoS(k);//订单详情信息
|
|
|
+ String fDeliveryDate;
|
|
|
+ if(mapList.size()>0){
|
|
|
+ fDeliveryDate = mapList.get(0).get("FDeliveryDate").toString();
|
|
|
+ } else {
|
|
|
+ fDeliveryDate = "";
|
|
|
+ }
|
|
|
+ //拿到了关于这个订单的销售订单
|
|
|
+ if(mapList.size()>0){
|
|
|
+ if(StringUtils.isNotNull(mapList.get(0).get("F.PONP.Text"))){
|
|
|
+ productionPlanningManagement.setContractNumber(mapList.get(0).get("F.PONP.Text").toString());
|
|
|
+ }
|
|
|
+ productionPlanningManagement.setCompletionTime(fDeliveryDate);
|
|
|
+ //======处理基本的订单信息
|
|
|
+ productionPlanningManagementMapper.insertProductionPlanningManagement(productionPlanningManagement);
|
|
|
+ v.forEach(a->{
|
|
|
+ PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
+ planTaskDetails.setDemandDocument(a.getDocumentNumber());//需求单据号
|
|
|
+ planTaskDetails.setPlanId(productionPlanningManagement.getId());//计划id
|
|
|
+ planTaskDetails.setMaterialId(a.getMaterialCode());//原材料编码
|
|
|
+ planTaskDetails.setMaterialName(a.getMaterialName());//名称
|
|
|
+ planTaskDetails.setQuantity(a.getQuantity());//数量
|
|
|
+ // planTaskDetails.setTimeOfRequest(a.getCompletionTime());//要货时间
|
|
|
+ planTaskDetails.setModelNumber(a.getModelNumber());//型号
|
|
|
+ planTaskDetails.setSpecification(a.getSpecification());//规格
|
|
|
+ planTaskDetails.setMaterialUnit(a.getUnit());//单位
|
|
|
+ planTaskDetails.setPower(a.getGl());//功率
|
|
|
+ planTaskDetails.setVoltage(a.getDianYaPinLv());//电压频率
|
|
|
+ planTaskDetails.setColour(a.getYanse());//颜色
|
|
|
+ planTaskDetails.setMingpai(a.getMingpai());//铭牌
|
|
|
+ planTaskDetails.setShuomingshu(a.getShuomingshu());//说明书
|
|
|
+ planTaskDetails.setHegezheng(a.getHegezheng());//合格证
|
|
|
+ planTaskDetails.setBaozhuangxiang(a.getBaozhuangxiang());//包装箱
|
|
|
+ planTaskDetails.setSwitchBox(a.getKaiguanxiang());//开关箱
|
|
|
+ planTaskDetails.setScheduledCommencement(a.getFPlanStartDate()); //计划开始时间
|
|
|
+ planTaskDetails.setScheduledCompletion(a.getFPlanFinishDate()); //计划完工时间
|
|
|
+ planTaskDetails.setRemark(a.getRemark());
|
|
|
+ if(StringUtils.isNotNull(a.getDocumentDate())){
|
|
|
+ SimpleDateFormat formatter1= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String formattedDate = formatter1.format(a.getDocumentDate());
|
|
|
+ planTaskDetails.setTimeOfRequest(formattedDate);//单据日期
|
|
|
+ }
|
|
|
+ planTaskDetailsMapper.insertPlanTaskDetails(planTaskDetails);
|
|
|
+ });
|
|
|
}
|
|
|
- planTaskDetailsMapper.insertPlanTaskDetails(planTaskDetails);
|
|
|
});
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
- System.out.println(1);
|
|
|
- if (jdProductionOrders.size() < 5000) {
|
|
|
- flag = false;
|
|
|
- }
|
|
|
- // 更新起始行号
|
|
|
- startRow += limit;
|
|
|
- // 如果返回的数据量小于5000,说明已经没有更多的数据,结束循环
|
|
|
+ System.out.println(1);
|
|
|
+ if (jdProductionOrders.size() < 5000) {
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ // 更新起始行号
|
|
|
+ startRow += limit;
|
|
|
+ // 如果返回的数据量小于5000,说明已经没有更多的数据,结束循环
|
|
|
+ }
|
|
|
+ } while (flag);
|
|
|
+ } catch (Exception e) {
|
|
|
+ stringRedisTemplate.delete("fjqy:hjd:pulled");
|
|
|
+ throw new RuntimeException(e);
|
|
|
}
|
|
|
- } while (flag);
|
|
|
-
|
|
|
-//
|
|
|
-// //生产信息
|
|
|
-// List<JdProductionOrder> jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
-//
|
|
|
-//
|
|
|
-// //查询系统中的订单信息
|
|
|
-// ProductionPlanningManagement productionPlanningManagement1 = new ProductionPlanningManagement();
|
|
|
-// productionPlanningManagement1.setIsWeldSheet("2");
|
|
|
-// List<ProductionPlanningManagement> productionPlanningManagements = productionPlanningManagementMapper.selectProductionPlanningManagementList(productionPlanningManagement1);
|
|
|
-//
|
|
|
-// List<String> collectTwo = productionPlanningManagements.stream().map(ProductionPlanningManagement::getOrderNumber).collect(Collectors.toSet())
|
|
|
-// .stream().collect(Collectors.toList());
|
|
|
-//
|
|
|
-//// List<String> cj= collectOne.stream().filter(item -> !collectTwo.contains(item)).collect(Collectors.toList());
|
|
|
-// //分组
|
|
|
-// // 按照订单号分组并去重
|
|
|
-//// Map<String, JdProductionOrder> groupedByDemandDocument = jdProductionOrders.stream().filter(item->!collectTwo.contains(item.getDemandDocument()))
|
|
|
-//// .collect(Collectors.toMap(
|
|
|
-//// JdProductionOrder::getDemandDocument,
|
|
|
-//// order -> order,
|
|
|
-//// (existing, replacement) -> existing // 保留第一个出现的订单
|
|
|
-//// ));
|
|
|
-// // 过滤掉 collectTwo 中包含的需求文档编号,并按 demandDocument 分组
|
|
|
-// Map<String, List<JdProductionOrder>> groupedByDemandDocument = jdProductionOrders.stream()
|
|
|
-// .filter(item -> !collectTwo.contains(item.getDemandDocument()))
|
|
|
-// .collect(Collectors.groupingBy(JdProductionOrder::getDemandDocument));
|
|
|
-// if (groupedByDemandDocument.size() > 0) {
|
|
|
-// //订单循环
|
|
|
-// groupedByDemandDocument.forEach((k, v) -> {
|
|
|
-// //计划编号
|
|
|
-// String planNumnber = generator.generateCommissionNumber();
|
|
|
-// //订单号
|
|
|
-// ProductionPlanningManagement productionPlanningManagement = new ProductionPlanningManagement();
|
|
|
-// productionPlanningManagement.setOrderNumber(k); //订单编号
|
|
|
-// productionPlanningManagement.setPlanNumber(planNumnber);//计划号
|
|
|
-// productionPlanningManagement.setPlanType("0"); //待生产
|
|
|
-// productionPlanningManagement.setTaskStatus("2");//待排产
|
|
|
-// productionPlanningManagement.setIsWeldSheet("2");//焊接订单
|
|
|
-// //计算订单的最大完成时间
|
|
|
-// Optional<LocalDateTime> maxCompletionTime = v.stream()
|
|
|
-// .map(item -> LocalDateTime.parse(item.getCompletionTime(), DateTimeFormatter.ISO_LOCAL_DATE_TIME))
|
|
|
-// .max(Comparator.naturalOrder());
|
|
|
-//
|
|
|
-// maxCompletionTime.ifPresent(maxTime -> {
|
|
|
-// System.out.println("最大的时间: " + maxTime);
|
|
|
-// String format1 = maxTime.format(formatter);
|
|
|
-// productionPlanningManagement.setCompletionTime(format1);//订单的最大完成时间
|
|
|
-// });
|
|
|
-// //备注
|
|
|
-// if (StringUtils.isNotNull(v.get(0).getRemark())) {
|
|
|
-// productionPlanningManagement.setRemark(v.get(0).getRemark()); //备注
|
|
|
-// }
|
|
|
-// //订单的创建时间
|
|
|
-// productionPlanningManagement.setCreationtimeString(v.get(0).getCreationtimeString());//单据的创建时间
|
|
|
-// //特殊要求
|
|
|
-// if (StringUtils.isNotNull(v.get(0).getTsyq())) {
|
|
|
-// productionPlanningManagement.setSpecialRequirements(v.get(0).getTsyq());//特殊要求
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// //编号订单号
|
|
|
-// List<Map> mapList = this.jdSalesOrderInfoS(k);//订单详情信息
|
|
|
-//
|
|
|
-// //拿到了关于这个订单的销售订单
|
|
|
-// if (mapList.size() > 0) {
|
|
|
-// if (StringUtils.isNotNull(mapList.get(0).get("F.PONP.Text"))) {
|
|
|
-// productionPlanningManagement.setContractNumber(mapList.get(0).get("F.PONP.Text").toString());
|
|
|
-// }
|
|
|
-// //======处理基本的订单信息
|
|
|
-// productionPlanningManagementMapper.insertProductionPlanningManagement(productionPlanningManagement);
|
|
|
-// v.forEach(a -> {
|
|
|
-// PlanTaskDetails planTaskDetails = new PlanTaskDetails();
|
|
|
-// planTaskDetails.setDemandDocument(a.getDocumentNumber());//需求单据号
|
|
|
-// planTaskDetails.setPlanId(productionPlanningManagement.getId());//计划id
|
|
|
-// planTaskDetails.setMaterialId(a.getMaterialCode());//原材料编码
|
|
|
-// planTaskDetails.setMaterialName(a.getMaterialName());//名称
|
|
|
-// planTaskDetails.setQuantity(a.getQuantity());//数量
|
|
|
-// planTaskDetails.setTimeOfRequest(a.getCompletionTime());//要货时间
|
|
|
-// planTaskDetails.setModelNumber(a.getModelNumber());//型号
|
|
|
-// planTaskDetails.setSpecification(a.getSpecification());//规格
|
|
|
-// planTaskDetails.setMaterialUnit(a.getUnit());//单位
|
|
|
-// planTaskDetails.setPower(a.getGl());//功率
|
|
|
-// planTaskDetails.setVoltage(a.getDianYaPinLv());//电压频率
|
|
|
-// planTaskDetails.setColour(a.getYanse());//颜色
|
|
|
-// planTaskDetails.setMingpai(a.getMingpai());//铭牌
|
|
|
-// planTaskDetails.setShuomingshu(a.getShuomingshu());//说明书
|
|
|
-// planTaskDetails.setHegezheng(a.getHegezheng());//合格证
|
|
|
-// planTaskDetails.setBaozhuangxiang(a.getBaozhuangxiang());//包装箱
|
|
|
-// planTaskDetails.setSwitchBox(a.getKaiguanxiang());//开关箱
|
|
|
-// planTaskDetails.setScheduledCommencement(a.getFPlanStartDate()); //计划开始时间
|
|
|
-// planTaskDetails.setScheduledCompletion(a.getFPlanFinishDate()); //计划完工时间
|
|
|
-// planTaskDetails.setRemark(a.getRemark());
|
|
|
-// planTaskDetailsMapper.insertPlanTaskDetails(planTaskDetails);
|
|
|
-// });
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
+ stringRedisTemplate.delete("fjqy:hjd:pulled");
|
|
|
+ return AjaxResult.success("焊接单拉取成功");
|
|
|
+ }else {
|
|
|
+ System.out.println("定时任务正在执行请稍后在拉去");
|
|
|
+ return AjaxResult.success("定时任务正在执行请稍后在拉去");
|
|
|
}
|
|
|
- return AjaxResult.success();
|
|
|
}
|
|
|
}
|