Parcourir la source

履职任务增加orgpath,orgname

jiawuxian il y a 2 ans
Parent
commit
32d8079e65

+ 29 - 1
project_data/sql/0.0.2/soc/soc.sql

@@ -1172,12 +1172,40 @@ END IF;
         ALTER TABLE `core_resumption_data`
 			ADD COLUMN `point_scan` tinyint(1) NULL DEFAULT NULL COMMENT '是否扫描NFC 1扫描,0不扫描' AFTER `data_status`;
     END IF;
-       IF
+    IF
         NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE () and TABLE_NAME = 'core_resumption_data' AND COLUMN_NAME = 'required' ) THEN
         ALTER TABLE `core_resumption_data`
 			ADD COLUMN `required` tinyint(0) NULL DEFAULT 1 COMMENT '是否必须检查 1必检查,0非必捡' AFTER `data_status`;
     END IF;
 
+	IF
+        NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE () and TABLE_NAME = 'core_resumption' AND COLUMN_NAME = 'org_path' ) THEN
+        ALTER TABLE `core_resumption` 
+			ADD COLUMN `org_path` varchar(256) NULL AFTER `org_id`,
+			ADD COLUMN `org_name` varchar(64) NULL AFTER `org_path`;
+		UPDATE core_resumption 
+			SET org_path =(
+				SELECT
+					path 
+				FROM
+					sys_org 
+				WHERE
+					sys_org.id = core_resumption.org_id 
+				),
+				org_name =(
+				SELECT
+					short_name 
+				FROM
+					sys_org 
+				WHERE
+					sys_org.id = core_resumption.org_id 
+				)
+				
+			WHERE
+				org_path IS NULL;
+    END IF;
+	
+
 
 ALTER TABLE `core_protection` MODIFY COLUMN `device_id` BIGINT NULL DEFAULT NULL COMMENT '设备ID' AFTER `id`;
 -- 机构扩展添加是否业务库

+ 4 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/domain/Resumption.java

