Browse Source

月度定额判断条件更新

fyz 3 weeks ago
parent
commit
de6eb916b9

+ 10 - 1
mjava-lanyun/pom.xml

@@ -25,7 +25,16 @@
             <artifactId>mjava</artifactId>
             <version>${mjava.version}</version>
         </dependency>
-
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.13</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpmime</artifactId>
+            <version>4.5.13</version>
+        </dependency>
         <!-- sqlserver依赖 -->
         <dependency>
             <groupId>com.microsoft.sqlserver</groupId>

+ 11 - 0
mjava-lanyun/src/main/java/com/malk/lanyun/schedule/ScheduleTask.java

@@ -173,4 +173,15 @@ public class ScheduleTask {
         log.info("删除账龄表重复uuid");
         fService.syncDeleteAgingTask();
     }
+
+
+    /**
+     * 每2小时全量同步账龄表
+     */
+//    @Scheduled(cron = "0 0 0/2 * * ?")
+    @Scheduled(cron = "0 0 10 ? * SAT")
+    void updateUseCar(){
+        log.info("每周六上午10点更新每日用车");
+        timerService.updateUseCar();
+    }
 }

+ 2 - 0
mjava-lanyun/src/main/java/com/malk/lanyun/service/NCService.java

@@ -20,6 +20,8 @@ public interface NCService {
     //部门费用达成明细
     void getNcCollection();
 
+    void getNcCollectionOld();
+
     //供应商付款
     void getSupplierPay();
 

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

@@ -125,4 +125,6 @@ public interface TimerService {
     void terminateDataById(String processInstanceId);
 
     void updateYearPredict();
+
+    void updateUseCar();
 }

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

@@ -158,7 +158,7 @@ public class FImplService implements FService {
         // 账龄表主表: 3 项目点名称, 项目点编号, 收款协议
         compId_main.putAll(UtilMap.map("textField_lvdntzul, textField_m25j5gxk, selectField_lvc9x4vq", "textField_m4h15mt7, textField_lvdntzul, selectField_lvc9x4vq"));
         // 账龄表主表: 4 客户名称, 客户编号, 实际开票日期
-        compId_main.putAll(UtilMap.map("selectField_lvdojfui, textField_lvdojfuj, dateField_lw5ud9bk", "selectField_lvdojfui, textField_lvdojfuj, dateField_lw5ud9bk"));
+        compId_main.putAll(UtilMap.map("selectField_lvdojfui, textField_lvdojfuj, dateField_lw5ud9bk, numberField_lvd8pp36", "selectField_lvdojfui, textField_lvdojfuj, dateField_lw5ud9bk, numberField_lvd8pp36"));
         // 账龄表主表: 5 实例ID, 发票号码, 发票状态, 是否往年退票重开
         compId_main.putAll(UtilMap.map("textField_m25j5gyi, textField_lvd8pp35, selectField_lvituew9, radioField_m883s9n6", "formInstanceId, textField_lvd8pp35, selectField_lvituew9, radioField_m883s9n6"));
 

+ 231 - 122
mjava-lanyun/src/main/java/com/malk/lanyun/service/impl/NCServiceImpl.java

@@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
 
 import java.sql.*;
 import java.time.LocalDate;
+import java.time.Year;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -253,6 +254,107 @@ public class NCServiceImpl implements NCService {
         String month = String.format("%02d",lastMonth.getMonthValue()) ;
         deleteMonthDate("FORM-5654B7C22E7546E9BBE7B4EF46DE08BAXZXU","textField_m0dkzhwo", String.valueOf(year),month);
 
+        System.out.println(month);
+        Connection connection = null;
+        Statement statement = null;
+        ResultSet resultSet = null;
+        try {
+            // 加载 JDBC 驱动
+            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
+            // 建立连接
+            connection = DriverManager.getConnection(sqlBean.getUrl(), sqlBean.getUsername(), sqlBean.getPassword());
+
+            // 创建 Statement 对象
+            statement = connection.createStatement();
+
+            // 测试sql 执行查询
+            String sql = "select \n" +
+                    "  org_accountingbook.code orgcode,\n" +
+                    "  org_accountingbook.name orgname,\n" +
+                    "  bd_account.code kmcode,\n" +
+                    "  substring(bd_account.code,0,5) kmbm,\n" +
+                    "  bd_accasoa.name kmname,\n" +
+                    "  bd_accasoa.dispname KMMC,\n" +
+                    " org_dept.code bmcode,\n" +
+                    " org_dept.name bmname,\n" +
+                    " bd_project.project_code xmcode,\n" +
+                    " bd_project.project_name xmname,\n" +
+                    " SUM(gl_detail.localdebitamount) JFFS\n" +
+                    "  from gl_detail gl_detail\n" +
+                    "  left join gl_docfree1 on gl_detail.assid = gl_docfree1.assid\n" +
+                    "  left join org_dept on gl_docfree1.f1 = org_dept.pk_dept\n" +
+                    "  left join bd_project on gl_docfree1.f10=bd_project.pk_project\n" +
+                    "  left join org_accountingbook on gl_detail.pk_accountingbook=org_accountingbook.pk_accountingbook\n" +
+                    "  left join bd_accasoa on gl_detail.pk_accasoa=bd_accasoa.pk_accasoa\n" +
+                    "  left join bd_account on bd_accasoa.pk_account=bd_account.pk_account\n" +
+                    "  \n" +
+                    " where  substring(bd_account.code,0,5) in ('6602','6601')\n" +
+                    "   and gl_detail.yearv = '"+ year +"'\n" +
+                    "   and gl_detail.adjustperiod = '" + month + "'\n" +
+                    "   and org_accountingbook.code in('A01-0004','A02-0004','A11-0004','A03-0004','A06-0004','A04-0004','A05-0004','A10-0004')\n" +
+                    "   and gl_detail.discardflagv <> 'Y'\n" +
+                    "   and gl_detail.dr = 0\n" +
+                    "   and gl_detail.voucherkindv <> 255\n" +
+                    "   and gl_detail.tempsaveflag <> 'Y'\n" +
+                    "   and gl_detail.voucherkindv <> 5\n" +
+                    "   and (gl_docfree1.F1 <> 'NN/A' or gl_docfree1.F10 <> 'NN/A' )\n" +
+                    "   and 1 = 1\n" +
+                    " group by gl_detail.pk_accasoa,\n" +
+                    "          gl_detail.pk_accountingbook,\n" +
+                    "          gl_detail.yearv,\n" +
+                    "          org_dept.code ,\n" +
+                    "          org_dept.name ,\n" +
+                    "          org_accountingbook.code,\n" +
+                    "          org_accountingbook.name,\n" +
+                    "          bd_accasoa.dispname,\n" +
+                    "  bd_account.code,\n" +
+                    "  bd_accasoa.name,\n" +
+                    "  bd_project.project_code,\n" +
+                    "  bd_project.project_name";
+
+
+            resultSet = statement.executeQuery(sql);
+
+            while (resultSet.next()) {
+                Map hashMap = new HashMap();
+
+                String yearAndNonth = year +"-"+month;
+                hashMap.put("dateField_m0dkzhwp", UtilDateTime.parse(yearAndNonth,"yyyy-MM"));
+                hashMap.put("textField_m0dkzhwo", yearAndNonth);
+                hashMap.put("textField_m0dkzhwu",resultSet.getString("kmcode"));
+                hashMap.put("textField_m0dkzhwv",resultSet.getString("kmname"));
+                hashMap.put("textField_m0eudqp0",resultSet.getString("bmname"));//部门
+                hashMap.put("numberField_m0dkzhx1",resultSet.getBigDecimal("JFFS"));
+
+                ydClient.operateData(YDParam.builder()
+                        .appType("APP_ERBDTFS82HOVBPL3NFH0")
+                        .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
+                        .formUuid("FORM-5654B7C22E7546E9BBE7B4EF46DE08BAXZXU")
+                        .formDataJson(JSON.toJSONString(hashMap))
+                        .build(), YDConf.FORM_OPERATION.create);
+            }
+        } catch (Exception e) {
+            log.info("数据库连接异常"+e.toString());
+            e.printStackTrace();
+        } finally {
+            // 关闭资源
+            try {
+                if (resultSet != null) resultSet.close();
+                if (statement != null) statement.close();
+                if (connection != null) connection.close();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    @Override
+    public void getNcCollectionOld() {
+        // 获取当前年
+        int year = lastMonth.getYear();
+        String month = String.format("%02d",lastMonth.getMonthValue()) ;
+        deleteMonthDate("FORM-5654B7C22E7546E9BBE7B4EF46DE08BAXZXU","textField_m0dkzhwo", String.valueOf(year),month);
+
         System.out.println(month);
         Connection connection = null;
         Statement statement = null;
@@ -294,7 +396,7 @@ public class NCServiceImpl implements NCService {
                 ydClient.operateData(YDParam.builder()
                         .appType("APP_ERBDTFS82HOVBPL3NFH0")
                         .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
-                        .formUuid("FORM-5654B7C22E7546E9BBE7B4EF46DE08BAXZXU")
+                        .formUuid("FORM-0A7979E168AF494F9AA190F043DCBBC7CW9Z")
                         .formDataJson(JSON.toJSONString(hashMap))
                         .build(), YDConf.FORM_OPERATION.create);
             }
@@ -789,6 +891,7 @@ public class NCServiceImpl implements NCService {
             });
             Map<String, Long> collect = personList.stream().collect(Collectors.groupingBy(i -> i, Collectors.counting()));
 
+//            log.info("collect:{}",collect);
             final Double[] zsdglfy = {0.0};
             final Double[] zsdsum = {0.0};
             //直属队
@@ -799,19 +902,21 @@ public class NCServiceImpl implements NCService {
                     .searchCondition(JSON.toJSONString(UtilMap.map("textField_lrr3rg6i","直属队")))
                     .build());
             zsd.forEach(e->{
-                if (ObjectUtil.isNotNull(manageList)){
+                if (ObjectUtil.isNotNull(manageList) && manageList.size() > 0){
                     manageList.forEach(s->{
-                        double manage_compute = s.get("manage_compute") == null ? 0.0 : Double.parseDouble(s.get("manage_compute").toString());
+//                        log.info("manage_compute数据:{}",s.get("manage_compute"));
+                        double manage_compute = s.get("manage_compute") == null || s.get("manage_compute").toString().isEmpty() ? 0.0 : Double.parseDouble(s.get("manage_compute").toString());
                         zsdsum[0] = zsdsum[0] + manage_compute;
                     });
-                    if (workingEmployeeIds.size() * zsdsum[0] == 0.0){
+                    if (workingEmployeeIds.size() == 0 || workingEmployeeIds.size() * zsdsum[0] == 0.0){
                         zsdglfy[0] = 0.0;
                     }else {
-                        zsdglfy[0] = zsdglfy[0] + collect.get("直属队") / workingEmployeeIds.size() * zsdsum[0];
+                        zsdglfy[0] = zsdglfy[0] + (collect.get("工程部(直属队)")==null||collect.get("工程部(直属队)").toString().isEmpty()?0.0:Double.parseDouble(collect.get("工程部(直属队)").toString()) )/ zsdsum[0];
                     }
                 }
             });
 
+            log.info("zsdglfy[0]:{}",zsdglfy[0]);
             List<Map> projectList = new ArrayList<>();
             dataList = dataList.stream().filter(e -> !"PM99006".equals(e.get("textField_ltxrn8h1")) && !"PM99016".equals(e.get("textField_ltxrn8h1")) && !"PM99014".equals(e.get("textField_ltxrn8h1"))).collect(Collectors.toList());
             dataList.forEach(e-> {
@@ -864,7 +969,7 @@ public class NCServiceImpl implements NCService {
                     "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
             ps[0] = mysqlCon.prepareStatement(insert);
 
-            dataList.forEach(e->{
+            dataList.forEach(e-> {
                 List<Map> tableList = ydService.queryDetails(YDParam.builder().
                         appType("APP_ERBDTFS82HOVBPL3NFH0")
                         .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
@@ -877,13 +982,13 @@ public class NCServiceImpl implements NCService {
                 String name = e.get("textField_lrr3rg6i").toString();
 //                int personCount = e.get("numberField_lrpvi1wf_value") == null || e.get("numberField_lrpvi1wf_value").toString().isEmpty() ? 0 : Integer.parseInt(e.get("numberField_lrpvi1wf_value").toString());
 //                log.info("项目点名称:{}",name);
-                final Double[] sum = {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
+                final Double[] sum = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
                 final Integer[] person = {0};
 //                person[0] = person[0] + personCount;
-                if (!tableList.isEmpty()){
-                    tableList.forEach(t->{
-                        double open = t.get("numberField_lrru2to2_value") == null || t.get("numberField_lrru2to2_value").toString().isEmpty() ? 0.0: Double.parseDouble(t.get("numberField_lrru2to2_value").toString());
-                        double income = open == 0.0 ? Double.parseDouble("".equals(t.get("numberField_lryopn7o_value")) ?"0.0":t.get("numberField_lryopn7o_value").toString()) : open;
+                if (!tableList.isEmpty()) {
+                    tableList.forEach(t -> {
+                        double open = t.get("numberField_lrru2to2_value") == null || t.get("numberField_lrru2to2_value").toString().isEmpty() ? 0.0 : Double.parseDouble(t.get("numberField_lrru2to2_value").toString());
+                        double income = open == 0.0 ? Double.parseDouble("".equals(t.get("numberField_lryopn7o_value")) ? "0.0" : t.get("numberField_lryopn7o_value").toString()) : open;
                         //小业主预估
                         double small = (t.get("numberField_m5uf580r_value") == null || t.get("numberField_m5uf580r_value").toString().isEmpty()) ? 0f : Double.parseDouble(t.get("numberField_m5uf580r_value").toString());
                         //总计人数
@@ -893,6 +998,9 @@ public class NCServiceImpl implements NCService {
                     });
                 }
 
+                if (sum[7] > 0.0) {
+
+//                }
 //                //小业主合同月金额数据
 //                if (ObjectUtil.isNotNull(smallList)){
 //                    smallList.forEach(s->{
@@ -903,62 +1011,62 @@ public class NCServiceImpl implements NCService {
 //                    });
 //                }
 //                //算薪人数
-                if (ObjectUtil.isNotNull(collect)){
-                    person[0] = ObjectUtil.isNotNull(collect.get(name))?Math.toIntExact(collect.get(name)):0;
-                }
-                //生产成本-工资
-                if (ObjectUtil.isNotNull(personCostList)){
-                    personCostList.forEach(s->{
-                        if (code.equals(s.get("xmcode"))){
-                            double person_cost_compute = s.get("person_cost_compute") == null ? 0.0 : Double.parseDouble(s.get("person_cost_compute").toString());
-                            sum[1] = sum[1] + person_cost_compute;
-                        }
-                    });
-                }
-                //500114,500115生产成本-材料费
-                if (ObjectUtil.isNotNull(materialList)){
-                    materialList.forEach(s->{
-                        if (code.equals(s.get("xmcode"))){
-                            double material_compute = s.get("material_compute") == null ? 0.0 : Double.parseDouble(s.get("material_compute").toString());
-                            sum[2] = sum[2] + material_compute;
-                        }
-                    });
-                }
-                //500118,500119,500120,500121生产成本-折修
-                if (ObjectUtil.isNotNull(repairList)){
-                    repairList.forEach(s->{
-                        if (code.equals(s.get("xmcode"))){
-                            double material_compute = s.get("material_compute") == null ? 0.0 : Double.parseDouble(s.get("material_compute").toString());
-                            sum[9] = sum[9] + material_compute;
-                        }
-                    });
-                }
-                //5001生产成本-其他
-                if (ObjectUtil.isNotNull(otherList)) {
-                    otherList.forEach(s -> {
-                        if (code.equals(s.get("xmcode"))) {
-                            double other_compute = s.get("other_compute") == null ? 0.0 : Double.parseDouble(s.get("other_compute").toString());
-                            sum[3] = sum[3] + other_compute;
-                        }
-                    });
-                }
-                //6001+6002+6003 管理费用分子(去掉6003)
-                if (ObjectUtil.isNotNull(manageList)){
-                    manageList.forEach(s->{
-                        double manage_compute = s.get("manage_compute") == null ? 0.0 : Double.parseDouble(s.get("manage_compute").toString());
-                        sum[4] = sum[4] + manage_compute;
-                    });
-                }
-                //600101+600102+600103+600106+600109 管理费用分母
-                if (ObjectUtil.isNotNull(manageProjectList)){
-                    manageProjectList.forEach(s->{
-                        if (code.equals(s.get("xmcode"))) {
-                            double manage_project_compute = s.get("manage_project_compute") == null ? 0.0 : Double.parseDouble(s.get("manage_project_compute").toString());
-                            sum[5] = sum[5] + manage_project_compute;
-                        }
-                    });
-                }
-                //6801企业所得税
+                    if (ObjectUtil.isNotNull(collect)) {
+                        person[0] = ObjectUtil.isNotNull(collect.get(name)) ? Math.toIntExact(collect.get(name)) : 0;
+                    }
+                    //生产成本-工资
+                    if (ObjectUtil.isNotNull(personCostList)) {
+                        personCostList.forEach(s -> {
+                            if (code.equals(s.get("xmcode"))) {
+                                double person_cost_compute = s.get("person_cost_compute") == null ? 0.0 : Double.parseDouble(s.get("person_cost_compute").toString());
+                                sum[1] = sum[1] + person_cost_compute;
+                            }
+                        });
+                    }
+                    //500114,500115生产成本-材料费
+                    if (ObjectUtil.isNotNull(materialList)) {
+                        materialList.forEach(s -> {
+                            if (code.equals(s.get("xmcode"))) {
+                                double material_compute = s.get("material_compute") == null ? 0.0 : Double.parseDouble(s.get("material_compute").toString());
+                                sum[2] = sum[2] + material_compute;
+                            }
+                        });
+                    }
+                    //500118,500119,500120,500121生产成本-折修
+                    if (ObjectUtil.isNotNull(repairList)) {
+                        repairList.forEach(s -> {
+                            if (code.equals(s.get("xmcode"))) {
+                                double material_compute = s.get("material_compute") == null ? 0.0 : Double.parseDouble(s.get("material_compute").toString());
+                                sum[9] = sum[9] + material_compute;
+                            }
+                        });
+                    }
+                    //5001生产成本-其他
+                    if (ObjectUtil.isNotNull(otherList)) {
+                        otherList.forEach(s -> {
+                            if (code.equals(s.get("xmcode"))) {
+                                double other_compute = s.get("other_compute") == null ? 0.0 : Double.parseDouble(s.get("other_compute").toString());
+                                sum[3] = sum[3] + other_compute;
+                            }
+                        });
+                    }
+                    //6001+6002+6003 管理费用分子(去掉6003)
+                    if (ObjectUtil.isNotNull(manageList)) {
+                        manageList.forEach(s -> {
+                            double manage_compute = s.get("manage_compute") == null ? 0.0 : Double.parseDouble(s.get("manage_compute").toString());
+                            sum[4] = sum[4] + manage_compute;
+                        });
+                    }
+                    //600101+600102+600103+600106+600109 管理费用分母
+                    if (ObjectUtil.isNotNull(manageProjectList)) {
+                        manageProjectList.forEach(s -> {
+                            if (code.equals(s.get("xmcode"))) {
+                                double manage_project_compute = s.get("manage_project_compute") == null ? 0.0 : Double.parseDouble(s.get("manage_project_compute").toString());
+                                sum[5] = sum[5] + manage_project_compute;
+                            }
+                        });
+                    }
+                    //6801企业所得税
 /*                if(ObjectUtil.isNotNull(businessIncomeList)){
                     businessIncomeList.forEach(s->{
 //                        if (code.equals(s.get("xmcode"))) {
@@ -968,72 +1076,73 @@ public class NCServiceImpl implements NCService {
                     });
                 }*/
 
-                try {
-                    ps[0].setObject(1,name);
-                    ps[0].setObject(2,null);
-                    ps[0].setObject(3,UtilDateTime.parse(yearAndMonth,"yyyy-MM").getTime());
-                    ps[0].setObject(4,e.get("selectField_lrn2oy4a")==null?null:e.get("selectField_lrn2oy4a").toString());
-                    ps[0].setObject(5,sum[7]/*/1.06*//10000); //预估
-                    ps[0].setObject(6,sum[8]/*/1.06*//10000); //开票
-                    ps[0].setObject(7,(sum[7]+sum[0])/*/1.06*//10000);//收入
-                    ps[0].setObject(8,person[0]);//人数
-                    ps[0].setObject(9,sum[1]/10000);
-                    ps[0].setObject(10,sum[2]/10000);
-                    ps[0].setObject(11,(sum[3]-sum[2]-sum[1]-sum[9])/10000);
-                    ps[0].setObject(12,sum[3]/10000);
-                    ps[0].setObject(13,(sum[7]+sum[0])*0.066/*/1.06*//10000);
-                    ps[0].setObject(14,((sum[7]+sum[0])/1.06-sum[3])/10000);
-                    ps[0].setObject(15,(sum[7]+sum[0]) == 0.0 ? 0.0:(sum[7]+sum[0]-sum[3])/(sum[7]+sum[0]));
-                    double glfy = 0.0 ;
-                    double corporate_income_tax = (sum[7]+sum[0])/10000 * 0.01;
-                    if ("直属队".equals(name)){
-                        glfy = zsdglfy[0];
-                    }else {
-                        //除直属队外项目的管理费用分摊,项目点收入 /(去除直属队、去除运作模式=整体外包的项目收入合计)*(管理费用合计-直属队管理费用);
-                        glfy = sum[7] / exceptZSDIncome * zsdsum[0];
-                    }
+                    try {
+                        ps[0].setObject(1, name);
+                        ps[0].setObject(2, null);
+                        ps[0].setObject(3, UtilDateTime.parse(yearAndMonth, "yyyy-MM").getTime());
+                        ps[0].setObject(4, e.get("selectField_lrn2oy4a") == null ? null : e.get("selectField_lrn2oy4a").toString());
+                        ps[0].setObject(5, sum[7]/*/1.06*/ / 10000); //预估
+                        ps[0].setObject(6, sum[8]/*/1.06*/ / 10000); //开票
+                        ps[0].setObject(7, (sum[7] + sum[0])/*/1.06*/ / 10000);//收入
+                        ps[0].setObject(8, person[0]);//人数
+                        ps[0].setObject(9, sum[1] / 10000);
+                        ps[0].setObject(10, sum[2] / 10000);
+                        ps[0].setObject(11, (sum[3] - sum[2] - sum[1] - sum[9]) / 10000);
+                        ps[0].setObject(12, sum[3] / 10000);
+                        ps[0].setObject(13, (sum[7] + sum[0]) * 0.066/*/1.06*/ / 10000);
+                        ps[0].setObject(14, ((sum[7] + sum[0]) / 1.06 - sum[3]) / 10000);
+                        ps[0].setObject(15, (sum[7] + sum[0]) == 0.0 ? 0.0 : (sum[7] + sum[0] - sum[3]) / (sum[7] + sum[0]));
+                        double glfy = 0.0;
+                        double corporate_income_tax = (sum[7] + sum[0]) / 10000 * 0.01;
+                        if ("直属队".equals(name)) {
+                            glfy = zsdglfy[0];
+                        } else {
+                            //除直属队外项目的管理费用分摊,项目点收入 /(去除直属队、去除运作模式=整体外包的项目收入合计)*(管理费用合计-直属队管理费用);
+                            glfy = sum[7] / exceptZSDIncome * zsdsum[0];
+                        }
 //                    if ((sumProject+sumSamll) != 0.0){
 //                        corporate_income_tax = (sum[7]+sum[0])/(sumProject+sumSamll)*sum[6];
 //                        glfy = sum[4]/(sumProject+sumSamll)*(sum[7]+sum[0]);
 //                    }
-                    ps[0].setObject(16,glfy/10000);
-                    //企业所得税corporate_income_tax
-                    ps[0].setObject(17,corporate_income_tax/10000);
-                    ps[0].setObject(18,((sum[7] + sum[0])/* / 1.06*/ - sum[3] - glfy - corporate_income_tax)/10000);
-                    double net_margin = (sum[7] + sum[0]) == 0.0 ? 0.0:(sum[7] + sum[0] - sum[3] - glfy - corporate_income_tax) / (sum[7] + sum[0]);
-                    ps[0].setObject(19,net_margin);
-                    String profit_loss = "";
-                    if (net_margin < 0){
-                        profit_loss = "亏损";
-                    }else if (net_margin >=0 && net_margin <=0.05){
-                        profit_loss = "净利较低";
-                    }else if(net_margin > 0.05){
-                        profit_loss = "盈利";
+                        ps[0].setObject(16, glfy / 10000);
+                        //企业所得税corporate_income_tax
+                        ps[0].setObject(17, corporate_income_tax / 10000);
+                        ps[0].setObject(18, ((sum[7] + sum[0])/* / 1.06*/ - sum[3] - glfy - corporate_income_tax) / 10000);
+                        double net_margin = (sum[7] + sum[0]) == 0.0 ? 0.0 : (sum[7] + sum[0] - sum[3] - glfy - corporate_income_tax) / (sum[7] + sum[0]);
+                        ps[0].setObject(19, net_margin);
+                        String profit_loss = "";
+                        if (net_margin < 0) {
+                            profit_loss = "亏损";
+                        } else if (net_margin >= 0 && net_margin <= 0.05) {
+                            profit_loss = "净利较低";
+                        } else if (net_margin > 0.05) {
+                            profit_loss = "盈利";
+                        }
+                        ps[0].setObject(20, e.get("selectField_lrhjdu45") == null ? null : e.get("selectField_lrhjdu45").toString());
+                        ps[0].setObject(21, e.get("textField_lrn2oy4n") == null ? null : e.get("textField_lrn2oy4n").toString());
+                        ps[0].setObject(22, profit_loss);
+                        ps[0].setObject(23, e.get("dateField_lrn2oy54") == null ? null : e.get("dateField_lrn2oy54").toString());
+                        ps[0].setObject(24, e.get("selectField_ltfgfke7") == null ? null : e.get("selectField_ltfgfke7").toString());
+                        ps[0].setObject(25, "");
+                        ps[0].setObject(26, yearAndMonth);
+                        ps[0].setObject(27, sum[0]);
+                        ps[0].setObject(28, sum[6]);
+                        ps[0].setObject(29, sumProject + sumSamll);
+                        ps[0].setObject(30, sum[9] / 10000);
+                        ps[0].setObject(31, code);
+
+                        ps[0].addBatch();
+                    } catch (SQLException ex) {
+                        ex.printStackTrace();
                     }
-                    ps[0].setObject(20,e.get("selectField_lrhjdu45")==null?null:e.get("selectField_lrhjdu45").toString());
-                    ps[0].setObject(21,e.get("textField_lrn2oy4n")==null?null:e.get("textField_lrn2oy4n").toString());
-                    ps[0].setObject(22,profit_loss);
-                    ps[0].setObject(23,e.get("dateField_lrn2oy54")==null?null:e.get("dateField_lrn2oy54").toString());
-                    ps[0].setObject(24,e.get("selectField_ltfgfke7")==null?null:e.get("selectField_ltfgfke7").toString());
-                    ps[0].setObject(25,"");
-                    ps[0].setObject(26,yearAndMonth);
-                    ps[0].setObject(27,sum[0]);
-                    ps[0].setObject(28,sum[6]);
-                    ps[0].setObject(29,sumProject+sumSamll);
-                    ps[0].setObject(30,sum[9]/10000);
-                    ps[0].setObject(31,code);
-
-                    ps[0].addBatch();
-                } catch (SQLException ex) {
-                    ex.printStackTrace();
-                }
 //                }
+                }
             });
             ps[0].executeBatch();
 
         } catch (Exception e) {
-            log.info("数据库连接异常"+e.toString());
             e.printStackTrace();
+            log.info("数据库连接异常"+e.toString());
         } finally {
             // 关闭资源
             try {

+ 52 - 8
mjava-lanyun/src/main/java/com/malk/lanyun/service/impl/TimerServiceImpl.java

@@ -85,7 +85,7 @@ public class TimerServiceImpl implements TimerService {
                 .appType("APP_ERBDTFS82HOVBPL3NFH0")
                 .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
                 .formUuid("FORM-97BA6C6C8C50416A9E5854F2F4B5C3F3R4WC")
-//                .searchFieldJson(JSON.toJSONString(UtilMap.map("textField_ltxrn8h1", "PM00411")))
+//                .searchFieldJson(JSON.toJSONString(UtilMap.map("textField_ltxrn8h1", "PM00413")))
                 .build());
         log.info("项目点数据, {}", dataList.size());
         dataList.forEach(formData -> {
@@ -108,16 +108,16 @@ public class TimerServiceImpl implements TimerService {
 //            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") || (currentDate.getYear() +"-"+ String.format("%02d", currentDate.getMonthValue())).equals(UtilMap.getString(item,"textField_luh0k82j"))).findAny();
+                        Optional optional = details.stream().filter(item -> (ObjectUtil.isNotNull(item.get("dateField_lrru2tnr")) && 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) {
+                        if (!optional.isPresent() || UtilMap.getFloat((Map) optional.get(), "numberField_lrru2tnz") != 0f) {
                             return;
                         }
 
                         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") || (currentDate.getYear() +"-"+ String.format("%02d", currentDate.getMonthValue())).equals(UtilMap.getString(item,"textField_luh0k82j"))).findAny();
+                        optional = details.stream().filter(item -> (ObjectUtil.isNotNull(item.get("dateField_lrru2tnr")) && 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;
@@ -135,7 +135,7 @@ public class TimerServiceImpl implements TimerService {
                         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, formData.get("textField_ltxrn8h1"))));
                         // 合计初始化
 //            price = details.stream().map(item -> UtilMap.getFloat(item, "numberField_lrru2tnz")).collect(Collectors.toList()).stream().reduce(0f, (acc, cur) -> acc + cur);
                         ydClient.operateData(YDParam.builder()
@@ -391,12 +391,12 @@ public class TimerServiceImpl implements TimerService {
             JSONObject jsonObject = new JSONObject(jsonMap);
             jsonArray.add(jsonObject);
             /*发起流程*/
-            ydClient.operateData(YDParam.builder()
+            ydClient.operateData(YDParam.builder().userId("026150181237-1254068060")
                     .appType("APP_ERBDTFS82HOVBPL3NFH0")
                     .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
                     .formUuid("FORM-A4B37CFEB8524947939C00523373532BT3TH")
-                    .formDataJson(JSON.toJSONString(UtilMap.map("dateField_ls2u8mbv, departmentSelectField_ls2u8mbw, employeeField_ls2u8mbx, tableField_ls2u8mc6, associationFormField_ls2u8mcb, dateField_ls1ky8c5, employeeField_ls1ky8c3",
-                            beginTime,department,header,tableList,jsonArray,sendTime,"026150181237-1254068060")))
+                    .formDataJson(JSON.toJSONString(UtilMap.map("dateField_ls2u8mbv, departmentSelectField_ls2u8mbw, employeeField_ls2u8mbx, tableField_ls2u8mc6, associationFormField_ls2u8mcb, dateField_ls1ky8c5",
+                            beginTime,department,header,tableList,jsonArray,sendTime)))
                     .build(), YDConf.FORM_OPERATION.start);
         });
     }
@@ -1627,4 +1627,48 @@ public class TimerServiceImpl implements TimerService {
                     }
                 });
     }
+
+    @Override
+    public void updateUseCar() {
+        List<Map> zsd = ydService.queryFormData_all(YDParam.builder()
+                .appType("APP_ERBDTFS82HOVBPL3NFH0")
+                .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
+                .formUuid("FORM-6DE9230D672C48188E0512F189C27B03MP2R")
+//                .searchCondition(JSON.toJSONString(UtilMap.map("textField_lrr3rg6i","直属队")))
+                .build());
+        zsd.forEach(e->{
+            List<Map> mapList = (List<Map>) e.get("tableField_lrn8mg3m");
+            final String[] lastStart = {""};
+            String lastEnd[] = {""};
+            if(ObjectUtil.isNotNull(mapList) && mapList.size()>0){
+                mapList.forEach(s->{
+                    if (ObjectUtil.isNotNull(s.get("dateField_lrn8mg3n")) && ObjectUtil.isNotNull(s.get("dateField_lrn8mg3s"))) {
+                        String start = s.get("dateField_lrn8mg3n").toString();
+                        String end = s.get("dateField_lrn8mg3s").toString();
+                        if (lastStart[0].isEmpty() || lastStart[0].compareTo(start) > 0) {
+                            lastStart[0] = start;
+                        }
+                        if (lastEnd[0].isEmpty() || lastEnd[0].compareTo(end) < 0) {
+                            lastEnd[0] = end;
+                        }
+                    }
+                });
+                if (!lastStart[0].isEmpty() && !lastEnd[0].isEmpty()){
+                    long startLong = Long.parseLong(lastStart[0]);
+                    long endLong = Long.parseLong(lastEnd[0]);
+                    long abs = Math.abs(endLong - startLong);
+                    long dif = abs / 1000 / 60 / 60;
+                    System.out.println(e.get("formInstanceId").toString() + ":" + dif + ":" + startLong + ":" + endLong);
+
+                    ydClient.operateData(YDParam.builder()
+                            .appType("APP_ERBDTFS82HOVBPL3NFH0")
+                            .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
+                            .formInstanceId(e.get("formInstanceId").toString())
+                            .useLatestVersion(true)
+                            .updateFormDataJson(JSON.toJSONString(UtilMap.map("numberField_maey99ee, dateField_mag44lnh, dateField_mag44lni", dif,startLong,endLong)))
+                            .build(), YDConf.FORM_OPERATION.update);
+                }
+            }
+        });
+    }
 }