diff --git a/hw-modules/hw-dms/src/main/java/com/hw/dms/domain/DmsPlanMaint.java b/hw-modules/hw-dms/src/main/java/com/hw/dms/domain/DmsPlanMaint.java index dff70e8..1d8b1a9 100644 --- a/hw-modules/hw-dms/src/main/java/com/hw/dms/domain/DmsPlanMaint.java +++ b/hw-modules/hw-dms/src/main/java/com/hw/dms/domain/DmsPlanMaint.java @@ -69,6 +69,7 @@ public class DmsPlanMaint extends BaseEntity private Long timeLimitDays; private Long timeLimitHours; + public Long getTimeLimitDays() { return timeLimitDays; } diff --git a/hw-modules/hw-dms/src/main/java/com/hw/dms/mapper/DmsPlanMaintMapper.java b/hw-modules/hw-dms/src/main/java/com/hw/dms/mapper/DmsPlanMaintMapper.java index 6a402d0..edd394f 100644 --- a/hw-modules/hw-dms/src/main/java/com/hw/dms/mapper/DmsPlanMaintMapper.java +++ b/hw-modules/hw-dms/src/main/java/com/hw/dms/mapper/DmsPlanMaintMapper.java @@ -95,4 +95,14 @@ public interface DmsPlanMaintMapper */ public DmsPlanMaint selectDmsPlanMaintJoinByPlanMaintCode(String planMaintCode); + + + /** + * 查询保养计划信息,Join job + * + * @param planMaintId 保养计划信息主键 + * @return 保养计划信息 + */ + public DmsPlanMaint selectPlanMaintJoinJobByPlanMaintId(Long planMaintId); + } diff --git a/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsPlanMaintServiceImpl.java b/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsPlanMaintServiceImpl.java index f16cacd..cb4633a 100644 --- a/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsPlanMaintServiceImpl.java +++ b/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsPlanMaintServiceImpl.java @@ -47,8 +47,7 @@ public class DmsPlanMaintServiceImpl implements IDmsPlanMaintService { */ @Override public DmsPlanMaint selectDmsPlanMaintByPlanMaintId(Long planMaintId) { - DmsPlanMaint dmsPlanMaint = dmsPlanMaintMapper.selectDmsPlanMaintByPlanMaintId(planMaintId); - + DmsPlanMaint dmsPlanMaint = dmsPlanMaintMapper.selectPlanMaintJoinJobByPlanMaintId(planMaintId); Long timeLimit = dmsPlanMaint.getTimeLimit(); if (timeLimit != null) { @@ -108,14 +107,15 @@ public class DmsPlanMaintServiceImpl implements IDmsPlanMaintService { dmsPlanMaint.setMaintTime(nextExecution); dmsPlanMaint.setJobId(jobIdR.getData().longValue()); dmsPlanMaint.setPlanMaintCode(planMaintCode); - dmsPlanMaint.setTimeLimit((dmsPlanMaint.getTimeLimitDays() * 24 * 60 * 60) - + (dmsPlanMaint.getTimeLimitHours() * 60 * 60)); + Long timeLimitDays = dmsPlanMaint.getTimeLimitDays()==null?0L:dmsPlanMaint.getTimeLimitDays(); + Long timeLimitHours = dmsPlanMaint.getTimeLimitHours() == null?0L:dmsPlanMaint.getTimeLimitHours(); + dmsPlanMaint.setTimeLimit((timeLimitDays * 24 * 60 * 60) + + (timeLimitHours * 60 * 60)); dmsPlanMaint.setIsFlag(1l); dmsPlanMaint.setCreateBy(SecurityUtils.getUsername()); dmsPlanMaint.setCreateTime(DateUtils.getNowDate()); int rows = dmsPlanMaintMapper.insertDmsPlanMaint(dmsPlanMaint); - return rows; } @@ -128,12 +128,40 @@ public class DmsPlanMaintServiceImpl implements IDmsPlanMaintService { @Transactional @Override public int updateDmsPlanMaint(DmsPlanMaint dmsPlanMaint) { - dmsPlanMaint.setIsFlag(1l); - LoginUser user = new LoginUser(); - dmsPlanMaint.setUpdateBy(user.getUsername()); + Long jobId = dmsPlanMaint.getJobId(); + String cronExpression = dmsPlanMaint.getCronExpression(); + if(StringUtils.isNotEmpty(cronExpression)){ + if (jobId == null) { + String planMaintCode = dmsPlanMaint.getPlanMaintCode(); + SysJob job = new SysJob(); + job.setJobName("保养计划编号" + planMaintCode + "工单任务"); + job.setJobGroup("DEFAULT"); + job.setInvokeTarget("ryTask.getDmsBillsMaint(\"" + planMaintCode + "\")"); + job.setCronExpression(dmsPlanMaint.getCronExpression()); + job.setMisfirePolicy("1"); + job.setConcurrent("1"); + job.setStatus("1"); + R jobIdR = remoteJobService.add(SecurityConstants.INNER, job); + dmsPlanMaint.setJobId(jobIdR.getData().longValue()); + } else { + SysJob sysJob = remoteJobService.getJobInfo(jobId, SecurityConstants.INNER); + if (sysJob != null) { + sysJob.setCronExpression(dmsPlanMaint.getCronExpression()); + remoteJobService.update(SecurityConstants.INNER, sysJob); + } + } + } + + String time = dmsPlanMaint.getCronExpression(); + //通过cron表达式获取下一次执行时间 + Date nextExecution = CronUtils.getNextExecution(time); + dmsPlanMaint.setMaintTime(nextExecution); + Long timeLimitDays = dmsPlanMaint.getTimeLimitDays()==null?0L:dmsPlanMaint.getTimeLimitDays(); + Long timeLimitHours = dmsPlanMaint.getTimeLimitHours() == null?0L:dmsPlanMaint.getTimeLimitHours(); + dmsPlanMaint.setTimeLimit((timeLimitDays * 24 * 60 * 60) + + (timeLimitHours * 60 * 60)); + dmsPlanMaint.setUpdateBy(SecurityUtils.getUsername()); dmsPlanMaint.setUpdateTime(DateUtils.getNowDate()); - dmsPlanMaintMapper.deleteDmsPlanMaintDetailByPlanMaintId(dmsPlanMaint.getPlanMaintId()); - insertDmsPlanMaintDetail(dmsPlanMaint); return dmsPlanMaintMapper.updateDmsPlanMaint(dmsPlanMaint); } @@ -154,7 +182,7 @@ public class DmsPlanMaintServiceImpl implements IDmsPlanMaintService { jobIds[i] = dmsPlanMaint.getJobId(); } - remoteJobService.remove(SecurityConstants.INNER,jobIds); + remoteJobService.remove(SecurityConstants.INNER, jobIds); return dmsPlanMaintMapper.deleteDmsPlanMaintByPlanMaintIds(planMaintIds); } diff --git a/hw-modules/hw-dms/src/main/resources/mapper/dms/DmsPlanMaintMapper.xml b/hw-modules/hw-dms/src/main/resources/mapper/dms/DmsPlanMaintMapper.xml index f846231..f91c31f 100644 --- a/hw-modules/hw-dms/src/main/resources/mapper/dms/DmsPlanMaintMapper.xml +++ b/hw-modules/hw-dms/src/main/resources/mapper/dms/DmsPlanMaintMapper.xml @@ -22,6 +22,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -175,4 +177,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where a.plan_maint_code = #{planMaintCode} + + + diff --git a/hw-ui/src/views/dms/maint/index.vue b/hw-ui/src/views/dms/maint/index.vue index 3da34d9..cb219d7 100644 --- a/hw-ui/src/views/dms/maint/index.vue +++ b/hw-ui/src/views/dms/maint/index.vue @@ -72,48 +72,8 @@ - - - - - - - - +
-
- - - - - - - - - 搜索 @@ -170,13 +130,6 @@ - - - @@ -199,19 +152,6 @@ {{scope.row.timeLimitHours}}小时 - - - - - - - - - @@ -222,7 +162,7 @@ icon="el-icon-s-order" @click="jumpToDetail(scope.row)" v-hasPermi="['dms:checkplan:edit']" - >详情 + >计划明细 - - - + + + - - - --> + + + + - - + + - - + + - - - {{dict.label}} - - - - - {{dict.label}} - - + @@ -362,6 +286,8 @@ export default { loading: true, // 选中数组 ids: [], + // 选中数组 + codes: [], // 子表选中数据 checkedDmsPlanMaintDetail: [], // 非单个禁用 @@ -408,8 +334,8 @@ export default { planMaintCode: [ { required: true, message: "计划编号不能为空", trigger: "blur" } ], - isFlag: [ - { required: true, message: "是否标识:1-是;2-否不能为空", trigger: "blur" } + cronExpression: [ + { required: true, message: "定时计划不能为空", trigger: "blur" } ], } }; @@ -480,6 +406,7 @@ export default { cyclePeriod: null, maintStatus: null, createMethod: null, + cronExpression: null, isFlag: null, remark: null, createBy: null, @@ -503,6 +430,7 @@ export default { // 多选框选中数据 handleSelectionChange(selection) { this.ids = selection.map(item => item.planMaintId) + this.codes = selection.map(item => item.planMaintCode) this.single = selection.length!==1 this.multiple = !selection.length }, @@ -518,7 +446,6 @@ export default { const planMaintId = row.planMaintId || this.ids getMaint(planMaintId).then(response => { this.form = response.data; - this.dmsPlanMaintDetailList = response.data.dmsPlanMaintDetailList; this.open = true; this.title = "修改保养计划信息"; }); @@ -547,7 +474,8 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const planMaintIds = row.planMaintId || this.ids; - this.$modal.confirm('是否确认删除保养计划信息编号为"' + planMaintIds + '"的数据项?').then(function() { + const planMatinCodes = row.planMatinCode || this.codes + this.$modal.confirm('是否确认删除保养计划编号为"' + planMatinCodes + '"的数据项?').then(function() { return delMaint(planMaintIds); }).then(() => { this.getList(); diff --git a/hw-ui/src/views/dms/maintDetail/index.vue b/hw-ui/src/views/dms/maintDetail/index.vue index 058e2ae..42e75fd 100644 --- a/hw-ui/src/views/dms/maintDetail/index.vue +++ b/hw-ui/src/views/dms/maintDetail/index.vue @@ -4,7 +4,7 @@ - + @@ -147,7 +147,6 @@ - - - + @@ -280,7 +269,7 @@ - + @@ -304,22 +293,20 @@ - - - - - + + + + :value="item.maintStandardId"> @@ -385,7 +372,7 @@ export default { planMaintId: null, deviceId: null, maintStationId: null, - maintProtocol: null, + maintStandardId: null, operationDescription: null, isFlag: null, }, @@ -471,7 +458,7 @@ export default { planMaintId: null, deviceId: null, maintStationId: null, - maintProtocol: null, + maintStandardId: null, operationDescription: null, isFlag: null, remark: null,