|
@@ -86,6 +86,30 @@ public class JianhuiServiceImpl implements JianhuiService {
|
|
|
FERPCLSID.put("1","外购");
|
|
|
}
|
|
|
|
|
|
+ private static final Map<String,String> BUSINESS_TYPE = new HashMap<>();
|
|
|
+ static {
|
|
|
+ BUSINESS_TYPE.put("8","发货检验");
|
|
|
+ BUSINESS_TYPE.put("25","生产退料检验");
|
|
|
+ BUSINESS_TYPE.put("26","委外退料检验");
|
|
|
+ BUSINESS_TYPE.put("3","产品检验");
|
|
|
+ BUSINESS_TYPE.put("20","其他检验");
|
|
|
+ BUSINESS_TYPE.put("6","委外工序");
|
|
|
+ BUSINESS_TYPE.put("10","受托材料检验");
|
|
|
+ BUSINESS_TYPE.put("2","委外检验");
|
|
|
+ BUSINESS_TYPE.put("21","工序巡检");
|
|
|
+ BUSINESS_TYPE.put("7","退货检验");
|
|
|
+ BUSINESS_TYPE.put("9","生产线检验");
|
|
|
+ BUSINESS_TYPE.put("1","采购检验");
|
|
|
+ BUSINESS_TYPE.put("4","库存检验");
|
|
|
+ BUSINESS_TYPE.put("5","工序自制");
|
|
|
+ }
|
|
|
+
|
|
|
+ private static final Map<String,String> INSPECT_RESULT = new HashMap<>();
|
|
|
+ static {
|
|
|
+ INSPECT_RESULT.put("1","合格");
|
|
|
+ INSPECT_RESULT.put("2","不合格");
|
|
|
+ INSPECT_RESULT.put("3","保留");
|
|
|
+ }
|
|
|
|
|
|
private IdentifyInfo initIden(){
|
|
|
//注意 1:此处不再使用参数形式传入用户名及密码等敏感信息,改为在登录配置文件中设置。
|
|
@@ -306,6 +330,7 @@ public class JianhuiServiceImpl implements JianhuiService {
|
|
|
List<Map> filterString = new ArrayList<>();
|
|
|
//修改时间为昨天到今天
|
|
|
filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FModifyDate","265","1","","","0"));
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FModifyDate","39","2025-03-06 00:00:00","","","0"));
|
|
|
billQuery.setFilterString(filterString);
|
|
|
billQuery.setLimit(limit);
|
|
|
do {
|
|
@@ -359,6 +384,7 @@ public class JianhuiServiceImpl implements JianhuiService {
|
|
|
List<Map> filterString = new ArrayList<>();
|
|
|
//修改时间为昨天到今天
|
|
|
filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FModifyDate","265","1","","","0"));
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FModifyDate","39","2025-03-06 00:00:00","","","0"));
|
|
|
billQuery.setFilterString(filterString);
|
|
|
|
|
|
List<Map> result = new ArrayList<>();
|
|
@@ -430,6 +456,7 @@ public class JianhuiServiceImpl implements JianhuiService {
|
|
|
List<Map> filterString = new ArrayList<>();
|
|
|
//修改时间为昨天到今天
|
|
|
filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FModifyDate","265","1","","","0"));
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FModifyDate","39","2025-03-06 00:00:00","","","0"));
|
|
|
billQuery.setFilterString(filterString);
|
|
|
billQuery.setLimit(limit);
|
|
|
do {
|
|
@@ -445,6 +472,7 @@ public class JianhuiServiceImpl implements JianhuiService {
|
|
|
Map formData = new HashMap();
|
|
|
formData.put("textField_m6ak640p",material.get("FUseOrgId"));//使用组织
|
|
|
formData.put("textField_m6ak640v",material.get("FNumber"));//编码
|
|
|
+ formData.put("selectField_m83u6et1",getString(material.get("FNumber")).substring(0,1).equals("C") ? "成品" : "配件");
|
|
|
formData.put("textField_m6ak640w",material.get("FName"));//名称
|
|
|
formData.put("textField_m6ak640x",material.get("FSpecification"));//规格型号
|
|
|
formData.put("textField_m6ak6413",FDOCUMENTSTATUS.get(material.get("FDocumentStatus").toString()));//单据状态
|
|
@@ -636,6 +664,7 @@ public class JianhuiServiceImpl implements JianhuiService {
|
|
|
defectEntity.setFMateridlId(new FNumber(getString(detail.get("textField_m64pw0go"))));//物料
|
|
|
defectEntity.setFSupplierId(new FNumber(getString(detail.get("textField_m6yumh8w"))));//供应商
|
|
|
defectEntity.setFUnitID(new FNumber(getString(detail.get("textField_m6yntxnj"))));//单位
|
|
|
+ defectEntity.setFInspectDefectQty((int) detail.get("numberField_m82qkv1u"));//检验不良数量
|
|
|
|
|
|
//不良处理 A:接收 B:让步接收 F:判退
|
|
|
String FDefProcess = getString(detail.get("selectField_m64pw0gt"));
|
|
@@ -715,6 +744,7 @@ public class JianhuiServiceImpl implements JianhuiService {
|
|
|
List<Map> filterString = new ArrayList<>();
|
|
|
//修改时间为昨天到今天
|
|
|
filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FModifyDate","265","1","","","0"));
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FModifyDate","39","2025-03-06 00:00:00","","","0"));
|
|
|
billQuery.setFilterString(filterString);
|
|
|
|
|
|
List<Map> result = new ArrayList<>();
|
|
@@ -774,7 +804,7 @@ public class JianhuiServiceImpl implements JianhuiService {
|
|
|
billQuery.setFormId(formId);
|
|
|
billQuery.setFieldKeys("FBillNo");
|
|
|
billQuery.setStartRow(0);
|
|
|
- billQuery.setLimit(50);
|
|
|
+ billQuery.setLimit(100);
|
|
|
|
|
|
List<Map> filterString = new ArrayList<>();
|
|
|
filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FDocumentStatus","105","B","","","0"));
|
|
@@ -964,6 +994,7 @@ public class JianhuiServiceImpl implements JianhuiService {
|
|
|
List<Map> filterString = new ArrayList<>();
|
|
|
//修改时间为昨天到今天
|
|
|
filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FModifyDate","265","1","","","0"));
|
|
|
+// filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FModifyDate","39","2025-03-06 00:00:00","","","0"));
|
|
|
billQuery.setFilterString(filterString);
|
|
|
|
|
|
List<Map> result = new ArrayList<>();
|
|
@@ -1037,6 +1068,118 @@ public class JianhuiServiceImpl implements JianhuiService {
|
|
|
return McR.success();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public McR syncInspectionOrder() {
|
|
|
+ try {
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
|
|
+
|
|
|
+ //业务对象标识
|
|
|
+ String formId = "QM_InspectBill";
|
|
|
+
|
|
|
+ K3CloudApi client = new K3CloudApi(initIden());
|
|
|
+ Gson gson = new Gson();
|
|
|
+
|
|
|
+ //查询当天已审核且审核结果为不合格的数据
|
|
|
+ BillQuery billQuery = new BillQuery();
|
|
|
+ billQuery.setFormId(formId);
|
|
|
+ billQuery.setFieldKeys("FBillNo");
|
|
|
+ billQuery.setStartRow(0);
|
|
|
+ billQuery.setLimit(100);
|
|
|
+
|
|
|
+ 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"));
|
|
|
+ billQuery.setFilterString(filterString);
|
|
|
+
|
|
|
+ String resultJson = client.billQuery(JSONObject.toJSONString(billQuery));
|
|
|
+
|
|
|
+ List<Map> list = (List<Map>) JSONObject.parse(resultJson);
|
|
|
+
|
|
|
+ Set<String> fBillNoSet = new HashSet<>();
|
|
|
+
|
|
|
+ for (Map map : list) {
|
|
|
+ String fBillNo = getString(map.get("FBillNo"));
|
|
|
+
|
|
|
+ if (!fBillNoSet.contains(fBillNo)){
|
|
|
+ fBillNoSet.add(fBillNo);
|
|
|
+ }else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询宜搭中是否已添加该检验单
|
|
|
+ List<Map> data = (List<Map>) ydClient.queryData(YDParam.builder()
|
|
|
+ .formUuid("FORM-959B1CB0AF9F41A091DFDE1203D0C7B2FQBO")
|
|
|
+ .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("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")));//物料编码
|
|
|
+ detail.put("textField_m82j5zsr",getMultiLanguageTextSpecification(entity.get("MaterialId")));//规格型号
|
|
|
+ detail.put("textField_m82j5zsq",getMultiLanguageTextName(entity.get("MaterialId")));//物料名称
|
|
|
+ detail.put("textField_m82og859",getMultiLanguageTextName(entity.get("UnitId")));//单位
|
|
|
+ detail.put("textField_m82og85a",getEntryNumber(entity.get("UnitId")));//单位编码
|
|
|
+ detail.put("textField_m82qhpm0",getMultiLanguageTextName(entity.get("SupplierId")));//供应商
|
|
|
+ detail.put("textField_m82qhpm1",getEntryNumber(entity.get("SupplierId")));//供应商编码
|
|
|
+ detail.put("numberField_m82j5zst",entity.get("InspectQty"));//检验数量
|
|
|
+ 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"))));//检验结果
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ return McR.errorUnknown(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return McR.success();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public McR syncData() {
|
|
|
syncCustomers();//同步客户
|