|
@@ -2,10 +2,13 @@ package com.malk.kuaikeli.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
import cn.hutool.core.util.NumberUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.malk.kuaikeli.service.KKLService;
|
|
import com.malk.kuaikeli.service.KKLService;
|
|
import com.malk.server.aliwork.YDConf;
|
|
import com.malk.server.aliwork.YDConf;
|
|
import com.malk.server.aliwork.YDParam;
|
|
import com.malk.server.aliwork.YDParam;
|
|
|
|
+import com.malk.server.common.McR;
|
|
|
|
+import com.malk.server.dingtalk.DDR_New;
|
|
import com.malk.service.aliwork.YDClient;
|
|
import com.malk.service.aliwork.YDClient;
|
|
import com.malk.service.aliwork.YDService;
|
|
import com.malk.service.aliwork.YDService;
|
|
import com.malk.utils.PublicUtil;
|
|
import com.malk.utils.PublicUtil;
|
|
@@ -15,7 +18,10 @@ import com.malk.utils.UtilNumber;
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
import lombok.Synchronized;
|
|
import lombok.Synchronized;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.lang3.StringEscapeUtils;
|
|
|
|
+import org.apache.logging.log4j.util.Strings;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -25,6 +31,14 @@ import java.util.stream.Collectors;
|
|
@Slf4j
|
|
@Slf4j
|
|
public class KKLImplService implements KKLService {
|
|
public class KKLImplService implements KKLService {
|
|
|
|
|
|
|
|
+ //供应商原材料档案表
|
|
|
|
+ private static final String SUPPLIER_MATERIALS = "FORM-12EB6BCE3C264630824721E7BBABCC03L8U9";
|
|
|
|
+ private static final String SUPPLIER_CHANGE = "FORM-C939E9F486124464B17A6910D66A2425EWPX";
|
|
|
|
+ //定价单明细中间表
|
|
|
|
+ private static final String PRICE_DETAIL_MIDDLE = "FORM-E6766M811CKD2PIXEAKOM9S2DKBM2PBQU1MLL5";
|
|
|
|
+ //菜品管理
|
|
|
|
+ private static final String FOOD = "FORM-GP666M71DIGDE0ZADDLZ85VEFBD128OUH1MLLF";
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private YDService ydService;
|
|
private YDService ydService;
|
|
|
|
|
|
@@ -486,4 +500,450 @@ public class KKLImplService implements KKLService {
|
|
.build(), YDConf.FORM_OPERATION.update);
|
|
.build(), YDConf.FORM_OPERATION.update);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<Map<String, String>> getDiffMatchingSuppliers(String oldSupplierCode,String newSupplierCode) {
|
|
|
|
+ List<Map<String,String>> diffList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ //获取旧供应商原材料信息
|
|
|
|
+ List<Map> oldSupplierMaterials = getYdFormDataList(SUPPLIER_MATERIALS, JSON.toJSONString(UtilMap.map("textField_llzzbyj1", oldSupplierCode)), YDConf.FORM_QUERY.retrieve_list);
|
|
|
|
+ List<Map<String,String>> oldSupplierMaterialsFormData = oldSupplierMaterials.stream()
|
|
|
|
+ .map(item -> {
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
+ map.put("textField_lywr2qcq", String.valueOf(((Map) item.get("formData")).get("textField_llkb7kd1")));//物品名称
|
|
|
|
+ map.put("textField_lyxr5c44", String.valueOf(((Map) item.get("formData")).get("textField_llkb7kd2")));//物品编号
|
|
|
|
+ map.put("textField_lyxr5c46", String.valueOf(((Map) item.get("formData")).get("textField_llkb7kd4")));//物品规格
|
|
|
|
+ return map;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ //按物品名称进行分组
|
|
|
|
+ Map<String, List<Map<String, String>>> groupOldSupplierMaterials = oldSupplierMaterialsFormData.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(map -> map.get("textField_lywr2qcq")));
|
|
|
|
+ //物品名称重复的物品
|
|
|
|
+ List<String> oldRepeatNames = new ArrayList<>();
|
|
|
|
+ //物品名称未重复的物品
|
|
|
|
+ List<String> oldNames = new ArrayList<>();
|
|
|
|
+ groupOldSupplierMaterials.forEach((name, value) -> {
|
|
|
|
+ if (value.size() > 1) {
|
|
|
|
+ diffList.addAll(value);
|
|
|
|
+ oldRepeatNames.add(name);
|
|
|
|
+ }else {
|
|
|
|
+ oldNames.add(name);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ //待匹配的物品
|
|
|
|
+ oldSupplierMaterialsFormData = oldSupplierMaterialsFormData.stream().filter(item -> !oldRepeatNames.contains(item.get("name"))).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //获取新供应商原材料信息
|
|
|
|
+ List<Map> newSupplierMaterials = getYdFormDataList(SUPPLIER_MATERIALS, JSON.toJSONString(UtilMap.map("textField_llzzbyj1", newSupplierCode)), YDConf.FORM_QUERY.retrieve_list);
|
|
|
|
+ List<Map<String,String>> newSupplierMaterialsFormData = newSupplierMaterials.stream()
|
|
|
|
+ .map(item -> {
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
+ map.put("textField_lywr2qcq", String.valueOf(((Map) item.get("formData")).get("textField_llkb7kd1")));//物品名称
|
|
|
|
+ map.put("textField_lyxr5c44", String.valueOf(((Map) item.get("formData")).get("textField_llkb7kd2")));//物品编号
|
|
|
|
+ map.put("textField_lyxr5c46", String.valueOf(((Map) item.get("formData")).get("textField_llkb7kd4")));//物品规格
|
|
|
|
+ return map;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ //按物品名称进行分组
|
|
|
|
+ Map<String, List<Map<String, String>>> groupNewSupplierMaterials = newSupplierMaterialsFormData.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(map -> map.get("textField_lywr2qcq")));
|
|
|
|
+ //物品名称重复的物品
|
|
|
|
+ List<String> newRepeatNames = new ArrayList<>();
|
|
|
|
+ //物品名称未重复的物品
|
|
|
|
+ List<String> newNames = new ArrayList<>();
|
|
|
|
+ groupNewSupplierMaterials.forEach((name, value) -> {
|
|
|
|
+ if (value.size() > 1) {
|
|
|
|
+// diffList.addAll(value);
|
|
|
|
+ newRepeatNames.add(name);
|
|
|
|
+ }else {
|
|
|
|
+ newNames.add(name);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ //待匹配的物品
|
|
|
|
+// newSupplierMaterialsFormData = newSupplierMaterialsFormData.stream().filter(item -> !newRepeatNames.contains(item.get("name"))).collect(Collectors.toList());
|
|
|
|
+ List<String> matchNameList = new ArrayList<>();
|
|
|
|
+ matchNameList.addAll(oldNames);
|
|
|
|
+ matchNameList.retainAll(newNames);
|
|
|
|
+
|
|
|
|
+ List<String> diffNameList = new ArrayList<>();
|
|
|
|
+ diffNameList.addAll(oldNames);
|
|
|
|
+ diffNameList.removeAll(newNames);
|
|
|
|
+
|
|
|
|
+// oldNames.removeAll(newNames);
|
|
|
|
+
|
|
|
|
+ oldSupplierMaterialsFormData.forEach(item -> {
|
|
|
|
+ if (diffNameList.contains(item.get("textField_lywr2qcq"))){
|
|
|
|
+ diffList.add(item);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return diffList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<Map<String, String>> getDiffMatchingSuppliers2(String projectCode,String oldSupplierCode, String newSupplierCode) {
|
|
|
|
+ List<Map<String,String>> diffList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ //获取旧供应商定价单明细中间表
|
|
|
|
+ List<Map> oldSupplierMaterials = getYdFormDataList(PRICE_DETAIL_MIDDLE, JSON.toJSONString(UtilMap.map("textField_llzzbyj1, textField_llm1vtjm", oldSupplierCode,projectCode)), YDConf.FORM_QUERY.retrieve_list);
|
|
|
|
+
|
|
|
|
+ List<Map<String,String>> oldSupplierMaterialsFormData = oldSupplierMaterials.stream()
|
|
|
|
+ .map(item -> {
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
+ map.put("textField_lywr2qcq", String.valueOf(((Map) item.get("formData")).get("textField_llkb7kd1")));//物品名称
|
|
|
|
+ map.put("textField_lyxr5c44", String.valueOf(((Map) item.get("formData")).get("textField_llkb7kd2")));//物品编号
|
|
|
|
+ map.put("textField_lyxr5c46", String.valueOf(((Map) item.get("formData")).get("textField_llkb7kd4")));//物品规格
|
|
|
|
+ return map;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ //按物品名称进行分组
|
|
|
|
+ Map<String, List<Map<String, String>>> groupOldSupplierMaterials = oldSupplierMaterialsFormData.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(map -> map.get("textField_lywr2qcq")));
|
|
|
|
+ //物品名称重复的物品
|
|
|
|
+ List<String> oldRepeatNames = new ArrayList<>();
|
|
|
|
+ //物品名称未重复的物品
|
|
|
|
+ List<String> oldNames = new ArrayList<>();
|
|
|
|
+ groupOldSupplierMaterials.forEach((name, value) -> {
|
|
|
|
+ if (value.size() > 1) {
|
|
|
|
+ diffList.addAll(value);
|
|
|
|
+ oldRepeatNames.add(name);
|
|
|
|
+ }else {
|
|
|
|
+ oldNames.add(name);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ //待匹配的物品
|
|
|
|
+ oldSupplierMaterialsFormData = oldSupplierMaterialsFormData.stream().filter(item -> !oldRepeatNames.contains(item.get("name"))).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //获取新供应商原材料信息
|
|
|
|
+ List<Map> newSupplierMaterials = getYdFormDataList(SUPPLIER_MATERIALS, JSON.toJSONString(UtilMap.map("textField_llzzbyj1", newSupplierCode)), YDConf.FORM_QUERY.retrieve_list);
|
|
|
|
+ List<Map<String,String>> newSupplierMaterialsFormData = newSupplierMaterials.stream()
|
|
|
|
+ .map(item -> {
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
+ map.put("textField_lywr2qcq", String.valueOf(((Map) item.get("formData")).get("textField_llkb7kd1")));//物品名称
|
|
|
|
+ map.put("textField_lyxr5c44", String.valueOf(((Map) item.get("formData")).get("textField_llkb7kd2")));//物品编号
|
|
|
|
+ map.put("textField_lyxr5c46", String.valueOf(((Map) item.get("formData")).get("textField_llkb7kd4")));//物品规格
|
|
|
|
+ return map;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ //按物品名称进行分组
|
|
|
|
+ Map<String, List<Map<String, String>>> groupNewSupplierMaterials = newSupplierMaterialsFormData.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(map -> map.get("textField_lywr2qcq")));
|
|
|
|
+ //物品名称重复的物品
|
|
|
|
+ List<String> newRepeatNames = new ArrayList<>();
|
|
|
|
+ //物品名称未重复的物品
|
|
|
|
+ List<String> newNames = new ArrayList<>();
|
|
|
|
+ groupNewSupplierMaterials.forEach((name, value) -> {
|
|
|
|
+ if (value.size() > 1) {
|
|
|
|
+// diffList.addAll(value);
|
|
|
|
+ newRepeatNames.add(name);
|
|
|
|
+ }else {
|
|
|
|
+ newNames.add(name);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ //待匹配的物品
|
|
|
|
+// newSupplierMaterialsFormData = newSupplierMaterialsFormData.stream().filter(item -> !newRepeatNames.contains(item.get("name"))).collect(Collectors.toList());
|
|
|
|
+ List<String> matchNameList = new ArrayList<>();
|
|
|
|
+ matchNameList.addAll(oldNames);
|
|
|
|
+ matchNameList.retainAll(newNames);
|
|
|
|
+
|
|
|
|
+ List<String> diffNameList = new ArrayList<>();
|
|
|
|
+ diffNameList.addAll(oldNames);
|
|
|
|
+ diffNameList.removeAll(newNames);
|
|
|
|
+
|
|
|
|
+// oldNames.removeAll(newNames);
|
|
|
|
+
|
|
|
|
+ oldSupplierMaterialsFormData.forEach(item -> {
|
|
|
|
+ if (diffNameList.contains(item.get("textField_lywr2qcq"))){
|
|
|
|
+ diffList.add(item);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return diffList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<Map> getYdFormDataList(String formUuid, String searchCondition, YDConf.FORM_QUERY formQuery) {
|
|
|
|
+ List<Map> list = new ArrayList<>();
|
|
|
|
+ DDR_New ddrNew;
|
|
|
|
+ int pageNumber = 1;
|
|
|
|
+ int pageSize = 100;
|
|
|
|
+ do {
|
|
|
|
+ ddrNew = ydClient.queryData(YDParam.builder().formUuid(formUuid)
|
|
|
|
+ .searchCondition(searchCondition)
|
|
|
|
+ .pageNumber(pageNumber)
|
|
|
|
+ .pageSize(pageSize).build(), formQuery);
|
|
|
|
+
|
|
|
|
+ list.addAll((List<Map>) ddrNew.getData());
|
|
|
|
+ pageNumber++;
|
|
|
|
+ }while (ddrNew.getTotalCount() > ddrNew.getPageNumber() * pageSize);
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<Map> getYdInnerTableList(String formUuid,String formInstId,String tableFieldId) {
|
|
|
|
+ List<Map> list = new ArrayList<>();
|
|
|
|
+ DDR_New ddrNew;
|
|
|
|
+ int pageNumber = 1;
|
|
|
|
+ int pageSize = 50;
|
|
|
|
+ do {
|
|
|
|
+ ddrNew = ydClient.queryData(YDParam.builder()
|
|
|
|
+ .formUuid(formUuid)
|
|
|
|
+ .formInstanceId(formInstId)
|
|
|
|
+ .tableFieldId(tableFieldId)
|
|
|
|
+ .pageNumber(pageNumber)
|
|
|
|
+ .pageSize(pageSize).build(), YDConf.FORM_QUERY.retrieve_details);
|
|
|
|
+
|
|
|
|
+ list.addAll((List<Map>) ddrNew.getData());
|
|
|
|
+ pageNumber++;
|
|
|
|
+ }while (ddrNew.getTotalCount() > ddrNew.getPageNumber() * pageSize);
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public McR updateSuppliers(String formInstId) {
|
|
|
|
+ //查询定价单供应商变更实例
|
|
|
|
+ Map formData = ydClient.queryData(YDParam.builder()
|
|
|
|
+ .formInstanceId(formInstId).build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
|
+
|
|
|
|
+ String oldSupplierCode = String.valueOf(formData.get("textField_lv3w1k1l"));//旧供应商编号
|
|
|
|
+ String newSupplierCode = String.valueOf(formData.get("textField_llzzbai8"));//新供应商编号
|
|
|
|
+ String newSupplierName = String.valueOf(formData.get("textField_lmsli3bq"));//新供应商名称
|
|
|
|
+ String jsonString = formData.get("associationFormField_llkb7kct_id").toString();
|
|
|
|
+ String supplierJsonString = StringEscapeUtils.unescapeJava(jsonString.substring(1, jsonString.length() - 1));//新供应商(关联表单)
|
|
|
|
+ List<Map> supplier =(List<Map>) JSONArray.parse(supplierJsonString);
|
|
|
|
+
|
|
|
|
+ String jsonString2 = formData.get("associationFormField_llkb7kcs_id").toString();
|
|
|
|
+ String orderJsonString = StringEscapeUtils.unescapeJava(jsonString2.substring(1, jsonString2.length() - 1));//定价单(关联表单)
|
|
|
|
+ List<Map> order =(List<Map>) JSONArray.parse(orderJsonString);
|
|
|
|
+
|
|
|
|
+ String projectCode = String.valueOf(formData.get("textField_lllovku7"));//定价单编号
|
|
|
|
+
|
|
|
|
+ //新供应商差异原材料编号
|
|
|
|
+ List<String> newDiffSupplierMaterialCodes = new ArrayList<>();
|
|
|
|
+ //新供应商匹配原材料编号
|
|
|
|
+ List<String> newMatchSupplierMaterialCodes = new ArrayList<>();
|
|
|
|
+ //新供应商匹配原材料名称
|
|
|
|
+ List<String> newMatchSupplierMaterialNames = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ //老供应商差异原材料编号
|
|
|
|
+ List<String> oldDiffSupplierMaterialCodes = new ArrayList<>();
|
|
|
|
+ //老供应商匹配原材料编号
|
|
|
|
+ List<String> oldMatchSupplierMaterialCodes = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //校验新供应商原材料是否存在
|
|
|
|
+ List<Map> newSupplierMaterials = getYdFormDataList(SUPPLIER_MATERIALS, JSON.toJSONString(UtilMap.map("textField_llzzbyj1", newSupplierCode)), YDConf.FORM_QUERY.retrieve_list);
|
|
|
|
+ List<String> newSupplierMaterialCodes = newSupplierMaterials.stream()
|
|
|
|
+ .map(item -> String.valueOf(((Map)item.get("formData")).get("textField_llkb7kd2")))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ //获取差异子表所有数据(可能超过50条)
|
|
|
|
+ List<Map> diffList = getYdInnerTableList(SUPPLIER_CHANGE, formInstId, "tableField_lywr2qcp");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// List<Map> diffList = (List<Map>) formData.get("tableField_lywr2qcp");
|
|
|
|
+
|
|
|
|
+ for (Map diff : diffList) {
|
|
|
|
+ String oldCode = String.valueOf(diff.get("textField_lyxr5c44"));//老供应商原材料编号
|
|
|
|
+ String newCode = String.valueOf(diff.get("textField_lywr2qcv"));//新供应商原材料编号
|
|
|
|
+ String newName = String.valueOf(diff.get("textField_lz70gmob"));//新供应商原材料名称
|
|
|
|
+ //选择新供应商原材料且新供应商原材料编号存在
|
|
|
|
+ if ((Objects.nonNull(diff.get("associationFormField_lywr2qcr_id")) && newSupplierMaterialCodes.contains(newCode))){
|
|
|
|
+ oldMatchSupplierMaterialCodes.add(oldCode);
|
|
|
|
+ newMatchSupplierMaterialCodes.add(newCode);
|
|
|
|
+ newMatchSupplierMaterialNames.add(newName);
|
|
|
|
+ }
|
|
|
|
+ //未选择老供应商原材料且新供应商原材料不存在
|
|
|
|
+ if ((Objects.isNull(diff.get("associationFormField_lywr2qcr_id")) && !newSupplierMaterialCodes.contains(newCode))){
|
|
|
|
+ oldDiffSupplierMaterialCodes.add(oldCode);
|
|
|
|
+ newDiffSupplierMaterialCodes.add(newCode);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //校验新供应商原材料编号是否重复
|
|
|
|
+ HashSet<String> set = new HashSet<>(newDiffSupplierMaterialCodes);
|
|
|
|
+ if (set.size() != newDiffSupplierMaterialCodes.size()){
|
|
|
|
+ return McR.errorUnknown("新供应商原材料编号存在重复!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*for (Map diff : diffList) {
|
|
|
|
+ String oldCode = String.valueOf(diff.get("textField_lyxr5c44"));//老供应商原材料编号
|
|
|
|
+ String newCode = String.valueOf(diff.get("textField_lywr2qcv"));//新供应商原材料编号
|
|
|
|
+
|
|
|
|
+ if (!newMatchSupplierMaterialCodes.contains(newCode)){
|
|
|
|
+ //查询旧供应商原材料信息
|
|
|
|
+ List<Map> data = (List<Map>) ydClient.queryData(YDParam.builder()
|
|
|
|
+ .formUuid(SUPPLIER_MATERIALS)
|
|
|
|
+ .searchCondition(JSON.toJSONString(UtilMap.map("textField_llkb7kd2, textField_llzzbyj1", oldCode, oldSupplierCode)))
|
|
|
|
+ .build(), YDConf.FORM_QUERY.retrieve_list).getData();
|
|
|
|
+ //复制旧供应商原材料信息到新供应商
|
|
|
|
+ if (Objects.nonNull(data) && !data.isEmpty()){
|
|
|
|
+ Map diffFormData = (Map) data.get(0).get("formData");
|
|
|
|
+ diffFormData.put("associationFormField_lphya7cq",supplierJsonString);//供应商(关联表单)
|
|
|
|
+ diffFormData.put("textField_llzzbyj1", newSupplierCode);//供应商编号
|
|
|
|
+ diffFormData.put("textField_lmsli3bq", newSupplierName);//供应商名称
|
|
|
|
+ diffFormData.put("textField_llkb7kd2", newCode);//物品编号
|
|
|
|
+
|
|
|
|
+ ydClient.operateData(YDParam.builder().formUuid(SUPPLIER_MATERIALS)
|
|
|
|
+ .formDataJson(JSON.toJSONString(diffFormData)).build(), YDConf.FORM_OPERATION.create);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ //未匹配上的原材料
|
|
|
|
+ List<String> notMatchCodes = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ //获取旧供应商定价单明细中间表
|
|
|
|
+ List<Map> oldSupplierMaterials = getYdFormDataList(PRICE_DETAIL_MIDDLE, JSON.toJSONString(UtilMap.map("textField_llzzbyj1, textField_llm1vtjm", oldSupplierCode,projectCode)), YDConf.FORM_QUERY.retrieve_list);
|
|
|
|
+ for (Map oldSupplierMaterial : oldSupplierMaterials) {
|
|
|
|
+ Map oldSupplierMaterialFormData = (Map) oldSupplierMaterial.get("formData");
|
|
|
|
+ String code = String.valueOf(oldSupplierMaterialFormData.get("textField_llkb7kd2"));
|
|
|
|
+ String name = String.valueOf(oldSupplierMaterialFormData.get("textField_llkb7kd1"));
|
|
|
|
+ String formInstanceId = String.valueOf(oldSupplierMaterial.get("formInstanceId"));
|
|
|
|
+
|
|
|
|
+ String newCode = "";
|
|
|
|
+
|
|
|
|
+ //更新定价单明细中间表
|
|
|
|
+ oldSupplierMaterialFormData.put("textField_lmsli3bq", newSupplierName);//供应商名称
|
|
|
|
+ oldSupplierMaterialFormData.put("textField_llzzbyj1", newSupplierCode);//供应商编号
|
|
|
|
+
|
|
|
|
+ //未匹配上的原材料 将明细删除
|
|
|
|
+ int index1 = oldDiffSupplierMaterialCodes.indexOf(code);
|
|
|
|
+ if (index1 != -1){
|
|
|
|
+ /*ydClient.operateData(YDParam.builder().formUuid(PRICE_DETAIL_MIDDLE)
|
|
|
|
+ .formInstanceId(formInstanceId)
|
|
|
|
+ .updateFormDataJson(JSON.toJSONString(UtilMap.map("textField_lm4lxur8","已停用"))).build(), YDConf.FORM_OPERATION.update);
|
|
|
|
+*/
|
|
|
|
+ ydClient.operateData(YDParam.builder().formUuid(PRICE_DETAIL_MIDDLE)
|
|
|
|
+ .formInstanceId(formInstanceId)
|
|
|
|
+ .build(), YDConf.FORM_OPERATION.delete);
|
|
|
|
+ notMatchCodes.add(code);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //手动匹配上的原材料
|
|
|
|
+ int index2 = oldMatchSupplierMaterialCodes.indexOf(code);
|
|
|
|
+ if (index2 != -1){
|
|
|
|
+ newCode = newMatchSupplierMaterialCodes.get(index2);
|
|
|
|
+ oldSupplierMaterialFormData.put("textField_llkb7kd2", newCode);//物品编号
|
|
|
|
+ oldSupplierMaterialFormData.put("textField_llkb7kd1",newMatchSupplierMaterialNames.get(index2));//物品名称
|
|
|
|
+ ydClient.operateData(YDParam.builder().formUuid(PRICE_DETAIL_MIDDLE)
|
|
|
|
+ .formInstanceId(formInstanceId)
|
|
|
|
+ .updateFormDataJson(JSON.toJSONString(oldSupplierMaterialFormData)).build(), YDConf.FORM_OPERATION.update);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //自动匹配上的原材料
|
|
|
|
+ for (Map newSupplierMaterial : newSupplierMaterials) {
|
|
|
|
+ Map newSupplierMaterialFormData = (Map) newSupplierMaterial.get("formData");
|
|
|
|
+ if (String.valueOf(newSupplierMaterialFormData.get("textField_llkb7kd1")).equals(name)){
|
|
|
|
+ newCode = newSupplierMaterialFormData.get("textField_llkb7kd2").toString();
|
|
|
|
+ oldSupplierMaterialFormData.put("textField_llkb7kd2", newCode);//物品编号
|
|
|
|
+ ydClient.operateData(YDParam.builder().formUuid(PRICE_DETAIL_MIDDLE)
|
|
|
|
+ .formInstanceId(formInstanceId)
|
|
|
|
+ .updateFormDataJson(JSON.toJSONString(oldSupplierMaterialFormData)).build(), YDConf.FORM_OPERATION.update);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //更新定价单
|
|
|
|
+ String supplierInstanceId = supplier.get(0).get("instanceId").toString();
|
|
|
|
+ Map supplierMap = ydClient.queryData(YDParam.builder()
|
|
|
|
+ .formInstId(supplierInstanceId).build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
|
+ List<Map> employee = (List<Map>) supplierMap.get("employeeField_lllodwha_id");
|
|
|
|
+
|
|
|
|
+ String orderInstanceId = order.get(0).get("instanceId").toString();
|
|
|
|
+ Map updateFormData = new HashMap<>();
|
|
|
|
+ updateFormData.put("associationFormField_llkb7kct",supplierJsonString);//供应商(关联表单)
|
|
|
|
+ updateFormData.put("textField_llzzbai8", newSupplierCode);//供应商编号
|
|
|
|
+ updateFormData.put("textField_lmsli3bq", newSupplierName);//供应商名称
|
|
|
|
+ updateFormData.put("textField_lv3w1k1l", oldSupplierCode);//历史供应商编号
|
|
|
|
+ updateFormData.put("employeeField_lmsli3br", employee);//供应商负责人
|
|
|
|
+
|
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
|
+ .formInstId(orderInstanceId)
|
|
|
|
+ .updateFormDataJson(JSON.toJSONString(updateFormData))
|
|
|
|
+ .build(), YDConf.FORM_OPERATION.update);
|
|
|
|
+
|
|
|
|
+ //更新菜品
|
|
|
|
+ List<Map> data = (List<Map>) ydClient.queryData(YDParam.builder()
|
|
|
|
+ .formUuid(FOOD)
|
|
|
|
+ .searchCondition(JSON.toJSONString(UtilMap.map("textField_lln3lmn1", projectCode)))
|
|
|
|
+ .build(), YDConf.FORM_QUERY.retrieve_list_all).getData();
|
|
|
|
+ for (Map datum : data) {
|
|
|
|
+ //获取菜品管理信息
|
|
|
|
+ Map foodFormData = (Map) datum.get("formData");
|
|
|
|
+ List<Map> materialList = (List<Map>) foodFormData.get("tableField_llm1i9yy");
|
|
|
|
+ List<String> errorCodes = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+// Map foodFormData = ydClient.queryData(YDParam.builder().formInstanceId(formInstId).build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
|
+// List<Map> materialList = (List<Map>) foodFormData.get("tableField_llm1i9yy");
|
|
|
|
+ for (Map material : materialList) {
|
|
|
|
+ String code = material.get("textField_lmk94yf5").toString();
|
|
|
|
+ //如果明细被删除
|
|
|
|
+ if (notMatchCodes.contains(code)){
|
|
|
|
+ errorCodes.add(code);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ String jsonString3 = material.get("associationFormField_lln3lmmv_id").toString();
|
|
|
|
+ String materialJsonString = StringEscapeUtils.unescapeJava(jsonString3.substring(1, jsonString3.length() - 1));//新供应商原材料(关联表单)
|
|
|
|
+
|
|
|
|
+ Map materialMap =(((List<Map>) JSONArray.parse(materialJsonString))).get(0);
|
|
|
|
+ String instanceId = materialMap.get("instanceId").toString();
|
|
|
|
+
|
|
|
|
+ //获取定价单明细中间表信息
|
|
|
|
+ Map formData1 = ydClient.queryData(YDParam.builder().formInstanceId(instanceId).build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
|
+
|
|
|
|
+ materialMap.put("title",formData1.get("textField_llkb7kd1").toString());
|
|
|
|
+ materialMap.put("subTitle",formData1.get("textField_lmkfg67e"));
|
|
|
|
+ List<Map> list = new ArrayList<>();
|
|
|
|
+ list.add(materialMap);
|
|
|
|
+ material.put("associationFormField_lln3lmmv",list);//原材料(关联表单)
|
|
|
|
+ material.put("textField_lln3lmn2",formData1.get("textField_llkb7kd3"));//单位
|
|
|
|
+ material.put("textField_llyy3khw",formData1.get("textField_lmkfg67e"));//品牌
|
|
|
|
+ material.put("textField_lz0ve9ct",formData1.get("textField_llkb7kd4"));//规格
|
|
|
|
+ material.put("numberField_lnrzzg03",formData1.get("numberField_lnrzzg03"));//整包装数量
|
|
|
|
+ material.put("textField_lnrzzg04",formData1.get("textField_lnrzzg04"));//整包装单位
|
|
|
|
+ material.put("textField_llndm599",formData1.get("textField_llkb7kd1"));//原材料名称
|
|
|
|
+ material.put("textField_lmk94yf5",formData1.get("textField_llkb7kd2"));//原材料编号
|
|
|
|
+ material.put("selectField_lmqclyx9",formData1.get("selectField_llkb7kd5"));//第一分类
|
|
|
|
+ material.put("numberField_lmqclyxa",formData1.get("numberField_llkknd6h"));//供货价
|
|
|
|
+ material.put("numberField_lmsvffts",formData1.get("numberField_llkknd6g"));//成本单价
|
|
|
|
+ material.put("numberField_lmsvfftt",formData1.get("numberField_llkb7kcy"));//服务费率
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!errorCodes.isEmpty()){
|
|
|
|
+ foodFormData.put("selectField_lzaq9r7i","异常");
|
|
|
|
+ foodFormData.put("textField_lzaq9r7n",String.join(",",errorCodes));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ foodFormData.put("tableField_llm1i9yy",materialList);
|
|
|
|
+
|
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
|
+ .formInstanceId(formInstId)
|
|
|
|
+ .updateFormDataJson(JSON.toJSONString(foodFormData))
|
|
|
|
+ .build(), YDConf.FORM_OPERATION.update);
|
|
|
|
+
|
|
|
|
+ /*for (Map material : materialList) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String code = material.get("textField_lmk94yf5").toString();//老供应商原材料编号
|
|
|
|
+ if (changeCodeMap.containsKey(code)){
|
|
|
|
+ material.put("textField_lmk94yf5", changeCodeMap.get(code));//新供应商原材料编号
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ foodFormData.put("tableField_llm1i9yy",materialList);
|
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
|
+ .formInstanceId(datum.get("formInstanceId").toString())
|
|
|
|
+ .updateFormDataJson(JSON.toJSONString(foodFormData))
|
|
|
|
+ .build(),YDConf.FORM_OPERATION.update);*/
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return McR.success();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|