@@ -49,6 +49,10 @@ public class Resumption extends BaseEntity {
      */
     private Long orgId;
 
+    private String orgPath;
+
+    private String orgName;
+
     /**
      * 年月日
      */

+ 17 - 16
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/task/ResumptionTaskBusiness.java

@@ -92,7 +92,7 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
     public int buildTask(List<Long> execOrgIds, @NotEmpty List<AppPlan> plans, @NotNull Date date) {
         List<Resumption> resumptions = new ArrayList<>();
         for (AppPlan appPlan : plans) {
-            if(ObjectUtil.notEqual(appPlan.getPlanStatus(),1)){
+            if (ObjectUtil.notEqual(appPlan.getPlanStatus(), 1)) {
                 continue;
             }
             //获取履职计划中对应的检查要点
@@ -109,16 +109,17 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
                 continue;
             }
 
-            List<Long> orgIds = getPlanOrgIds(appPlan, execOrgIds);
-            if (CollectionUtils.isEmpty(orgIds)) {
+            List<SysOrg> orgs = getPlanOrgIds(appPlan, execOrgIds);
+            if (CollectionUtils.isEmpty(orgs)) {
                 log.info("error:该计划ID:{}没有执行机构", appPlan.getId());
                 continue;
             }
 
             CycleCommonEnum cycleCommonEnum = CycleCommonEnum.getEnum(appPlan.getPlanCycle());
             DateRange range = DateUtils.getStartAndEnd(date, cycleCommonEnum);
-            Map<Long, SysWorkTime> workTimes = orgSingleWorkTimeMap(new Date(), cycleCommonEnum, orgIds);
-            for (Long orgId : orgIds) {
+            Map<Long, SysWorkTime> workTimes = orgSingleWorkTimeMap(new Date(), cycleCommonEnum, orgs.stream().map(SysOrg::getId).collect(Collectors.toList()));
+            for (SysOrg org : orgs) {
+                Long orgId = org.getId();
                 if (!workTimes.containsKey(orgId) || ObjectUtil.isNull(workTimes.get(orgId)) || ObjectUtil.notEqual(workTimes.get(orgId).getIsEnable(), 1L)) {
                     continue;
                 }
@@ -126,9 +127,9 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
 
                 List<Resumption> tasks;
                 if (ObjectUtil.equal(CycleCommonEnum.DAILY.getCode(), appPlan.getPlanCycle())) {
-                    tasks = buildResumptions(appPlan, orgId, workTime);
+                    tasks = buildResumptions(appPlan, org, workTime);
                 } else {
-                    tasks = buildResumptions(appPlan, orgId, range.getStartTime(), range.getEndTime(), 0L);
+                    tasks = buildResumptions(appPlan, org, range.getStartTime(), range.getEndTime(), 0L);
                 }
 
                 if (CollectionUtils.isNotEmpty(tasks)) {
@@ -334,9 +335,9 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
 
                 List<Resumption> planResumptionList;
                 if (ObjectUtil.equal(cycle, CycleCommonEnum.DAILY)) {
-                    planResumptionList = this.buildResumptions(plan, orgId, workTime);
+                    planResumptionList = this.buildResumptions(plan, org, workTime);
                 } else {
-                    planResumptionList = this.buildResumptions(plan, orgId, startDate, endDate, executedCount);
+                    planResumptionList = this.buildResumptions(plan, org, startDate, endDate, executedCount);
                 }
 
                 if (CollectionUtils.isNotEmpty(planResumptionList)) {
@@ -358,7 +359,7 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
         return resumptionService.update(wrapper);
     }
 
-    private List<Resumption> buildResumptions(AppPlan appPlan, Long execOrgId, SysWorkTime workTime) {
+    private List<Resumption> buildResumptions(AppPlan appPlan, SysOrg execOrg, SysWorkTime workTime) {
         DateTime dateTime = new DateTime(workTime.getYmdDate());
         String opentime = workTime.getOpenTime();//营业时间
         String closetime = workTime.getCloseTime();//营业终了
@@ -388,10 +389,10 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
             planendTime = DateUtil.endOfDay(time2).setField(DateField.MILLISECOND, 0);
         }
 
-        return buildResumptions(appPlan, execOrgId, planstartTime, planendTime, 0L);
+        return buildResumptions(appPlan, execOrg, planstartTime, planendTime, 0L);
     }
 
-    private List<Resumption> buildResumptions(AppPlan appPlan, Long execOrgId, Date planStartTime, Date planEndTime, Long executedCount) {
+    private List<Resumption> buildResumptions(AppPlan appPlan, SysOrg execOrg, Date planStartTime, Date planEndTime, Long executedCount) {
         List<Resumption> resumptionList = new ArrayList<>();
         Long count = 1L;
         if (NumberUtil.isNumber(appPlan.getCount())) {
@@ -414,7 +415,9 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
             resumption.setYmdHalfyear(Long.valueOf(ymd.getHalfyear()));
             resumption.setParentPlanId((ObjectUtil.equal(appPlan.getParentId(), -1L) || ObjectUtil.isNull(appPlan.getParentId())) ? appPlan.getId() : appPlan.getParentId());
             resumption.setPlanId(appPlan.getId());
-            resumption.setOrgId(execOrgId);
+            resumption.setOrgId(execOrg.getId());
+            resumption.setOrgPath(execOrg.getPath());
+            resumption.setOrgName(execOrg.getShortName());
             resumption.setType(appPlan.getPlanCycle());
             resumption.setPlanStartTime(planStartTime);
             resumption.setPlanEndTime(planEndTime);
@@ -462,8 +465,6 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
         if (CollectionUtils.isNotEmpty(planIds)) {
             qw.lambda().in(AppPlan::getId, planIds);
         }
-        List<AppPlan> listPlans = appPlanMapper.selectList(qw);
-
-        return listPlans;
+        return appPlanMapper.selectList(qw);
     }
 }