Переглянути джерело

日常物耗申请采购专员节点更新

fyz 8 місяців тому
батько
коміт
79c0a91c82

+ 2 - 2
mjava-lanyun/src/main/java/com/malk/lanyun/controller/TimerController.java

@@ -111,9 +111,9 @@ public class TimerController {
      * @param
      */
     @PostMapping("materialProject")
-    void updateMaterialProject(String projectCode,String date,Double firstCost,Double nowCost,int type){
+    void updateMaterialProject(String projectCode,String date,Double firstCost,Double nowCost,String formInstId){
         log.info("进入更新字段初始物耗费用总计方法");
-        timerService.updateMaterialProject(projectCode,date,firstCost,nowCost,type);
+        timerService.updateMaterialProject(projectCode,date,firstCost,nowCost,formInstId);
     }
 
     /**

+ 1 - 1
mjava-lanyun/src/main/java/com/malk/lanyun/service/TimerService.java

@@ -70,7 +70,7 @@ public interface TimerService {
      * @param firstCost 初始物耗费用合计
      * @param nowCost 本次物耗
      */
-    void updateMaterialProject(String projectCode, String date, Double firstCost, Double nowCost, int type);
+    void updateMaterialProject(String projectCode, String date, Double firstCost, Double nowCost, String formInstId);
 
     /**
      * 定时更新本周未出库项目数

+ 7 - 6
mjava-lanyun/src/main/java/com/malk/lanyun/service/impl/NCServiceImpl.java

@@ -37,7 +37,7 @@ public class NCServiceImpl implements NCService {
     public void getNcInfo() {
         // 获取上月年,月
         int year = lastMonth.getYear();
-        int month = lastMonth.getMonthValue();
+        String month = String.format("%02d",lastMonth.getMonthValue()) ;
 
         Connection connection = null;
         Statement statement = null;
@@ -102,7 +102,7 @@ public class NCServiceImpl implements NCService {
     public void getNcCgInfo() {
         // 获取当前年
         int year = lastMonth.getYear();
-        int month = lastMonth.getMonthValue();
+        String month = String.format("%02d",lastMonth.getMonthValue()) ;
 
         Connection connection = null;
         Statement statement = null;
@@ -171,7 +171,7 @@ public class NCServiceImpl implements NCService {
     public void getNcCost() {
         // 获取当前年
         int year = lastMonth.getYear();
-        int month = lastMonth.getMonthValue();
+        String month = String.format("%02d",lastMonth.getMonthValue()) ;
 
         Connection connection = null;
         Statement statement = null;
@@ -238,8 +238,9 @@ public class NCServiceImpl implements NCService {
     public void getNcCollection() {
         // 获取当前年
         int year = lastMonth.getYear();
-        int month = lastMonth.getMonthValue();
+        String month = String.format("%02d",lastMonth.getMonthValue()) ;
 
+        System.out.println(month);
         Connection connection = null;
         Statement statement = null;
         ResultSet resultSet = null;
@@ -254,7 +255,7 @@ public class NCServiceImpl implements NCService {
 
             // 测试sql 执行查询
             String sql = "SELECT b.adjustperiod AS adjustperiod, b.pk_accasoa AS pk_accasoa,a.name AS accasoa_name, SUM ( b.creditamount ) AS creditamount\n" +
-                    "            FROM gl_detail b JOIN bd_accasoa a ON b.pk_accasoa = a.pk_accasoa WHERE b.yearv = "+year+" AND b.adjustperiod = "+ month +
+                    "            FROM gl_detail b JOIN bd_accasoa a ON b.pk_accasoa = a.pk_accasoa WHERE b.yearv = "+year+" AND b.adjustperiod = '"+ month + "'" +
                     "            AND (b.accountcode like '6602%' OR b.accountcode IN ('660101','660103','660104'))" +
                     "            AND b.pk_accountingbook IN ( SELECT pk_accountingbook FROM org_accountingbook WHERE code IN ( 'A01-0004', 'A02-0004', 'A03-0004', 'A04-0004', 'A05-0004', 'A06-0004', 'A10-0004', 'A11-0004' ))\n" +
                     "            GROUP BY b.adjustperiod,  b.pk_accasoa,  a.name";
@@ -305,7 +306,7 @@ public class NCServiceImpl implements NCService {
     public void getSupplierPay() {
         // 获取当前年
         int year = lastMonth.getYear();
-        int month = lastMonth.getMonthValue();
+        String month = String.format("%02d",lastMonth.getMonthValue()) ;
 
         LocalDate firstDayOfYear = LocalDate.of(year, 1, 1);
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

+ 40 - 45
mjava-lanyun/src/main/java/com/malk/lanyun/service/impl/TimerServiceImpl.java

@@ -1,6 +1,5 @@
 package com.malk.lanyun.service.impl;
 
-import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
@@ -33,7 +32,6 @@ import java.sql.PreparedStatement;
 import java.text.DecimalFormat;
 import java.time.LocalDateTime;
 import java.util.*;
-import java.util.logging.Level;
 import java.util.stream.Collectors;
 
 import static java.lang.Integer.parseInt;
@@ -742,56 +740,53 @@ public class TimerServiceImpl implements TimerService {
     }
 
     @Override
-    public void updateMaterialProject(String projectCode, String date, Double firstCost, Double nowCost, int type) {
-        double cost;
+    public void updateMaterialProject(String projectCode, String date, Double firstCost, Double nowCost, String formInstId) {
         if(ObjectUtil.isEmpty(firstCost) || firstCost == 0.0){
-            cost = nowCost;
-        } else {
-            cost = firstCost;
-        }
-
-        List<Map> bigList = ydService.queryFormData_all(YDParam.builder()
-                .appType("APP_ERBDTFS82HOVBPL3NFH0")
-                .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
+            List<Map> bigList = ydService.queryFormData_all(YDParam.builder()
+                    .appType("APP_ERBDTFS82HOVBPL3NFH0")
+                    .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
                 .formUuid("FORM-97BA6C6C8C50416A9E5854F2F4B5C3F3R4WC")
-                //测试档案
-//                .formUuid("FORM-CE163643B967429CABA97CC8733E3B5B1RZZ")
-                .searchFieldJson(JSON.toJSONString(UtilMap.map("textField_ltxrn8h1", projectCode)))
-                .build());
-        bigList.forEach(e->{
-            List<Map> sonList = (List<Map>) e.get("tableField_lrru2tnq");
-            if (ObjectUtil.isNotEmpty(sonList)){
-                sonList.forEach(s->{
-                    //年月文本
-                    String projectDate = s.get("textField_luh0k82j").toString();
-                    //剩余物耗定额
-                    double remaining = Double.parseDouble(s.get("numberField_lrru2tnv").toString());
-                    //已用物耗定额
-                    double used = Double.parseDouble(s.get("numberField_ludujw4f").toString());
-                    log.info("cost:{}",cost);
-                    if (date.equals(projectDate)){
-                        if (type == 0){
-                            remaining = remaining - cost;
+                    //测试档案
+//                    .formUuid("FORM-D3F341E3315140F4ADC9E5005260309E8B27")
+                    .searchFieldJson(JSON.toJSONString(UtilMap.map("textField_ltxrn8h1", projectCode)))
+                    .build());
+            bigList.forEach(e->{
+                List<Map> sonList = (List<Map>) e.get("tableField_lrru2tnq");
+                if (ObjectUtil.isNotEmpty(sonList)){
+                    sonList.forEach(s->{
+                        //年月文本
+                        String projectDate = s.get("textField_luh0k82j").toString();
+                        //剩余物耗定额
+                        double remaining = Double.parseDouble(s.get("numberField_lrru2tnv").toString());
+                        //已用物耗定额
+                        double used = Double.parseDouble(s.get("numberField_ludujw4f").toString());
+                        log.info("cost:{}",nowCost);
+                        if (date.equals(projectDate)){
+                            remaining = remaining - nowCost;
                             s.put("numberField_lrru2tnv",remaining);
-                            used = used + cost;
-                            s.put("numberField_ludujw4f",used);
-                        } else if (type == 1) {
-                            remaining = remaining + cost - nowCost;
-                            s.put("numberField_lrru2tnv",remaining);
-                            used = used - cost + nowCost;
+                            used = used + nowCost;
                             s.put("numberField_ludujw4f",used);
                         }
-                    }
-                });
-            }
+                    });
+                }
+                ydClient.operateData(YDParam.builder()
+                        .appType("APP_ERBDTFS82HOVBPL3NFH0")
+                        .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
+                        .formInstanceId(e.get("formInstanceId").toString())
+//                    .useLatestVersion(true)
+                        .updateFormDataJson(JSON.toJSONString(UtilMap.map("tableField_lrru2tnq", sonList)))
+                        .build(), YDConf.FORM_OPERATION.update);
+            });
+            log.info("日常物耗流程id为:{}",formInstId);
+            log.info("初始物耗费用合计为:{}",firstCost);
+            log.info("本次物耗费用合计为:{}",nowCost);
             ydClient.operateData(YDParam.builder()
                     .appType("APP_ERBDTFS82HOVBPL3NFH0")
                     .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
-                    .formInstanceId(e.get("formInstanceId").toString())
-//                    .useLatestVersion(true)
-                    .updateFormDataJson(JSON.toJSONString(UtilMap.map("tableField_lrru2tnq", sonList)))
+                    .formInstanceId(formInstId)
+                    .updateFormDataJson(JSON.toJSONString(UtilMap.map("numberField_m0xizy3q", nowCost)))
                     .build(), YDConf.FORM_OPERATION.update);
-        });
+        }
     }
 
     @Override
@@ -921,9 +916,9 @@ public class TimerServiceImpl implements TimerService {
                         if (ObjectUtil.isNotNull(dataValue.get(0).get("value"))){
                             Date value = DateUtil.parse(dataValue.get(0).get("value").toString());
 //                            if (dataValue.get(0).get("value").toString().substring(0,7).equals("2024-09")){
-                                if (DateUtil.compare(value,beginOfMonth)>=0 && DateUtil.compare(date,value)>=0){
+                            if (DateUtil.compare(value,beginOfMonth)>=0 && DateUtil.compare(date,value)>=0){
 //                                month[0]++;
-                                    inJobIdSet.add(e.get("userid").toString());
+                                inJobIdSet.add(e.get("userid").toString());
 //                                }
                             }
                         }