Kaynağa Gözat

日常物耗申请服务注册代码更新
NC增量定时任务跑批更新

fyz 8 ay önce
ebeveyn
işleme
b8fadcbc5b

+ 53 - 0
mjava-lanyun/src/main/java/com/malk/lanyun/schedule/NCTask.java

@@ -0,0 +1,53 @@
+package com.malk.lanyun.schedule;
+
+import com.malk.lanyun.service.NCService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+
+@Slf4j
+@Configuration
+@EnableScheduling
+public class NCTask {
+    @Autowired
+    NCService ncService;
+
+    /**
+     * 每月1日凌晨4点跑批NC生产成本
+     */
+    @Scheduled(cron = "0 0 4 1 * ?")
+    void productCosts() {
+        ncService.getNcInfo();
+    }
+
+    /**
+     * 每月1日凌晨4点30跑批NC物耗成本
+     */
+    @Scheduled(cron = "0 30 4 1 * ?")
+    void materialCost() {
+        ncService.getNcCgInfo();
+    }
+    /**
+     * 每月1日凌晨5点跑批NC大业主生产成本
+     */
+    @Scheduled(cron = "0 0 5 1 * ?")
+    void bigProductCosts() {
+        ncService.getNcCost();
+    }
+    /**
+     * 每月1日凌晨5点30跑批NC部门费用达成明细
+     */
+    @Scheduled(cron = "0 30 5 1 * ?")
+    void departmentCost() {
+        ncService.getNcCollection();
+    }
+    /**
+     * 每月1日凌晨6点跑批NC供应商付款
+     */
+    @Scheduled(cron = "0 0 6 1 * ?")
+    void supplierPay() {
+        ncService.getSupplierPay();
+    }
+}

+ 3 - 5
mjava-lanyun/src/main/java/com/malk/lanyun/schedule/ScheduleTask.java

@@ -8,10 +8,8 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.web.bind.annotation.GetMapping;
 
 import java.time.LocalDate;
-import java.time.temporal.TemporalAdjusters;
 import java.util.Date;
 
 /**
@@ -31,7 +29,7 @@ public class ScheduleTask {
     /**
      * 每月1日凌晨2点自动执行
      */
-    @Scheduled(cron = "0 0 2 1 * ?")
+    @Scheduled(cron = "0 0 1 1 * ?")
     public void syncDingTalkFailedList() {
 
         timerService.updateYuedudinge();
@@ -40,7 +38,7 @@ public class ScheduleTask {
     /**
      * 每月1日凌晨1点自动执行更新业主产值每月累计
      */
-    @Scheduled(cron = "0 0 1 1 * ?")
+    @Scheduled(cron = "0 0 0 1 * ?")
     public void bigOwnerOutPut() {
         timerService.updateBigOut();
         log.info("定时方法执行时间 :" + new Date());
@@ -58,7 +56,7 @@ public class ScheduleTask {
     /**
      * 各项目经营分析每月1日上午4点自动插入数据库
      */
-    @Scheduled(cron = "0 0 4 1 * ?")
+    @Scheduled(cron = "0 0 2 1 * ?")
     void insertAnalysisList(){
         timerService.insertAnalysisList();
     }

+ 24 - 18
mjava-lanyun/src/main/java/com/malk/lanyun/service/impl/NCServiceImpl.java

@@ -6,19 +6,17 @@ import com.malk.lanyun.service.NCService;
 import com.malk.server.aliwork.YDConf;
 import com.malk.server.aliwork.YDParam;
 import com.malk.service.aliwork.YDClient;
-import com.malk.service.aliwork.YDService;
 import com.malk.utils.UtilDateTime;
-import com.malk.utils.UtilMap;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.stereotype.Service;
 
-import java.sql.*;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
-import java.time.temporal.TemporalAdjusters;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -32,14 +30,14 @@ public class NCServiceImpl implements NCService {
     @Autowired
     private SqlServerBean sqlBean;
 
-
     // 获取当前日期
-    LocalDate today = LocalDate.now();
+    LocalDate lastMonth = LocalDate.now().minusMonths(1);
     DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
     @Override
     public void getNcInfo() {
-        // 获取当前年
-        int year = today.getYear();
+        // 获取上月年,月
+        int year = lastMonth.getYear();
+        int month = lastMonth.getMonthValue();
 
         Connection connection = null;
         Statement statement = null;
@@ -54,7 +52,7 @@ public class NCServiceImpl implements NCService {
 
             // 执行查询
             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+"\n" +
+                    "            FROM gl_detail b JOIN bd_accasoa a ON b.pk_accasoa = a.pk_accasoa WHERE  b.yearv = "+year+"\n AND b.adjustperiod = "+ month +
                     "            AND b.accountcode IN ( '50010101', '500102', '500103', '500117', '500114', '500115', '500118', '500119', '500109', '500133' )\n" +
                     "            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";
@@ -103,7 +101,8 @@ public class NCServiceImpl implements NCService {
     @Override
     public void getNcCgInfo() {
         // 获取当前年
-        int year = today.getYear();
+        int year = lastMonth.getYear();
+        int month = lastMonth.getMonthValue();
 
         Connection connection = null;
         Statement statement = null;
@@ -119,7 +118,8 @@ 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.accountcode IN ( '500114', '500115' )\n" +
+                    "            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 IN ( '500114', '500115' )\n" +
                     "            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";
 
@@ -170,7 +170,8 @@ public class NCServiceImpl implements NCService {
     @Override
     public void getNcCost() {
         // 获取当前年
-        int year = today.getYear();
+        int year = lastMonth.getYear();
+        int month = lastMonth.getMonthValue();
 
         Connection connection = null;
         Statement statement = null;
@@ -186,7 +187,8 @@ 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.accountcode IN ( '500114', '500115' )\n" +
+                    "            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 IN ( '500114', '500115' )\n" +
                     "            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";
 
@@ -235,7 +237,8 @@ public class NCServiceImpl implements NCService {
     @Override
     public void getNcCollection() {
         // 获取当前年
-        int year = today.getYear();
+        int year = lastMonth.getYear();
+        int month = lastMonth.getMonthValue();
 
         Connection connection = null;
         Statement statement = null;
@@ -251,7 +254,8 @@ 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.accountcode like '6602%' " +
+                    "            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%' " +
                     "            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";
 
@@ -300,7 +304,9 @@ public class NCServiceImpl implements NCService {
     @Override
     public void getSupplierPay() {
         // 获取当前年
-        int year = today.getYear();
+        int year = lastMonth.getYear();
+        int month = lastMonth.getMonthValue();
+
         LocalDate firstDayOfYear = LocalDate.of(year, 1, 1);
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         String formattedBeginDate = firstDayOfYear.format(formatter);

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

@@ -60,7 +60,6 @@ public class SyncAssetsImpl implements SyncAssetsService {
                 //资产状态
                 String status = formMap.get("selectField_lty0oyvd").toString();
                 if (!"报废".equals(status)){
-
                     //净值
                     float metValue = UtilMap.getFloat((Map) formMap,"numberField_lu2ejqd4");
                     //月折旧额
@@ -84,7 +83,7 @@ public class SyncAssetsImpl implements SyncAssetsService {
                             }
                         }
                         DateBetween dateBetween = new DateBetween(DateUtil.date(buyTime),DateUtil.date(toMonth));
-                        long months = dateBetween.betweenMonth(true);
+                        long months = dateBetween.betweenMonth(true) + 1;
                         // 更新
                         ydClient.operateData(YDParam.builder()
                                 .appType("APP_ERBDTFS82HOVBPL3NFH0")