|
@@ -30,6 +30,7 @@ import java.sql.Connection;
|
|
|
import java.sql.DriverManager;
|
|
|
import java.sql.PreparedStatement;
|
|
|
import java.text.DecimalFormat;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -68,6 +69,8 @@ public class TimerServiceImpl implements TimerService {
|
|
|
@Autowired
|
|
|
private DDClient_Personnel ddClientPersonnel;
|
|
|
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
/**
|
|
|
* 月度定额更新
|
|
|
*/
|
|
@@ -83,64 +86,68 @@ public class TimerServiceImpl implements TimerService {
|
|
|
.build());
|
|
|
log.info("项目点数据, {}", dataList.size());
|
|
|
dataList.forEach(formData -> {
|
|
|
- //获取撤场时间
|
|
|
- Long withdrawalTime = formData.get("dateField_lzaqu26p")==null?null:DateUtil.beginOfMonth(DateUtil.date(Long.parseLong(formData.get("dateField_lzaqu26p").toString()))).getTime();
|
|
|
- if (UtilMap.getString(formData, "selectField_lrn2oy4a").equals("进行中") || (ObjectUtil.isNotNull(withdrawalTime) && lastMonth == withdrawalTime)){
|
|
|
- List<Map> details = UtilMap.getList(formData, "tableField_lrru2tnq");
|
|
|
+// if("PM00411".equals(UtilMap.getString(formData, "textField_ltxrn8h1"))){
|
|
|
+
|
|
|
+ //获取撤场时间
|
|
|
+ Long withdrawalTime = formData.get("dateField_lzaqu26p")==null?null:DateUtil.beginOfMonth(DateUtil.date(Long.parseLong(formData.get("dateField_lzaqu26p").toString()))).getTime();
|
|
|
+ if (UtilMap.getString(formData, "selectField_lrn2oy4a").equals("进行中") || (ObjectUtil.isNotNull(withdrawalTime) && lastMonth == withdrawalTime)){
|
|
|
+ List<Map> details = UtilMap.getList(formData, "tableField_lrru2tnq");
|
|
|
// details = details.stream().filter(item -> UtilMap.isNotBlankString(item, "dateField_lrru2tnr")).collect(Collectors.toList());
|
|
|
- // 数据格式化
|
|
|
+ // 数据格式化
|
|
|
// details.forEach(row -> {
|
|
|
// row.put("textField_luh0k82j", UtilDateTime.format(new Date(UtilMap.getLong(row, "dateField_lrru2tnr")), "yyyy-MM"));
|
|
|
// }
|
|
|
// });
|
|
|
// Collections.sort(details, Comparator.comparingLong(o -> UtilMap.getLong(o, "dateField_lrru2tnr")));
|
|
|
|
|
|
- // 查找当月数据
|
|
|
- LocalDateTime currentDate = UtilDateTime.firstDayOfLastMonth(LocalDateTime.now());
|
|
|
+ // 查找当月数据
|
|
|
+ LocalDateTime currentDate = UtilDateTime.firstDayOfLastMonth(LocalDateTime.now());
|
|
|
// LocalDateTime currentDate = UtilDateTime.parseLocalDateTime("2024-07-01 00:00:00");
|
|
|
|
|
|
- try {
|
|
|
- Optional optional = details.stream().filter(item -> UtilDateTime.getLocalDateTimeTimeStamp(currentDate) == UtilMap.getLong(item, "dateField_lrru2tnr")).findAny();
|
|
|
- log.info("上个月数据, {}, {}", currentDate, optional);
|
|
|
- if (!optional.isPresent() || UtilMap.getFloat((Map) optional.get(), "numberField_lrru2tnz") != 0f) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ try {
|
|
|
+ Optional optional = details.stream().filter(item -> UtilDateTime.getLocalDateTimeTimeStamp(currentDate) == UtilMap.getLong(item, "dateField_lrru2tnr") || (currentDate.getYear() +"-"+ String.format("%02d", currentDate.getMonthValue())).equals(UtilMap.getString(item,"textField_luh0k82j"))).findAny();
|
|
|
+ log.info("上个月数据, {}, {}", currentDate, optional);
|
|
|
+ if (!optional.isPresent() || UtilMap.getFloat((Map) optional.get(), "numberField_lrru2tnz") == 0f) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- LocalDateTime lastMonthDate = UtilDateTime.firstDayOfLastMonth(currentDate);
|
|
|
+ LocalDateTime lastMonthDate = UtilDateTime.firstDayOfLastMonth(currentDate);
|
|
|
// LocalDateTime lastMonthDate = UtilDateTime.parseLocalDateTime("2024-06-01 00:00:00");
|
|
|
- Map currentRow = (Map) optional.get();
|
|
|
- optional = details.stream().filter(item -> UtilDateTime.getLocalDateTimeTimeStamp(lastMonthDate) == UtilMap.getLong(item, "dateField_lrru2tnr")).findAny();
|
|
|
- log.info("上上月数据, {}, {}", lastMonthDate, optional);
|
|
|
-
|
|
|
- float price;
|
|
|
- if (!optional.isPresent() || UtilMap.getFloat((Map) optional.get(), "numberField_lrru2tnz") == 0f) {
|
|
|
- price = UtilMap.getFloat(currentRow, "numberField_lrru2tns");
|
|
|
- currentRow.put("numberField_lrru2tnz", price); // 取本月收入定额
|
|
|
- } else {
|
|
|
- price = UtilMap.getFloat((Map) optional.get(), "numberField_lrru2tnz");
|
|
|
- currentRow.put("numberField_lrru2tnz", price); // 取上月收入预估
|
|
|
- }
|
|
|
- //明细合计
|
|
|
- currentRow.put("numberField_lryopn7o", UtilMap.getFloat(currentRow, "numberField_lrru2tnz") + UtilMap.getFloat(currentRow, "numberField_lrru2to0") + UtilMap.getFloat(currentRow, "numberField_lrru2to1"));
|
|
|
- currentRow.put("numberField_m1hhyqiv", UtilMap.getFloat(currentRow, "numberField_lrru2tnz") + UtilMap.getFloat(currentRow, "numberField_lrru2to0") + UtilMap.getFloat(currentRow, "numberField_lrru2to1"));
|
|
|
+ Map currentRow = (Map) optional.get();
|
|
|
+ optional = details.stream().filter(item -> UtilDateTime.getLocalDateTimeTimeStamp(lastMonthDate) == UtilMap.getLong(item, "dateField_lrru2tnr") || (currentDate.getYear() +"-"+ String.format("%02d", currentDate.getMonthValue())).equals(UtilMap.getString(item,"textField_luh0k82j"))).findAny();
|
|
|
+ log.info("上上月数据, {}, {}", lastMonthDate, optional);
|
|
|
+
|
|
|
+ float price;
|
|
|
+ if (!optional.isPresent() || UtilMap.getFloat((Map) optional.get(), "numberField_lrru2tnz") == 0f) {
|
|
|
+ price = UtilMap.getFloat(currentRow, "numberField_lrru2tns");
|
|
|
+ currentRow.put("numberField_lrru2tnz", price); // 取本月收入定额
|
|
|
+ } else {
|
|
|
+ price = UtilMap.getFloat((Map) optional.get(), "numberField_lrru2tnz");
|
|
|
+ currentRow.put("numberField_lrru2tnz", price); // 取上月收入预估
|
|
|
+ }
|
|
|
+ //明细合计
|
|
|
+ currentRow.put("numberField_lryopn7o", UtilMap.getFloat(currentRow, "numberField_lrru2tnz") + UtilMap.getFloat(currentRow, "numberField_lrru2to0") + UtilMap.getFloat(currentRow, "numberField_lrru2to1"));
|
|
|
+ currentRow.put("numberField_m1hhyqiv", UtilMap.getFloat(currentRow, "numberField_lrru2tnz") + UtilMap.getFloat(currentRow, "numberField_lrru2to0") + UtilMap.getFloat(currentRow, "numberField_lrru2to1"));
|
|
|
|
|
|
- price += UtilMap.getFloat(formData, "numberField_lutjev0u");
|
|
|
- log.info("price, {}", price);
|
|
|
+ price += UtilMap.getFloat(formData, "numberField_lutjev0u");
|
|
|
+ log.info("price, {}", price);
|
|
|
|
|
|
- System.out.println("更新内容:" + JSON.toJSONString(UtilMap.map("tableField_lrru2tnq, numberField_lutjev0u", details, price)));
|
|
|
- // 合计初始化
|
|
|
+ System.out.println("更新内容:" + JSON.toJSONString(UtilMap.map("tableField_lrru2tnq, numberField_lutjev0u", details, price)));
|
|
|
+ // 合计初始化
|
|
|
// price = details.stream().map(item -> UtilMap.getFloat(item, "numberField_lrru2tnz")).collect(Collectors.toList()).stream().reduce(0f, (acc, cur) -> acc + cur);
|
|
|
- ydClient.operateData(YDParam.builder()
|
|
|
- .appType("APP_ERBDTFS82HOVBPL3NFH0")
|
|
|
- .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
|
|
|
- .formInstanceId(UtilMap.getString(formData, "formInstanceId"))
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .appType("APP_ERBDTFS82HOVBPL3NFH0")
|
|
|
+ .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
|
|
|
+ .formInstanceId(UtilMap.getString(formData, "formInstanceId"))
|
|
|
// .useLatestVersion(true)
|
|
|
- .updateFormDataJson(JSON.toJSONString(UtilMap.map("tableField_lrru2tnq, numberField_lutjev0u", details, price)))
|
|
|
- .build(), YDConf.FORM_OPERATION.update);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ .updateFormDataJson(JSON.toJSONString(UtilMap.map("tableField_lrru2tnq, numberField_lutjev0u", details, price)))
|
|
|
+ .build(), YDConf.FORM_OPERATION.update);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+// }
|
|
|
+
|
|
|
});
|
|
|
|
|
|
return null;
|