|
@@ -43,8 +43,7 @@ import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
-import java.time.DayOfWeek;
|
|
|
-import java.time.LocalDate;
|
|
|
+import java.time.*;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
@@ -606,11 +605,11 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
DateTime beginOfMonth = DateUtil.beginOfMonth(DateUtil.lastMonth());
|
|
|
String beginOfMonthString = beginOfMonth.toString("yyyy-MM-dd");
|
|
|
|
|
|
- /*String beginOfMonthString = "2025-06-12";
|
|
|
+ /*String beginOfMonthString = "2025-06-25";
|
|
|
|
|
|
- String yesterday = "2025-06-12";*/
|
|
|
+ String yesterday = "2025-06-25";*/
|
|
|
for (Integer dsSequence : factory.keySet()) {
|
|
|
- /*if (dsSequence == 2){
|
|
|
+ /*if (dsSequence != 8){
|
|
|
continue;
|
|
|
}*/
|
|
|
|
|
@@ -646,7 +645,7 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
//查询单个出库单详情
|
|
|
String id = getString(saleout.get("code"));
|
|
|
|
|
|
- /*if (!id.equals("00000044856")){
|
|
|
+ /*if (!id.equals("0000009439")){
|
|
|
continue;
|
|
|
}*/
|
|
|
|
|
@@ -732,6 +731,8 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
//是否退线
|
|
|
boolean isReject = false;
|
|
|
|
|
|
+ Map<String,String> inventoryPrice = new HashMap<>();
|
|
|
+
|
|
|
//出库明细
|
|
|
List<Map> list1 = new ArrayList();
|
|
|
|
|
@@ -764,7 +765,41 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
|
|
|
totalQuantity.updateAndGet(v -> new Double((double) (v + Double.parseDouble(getString(item.get("quantity"))))));
|
|
|
|
|
|
- if (Objects.nonNull(item.get("price")) && isNumber(getString(item.get("price")))){
|
|
|
+ String price = getString(item.get("price"));
|
|
|
+ String cost = getString(item.get("cost"));
|
|
|
+
|
|
|
+ try {
|
|
|
+ double numericValue = Double.parseDouble(price);
|
|
|
+
|
|
|
+ //单价为0时查询存货价目表
|
|
|
+ if (numericValue == 0d){
|
|
|
+ String inventorycode = getString(item.get("inventorycode"));
|
|
|
+
|
|
|
+ if (inventoryPrice.containsKey(inventorycode)){
|
|
|
+ price = inventoryPrice.get(inventorycode);
|
|
|
+ }else {
|
|
|
+ price = getInventoryPrice(factory.get(dsSequence), getString(item.get("free1")), getString(saleout2.get("date")), getString(item.get("inventorycode")));
|
|
|
+
|
|
|
+ inventoryPrice.put(getString(item.get("inventorycode")),price);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!"0".equals(price)){
|
|
|
+ cost = Double.parseDouble(price) * Double.parseDouble(getString(item.get("quantity"))) + "";
|
|
|
+ detail.put("numberField_m18nvp8k", price);//单价
|
|
|
+ detail.put("numberField_m18nvp8m", cost);//金额
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ detail.put("numberField_m18nvp8k", price);//单价
|
|
|
+ detail.put("numberField_m18nvp8m", cost);//金额
|
|
|
+ }
|
|
|
+
|
|
|
+ String finalCost = cost;
|
|
|
+ totalCost.updateAndGet(v -> new Double((double) (v + Double.parseDouble(finalCost))));
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ System.out.println("字符串不是有效的数值: " + price);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* if (Objects.nonNull(item.get("price")) && isNumber(getString(item.get("price")))){
|
|
|
detail.put("numberField_m18nvp8k", getString(item.get("price")));//单价
|
|
|
}
|
|
|
|
|
@@ -772,7 +807,7 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
detail.put("numberField_m18nvp8m", getString(item.get("cost")));//金额
|
|
|
|
|
|
totalCost.updateAndGet(v -> new Double((double) (v + Double.parseDouble(getString(item.get("cost"))))));
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
list1.add(detail);
|
|
|
}
|
|
@@ -801,7 +836,41 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
|
|
|
totalQuantity.updateAndGet(v -> new Double((double) (v + Double.parseDouble(getString(item.get("quantity"))))));
|
|
|
|
|
|
- if (Objects.nonNull(item.get("price")) && isNumber(getString(item.get("price")))){
|
|
|
+ String price = getString(item.get("price"));
|
|
|
+ String cost = getString(item.get("cost"));
|
|
|
+
|
|
|
+ try {
|
|
|
+ double numericValue = Double.parseDouble(price);
|
|
|
+
|
|
|
+ //单价为0时查询存货价目表
|
|
|
+ if (numericValue == 0d){
|
|
|
+ String inventorycode = getString(item.get("inventorycode"));
|
|
|
+
|
|
|
+ if (inventoryPrice.containsKey(inventorycode)){
|
|
|
+ price = inventoryPrice.get(inventorycode);
|
|
|
+ }else {
|
|
|
+ price = getInventoryPrice(factory.get(dsSequence), getString(item.get("free1")), getString(saleout2.get("date")), getString(item.get("inventorycode")));
|
|
|
+
|
|
|
+ inventoryPrice.put(getString(item.get("inventorycode")),price);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!"0".equals(price)){
|
|
|
+ cost = Double.parseDouble(price) * Double.parseDouble(getString(item.get("quantity"))) + "";
|
|
|
+ detail.put("numberField_m2j0wj8v", price);//单价
|
|
|
+ detail.put("numberField_m2j0wj8w", cost);//金额
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ detail.put("numberField_m2j0wj8v", price);//单价
|
|
|
+ detail.put("numberField_m2j0wj8w", cost);//金额
|
|
|
+ }
|
|
|
+
|
|
|
+ String finalCost = cost;
|
|
|
+ totalCost.updateAndGet(v -> new Double((double) (v + Double.parseDouble(finalCost))));
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ System.out.println("字符串不是有效的数值: " + price);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*if (Objects.nonNull(item.get("price")) && isNumber(getString(item.get("price")))){
|
|
|
detail.put("numberField_m2j0wj8v", getString(item.get("price")));//单价
|
|
|
}
|
|
|
|
|
@@ -809,7 +878,7 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
detail.put("numberField_m2j0wj8w", getString(item.get("cost")));//金额
|
|
|
|
|
|
totalCost.updateAndGet(v -> new Double((double) (v + Double.parseDouble(getString(item.get("cost"))))));
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
list2.add(detail);
|
|
|
}
|
|
@@ -839,7 +908,41 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
|
|
|
totalQuantity.updateAndGet(v -> new Double((double) (v + Double.parseDouble(getString(item.get("quantity"))))));
|
|
|
|
|
|
- if (Objects.nonNull(item.get("price")) && isNumber(getString(item.get("price")))){
|
|
|
+ String price = getString(item.get("price"));
|
|
|
+ String cost = getString(item.get("cost"));
|
|
|
+
|
|
|
+ try {
|
|
|
+ double numericValue = Double.parseDouble(price);
|
|
|
+
|
|
|
+ //单价为0时查询存货价目表
|
|
|
+ if (numericValue == 0d){
|
|
|
+ String inventorycode = getString(item.get("inventorycode"));
|
|
|
+
|
|
|
+ if (inventoryPrice.containsKey(inventorycode)){
|
|
|
+ price = inventoryPrice.get(inventorycode);
|
|
|
+ }else {
|
|
|
+ price = getInventoryPrice(factory.get(dsSequence), getString(item.get("free1")), getString(saleout2.get("date")), getString(item.get("inventorycode")));
|
|
|
+
|
|
|
+ inventoryPrice.put(getString(item.get("inventorycode")),price);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!"0".equals(price)){
|
|
|
+ cost = Double.parseDouble(price) * Double.parseDouble(getString(item.get("quantity"))) + "";
|
|
|
+ detail.put("numberField_m2j0wj9a", price);//单价
|
|
|
+ detail.put("numberField_m2j0wj9b", cost);//金额
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ detail.put("numberField_m2j0wj9a", price);//单价
|
|
|
+ detail.put("numberField_m2j0wj9b", cost);//金额
|
|
|
+ }
|
|
|
+
|
|
|
+ String finalCost = cost;
|
|
|
+ totalCost.updateAndGet(v -> new Double((double) (v + Double.parseDouble(finalCost))));
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ System.out.println("字符串不是有效的数值: " + price);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*if (Objects.nonNull(item.get("price")) && isNumber(getString(item.get("price")))){
|
|
|
detail.put("numberField_m2j0wj9a", getString(item.get("price")));//单价
|
|
|
}
|
|
|
|
|
@@ -847,7 +950,7 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
detail.put("numberField_m2j0wj9b", getString(item.get("cost")));//金额
|
|
|
|
|
|
totalCost.updateAndGet(v -> new Double((double) (v + Double.parseDouble(getString(item.get("cost"))))));
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
list3.add(detail);
|
|
|
}
|
|
@@ -877,7 +980,41 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
|
|
|
totalQuantity.updateAndGet(v -> new Double((double) (v + Double.parseDouble(getString(item.get("quantity"))))));
|
|
|
|
|
|
- if (Objects.nonNull(item.get("price")) && isNumber(getString(item.get("price")))){
|
|
|
+ String price = getString(item.get("price"));
|
|
|
+ String cost = getString(item.get("cost"));
|
|
|
+
|
|
|
+ try {
|
|
|
+ double numericValue = Double.parseDouble(price);
|
|
|
+
|
|
|
+ //单价为0时查询存货价目表
|
|
|
+ if (numericValue == 0d){
|
|
|
+ String inventorycode = getString(item.get("inventorycode"));
|
|
|
+
|
|
|
+ if (inventoryPrice.containsKey(inventorycode)){
|
|
|
+ price = inventoryPrice.get(inventorycode);
|
|
|
+ }else {
|
|
|
+ price = getInventoryPrice(factory.get(dsSequence), getString(item.get("free1")), getString(saleout2.get("date")), getString(item.get("inventorycode")));
|
|
|
+
|
|
|
+ inventoryPrice.put(getString(item.get("inventorycode")),price);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!"0".equals(price)){
|
|
|
+ cost = Double.parseDouble(price) * Double.parseDouble(getString(item.get("quantity"))) + "";
|
|
|
+ detail.put("numberField_m4cfhc77", price);//单价
|
|
|
+ detail.put("numberField_m4cfhc78", cost);//金额
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ detail.put("numberField_m4cfhc77", price);//单价
|
|
|
+ detail.put("numberField_m4cfhc78", cost);//金额
|
|
|
+ }
|
|
|
+
|
|
|
+ String finalCost = cost;
|
|
|
+ totalCost.updateAndGet(v -> new Double((double) (v + Double.parseDouble(finalCost))));
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ System.out.println("字符串不是有效的数值: " + price);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*if (Objects.nonNull(item.get("price")) && isNumber(getString(item.get("price")))){
|
|
|
detail.put("numberField_m4cfhc77", getString(item.get("price")));//单价
|
|
|
}
|
|
|
|
|
@@ -885,7 +1022,7 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
detail.put("numberField_m4cfhc78", getString(item.get("cost")));//金额
|
|
|
|
|
|
totalCost.updateAndGet(v -> new Double((double) (v + Double.parseDouble(getString(item.get("cost"))))));
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
list4.add(detail);
|
|
|
}
|
|
@@ -915,7 +1052,41 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
|
|
|
totalQuantity.updateAndGet(v -> new Double((double) (v + Double.parseDouble(getString(item.get("quantity"))))));
|
|
|
|
|
|
- if (Objects.nonNull(item.get("price")) && isNumber(getString(item.get("price")))){
|
|
|
+ String price = getString(item.get("price"));
|
|
|
+ String cost = getString(item.get("cost"));
|
|
|
+
|
|
|
+ try {
|
|
|
+ double numericValue = Double.parseDouble(price);
|
|
|
+
|
|
|
+ //单价为0时查询存货价目表
|
|
|
+ if (numericValue == 0d){
|
|
|
+ String inventorycode = getString(item.get("inventorycode"));
|
|
|
+
|
|
|
+ if (inventoryPrice.containsKey(inventorycode)){
|
|
|
+ price = inventoryPrice.get(inventorycode);
|
|
|
+ }else {
|
|
|
+ price = getInventoryPrice(factory.get(dsSequence), getString(item.get("free1")), getString(saleout2.get("date")), getString(item.get("inventorycode")));
|
|
|
+
|
|
|
+ inventoryPrice.put(getString(item.get("inventorycode")),price);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!"0".equals(price)){
|
|
|
+ cost = Double.parseDouble(price) * Double.parseDouble(getString(item.get("quantity"))) + "";
|
|
|
+ detail.put("numberField_m4cfhc7m", price);//单价
|
|
|
+ detail.put("numberField_m4cfhc7n", cost);//金额
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ detail.put("numberField_m4cfhc7m", price);//单价
|
|
|
+ detail.put("numberField_m4cfhc7n", cost);//金额
|
|
|
+ }
|
|
|
+
|
|
|
+ String finalCost = cost;
|
|
|
+ totalCost.updateAndGet(v -> new Double((double) (v + Double.parseDouble(finalCost))));
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ System.out.println("字符串不是有效的数值: " + price);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*if (Objects.nonNull(item.get("price")) && isNumber(getString(item.get("price")))){
|
|
|
detail.put("numberField_m4cfhc7m", getString(item.get("price")));//单价
|
|
|
}
|
|
|
|
|
@@ -923,7 +1094,7 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
detail.put("numberField_m4cfhc7n", getString(item.get("cost")));//金额
|
|
|
|
|
|
totalCost.updateAndGet(v -> new Double((double) (v + Double.parseDouble(getString(item.get("cost"))))));
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
list5.add(detail);
|
|
|
}
|
|
@@ -1016,6 +1187,46 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
return McR.success();
|
|
|
}
|
|
|
|
|
|
+ public String getInventoryPrice(String factory,String customerCode,String dateStr,String inventoryCode){
|
|
|
+ String price = "0";
|
|
|
+ List<Map> searchCondition = new ArrayList<>();
|
|
|
+ searchCondition.add(UtilMap.map("key, value, type, operator, componentName","selectField_mc36onxf",factory,"TEXT","eq","TextField"));//工厂
|
|
|
+ searchCondition.add(UtilMap.map("key, value, type, operator, componentName","selectField_mc36onxg",customerCode,"TEXT","eq","TextField"));//客户码
|
|
|
+
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+
|
|
|
+ // 解析日期字符串为 LocalDate
|
|
|
+ LocalDate date = LocalDate.parse(dateStr, formatter);
|
|
|
+
|
|
|
+ // 获取当天的起始时间(00:00:00)
|
|
|
+ LocalDateTime startOfDay = date.atStartOfDay();
|
|
|
+ // 获取当天的结束时间(23:59:59)
|
|
|
+ LocalDateTime endOfDay = date.atTime(23, 59, 59);
|
|
|
+
|
|
|
+ // 转换为时间戳(假设使用系统默认时区)
|
|
|
+ ZoneId zoneId = ZoneId.systemDefault();
|
|
|
+ ZonedDateTime startZonedDateTime = startOfDay.atZone(zoneId);
|
|
|
+ ZonedDateTime endZonedDateTime = endOfDay.atZone(zoneId);
|
|
|
+
|
|
|
+ long startTimestamp = startZonedDateTime.toInstant().toEpochMilli();
|
|
|
+ long endTimestamp = endZonedDateTime.toInstant().toEpochMilli();
|
|
|
+
|
|
|
+ searchCondition.add(UtilMap.map("key, value, type, operator, componentName","dateField_mc36onxh",Arrays.asList(startTimestamp,endTimestamp),"DOUBLE","between","DateField"));//出库时间
|
|
|
+ searchCondition.add(UtilMap.map("key, value, type, operator, componentName","textField_mc36onxm",inventoryCode,"TEXT","eq","TextField"));//存货编码
|
|
|
+
|
|
|
+ List<Map> priceData = (List<Map>) ydClient.queryData(YDParam.builder()
|
|
|
+ .formUuid("FORM-934F1DF0B6C34535B81102F0CEFB6C1FR55N")
|
|
|
+ .searchCondition(JSONObject.toJSONString(searchCondition))
|
|
|
+ .pageSize(1)
|
|
|
+ .build(), YDConf.FORM_QUERY.retrieve_list).getData();
|
|
|
+
|
|
|
+ if (priceData.size() == 1){
|
|
|
+ price = getString(((Map)priceData.get(0).get("formData")).get("numberField_mc36onxj"));
|
|
|
+ }
|
|
|
+
|
|
|
+ return price;
|
|
|
+ }
|
|
|
+
|
|
|
public String getInventoryName(String inventoryCode,int dsSequence,Map<String,String> inventory){
|
|
|
if (inventory.containsKey(inventoryCode)){
|
|
|
return inventory.get(inventoryCode);
|