home il y a 2 ans
Parent
commit
42c797745d

+ 1 - 1
hx-service-api/storage-restructure-api/src/main/java/com/fjhx/params/contract/SupplierInfo.java

@@ -15,7 +15,7 @@ public class SupplierInfo {
     /**
      * 供应商名称
      */
-    private Long supplierName;
+    private String supplierName;
 
     /**
      * 总计金额

+ 21 - 2
hx-service/storage-restructure/src/main/java/com/fjhx/controller/contract/ContractPayController.java

@@ -62,8 +62,26 @@ public class ContractPayController {
      * 合同付款供应商统计
      */
     @PostMapping("/supplierStatistics")
-    public R supplierStatistics(@RequestBody DateStatisticsResult dateStatisticsResult) {
-        List<SupplierStatisticsResult> result = contractPayService.supplierStatistics(dateStatisticsResult);
+    public R supplierStatistics(@RequestBody Condition condition) {
+        List<SupplierStatisticsResult> result = contractPayService.supplierStatistics(condition);
+        return R.success(result);
+    }
+
+    /**
+     * 可发起、待补齐状态统计
+     */
+    @PostMapping("/statusStatistics")
+    public R statusStatistics(@RequestBody Condition condition) {
+        Map<String, Object> result = contractPayService.statusStatistics(condition);
+        return R.success(result);
+    }
+
+    /**
+     * 本周期、上周期顺延、其他
+     */
+    @PostMapping("/cycleStatistics")
+    public R cycleStatistics(@RequestBody Condition condition) {
+        Map<String, Object> result = contractPayService.cycleStatistics(condition);
         return R.success(result);
     }
 
@@ -76,5 +94,6 @@ public class ContractPayController {
         return R.success(result);
     }
 
+
 }
 

+ 7 - 0
hx-service/storage-restructure/src/main/java/com/fjhx/mapper/contract/ContractPayMapper.java

@@ -7,6 +7,7 @@ import com.fjhx.entity.contract.ContractPay;
 import com.fjhx.params.contract.SupplierInfo;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -24,4 +25,10 @@ public interface ContractPayMapper extends BaseMapper<ContractPay> {
 
     Page<Map<String, Object>> getPage(@Param("page") Page<Object> page, @Param("ew") QueryWrapper<Object> wrapper);
 
+    Map<String, Object> statusStatistics(@Param("ew") QueryWrapper<Object> wrapper);
+
+    Map<String, Object> cycleStatistics(@Param("ew") QueryWrapper<Object> wrapper,
+                                        @Param("currentAccountBeginTime") Date currentAccountBeginTime,
+                                        @Param("currentAccountEndTime") Date currentAccountEndTime);
+
 }

+ 55 - 0
hx-service/storage-restructure/src/main/java/com/fjhx/mapper/contract/ContractPayMapper.xml

@@ -47,4 +47,59 @@
             ${ew.customSqlSegment}
     </select>
 
+    <select id="statusStatistics" resultType="java.util.Map">
+        select ifnull(sum(if(c.apply_pay_amount = 0
+                                 and t.batchCount = t.qualityTestingCount
+                                 and t.contractFileCount > 0
+                                 and c.invoice_amount >= c.adjust_amount,
+                             1, 0)), 0) canLaunch,
+               ifnull(sum(if(t.batchCount != t.qualityTestingCount
+                                 or t.contractFileCount &lt;= 0
+                                 or c.invoice_amount &lt; c.adjust_amount,
+                             1, 0)), 0) needSupplemented,
+               count(0)                 total
+        from contract c
+                 left join (
+            select count(wb.id)               batchCount,
+                   count(qt.id)               qualityTestingCount,
+                   sum(if(ce.type = 3, 1, 0)) contractFileCount,
+                   wb.contract_id
+            from water_batch wb
+                     left join quality_testing qt on wb.id = qt.water_batch_id
+                     left join contract_enclosure ce on wb.contract_id = ce.contract_id
+            group by wb.contract_id
+        ) t on t.contract_id = c.id
+            ${ew.customSqlSegment}
+    </select>
+
+    <select id="cycleStatistics" resultType="java.util.Map">
+        select ifnull(sum(if(date_add(c.complete_time, interval c.account_date day) &lt; #{currentAccountBeginTime}, 1,
+                             0)), 0)
+                        historicalCycle,
+               ifnull(sum(if(date_add(c.complete_time, interval c.account_date day) &gt; #{currentAccountEndTime}, 1,
+                             0)), 0)
+                        futureCycle,
+               count(0) total,
+               (count(0)
+                   - ifnull(
+                        sum(if(date_add(c.complete_time, interval c.account_date day) &lt; #{currentAccountBeginTime},
+                               1, 0)), 0)
+                   - ifnull(
+                        sum(if(date_add(c.complete_time, interval c.account_date day) &gt; #{currentAccountEndTime}, 1,
+                               0)), 0))
+                        currentCycle
+        from contract c
+                 left join (
+            select count(wb.id)               batchCount,
+                   count(qt.id)               qualityTestingCount,
+                   sum(if(ce.type = 3, 1, 0)) contractFileCount,
+                   wb.contract_id
+            from water_batch wb
+                     left join quality_testing qt on wb.id = qt.water_batch_id
+                     left join contract_enclosure ce on wb.contract_id = ce.contract_id
+            group by wb.contract_id
+        ) t on t.contract_id = c.id
+            ${ew.customSqlSegment}
+    </select>
+
 </mapper>

+ 5 - 1
hx-service/storage-restructure/src/main/java/com/fjhx/service/contract/ContractPayService.java

@@ -29,7 +29,11 @@ public interface ContractPayService extends StorageBaseService<ContractPay> {
 
     Map<Integer, DateStatisticsResult> dateStatistics();
 
-    List<SupplierStatisticsResult> supplierStatistics(DateStatisticsResult dateStatisticsResult);
+    List<SupplierStatisticsResult> supplierStatistics(Condition condition);
+
+    Map<String, Object> statusStatistics(Condition condition);
+
+    Map<String, Object> cycleStatistics(Condition condition);
 
     Page<Map<String, Object>> getPage(Condition condition);
 

+ 152 - 102
hx-service/storage-restructure/src/main/java/com/fjhx/service/contract/impl/ContractPayServiceImpl.java

@@ -146,27 +146,23 @@ public class ContractPayServiceImpl extends ServiceImpl<ContractPayMapper, Contr
     }
 
     @Override
-    public List<SupplierStatisticsResult> supplierStatistics(DateStatisticsResult dateStatisticsResult) {
+    public List<SupplierStatisticsResult> supplierStatistics(Condition condition) {
         // 初始化返回值
         List<SupplierStatisticsResult> result = initSupplierStatisticsResult();
 
-        Integer type = dateStatisticsResult.getType();
-        // 历史账期没有需要付款的记录
-        if (ObjectUtil.equals(type, 1)) {
+        // 历史账期没有待付款记录
+        if (HISTORICAL_ACCOUNTING_PERIOD.equals(condition.getType())) {
             return result;
         }
 
-        Date beginTime = dateStatisticsResult.getBeginTime();
-        Date endTime = dateStatisticsResult.getEndTime();
-
         QueryWrapper<Object> wrapper = Wrappers.query();
-        splicingContractSelectCondition(wrapper);
 
-        String whereTime = "date_add( c.complete_time , interval c.account_date day)";
+        // 合同筛选
+        contractScreen(wrapper);
+        // 账期筛选
+        accountDateScreen(wrapper, condition);
 
-        wrapper.ge(ObjectUtil.notEqual(type, 2) && ObjectUtil.isNotEmpty(beginTime), whereTime, beginTime)
-                .le(ObjectUtil.isNotEmpty(endTime), whereTime, endTime)
-                .groupBy("c.supplier_id");
+        wrapper.groupBy("c.supplier_id");
 
         List<SupplierInfo> supplierInfoList = baseMapper.getSupplierInfoList(wrapper);
 
@@ -200,6 +196,51 @@ public class ContractPayServiceImpl extends ServiceImpl<ContractPayMapper, Contr
     }
 
     @Override
+    public Map<String, Object> statusStatistics(Condition condition) {
+        // 历史账期没有待付款记录
+        if (HISTORICAL_ACCOUNTING_PERIOD.equals(condition.getType())) {
+            HashMap<String, Object> map = new HashMap<>();
+            map.put("canLaunch", 0);
+            map.put("needSupplemented", 0);
+            map.put("total", 0);
+            return map;
+        }
+
+        QueryWrapper<Object> wrapper = Wrappers.query();
+
+        // 合同筛选
+        contractScreen(wrapper);
+        // 账期筛选
+        accountDateScreen(wrapper, condition);
+        // 供应商筛选
+        supplierIdScreen(wrapper, condition);
+
+        return baseMapper.statusStatistics(wrapper);
+    }
+
+    @Override
+    public Map<String, Object> cycleStatistics(Condition condition) {
+
+        QueryWrapper<Object> wrapper = Wrappers.query();
+
+        // 合同筛选
+        contractScreen(wrapper);
+        // 账期筛选
+        accountDateScreen(wrapper, condition);
+        // 供应商筛选
+        supplierIdScreen(wrapper, condition);
+        // 合同状态筛选
+        statusScreen(wrapper, condition);
+
+        Date date = new Date();
+
+        Date currentAccountBeginTime = getCurrentAccountBeginTime(date);
+        Date currentAccountEndTime = getCurrentAccountEndTime(date);
+
+        return baseMapper.cycleStatistics(wrapper, currentAccountBeginTime, currentAccountEndTime);
+    }
+
+    @Override
     public Page<Map<String, Object>> getPage(Condition condition) {
 
         // 历史账期没有待付款记录
@@ -211,21 +252,20 @@ public class ContractPayServiceImpl extends ServiceImpl<ContractPayMapper, Contr
 
         QueryWrapper<Object> wrapper = Wrappers.query();
 
-        // 拼接合同查询条件
-        splicingContractSelectCondition(wrapper);
-
-        // 拼接传入查询条件
-        splicingPageWrapper(wrapper, condition);
+        // 合同筛选
+        contractScreen(wrapper);
+        // 账期筛选
+        accountDateScreen(wrapper, condition);
+        // 供应商筛选
+        supplierIdScreen(wrapper, condition);
+        // 合同状态筛选
+        statusScreen(wrapper, condition);
+        // 周期筛选
+        cycleScreen(wrapper, condition, date);
 
         Page<Map<String, Object>> page = baseMapper.getPage(condition.getPage(), wrapper);
 
-        List<Map<String, Object>> records = page.getRecords();
-
-        if (records.size() == 0) {
-            return page;
-        }
-
-        for (Map<String, Object> record : records) {
+        for (Map<String, Object> record : page.getRecords()) {
             // 赋值付款期限
             setTermsPayment(date, record);
             // 质检是否完成
@@ -240,19 +280,6 @@ public class ContractPayServiceImpl extends ServiceImpl<ContractPayMapper, Contr
     }
 
     /**
-     * 初始化供应商统计结果集
-     */
-    private List<SupplierStatisticsResult> initSupplierStatisticsResult() {
-        List<SupplierStatisticsResult> result = new ArrayList<>();
-        for (int i = 0; i < 6; i++) {
-            SupplierStatisticsResult supplierStatisticsResult = new SupplierStatisticsResult();
-            supplierStatisticsResult.setTitleType(i);
-            result.add(supplierStatisticsResult);
-        }
-        return result;
-    }
-
-    /**
      * 合同付款时间段统计返回值初始化
      *
      * @param date 当前日期
@@ -299,6 +326,18 @@ public class ContractPayServiceImpl extends ServiceImpl<ContractPayMapper, Contr
         return result;
     }
 
+    /**
+     * 初始化供应商统计结果集
+     */
+    private List<SupplierStatisticsResult> initSupplierStatisticsResult() {
+        List<SupplierStatisticsResult> result = new ArrayList<>();
+        for (int i = 0; i < 6; i++) {
+            SupplierStatisticsResult supplierStatisticsResult = new SupplierStatisticsResult();
+            supplierStatisticsResult.setTitleType(i);
+            result.add(supplierStatisticsResult);
+        }
+        return result;
+    }
 
     /**
      * 生成返回结果集
@@ -313,17 +352,6 @@ public class ContractPayServiceImpl extends ServiceImpl<ContractPayMapper, Contr
     }
 
     /**
-     * 拼接合同查询条件
-     */
-    private void splicingContractSelectCondition(QueryWrapper<Object> wrapper) {
-        wrapper.eq("c.del_flag", StatusConstant.NOT_DELETED)
-                .lt("c.pay_status", ContractPayStatusEnum.COMPLETED.getType())
-                .and(q -> q.eq("c.account_date", 0)
-                        .or(w -> w.gt("c.account_date", 0)
-                                .eq("c.status", ContractStatusEnum.COMPLETED.getType())));
-    }
-
-    /**
      * 赋值付款期限
      */
     private void setTermsPayment(Date date, Map<String, Object> record) {
@@ -331,74 +359,96 @@ public class ContractPayServiceImpl extends ServiceImpl<ContractPayMapper, Contr
         Date completeTime = Convert.toDate(record.get("completeTime"));
         // 账期
         Integer accountDate = Convert.toInt(record.get("accountDate"));
-        // 完成时间到今天距离多少天
-        long day = DateUtil.betweenDay(completeTime, date, true);
+
+        long day = completeTime == null ? 0 : DateUtil.betweenDay(completeTime, date, true);
 
         // 赋值付钱期限(距离账期还要多少天,负值为超过付款日期多少天)
         record.put("termsPayment", accountDate - day);
     }
 
+    // 付款时间:最后入库时间 + 账期
+    private static final String whereTime = "date_add( c.complete_time , interval c.account_date day)";
+
+    /**
+     * 合同筛选
+     */
+    private void contractScreen(QueryWrapper<Object> wrapper) {
+        wrapper.eq("c.del_flag", StatusConstant.NOT_DELETED)
+                .lt("c.pay_status", ContractPayStatusEnum.COMPLETED.getType())
+                .and(q -> q.eq("c.account_date", 0)
+                        .or(w -> w.gt("c.account_date", 0)
+                                .eq("c.status", ContractStatusEnum.COMPLETED.getType())));
+    }
+
     /**
-     * 拼接分页查询条件
+     * 账期筛选
      */
-    private void splicingPageWrapper(QueryWrapper<Object> wrapper, Condition condition) {
+    private void accountDateScreen(QueryWrapper<Object> wrapper, Condition condition) {
 
-        Long supplierId = condition.getLong("supplierId");
         Integer type = condition.getType();
-        String beginTime = condition.getStr("beginTime");
-        String endTime = condition.getStr("endTime");
+        Date beginTime = condition.getBeginTime();
+        Date endTime = condition.getEndTime();
+
+        wrapper.func(q -> {
+            if (CURRENT_ACCOUNTING_PERIOD.equals(type)) {
+                q.le(whereTime, endTime);
+            } else if (FUTURE_ACCOUNTING_PERIOD.equals(type)) {
+                q.between(whereTime, beginTime, endTime);
+            }
+        });
+    }
+
+    /**
+     * 供应商筛选
+     */
+    private void supplierIdScreen(QueryWrapper<Object> wrapper, Condition condition) {
+        Long supplierId = condition.getLong("supplierId");
+        wrapper.eq(ObjectUtil.isNotEmpty(supplierId), "c.supplier_id", supplierId);
+    }
 
+    /**
+     * 合同状态筛选
+     */
+    private void statusScreen(QueryWrapper<Object> wrapper, Condition condition) {
         Integer status = condition.getStatus();
-        Integer accountStatus = condition.getInt("accountStatus");
+        wrapper.func(q -> {
+            // 可发起
+            if (ObjectUtil.equals(status, 1)) {
+                q.apply("c.apply_pay_amount = 0 " +
+                        "and t.batchCount = t.qualityTestingCount " +
+                        "and t.contractFileCount > 0 " +
+                        "and c.invoice_amount >= c.adjust_amount");
+            }
+            // 待补齐
+            else if (ObjectUtil.equals(status, 2)) {
+                q.apply("t.batchCount != t.qualityTestingCount " +
+                        "or t.contractFileCount <= 0 " +
+                        "or c.invoice_amount < c.adjust_amount");
+            }
+        });
+    }
 
-        Date date = new Date();
+    /**
+     * 周期筛选
+     */
+    private void cycleScreen(QueryWrapper<Object> wrapper, Condition condition, Date date) {
 
-        // 付款时间:最后入库时间 + 账期
-        String whereTime = "date_add( c.complete_time , interval c.account_date day)";
-
-        wrapper
-                // 供应商
-                .eq(ObjectUtil.isNotEmpty(supplierId), "c.supplier_id", supplierId)
-                // 账期
-                .func(type != null, q -> {
-                    if (CURRENT_ACCOUNTING_PERIOD.equals(type)) {
-                        q.le(whereTime, endTime);
-                    } else {
-                        q.between(whereTime, beginTime, endTime);
-                    }
-                })
-
-                .func(q -> {
-                    // 可发起
-                    if (ObjectUtil.equals(status, 1)) {
-                        q.apply("c.apply_pay_amount = 0 " +
-                                "and t.batchCount = t.qualityTestingCount " +
-                                "and t.contractFileCount > 0 " +
-                                "and c.invoice_amount >= c.adjust_amount");
-                    }
-                    // 待补齐
-                    else if (ObjectUtil.equals(status, 2)) {
-                        q.apply("t.batchCount != t.qualityTestingCount " +
-                                "or t.contractFileCount <= 0 " +
-                                "or c.invoice_amount < c.adjust_amount");
-                    }
-                })
+        Integer cycleType = condition.getInt("cycleType");
 
-                .func(q -> {
-                    // 本周期
-                    if (ObjectUtil.equals(accountStatus, 1)) {
-                        q.between(whereTime, getCurrentAccountBeginTime(date), getCurrentAccountEndTime(date));
-                    }
-                    // 上周期顺延
-                    else if (ObjectUtil.equals(accountStatus, 2)) {
-                        q.lt(whereTime, getCurrentAccountBeginTime(date));
-                    }
-                    // 其他(未来账期)
-                    else if (ObjectUtil.equals(accountStatus, 3)) {
-                        q.gt(whereTime, getCurrentAccountEndTime(date));
-                    }
-                })
-        ;
+        wrapper.func(q -> {
+            // 本周期
+            if (ObjectUtil.equals(cycleType, 1)) {
+                q.between(whereTime, getCurrentAccountBeginTime(date), getCurrentAccountEndTime(date));
+            }
+            // 上周期顺延
+            else if (ObjectUtil.equals(cycleType, 2)) {
+                q.lt(whereTime, getCurrentAccountBeginTime(date));
+            }
+            // 其他(未来账期)
+            else if (ObjectUtil.equals(cycleType, 3)) {
+                q.gt(whereTime, getCurrentAccountEndTime(date));
+            }
+        });
     }
 
 

+ 4 - 0
hx-service/storage-restructure/src/main/resources/application-dev.yml

@@ -9,3 +9,7 @@ spring:
     url: ${blade.datasource.storage.dev.url}
     username: ${blade.datasource.storage.dev.username}
     password: ${blade.datasource.storage.dev.password}
+
+    druid:
+      time-between-eviction-runs-millis: 30000000
+      test-while-idle: false

+ 3 - 3
hx-service/storage/src/main/java/com/fjhx/stock/service/impl/StockBackPlanServiceImpl.java

@@ -413,7 +413,7 @@ public class StockBackPlanServiceImpl extends ServiceImpl<StockBackPlanMapper, S
 
     private void returnWarehouseA008(Date beginDate, Map<String, StockBackPlanDetails> stockBackPlanMap) {
         List<Map<String, Object>> backList = baseMapper.getReturnWarehouse(Wrappers.query()
-                .ge("sb.checker_time", DateUtil.format(beginDate, "yyyy-MM-dd 08:00:00"))
+                .ge("sb.checker_time", DateUtil.format(beginDate, "yyyy-MM-dd 10:00:00"))
                 .eq("uu.IsDelete", 0)
                 .eq("uu.DepartmentID", "A008")
                 .isNotNull("uu.JobNo")
@@ -426,8 +426,8 @@ public class StockBackPlanServiceImpl extends ServiceImpl<StockBackPlanMapper, S
 
             int h = Integer.parseInt(DateUtil.format(createTime, "H"));
             // int m = Integer.parseInt(DateUtil.format(createTime, "m"));
-            // 小于9点算前一日
-            if (h < 8) {
+            // 小于10点算前一日
+            if (h < 10) {
                 createTime = DateUtil.offsetDay(createTime, -1);
             }
             // 排班时间

+ 1 - 1
hx-service/storage/src/main/java/com/fjhx/task/controller/ScheduleTaskController.java

@@ -56,7 +56,7 @@ public class ScheduleTaskController {
      * 统计排班数据
      */
     @Scheduled(cron = "30 0/5 * * * ?")
-//    @Scheduled(cron = "0 26 17 * * ?")
+//    @Scheduled(cron = "0 52 11 * * ?")
     private void statisticsScheduleDateTask() {
         if (BladeApplication.isLocalDev()) {
             return;