Forráskód Böngészése

特采关联检验单

wzy 4 hónapja%!(EXTRA string=óta)
szülő
commit
8793640a1d

+ 4 - 0
mjava-jianhui/src/main/java/com/malk/jianhui/entity/DefectEntity.java

@@ -2,6 +2,8 @@ package com.malk.jianhui.entity;
 
 import lombok.Data;
 
+import java.util.List;
+
 @Data
 public class DefectEntity {
     //物料id
@@ -18,4 +20,6 @@ public class DefectEntity {
     private double FDefectiveQty;
     //使用决策备注
     private String FMemo;
+    //关联明细
+    private List<Object> FEntity_Link;
 }

+ 40 - 15
mjava-jianhui/src/main/java/com/malk/jianhui/service/impl/JianhuiServiceImpl.java

@@ -676,14 +676,36 @@ public class JianhuiServiceImpl implements JianhuiService {
             }
             defectEntity.setFDefectiveQty((int) detail.get("numberField_m64pw0gu"));//不良数量
 
+
+            //关联检验单
+            List<Object> linkEntity = new ArrayList<>();
+            Map link = new HashMap();
+            HashMap<String, Object> detailLink = new HashMap<>();
+
+//            link.put("FEntity_Link_FFlowId", "");//业务流程图
+//            link.put("FEntity_Link_FFlowLineId", "");//推进路线
+            link.put("FEntity_Link_FRuleId","QM_Inspect2DefProecess");//转换规则
+//            link.put("FEntity_Link_FSTableId", "");//源单表内码
+            link.put("FEntity_Link_FSTableName","T_QM_INSPECTBILLENTRY");//源单表
+            link.put("FEntity_Link_FSBillId",formData.get("numberField_m86nq0a5"));//源单内码
+            link.put("FEntity_Link_FSId", detail.get("numberField_m873a1q2"));//源单分录内码
+
+            linkEntity.add(link);
+
+            defectEntity.setFEntity_Link(linkEntity);
+
+
             FEntity.add(defectEntity);
         }
 
         model.setFEntity(FEntity);
 
-        save.setModel(model);
 
 
+
+
+        save.setModel(model);
+
         try{
             K3CloudApi client = new K3CloudApi(initIden());
             //业务对象标识
@@ -722,10 +744,10 @@ public class JianhuiServiceImpl implements JianhuiService {
                 }
             }
         } catch (Exception e) {
-            fail(e.getMessage());
+            McR.errorUnknown(e.getMessage());
         }
 
-        return null;
+        return McR.success();
     }
 
     @Override
@@ -1084,12 +1106,13 @@ public class JianhuiServiceImpl implements JianhuiService {
             billQuery.setFormId(formId);
             billQuery.setFieldKeys("FBillNo");
             billQuery.setStartRow(0);
-            billQuery.setLimit(100);
+            billQuery.setLimit(2000);
 
             List<Map> filterString = new ArrayList<>();
             filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FInspectResult","29","2","","","0"));
             filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FDocumentStatus","105","C","","","0"));
-            filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","13","","","","0"));
+            filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","13","","","","0"));//审核日期为今天
+//            filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","39","2025-03-10 00:00:00","","","0"));//审核日期大于2025-03-10 00:00:00
             billQuery.setFilterString(filterString);
 
             String resultJson = client.billQuery(JSONObject.toJSONString(billQuery));
@@ -1113,36 +1136,29 @@ public class JianhuiServiceImpl implements JianhuiService {
                         .searchFieldJson(JSONObject.toJSONString(UtilMap.map("textField_m82j5zsd", fBillNo)))
                         .build(), YDConf.FORM_QUERY.retrieve_list).getData();
 
-                //没有则新增
                 if (data.isEmpty()){
                     View view = new View();
                     view.setNumber(fBillNo);
                     String resultJson2 = client.view(formId,JSONObject.toJSONString(view));
-
                     RepoRet repoRet = gson.fromJson(resultJson2, RepoRet.class);
                     if (isTrue(repoRet)){
                         Map result = (Map) repoRet.getResult().getResult();
-
                         Map formData = new HashMap();
-
                         formData.put("textField_m82j5zsd",fBillNo);//单据编号
+                        formData.put("numberField_m86nmon3",result.get("Id"));//id
                         formData.put("textField_m82j5zse",getMultiLanguageTextName(result.get("FBillTypeID")));//单据类型
                         formData.put("textField_m82j5zsf",BUSINESS_TYPE.get(getString(result.get("BusinessType"))));//业务类型
-
                         // 解析字符串为 LocalDateTime
                         LocalDateTime localDateTime = LocalDateTime.parse(getString(result.get("FDate")), formatter);
                         // 将 LocalDateTime 转换为 ZonedDateTime
                         ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.systemDefault());
                         formData.put("dateField_m82j5zsk",zonedDateTime.toInstant().toEpochMilli());//单据日期
                         formData.put("textField_m82j5zsl",FDOCUMENTSTATUS.get(getString(result.get("DocumentStatus"))));//单据状态
-
                         if (!((List<Map>)result.get("Description")).isEmpty()){
                             formData.put("textareaField_m82j5zsm",((List<Map>)result.get("Description")).get(0).get("Value"));//描述
                         }
-
                         List<Map> entityList = (List<Map>) result.get("Entity");
                         List<Map> detailList = new ArrayList<>();
-
                         for (Map entity : entityList) {
                             Map detail = new HashMap();
                             detail.put("textField_m82j5zsp",getEntryNumber(entity.get("MaterialId")));//物料编码
@@ -1156,22 +1172,31 @@ public class JianhuiServiceImpl implements JianhuiService {
                             detail.put("numberField_m82j5zsu",entity.get("QualifiedQty"));//合格数
                             detail.put("numberField_m82j5zsv",entity.get("UnqualifiedQty"));//不合格数
                             detail.put("textField_m82j5zsx",INSPECT_RESULT.get(getString(entity.get("InspectResult"))));//检验结果
+                            detail.put("numberField_m873a1q2",entity.get("Id"));//分录明细id
                             if (!((List<Map>)entity.get("Memo")).isEmpty()){
                                 detail.put("textField_m82j5zsz",((List<Map>)entity.get("Memo")).get(0).get("Value"));//不良原因
                             }
-
                             detailList.add(detail);
                         }
-
                         formData.put("tableField_m82j5zso",detailList);
 
+
                         //新增数据
                         ydClient.operateData(YDParam.builder()
                                 .formUuid("FORM-959B1CB0AF9F41A091DFDE1203D0C7B2FQBO")
                                 .formDataJson(JSONObject.toJSONString(formData))
                                 .build(), YDConf.FORM_OPERATION.create);
                     }
+
+                    /*else {
+                        //更新数据
+                        ydClient.operateData(YDParam.builder()
+                                .formInstId(getString(data.get(0).get("formInstanceId")))
+                                .updateFormDataJson(JSONObject.toJSONString(formData))
+                                .useLatestVersion(true).build(), YDConf.FORM_OPERATION.update);
+                    }*/
                 }
+
             }
         }catch (Exception e){
             return McR.errorUnknown(e.getMessage());