Pārlūkot izejas kodu

1. 自动审批通过功能- 以分发的时间开始算

wangjiang 2 gadi atpakaļ
vecāks
revīzija
f4c4216327

+ 5 - 1
src/main/java/platform/modules/sys/dao/ApprovalDao.java

@@ -14,7 +14,10 @@ import platform.modules.sys.entity.Approval;
 public interface ApprovalDao extends BaseMapper<Approval> {
 
 	Approval getLatestApproval(@Param("apply_id")Integer apply_id,@Param("type") String type);
-	
+
+	Approval getLatestDispatchApproval(@Param("apply_id")Integer apply_id,@Param("type") String type);
+
+
 	//查找最近一条审核记录,含撤回的记录 不判断del_flag
 	Approval getLatestApprovalAll(@Param("apply_id")Integer apply_id,@Param("type") String type);
 
@@ -57,4 +60,5 @@ public interface ApprovalDao extends BaseMapper<Approval> {
     List<Approval> getNear3MonthStatistical(@Param("month") int month);
 
 	int getBusinessAcceptNum(@Param("businessSearchDto") BusinessSearchDto businessSearchDto);
+
 }

+ 6 - 0
src/main/java/platform/modules/sys/service/ApprovalService.java

@@ -62,6 +62,10 @@ public class ApprovalService extends BaseService<Approval> {
         return approvalDao.getLatestApprovalAll(apply_id, type);
     }
 
+    public Approval getLatestDispatchApproval(Integer apply_id, String type) {
+        return approvalDao.getLatestDispatchApproval(apply_id, type);
+    }
+
     //获取存量用地审核流程数据
     public List<Approval> getApprovalList(Integer apply_id) {
         //合规性审查只能看到自己部门的审核信息
@@ -393,4 +397,6 @@ public class ApprovalService extends BaseService<Approval> {
         List<Approval> approvals = this.selectByExample(example);
         return approvals;
     }
+
+
 }

+ 5 - 4
src/main/java/platform/modules/sys/task/StocklandAutoFinishFlowTask.java

@@ -33,7 +33,6 @@ import java.util.*;
  * 超过5天未审批的单据自动全部通过
  */
 @Component
-@EnableScheduling
 @Slf4j
 public class StocklandAutoFinishFlowTask {
 
@@ -58,6 +57,7 @@ public class StocklandAutoFinishFlowTask {
     private String companyMasterPhone;
 
     @Scheduled(cron = "0 0 0 * * ?") // 每天凌晨12点执行
+//    @Scheduled(cron = "0 0/1 * * * ?") // 每分钟执行一次
     public void autoFinishFlow() {
 
         List<StockLand> allNeedJudgeStockLand = stockLandService.findAllNeedJudgeStockLand();
@@ -81,8 +81,9 @@ public class StocklandAutoFinishFlowTask {
 
     private void autoJudge(StockLand stockLand) throws ParseException, ClientException, InterruptedException {
         Approval latestApproval = approvalService.getLatestApproval(stockLand.getId(), Constant.DictionaryType.STOCKLAND);
+        Approval dispatchApproval = approvalService.getLatestDispatchApproval(stockLand.getId(), Constant.DictionaryType.STOCKLAND);
         // 最后一个审批超过5天的 开始自动审批
-        Boolean overTime = DateUtil.isOverTime(latestApproval.getCreate_time(), 5);
+        Boolean overTime = DateUtil.isOverTime(dispatchApproval.getCreate_time(), 5);
         if (!overTime) return;
         log.info("开始自动审批单据, apply_no: " + stockLand.getApply_no());
         String nextchecker = latestApproval.getNextchecker();
@@ -104,7 +105,7 @@ public class StocklandAutoFinishFlowTask {
                             log.info("开始自动审批单据, apply_no: " + stockLand.getApply_no() + ",currentChecker: " + currentChecker +" 自动置为简易流程汇总");
 
                             stockLand.setApprove_status(Constant.LandApproveStatus.JYLCHZ);
-                            stockLandService.save(stockLand);
+                            stockLandService.saveStatus(stockLand);
                             stockLandService.autoSaveApproval(stockLand.getId(),
                                     "超时自动审批通过",
                                     currentChecker,
@@ -119,7 +120,7 @@ public class StocklandAutoFinishFlowTask {
                             //当最后一个人审核后,将该单据的状态设为“后面是合规性审查汇总”
                             log.info("开始自动审批单据, apply_no: " + stockLand.getApply_no() + ",currentChecker: " + currentChecker+ "自动置为合规性审查汇总");
                             stockLand.setApprove_status(Constant.LandApproveStatus.HGXSCTG);
-                            stockLandService.save(stockLand);
+                            stockLandService.saveStatus(stockLand);
                             stockLandService.autoSaveApproval(stockLand.getId(),
                                     "超时自动审批通过",
                                     currentChecker,

+ 13 - 0
src/main/resources/mapper/sys/ApprovalDao.xml

@@ -26,6 +26,17 @@
         	limit 0,1
     </select>
 
+	<select id="getLatestDispatchApproval" resultType="platform.modules.sys.entity.Approval">
+		select *
+		from z_approval
+		where apply_id = #{apply_id}
+		  and type = #{type}
+		  and del_flag = 0 and is_withdraw is null
+		  and BEFORE_APPROVALSTATUS = 2
+			order by id desc
+			limit 0,1
+	</select>
+
     <!-- 查找当前用户最近一条待审核记录 -->
     <select id="getLatestApprovalByUser" resultType="platform.modules.sys.entity.Approval">
         select * 
@@ -523,4 +534,6 @@
 			AND date_format(create_time, '%Y %m') = date_format(DATE_SUB(curdate(), INTERVAL #{month} MONTH),'%Y %m')
 		</if>
 	</select>
+
+
 </mapper>

+ 1 - 1
src/test/java/platform/modules/test/StockLandTest.java

@@ -95,7 +95,7 @@ public class StockLandTest {
                                     // 简易流程会签,后面是简易流程汇总
                                     //当最后一个人审核后,将该单据的状态设为“简易流程汇总”
                                     stockLand.setApprove_status(Constant.LandApproveStatus.JYLCHZ);
-                                    stockLandService.save(stockLand);
+                                    stockLandService.saveStatus(stockLand);
                                     stockLandService.autoSaveApproval(stockLand.getId(),
                                             "超时自动审批通过",
                                             currentChecker,