|
@@ -341,7 +341,7 @@ public class HeiHuOrderServiceImpl implements HeiHuOrderService {
|
|
|
formdata.put("textField_mkaudmn6",gysnumber);
|
|
formdata.put("textField_mkaudmn6",gysnumber);
|
|
|
formdata.put("dateField_mfqia329",purchaseTime);
|
|
formdata.put("dateField_mfqia329",purchaseTime);
|
|
|
formdata.put("dateField_mfqia32a",planArrivalTime);
|
|
formdata.put("dateField_mfqia32a",planArrivalTime);
|
|
|
-// formdata.put("employeeField_mfqia32g",getDDToken(purchaserName)); todo:这里调试完成后取消注释
|
|
|
|
|
|
|
+ formdata.put("employeeField_mfqia32g",getDDToken(purchaserName));
|
|
|
formdata.put("numberField_mfqia32h",orderDiscount*100);
|
|
formdata.put("numberField_mfqia32h",orderDiscount*100);
|
|
|
//采购订单-自定义
|
|
//采购订单-自定义
|
|
|
formdata.put("textField_mfqia32o",department);
|
|
formdata.put("textField_mfqia32o",department);
|
|
@@ -375,11 +375,12 @@ public class HeiHuOrderServiceImpl implements HeiHuOrderService {
|
|
|
tableData.add(row);
|
|
tableData.add(row);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- /*todo:新版栏目:客户、订单号、款号、产品描述、颜色、数量、销售单价、销售金额、币别、生产工厂、采购单价、采购金额、利润率*/
|
|
|
|
|
|
|
+ /*todo:新版栏目:客户、订单号、款号、产品描述、颜色、数量、销售单价、销售金额、币别、生产工厂、采购单价、采购金额、利润率、美金汇率、辅料预估成本*/
|
|
|
String customerName = "",styleNumber = "",productDescription = "",color = "",currency = "";
|
|
String customerName = "",styleNumber = "",productDescription = "",color = "",currency = "";
|
|
|
Double number,unitPrice,salesAmount;
|
|
Double number,unitPrice,salesAmount;
|
|
|
Double rate = 1.00;Double saletotalAmount = 0.00;Double procuretotalAmount = 0.00;Double saletotalnum =0.00;
|
|
Double rate = 1.00;Double saletotalAmount = 0.00;Double procuretotalAmount = 0.00;Double saletotalnum =0.00;
|
|
|
Double estimatedtotalAmount = 0.00;Double estimatedPrice = 0.00;
|
|
Double estimatedtotalAmount = 0.00;Double estimatedPrice = 0.00;
|
|
|
|
|
+ Double USDrate = 0.00;Double flygcb = 0.00;
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
JsonNode rootNode = objectMapper.readTree(jsonString);
|
|
JsonNode rootNode = objectMapper.readTree(jsonString);
|
|
|
JsonNode dataNode = rootNode.get("data");
|
|
JsonNode dataNode = rootNode.get("data");
|
|
@@ -454,9 +455,14 @@ public class HeiHuOrderServiceImpl implements HeiHuOrderService {
|
|
|
currency = node.get("value").asText();
|
|
currency = node.get("value").asText();
|
|
|
}else if (node.get("fieldId").asInt() == 165251){
|
|
}else if (node.get("fieldId").asInt() == 165251){
|
|
|
rate = node.get("value").asDouble();
|
|
rate = node.get("value").asDouble();
|
|
|
|
|
+ USDrate = rate;
|
|
|
|
|
+ }else if (node.get("fieldId").asInt() == 161783) {
|
|
|
|
|
+ flygcb = node.get("value").asDouble();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
row.put("textField_mhtxft3p",currency);//todo:币别
|
|
row.put("textField_mhtxft3p",currency);//todo:币别
|
|
|
|
|
+ row.put("numberField_ml85btkc",USDrate);//todo:美金汇率
|
|
|
|
|
+ row.put("numberField_ml85btkd",flygcb);//todo:辅料预估成本
|
|
|
//下面是采购订单的明细数据
|
|
//下面是采购订单的明细数据
|
|
|
row.put("textField_mhsj6gtv",shortName);//todo:生产工厂
|
|
row.put("textField_mhsj6gtv",shortName);//todo:生产工厂
|
|
|
for(int j=0;j<products.size();j++){
|
|
for(int j=0;j<products.size();j++){
|
|
@@ -464,7 +470,7 @@ public class HeiHuOrderServiceImpl implements HeiHuOrderService {
|
|
|
//找到对应的采购一行数据
|
|
//找到对应的采购一行数据
|
|
|
row.put("numberField_mhsj6gtw",products.getJSONObject(j).getDouble("purchasePrice"));//todo:采购单价
|
|
row.put("numberField_mhsj6gtw",products.getJSONObject(j).getDouble("purchasePrice"));//todo:采购单价
|
|
|
row.put("numberField_mhtxft3q",products.getJSONObject(j).getDouble("purchaseNum"));//todo:采购数量
|
|
row.put("numberField_mhtxft3q",products.getJSONObject(j).getDouble("purchaseNum"));//todo:采购数量
|
|
|
- row.put("numberField_mhsj6gtx",products.getJSONObject(j).getDouble("purchasePrice") * products.getJSONObject(i).getDouble("purchaseNum"));//todo:采购金额
|
|
|
|
|
|
|
+ row.put("numberField_mhsj6gtx",products.getJSONObject(j).getDouble("purchasePrice") * products.getJSONObject(j).getDouble("purchaseNum"));//todo:采购金额
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//销售总金额 币别:人民币 数量*单价 美元:数量*单价*美元汇率
|
|
//销售总金额 币别:人民币 数量*单价 美元:数量*单价*美元汇率
|
|
@@ -536,28 +542,41 @@ public class HeiHuOrderServiceImpl implements HeiHuOrderService {
|
|
|
Map formdata = ydClient.queryData(YDParam.builder().formInstId(formInstanceId)
|
|
Map formdata = ydClient.queryData(YDParam.builder().formInstId(formInstanceId)
|
|
|
.appType(ydConf.getAppType()).systemToken(ydConf.getSystemToken())
|
|
.appType(ydConf.getAppType()).systemToken(ydConf.getSystemToken())
|
|
|
.userId(ddConf.getOperator()).build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
.userId(ddConf.getOperator()).build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
- HashMap body = new HashMap();
|
|
|
|
|
- body.put("orderCode",formdata.get("textField_mfqia327"));//订单编号
|
|
|
|
|
- body.put("vendorCode",formdata.get("textField_mkaudmn6"));//供应商编号
|
|
|
|
|
- String aa = formdata.get("dateField_mfqia329").toString();
|
|
|
|
|
- String cgrq = Instant.ofEpochMilli(Long.parseLong(aa))
|
|
|
|
|
- .atZone(ZoneId.of("Asia/Shanghai"))
|
|
|
|
|
- .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
- body.put("purchaseTime",cgrq);//采购日期
|
|
|
|
|
- String bb = formdata.get("dateField_mfqia32a").toString();
|
|
|
|
|
- String jhdhrq = Instant.ofEpochMilli(Long.parseLong(bb))
|
|
|
|
|
- .atZone(ZoneId.of("Asia/Shanghai"))
|
|
|
|
|
- .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
- body.put("planArrivalTime",jhdhrq);//计划到货日期
|
|
|
|
|
- ArrayList<Map<String,String>> customFiled = new ArrayList();
|
|
|
|
|
- HashMap field = new HashMap();
|
|
|
|
|
- field.put("name","采购订单钉钉审批状态");
|
|
|
|
|
- field.put("value",Approvalresult);//审批状态
|
|
|
|
|
- customFiled.add(field);
|
|
|
|
|
- body.put("purchaseOrderCustomFieldsValue",customFiled);
|
|
|
|
|
- String dd = UtilHttp.doPost("https://liteweb.blacklake.cn/api/dytin/external/purchaseOrder/update", header, null, body);
|
|
|
|
|
- log.info("---------【回传采购订单状态完成】-----------");
|
|
|
|
|
- return McR.success(dd);
|
|
|
|
|
|
|
+ String jsonString = formdata.get("tableField_ml7ch2pj").toString();
|
|
|
|
|
+ JSONArray tableField_ml7ch2pj = JSON.parseArray(jsonString);
|
|
|
|
|
+ for (int i=0;i<tableField_ml7ch2pj.size();i++){
|
|
|
|
|
+ String poNumber = tableField_ml7ch2pj.getJSONObject(i).getString("textField_ml7ch2pk");//拿到采购订单号
|
|
|
|
|
+ HashMap body = new HashMap();
|
|
|
|
|
+ body.put("orderCode",poNumber);//订单编号
|
|
|
|
|
+ String jsonString2 = UtilHttp.doPost("https://liteweb.blacklake.cn/api/dytin/external/purchaseOrder/queryList2", header, null, body);//todo:查询采购订单
|
|
|
|
|
+ JSONArray dataArray = JSONObject.parseObject(jsonString2).getJSONArray("data");
|
|
|
|
|
+ for (int k=0;k<dataArray.size();k++) {
|
|
|
|
|
+ JSONObject data = dataArray.getJSONObject(k);
|
|
|
|
|
+ //提取订单基本信息 并赋值
|
|
|
|
|
+ HashMap body1 = new HashMap();
|
|
|
|
|
+ body1.put("orderCode",data.getString("orderCode"));//订单编号:orderCode
|
|
|
|
|
+ body1.put("vendorCode",data.getString("vendorCode"));//供应商编码:gysnumber
|
|
|
|
|
+ String aa = data.getLong("purchaseTime").toString();
|
|
|
|
|
+ String purchaseTime = Instant.ofEpochMilli(Long.parseLong(aa))
|
|
|
|
|
+ .atZone(ZoneId.of("Asia/Shanghai"))
|
|
|
|
|
+ .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ body1.put("purchaseTime",purchaseTime);//采购日期:purchaseTime
|
|
|
|
|
+ String bb = data.getLong("planArrivalTime").toString();
|
|
|
|
|
+ String planArrivalTime = Instant.ofEpochMilli(Long.parseLong(aa))
|
|
|
|
|
+ .atZone(ZoneId.of("Asia/Shanghai"))
|
|
|
|
|
+ .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ body1.put("planArrivalTime",planArrivalTime);//计划到货日期:planArrivalTime
|
|
|
|
|
+ ArrayList<Map<String,String>> customFiled = new ArrayList();
|
|
|
|
|
+ HashMap field = new HashMap();
|
|
|
|
|
+ field.put("name","采购订单钉钉审批状态");
|
|
|
|
|
+ field.put("value",Approvalresult);//审批状态
|
|
|
|
|
+ customFiled.add(field);
|
|
|
|
|
+ body1.put("purchaseOrderCustomFieldsValue",customFiled);
|
|
|
|
|
+ UtilHttp.doPost("https://liteweb.blacklake.cn/api/dytin/external/purchaseOrder/update", header, null, body1);
|
|
|
|
|
+ log.info("---------【回传,{},采购订单状态完成】-----------",data.getString("orderCode"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return McR.success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -963,15 +982,306 @@ public class HeiHuOrderServiceImpl implements HeiHuOrderService {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(doPost);
|
|
JSONObject jsonObject = JSONObject.parseObject(doPost);
|
|
|
JSONArray dataArray = jsonObject.getJSONArray("data");
|
|
JSONArray dataArray = jsonObject.getJSONArray("data");
|
|
|
System.out.println(dataArray);
|
|
System.out.println(dataArray);
|
|
|
- String productName = "";
|
|
|
|
|
|
|
+ /* String productName = "";
|
|
|
for (int i = 0; i < dataArray.size(); i++) {
|
|
for (int i = 0; i < dataArray.size(); i++) {
|
|
|
JSONObject data = dataArray.getJSONObject(i);
|
|
JSONObject data = dataArray.getJSONObject(i);
|
|
|
productName = data.getString("productName");
|
|
productName = data.getString("productName");
|
|
|
|
|
+ }*/
|
|
|
|
|
+
|
|
|
|
|
+ String colorValue = "";
|
|
|
|
|
+ if (dataArray != null && dataArray.size() > 0) {
|
|
|
|
|
+ JSONObject data = dataArray.getJSONObject(0);
|
|
|
|
|
+ JSONObject customFieldValues = data.getJSONObject("customFieldValues");
|
|
|
|
|
+ if (customFieldValues != null) {
|
|
|
|
|
+ // 直接获取指定字段的值
|
|
|
|
|
+ colorValue = customFieldValues.getString("product1741831360685211");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- return productName;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return colorValue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public McR test12() throws JacksonException {
|
|
|
|
|
+ HashMap header = new HashMap();
|
|
|
|
|
+ header.put("X-AUTH", HeiHuAccessToken().getData().toString());
|
|
|
|
|
+ header.put("Content-Type", "application/json");
|
|
|
|
|
+
|
|
|
|
|
+ String targetValue = "合同确认,提交审批";
|
|
|
|
|
+ Map<String, List<String>> purchaserOrderCodes = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ int pageNum = 1;
|
|
|
|
|
+ int pageSize = 100;
|
|
|
|
|
+ boolean hasMoreData = true;
|
|
|
|
|
+
|
|
|
|
|
+ while (hasMoreData) {
|
|
|
|
|
+ HashMap body = new HashMap();
|
|
|
|
|
+ Map<String, Integer> page = new HashMap<>();
|
|
|
|
|
+ page.put("pageNum", pageNum);
|
|
|
|
|
+ page.put("pageSize", pageSize);
|
|
|
|
|
+ List<Integer> status = Arrays.asList(1);
|
|
|
|
|
+ body.put("page", page);
|
|
|
|
|
+ body.put("status", status);
|
|
|
|
|
+
|
|
|
|
|
+ String doPost = UtilHttp.doPost("https://liteweb.blacklake.cn/api/dytin/external/purchaseOrder/queryList2", header, null, body);
|
|
|
|
|
+
|
|
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
+ Map<String, Object> response = mapper.readValue(doPost, Map.class);
|
|
|
|
|
+
|
|
|
|
|
+ if (!"01000000".equals(response.get("code"))) {
|
|
|
|
|
+ System.out.println("请求失败: " + response.get("msg"));
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String, Object>> dataList = (List<Map<String, Object>>) response.get("data");
|
|
|
|
|
+ if (dataList != null) {
|
|
|
|
|
+ for (Map<String, Object> item : dataList) {
|
|
|
|
|
+ String purchaserName = (String) item.get("purchaserName");
|
|
|
|
|
+ if (purchaserName == null) purchaserName = "未知";
|
|
|
|
|
+
|
|
|
|
|
+ boolean hasTargetStatus = false;
|
|
|
|
|
+ List<Map<String, Object>> customFieldValues = (List<Map<String, Object>>) item.get("customFieldValues");
|
|
|
|
|
+ if (customFieldValues != null) {
|
|
|
|
|
+ for (Map<String, Object> field : customFieldValues) {
|
|
|
|
|
+ if (targetValue.equals(field.get("value"))) {
|
|
|
|
|
+ hasTargetStatus = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (hasTargetStatus) {
|
|
|
|
|
+ String orderCode = (String) item.get("orderCode");
|
|
|
|
|
+ if (orderCode != null) {
|
|
|
|
|
+ purchaserOrderCodes.computeIfAbsent(purchaserName, k -> new ArrayList<>()).add(orderCode);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ hasMoreData = dataList.size() >= pageSize;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ hasMoreData = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ pageNum++;
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ Thread.sleep(200);
|
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 输出所有采购员的待审批订单
|
|
|
|
|
+ System.out.println("========== 所有采购员的待审批订单统计 ==========");
|
|
|
|
|
+
|
|
|
|
|
+ if (purchaserOrderCodes.isEmpty()) {
|
|
|
|
|
+ System.out.println("没有找到钉钉审批状态为'" + targetValue + "'的订单");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ int totalPurchasers = purchaserOrderCodes.size();
|
|
|
|
|
+ int totalOrders = purchaserOrderCodes.values().stream().mapToInt(List::size).sum();
|
|
|
|
|
|
|
|
|
|
+ System.out.println("共找到 " + totalOrders + " 个待审批订单");
|
|
|
|
|
+ System.out.println("涉及 " + totalPurchasers + " 位采购员");
|
|
|
|
|
+ System.out.println();
|
|
|
|
|
+
|
|
|
|
|
+ // 输出每个采购员的情况
|
|
|
|
|
+ for (Map.Entry<String, List<String>> entry : purchaserOrderCodes.entrySet()) {
|
|
|
|
|
+ String purchaserName = entry.getKey();
|
|
|
|
|
+ List<String> orderCodes = entry.getValue();
|
|
|
|
|
+ int orderCount = orderCodes.size();
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("采购员: " + purchaserName);
|
|
|
|
|
+ System.out.println("待审批订单数量: " + orderCount);
|
|
|
|
|
+
|
|
|
|
|
+ if (orderCount > 1) {
|
|
|
|
|
+ System.out.println("⚠️ 注意:该采购员有 " + orderCount + " 个待审批订单");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("订单编号: " + String.join(", ", orderCodes));
|
|
|
|
|
+ System.out.println();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 按订单数量排序输出
|
|
|
|
|
+ System.out.println("========== 按待审批订单数量排序 ==========");
|
|
|
|
|
+ purchaserOrderCodes.entrySet().stream()
|
|
|
|
|
+ .sorted((e1, e2) -> Integer.compare(e2.getValue().size(), e1.getValue().size()))
|
|
|
|
|
+ .forEach(entry -> {
|
|
|
|
|
+ String purchaserName = entry.getKey();
|
|
|
|
|
+ List<String> orderCodes = entry.getValue();
|
|
|
|
|
+ System.out.println(purchaserName + " (" + orderCodes.size() + "个): " +
|
|
|
|
|
+ String.join(", ", orderCodes));
|
|
|
|
|
+ //针对同一个采购员,遍历下面的订单编号
|
|
|
|
|
+ System.out.println("开始处理采购员 " + purchaserName + " 的 " + orderCodes.size() + " 个待审批订单");
|
|
|
|
|
+ HashMap formdata = new HashMap();
|
|
|
|
|
+ List<Map<String,String>> tabledata = new ArrayList();
|
|
|
|
|
+ for (String orderCode : orderCodes) {
|
|
|
|
|
+ System.out.println("正在处理订单: " + orderCode);
|
|
|
|
|
+ //todo:查询订单的销售订单 | 客户 销售订单号 款式 产品描述 颜色 | 数量 销售单价 销售金额 | 币别 美金汇率 辅料预估成本 销售总金额
|
|
|
|
|
+ String customerName = "",orderNumber ="",styleNumber ="",productDescription = "",color = "";
|
|
|
|
|
+ Double number,unitPrice,salesAmount;
|
|
|
|
|
+ String currency = ""; Double USDrate = 0.00; Double flygcb = 0.00; Double saletotalAmount = 0.00;
|
|
|
|
|
+ Double estimatedPrice = 0.00;//辅料预估单价
|
|
|
|
|
+
|
|
|
|
|
+ HashMap body = new HashMap();
|
|
|
|
|
+ body.put("orderCode",orderCode);//订单编号
|
|
|
|
|
+ String jsonString = UtilHttp.doPost("https://liteweb.blacklake.cn/api/dytin/external/purchaseOrder/queryList2", header, null, body);
|
|
|
|
|
+ //todo:查询采购订单 生产工厂(供应商)
|
|
|
|
|
+ String shortName = "";
|
|
|
|
|
+ JSONArray dataArray = JSONObject.parseObject(jsonString).getJSONArray("data");
|
|
|
|
|
+ for (int i=0;i<dataArray.size();i++) {
|
|
|
|
|
+ JSONObject data = dataArray.getJSONObject(i);
|
|
|
|
|
+ shortName = data.getString("shortName");//供应商:shortName
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONArray products = JSONObject.parseObject(jsonString).getJSONArray("data").getJSONObject(0).getJSONArray("purchaseSubOrderVOS");
|
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
+ JsonNode rootNode = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ rootNode = objectMapper.readTree(jsonString);
|
|
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ JsonNode dataNode = rootNode.get("data");
|
|
|
|
|
+ if(dataNode != null && dataNode.isArray()){
|
|
|
|
|
+ for(JsonNode item : dataNode){
|
|
|
|
|
+ JsonNode orderNoNode = item.get("orderCode");
|
|
|
|
|
+ JsonNode saleOrders = item.get("relationSaleOrders");
|
|
|
|
|
+ if(saleOrders != null && saleOrders.isArray() && saleOrders.size() > 0){
|
|
|
|
|
+ orderNumber = saleOrders.get(0).asText();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ HashMap body_A = new HashMap();
|
|
|
|
|
+ body_A.put("orderNo",orderNumber);
|
|
|
|
|
+ String jsonString2 = UtilHttp.doPost("https://liteweb.blacklake.cn/api/dytin/external/saleOrder/queryList2", header, null, body_A);//todo:查询销售订单,获取客户、订单号、款号、产品描述、颜色、数量、销售单价、销售金额、币别
|
|
|
|
|
+ JSONArray array = JSONObject.parseObject(jsonString2).getJSONArray("data");//主表数据
|
|
|
|
|
+ for(int i=0;i<array.size();i++){
|
|
|
|
|
+ JSONObject data = array.getJSONObject(i);
|
|
|
|
|
+ customerName = data.getString("customerCode");//客户
|
|
|
|
|
+ purchaserName = data.getString("purchaserName");//采购员
|
|
|
|
|
+ }
|
|
|
|
|
+ ObjectMapper objectMapper2 = new ObjectMapper();
|
|
|
|
|
+ JsonNode dataNode2 = null;//主表数据
|
|
|
|
|
+ try {
|
|
|
|
|
+ dataNode2 = objectMapper2.readTree(jsonString2).get("data");
|
|
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ for (JsonNode item : dataNode2){
|
|
|
|
|
+ JsonNode customFieldValues = item.get("customFieldValues");
|
|
|
|
|
+ for (JsonNode field : customFieldValues){
|
|
|
|
|
+ JsonNode fieldIdNode = field.get("fieldId");
|
|
|
|
|
+ if(fieldIdNode != null && fieldIdNode.asInt() == 161769){
|
|
|
|
|
+ JsonNode valueNode = field.get("value");
|
|
|
|
|
+ if(valueNode != null){
|
|
|
|
|
+ estimatedPrice = valueNode.asDouble();//辅料预估单价
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ JSONArray products_A = JSONObject.parseObject(jsonString2).getJSONArray("data").getJSONObject(0).getJSONArray("saleManageOrderDetailRowApiVOList");//销售订单明细数据
|
|
|
|
|
+
|
|
|
|
|
+ if(products_A != null) {
|
|
|
|
|
+ for (int i = 0; i < products_A.size(); i++) {
|
|
|
|
|
+ JSONObject detail = products_A.getJSONObject(i);
|
|
|
|
|
+ HashMap row = new HashMap();
|
|
|
|
|
+ row.put("textField_ml6g7k5e", customerName);//todo:客户
|
|
|
|
|
+ row.put("textField_ml6g7k5f", orderNumber);//todo:订单号
|
|
|
|
|
+
|
|
|
|
|
+ styleNumber = detail.getString("productCode");//款号
|
|
|
|
|
+ row.put("textField_ml7c3yhq", styleNumber);//todo:款号
|
|
|
|
|
+
|
|
|
|
|
+ productDescription = detail.getString("productName");//产品描述
|
|
|
|
|
+ row.put("textField_ml7c3yhr", productDescription);//todo:产品描述
|
|
|
|
|
+
|
|
|
|
|
+ JSONArray array1 = detail.getJSONArray("customFieldValues");
|
|
|
|
|
+ color = array1.stream()
|
|
|
|
|
+ .map(obj -> (JSONObject) obj)
|
|
|
|
|
+ .filter(item -> item.getIntValue("fieldId") == 82259)
|
|
|
|
|
+ .map(item -> item.getString("value"))
|
|
|
|
|
+ .findFirst()
|
|
|
|
|
+ .orElse(null);
|
|
|
|
|
+ ArrayList colorList = new ArrayList();
|
|
|
|
|
+ colorList.add(color);
|
|
|
|
|
+ String color_AAA = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ color_AAA = getProductColor(colorList);
|
|
|
|
|
+ } catch (JacksonException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ row.put("textField_ml7c3yhs", color_AAA);//todo:颜色
|
|
|
|
|
+
|
|
|
|
|
+ number = detail.getDoubleValue("qty");//数量
|
|
|
|
|
+ row.put("numberField_ml7c3yht", number);//todo:数量
|
|
|
|
|
+
|
|
|
|
|
+ unitPrice = detail.getDoubleValue("unitPrice");//销售单价
|
|
|
|
|
+ row.put("numberField_ml7c3yhu", unitPrice);//todo:销售单价
|
|
|
|
|
+
|
|
|
|
|
+ salesAmount = number * unitPrice;//销售金额
|
|
|
|
|
+ row.put("numberField_ml7c3yhv", salesAmount);//todo:销售金额
|
|
|
|
|
+ String customFieldValues = detail.getString("customFieldValues");
|
|
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
+ JsonNode jsonarray = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonarray = mapper.readTree(customFieldValues);
|
|
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ for (JsonNode node : jsonarray) {
|
|
|
|
|
+ if (node.get("fieldId").asInt() == 47919) {
|
|
|
|
|
+ currency = node.get("value").asText();
|
|
|
|
|
+ } else if (node.get("fieldId").asInt() == 165251) {
|
|
|
|
|
+ USDrate = node.get("value").asDouble();
|
|
|
|
|
+
|
|
|
|
|
+ } else if (node.get("fieldId").asInt() == 161783) {
|
|
|
|
|
+ flygcb = node.get("value").asDouble();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ row.put("textField_ml7c3yhw", currency);//todo:币别
|
|
|
|
|
+ row.put("numberField_ml86221y", USDrate);//todo:美金汇率
|
|
|
|
|
+ row.put("numberField_ml86221z", flygcb);//todo:辅料预估成本
|
|
|
|
|
+ if(currency.equals("USD")){
|
|
|
|
|
+ saletotalAmount = salesAmount * USDrate;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ saletotalAmount = salesAmount;
|
|
|
|
|
+ }
|
|
|
|
|
+ row.put("numberField_ml862220",saletotalAmount);
|
|
|
|
|
+ //下面是采购订单的明细数据
|
|
|
|
|
+ row.put("textField_ml7c3yhx",shortName);//todo:生产工厂
|
|
|
|
|
+ for(int j=0;j<products.size();j++){
|
|
|
|
|
+ if(styleNumber.equals(products.getJSONObject(j).getString("productCode"))){
|
|
|
|
|
+ //找到对应的采购一行数据
|
|
|
|
|
+ row.put("numberField_ml7c3yhy",products.getJSONObject(j).getDouble("purchasePrice"));//todo:采购单价
|
|
|
|
|
+ row.put("numberField_ml7c3yhz",products.getJSONObject(j).getDouble("purchaseNum"));//todo:采购数量
|
|
|
|
|
+ row.put("numberField_ml7c3yi0",products.getJSONObject(j).getDouble("purchasePrice") * products.getJSONObject(j).getDouble("purchaseNum"));//todo:采购金额
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ tabledata.add(row);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ //todo:组装数据塞到采购明细表
|
|
|
|
|
+ formdata.put("tableField_ml6g7k5d",tabledata);
|
|
|
|
|
+ //todo:组装数据塞到采购审批单号明细
|
|
|
|
|
+// formdata.put("tableField_ml7ch2pj",);
|
|
|
|
|
+ /*发起流程*/
|
|
|
|
|
+ String userId = getDDToken(purchaserName);
|
|
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
|
|
+ .appType(ydConf.getAppType()).systemToken(ydConf.getSystemToken())
|
|
|
|
|
+ .formUuid("FORM-3A54B12BE3D241218A75242B935F2987YWV2")
|
|
|
|
|
+ .userId(userId)
|
|
|
|
|
+ .formDataJson(JSON.toJSONString(formdata))
|
|
|
|
|
+ .build(), YDConf.FORM_OPERATION.start).toString();
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
/*获取宜搭采购订单汇总*/
|
|
/*获取宜搭采购订单汇总*/
|