4 Commits dce3af0735 ... 241b309d17

Autore SHA1 Messaggio Data
  hxx 241b309d17 配件任务表生成样品/大货/包装 2 settimane fa
  hxx eb1b3517a2 采购任务新增采购类型 2 mesi fa
  hxx 47cd061957 调整语言 2 mesi fa
  hxx 924e12313e 修改编号 3 mesi fa

+ 114 - 19
src/main/java/com/malk/eastar/service/impl/EastarTbServiceImpl.java

@@ -142,6 +142,7 @@ public class EastarTbServiceImpl  implements EastarTbService {
         Map orderData=ydClient.queryData(YDParam.builder().formInstId(orderFid).build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
         List<Map> orderLangConf=UtilMap.getList(orderData,"tableField_meqqj4we");// 语言配置
         List<Map> xlConf=UtilMap.getList(orderData,"tableField_mesc7nvj");// 系列源配置
+
         // 子任务拆分数据
         List<Map> sonConfData= ydService.queryDetails(YDParam.builder().formInstanceId("FINST-X1B66Y81IUFY9U417XIUE99I8YV93HGMJ8WEMF").formUuid(EastarParam.YD_FORMUUID_SONCONF).tableFieldId("tableField_mew7d9f3").build());// 全品类配件表
         Map<String,Map<String,List<String>>>  sonConf= ConfigDataProcessor.processConfigData(sonConfData);
@@ -227,6 +228,7 @@ public class EastarTbServiceImpl  implements EastarTbService {
         List<Map> recodTable = new ArrayList<>();
         List<String> jds=UtilMap.getList(data,"checkboxField_me9n37rs");
         Map<String,List<Map>> gysOrderData=new HashMap<>(); // 采购需求数据  按照供应商拆分BOM
+
         for(Map map:table){
             Map taskMap=UtilMap.map("projectId, tasklistId, scenariofieldconfigId, stageId",tbProjectId,tasklistId,scenariofieldconfigId,stageId);
             taskMap.put("content",getValue(map,"selectField_me2f7tw4","-")+getValue(map,"textField_me2f7tvo","")); //系列 配件
@@ -262,27 +264,118 @@ public class EastarTbServiceImpl  implements EastarTbService {
             recodTable.addAll(result);
         }
         saveRecod(data,tbProjectId,recodTable);
-        // 循环保存采购任务
-        for (String key:gysOrderData.keySet()){
-            List<Map> arr=gysOrderData.get(key);
-            Map order=UtilMap.map("textField_mifp03ew, selectField_mifp03e7, tableField_mifp03em",tbProjectId,"待排期",arr);
-            order.put("associationFormField_mifp03e9",projectOrder);
-            order.put("associationFormField_mifp03e8",UtilMap.getAssFieldValue(data,"associationFormField_mdy7w1wn_id")); // 项目
-            order.put("textField_mifp03e6",pName+"-"+key);
-            order.put("textField_mimwnauk",pId);
-            order.put("textField_mizs3841",pMainId);
-            order.put("employeeField_mifp03eu",Arrays.asList(mchDDIdMap.get(key)));
+        List<Map> projectPlan=UtilMap.getList(data,"tableField_mgu5rm3e");// 项目计划
+        List<String> jdList=Arrays.asList("白样", "产前样","大货样", "大货");
+        Object demoValue = orderData.get("textField_me2f7tvd");
+        //        项目阶段处理
+        for(String jd:jds){
+            System.out.println("项目阶段:"+jd);
+           if(jdList.contains(jd)){
+               long sevenDaysAgoTimestamp = 0;
+               long planTimestamp = 0;
+               for(Map stage:projectPlan){
+                   if(jd.equals(UtilMap.getString(stage,"textField_mgu5rm3f"))){
+                      sevenDaysAgoTimestamp = UtilMap.getLong(stage,"dateField_mgu5rm3h") - 7L * 24 * 60 * 60 * 1000;
+                       planTimestamp = UtilMap.getLong(stage,"dateField_mgu5rm3h");
+                   }
+               }
+               // 循环保存采购任务
+               for (String key:gysOrderData.keySet()){
+                   List<Map> arr=gysOrderData.get(key);
+                   List<Map> modifiedList = new ArrayList<>();
+                   String procuremenType ="";
+                   String taskStatus ="";
+                   String taskType="";
+                   for (Map<String, Object> map : arr) {
+                       if("大货".equals(jd)){
+                           procuremenType ="配件采购";
+                           taskStatus ="待排期";
+                           taskType ="大货";
+                           Map<String, Object> copiedMap = new HashMap<>(map); // 关键:创建副本
+                           copiedMap.put("dateField_mizvc5oi", planTimestamp);
+                           modifiedList.add(copiedMap);
+                       } else{
+                           if("大货样".equals(jd)){
+                               taskStatus ="无需合同";
+                           }else{
+                               taskStatus ="待排期";
+                           }
+                           procuremenType ="样品任务";
+                           taskType ="打样";
+                           Map<String, Object> copiedMap = new HashMap<>(map); // 关键:创建副本
+                           copiedMap.put("dateField_mizvc5oi", planTimestamp);
+                           copiedMap.put("numberField_mkosp94h", demoValue);
+                           copiedMap.put("numberField_mifp03el", demoValue);
+                           modifiedList.add(copiedMap);
+                       }
+                   }
+                   System.out.println("arr"+arr);
+                   Map order=UtilMap.map("textField_mifp03ew, selectField_mifp03e7, tableField_mifp03em, selectField_mkf6qv9b, dateField_mifp03eb, selectField_ml0l206x",tbProjectId,taskStatus,modifiedList,procuremenType,planTimestamp,taskType);
+                   order.put("associationFormField_mifp03e9",projectOrder);
+                   order.put("associationFormField_mifp03e8",UtilMap.getAssFieldValue(data,"associationFormField_mdy7w1wn_id")); // 项目
+                   order.put("textField_mifp03e6",pName+"-"+key+"-"+jd);
+                   order.put("textField_mimwnauk",pId);
+                   order.put("textField_mizs3841",pMainId);
+                   order.put("employeeField_mifp03eu",Arrays.asList(mchDDIdMap.get(key)));
+                   List<Map> gysList = (List<Map>) ydClient.queryData(YDParam.builder().formUuid(EastarParam.YD_FORMUUID_GYS_YW).searchCondition(
+                           JSONObject.toJSONString(Arrays.asList(new YDSearch("textField_mec6lku3",key,"供应商简称", YDSearch.Type.TEXT_FIELD,YDSearch.Operator.EQ)))
+                   ).build(), YDConf.FORM_QUERY.retrieve_list).getData();
+                   if(gysList!=null&&gysList.size()>0){
+                       List<UtilMap.assDetail> gys=UtilMap.getAssFieldValue(UtilMap.getMap(gysList.get(0),"formData"),"associationFormField_mec6lku4_id");
+                       order.put("associationFormField_mifp03ea",gys);
+                       order.put("textField_mifp03ez",gys.get(0).subTitle); // 供应商编号
+                   }
+                   ydClient.operateData(YDParam.builder().formUuid(EastarParam.YD_FORMUUID_CGTASK).formDataJson(JSONObject.toJSONString(order)).build(), YDConf.FORM_OPERATION.create);
+               }
+
+           }
+        }
+//        生成包装任务:打样不需要生成包装
+        if("大货".equals(orderType)){
+            savePackTask(tbProjectId, orderLangConf, data, pName, pId, pMainId, projectOrder, mchDDIdMap);
+        }
+        return Collections.emptyMap();
+    }
+
+//    生成包装任务
+    private List<Map> savePackTask(String tbProjectId, List <Map> orderLangConf,Map data,String pName,String pId,String pMainId,List projectOrder,Map mchDDIdMap) {
+        Map<String, List<Map>> packOrderData = new HashMap<>();
+        for (Map orderMap : orderLangConf) {
+            String supplier = UtilMap.getString(orderMap, "textField_mkp7yv76");
+            String setsValue = UtilMap.getString(orderMap, "numberField_meqqj4wd");
+            Map packTask = UtilMap.map(
+                    "textField_mecmytpr, textField_mifp03eo, textField_mjr129o4, selectField_me2f7tw4, numberField_mkosp94h, numberField_mifp03el, numberField_me2f7tw0",
+                    UtilMap.getString(orderMap, "textField_mizmmf8k"),
+                    UtilMap.getString(orderMap, "textField_mizmmf8j"),
+                    UtilMap.getString(orderMap, "textField_meqqj4wb"),
+                    UtilMap.getString(orderMap, "textField_meqqj4wa"),
+                    setsValue,
+                    setsValue,
+                    UtilMap.getString(orderMap, "numberField_mkf4bc4j")
+            );
+            packOrderData.computeIfAbsent(supplier, k -> new ArrayList<>()).add(packTask);
+        }
+        for (String key:packOrderData.keySet()){
+            List<Map> packdetails=packOrderData.get(key);
+            Map packTaskorder=UtilMap.map("textField_mifp03ew, selectField_mifp03e7, tableField_mifp03em, selectField_mkf6qv9b, selectField_ml0l206x",tbProjectId,"待排期",packdetails,"成品包装","包装");
+            packTaskorder.put("associationFormField_mifp03e9",projectOrder);
+            packTaskorder.put("associationFormField_mifp03e8",UtilMap.getAssFieldValue(data,"associationFormField_mdy7w1wn_id")); // 项目
+            packTaskorder.put("textField_mifp03e6",pName+"-"+key+"-包装");
+            packTaskorder.put("textField_mimwnauk",pId);
+            packTaskorder.put("textField_mizs3841",pMainId);
+            packTaskorder.put("employeeField_mifp03eu",Arrays.asList(mchDDIdMap.get(key)));
             List<Map> gysList = (List<Map>) ydClient.queryData(YDParam.builder().formUuid(EastarParam.YD_FORMUUID_GYS_YW).searchCondition(
                     JSONObject.toJSONString(Arrays.asList(new YDSearch("textField_mec6lku3",key,"供应商简称", YDSearch.Type.TEXT_FIELD,YDSearch.Operator.EQ)))
             ).build(), YDConf.FORM_QUERY.retrieve_list).getData();
             if(gysList!=null&&gysList.size()>0){
                 List<UtilMap.assDetail> gys=UtilMap.getAssFieldValue(UtilMap.getMap(gysList.get(0),"formData"),"associationFormField_mec6lku4_id");
-                order.put("associationFormField_mifp03ea",gys);
-                order.put("textField_mifp03ez",gys.get(0).subTitle); // 供应商编号
+                packTaskorder.put("associationFormField_mifp03ea",gys);
+                packTaskorder.put("textField_mifp03ez",gys.get(0).subTitle); // 供应商编号
             }
-            ydClient.operateData(YDParam.builder().formUuid(EastarParam.YD_FORMUUID_CGTASK).formDataJson(JSONObject.toJSONString(order)).build(), YDConf.FORM_OPERATION.create);
+            ydClient.operateData(YDParam.builder().formUuid(EastarParam.YD_FORMUUID_CGTASK).formDataJson(JSONObject.toJSONString(packTaskorder)).build(), YDConf.FORM_OPERATION.create);
         }
-        return Collections.emptyMap();
+
+        return null;
     }
 
     private String getValue(Map map,String key,String s){
@@ -305,19 +398,21 @@ public class EastarTbServiceImpl  implements EastarTbService {
             }
             List<Map> newCustomfields=new ArrayList<>(customfields);
             String skuId=String.valueOf(skuIdMap.get(UtilMap.getString(cgDetail,"selectField_mizsccds")));
+            String reportId =UtilMap.getString(cgDetail,"textField_me2f7tvn");// 文档编号
             skuId=PublicUtil.isNull(skuId)?"000":skuId;
-            String sku="2"+skuId+UtilMap.getString_first(map,"textField_mizmmf8h","textField_mizmmf8m");// sku 添加系列编号
+            String sku="2"+skuId+UtilMap.getString_first(map,"textField_mizmmf8h","textField_mizmmf8m")+reportId.substring(reportId.length()-2);// sku 添加系列编号及文档编号
+            String lang=UtilMap.getString(map,"textField_meqqj4wb"); // 语言
             if(isLang){
-                String lang=UtilMap.getString(map,"textField_meqqj4wb"); // 语言
                 if(PublicUtil.isNull(lang)){
                     lang="不区分";
-                    sku=sku+"NA"; // sku 不区分语言
+                    sku=sku+"AL"; // sku 不区分语言
                 }
                 tMap.put("content",tMap.get("content")+"-"+lang);
                 newCustomfields.add(tbConf.assembleCustomFieldName("语言",lang));
                 sku=sku+UtilMap.getString(map,"textField_mizmmf8i"); // sku 区分语言
             }else{
-                sku=sku+"NA"; // sku 不区分语言
+                lang ="不区分";
+                sku=sku+"AL"; // sku 不区分语言
             }
             sku=sku+pMainId.substring(pMainId.length()-10); // sku 添加项目号
             String value=UtilMap.getString_first(map,"numberField_meqqj4wd","numberField_mesc7nvi"); // 数量
@@ -327,7 +422,7 @@ public class EastarTbServiceImpl  implements EastarTbService {
             log.info("最终任务名称:{},详细参数:{}",tMap.get("content"),tMap);
             Map result=tbTask.createTask(tbConf.getOperatorId(), tMap);// 更新任务所属任务列表
             Map recod=new HashMap(cgDetail);
-            recod.putAll(UtilMap.map("textField_mecmytpr, textField_mecmytps, textField_mecmytpt, numberField_mifp03el, textField_mifp03eo, textField_miib17jx, textField_mizvc5oj",result.get("content"),result.get("taskId"),"未开始",value,sku,pId,result.get("taskId")));
+            recod.putAll(UtilMap.map("textField_mecmytpr, textField_mecmytps, textField_mecmytpt, numberField_mifp03el, textField_mifp03eo, textField_miib17jx, textField_mizvc5oj, textField_mjr129o4, numberField_mkosp94h",result.get("content"),result.get("taskId"),"未开始",value,sku,pId,result.get("taskId"),lang,value));
             recodTable.add(recod);
 //            for (String son:sonconf){
 //                Map sonMap=new HashMap();

+ 1 - 1
src/test/java/TbTest.java

@@ -57,7 +57,7 @@ public class TbTest {
 
     @Test
     public void createTask() {
-        Map map=eastarTbService.createTask("0bfbb77e-4b06-4bca-9265-4ae5b6515868");
+        Map map=eastarTbService.createTask("90552600-4540-4352-88bf-e8377aaafe66");
     }
 
     @Autowired