|
@@ -2,6 +2,8 @@ package com.zkqy.amichi.jd.service.impl;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -11,6 +13,7 @@ import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
|
|
import com.zkqy.amichi.domain.PlanTaskDetails;
|
|
|
import com.zkqy.amichi.domain.ProductionCardFlow;
|
|
|
import com.zkqy.amichi.domain.ProductionPlanningManagement;
|
|
|
+import com.zkqy.amichi.jd.domain.JdMaterialInfoVo;
|
|
|
import com.zkqy.amichi.jd.domain.ProductionCardFlowVo;
|
|
|
import com.zkqy.amichi.mapper.PlanTaskDetailsMapper;
|
|
|
import com.zkqy.amichi.mapper.ProductionCardFlowMapper;
|
|
@@ -300,9 +303,8 @@ public class JdProductionOrderServiceImpl implements JdProductionOrderService
|
|
|
|
|
|
/**
|
|
|
* 物料编码不等于焊接
|
|
|
- * 所有开工数据
|
|
|
- * fieldKeysList.add("FDescription");
|
|
|
- * fieldKeysList.add("F_PONP_teshuyaoqiu");
|
|
|
+ * 条件:所有开工数据
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
public AjaxResult jdProductionOrderPullTwo(){
|
|
@@ -314,7 +316,7 @@ public class JdProductionOrderServiceImpl implements JdProductionOrderService
|
|
|
" \"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,\",\n" +
|
|
|
+ "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" +
|
|
@@ -329,94 +331,102 @@ public class JdProductionOrderServiceImpl implements JdProductionOrderService
|
|
|
//生产信息
|
|
|
List<JdProductionOrder> jdProductionOrders = JSON.parseArray(resultJson, JdProductionOrder.class);
|
|
|
//单据编号去重
|
|
|
- List<String> collectOne = jdProductionOrders.stream().map(JdProductionOrder::getDemandDocument).collect(Collectors.toSet())
|
|
|
- .stream().collect(Collectors.toList());
|
|
|
+// 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());
|
|
|
+
|
|
|
+// List<String> cj= collectOne.stream().filter(item -> !collectTwo.contains(item)).collect(Collectors.toList());
|
|
|
//分组
|
|
|
// 按照订单号分组并去重
|
|
|
- Map<String, JdProductionOrder> groupedByDemandDocument = jdProductionOrders.stream()
|
|
|
+ Map<String, JdProductionOrder> groupedByDemandDocument = jdProductionOrders.stream().filter(item->!collectTwo.contains(item.getDemandDocument()))
|
|
|
.collect(Collectors.toMap(
|
|
|
JdProductionOrder::getDemandDocument,
|
|
|
order -> order,
|
|
|
(existing, replacement) -> existing // 保留第一个出现的订单
|
|
|
));
|
|
|
- //订单循环
|
|
|
- groupedByDemandDocument.forEach((k,v)->{
|
|
|
- //计划编号
|
|
|
- String planNumnber = generator.generateCommissionNumber();
|
|
|
- //编号订单号
|
|
|
- List<Map> mapList = this.jdSalesOrderInfoS(k);//订单详情信息
|
|
|
- System.err.println(mapList.size());
|
|
|
- //拿到了关于这个订单的销售订单
|
|
|
- if(mapList.size()>0){
|
|
|
+ if(groupedByDemandDocument.size()>0){
|
|
|
+ //订单循环
|
|
|
+ groupedByDemandDocument.forEach((k,v)->{
|
|
|
+ //计划编号
|
|
|
+ String planNumnber = generator.generateCommissionNumber();
|
|
|
//编号订单号
|
|
|
- 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.getBz())){ //备注
|
|
|
- productionPlanningManagement.setRemark(v.getBz());
|
|
|
- }
|
|
|
- productionPlanningManagement.setCreationtimeString(F_PONP_Datetime);
|
|
|
- productionPlanningManagement.setCompletionTime(F_PONP_Datetime);
|
|
|
- if(StringUtils.isNotNull(v.getTsyq())){
|
|
|
- productionPlanningManagement.setSpecialRequirements(v.getTsyq()); //特殊要求
|
|
|
- }
|
|
|
- productionPlanningManagement.setPlanType("0"); //待生产
|
|
|
- productionPlanningManagement.setTaskStatus("2");//待排产
|
|
|
- //======处理基本的订单信息
|
|
|
- productionPlanningManagementMapper.insertProductionPlanningManagement(productionPlanningManagement);
|
|
|
- mapList.forEach(a->{
|
|
|
- PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
-// String string = a.get("FMaterialId.FNumber").toString();
|
|
|
- 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){
|
|
|
- //需求单据(处理详情信息没有需求单据的问题)
|
|
|
- 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());
|
|
|
+ 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.getBz())){ //备注
|
|
|
+ productionPlanningManagement.setRemark(v.getBz());
|
|
|
}
|
|
|
+ productionPlanningManagement.setCreationtimeString(FDate);
|
|
|
+ productionPlanningManagement.setCompletionTime(F_PONP_Datetime);
|
|
|
+ if(StringUtils.isNotNull(v.getTsyq())){
|
|
|
+ productionPlanningManagement.setSpecialRequirements(v.getTsyq()); //特殊要求
|
|
|
+ }
|
|
|
+ productionPlanningManagement.setPlanType("0"); //待生产
|
|
|
+ productionPlanningManagement.setTaskStatus("2");//待排产
|
|
|
+ productionPlanningManagement.setIsWeldSheet("1"); //普通订单
|
|
|
+ //======处理基本的订单信息
|
|
|
+ productionPlanningManagementMapper.insertProductionPlanningManagement(productionPlanningManagement);
|
|
|
+ mapList.forEach(a->{
|
|
|
+ PlanTaskDetails planTaskDetails=new PlanTaskDetails();
|
|
|
+// String string = a.get("FMaterialId.FNumber").toString();
|
|
|
+ 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){
|
|
|
+ //需求单据(处理详情信息没有需求单据的问题)
|
|
|
+ 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.seti
|
|
|
+ }
|
|
|
// planTaskDetails.setDemandDocument(v.getDocumentNumber()); //需求单据
|
|
|
- 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.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()); //铭牌
|
|
@@ -424,34 +434,279 @@ public class JdProductionOrderServiceImpl implements JdProductionOrderService
|
|
|
// 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)->{
|
|
|
+ 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);
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 拉取焊接
|
|
|
+ */
|
|
|
+ @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\": 1000,\n" +
|
|
|
+ " \"SubSystemId\": \"\"\n" +
|
|
|
+ "}";
|
|
|
+ int startRow = 0; // 起始行号
|
|
|
+ int limit = 1000; // 每次查询的数量
|
|
|
+ // 更新查询条件中的起始行号
|
|
|
+ //查询条件
|
|
|
+ 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("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);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ System.out.println(1);
|
|
|
+ if (jdProductionOrders.size() < 1000) {
|
|
|
+ flag = false;
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
+ // 更新起始行号
|
|
|
+ startRow += limit;
|
|
|
+ // 如果返回的数据量小于5000,说明已经没有更多的数据,结束循环
|
|
|
}
|
|
|
- });
|
|
|
+ } 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);
|
|
|
}
|