|
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.pms.job;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
|
|
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
|
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
|
|
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
|
@@ -23,6 +24,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
@@ -49,6 +51,7 @@ public class InspectCreateOrderJob implements JobHandler {
|
|
|
|
|
|
@Override
|
|
|
@TenantJob
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public String execute(String param) throws Exception {
|
|
|
List<IotInspectPlanDO> plans = iotInspectPlanMapper.selectList();
|
|
|
plans.forEach(plan -> {
|
|
@@ -57,19 +60,27 @@ public class InspectCreateOrderJob implements JobHandler {
|
|
|
plan.getCreateTime().atZone(ZoneId.systemDefault()) // 使用系统默认时区
|
|
|
.toInstant() // 转为 Instant(时间戳)
|
|
|
);
|
|
|
- deal(plan, date);
|
|
|
+ try {
|
|
|
+ deal(plan, date);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException();
|
|
|
+ }
|
|
|
} else {
|
|
|
Date lastdate = Date.from(
|
|
|
plan.getLastCreateTime().atZone(ZoneId.systemDefault()) // 使用系统默认时区
|
|
|
.toInstant() // 转为 Instant(时间戳)
|
|
|
);
|
|
|
- deal(plan, lastdate);
|
|
|
+ try {
|
|
|
+ deal(plan, lastdate);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException();
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
return "创建成功";
|
|
|
}
|
|
|
|
|
|
- private void deal(IotInspectPlanDO plan, Date date) {
|
|
|
+ private void deal(IotInspectPlanDO plan, Date date) throws Exception {
|
|
|
Date date1 = new Date();
|
|
|
if ("hour".equals(plan.getPlanUnit())){
|
|
|
DateTime dateTime = DateUtil.offsetMinute(date, Integer.parseInt(StringUtils.substringBeforeLast(String.valueOf(plan.getPlanCycle()),".")));
|
|
@@ -105,7 +116,7 @@ public class InspectCreateOrderJob implements JobHandler {
|
|
|
}
|
|
|
return personToDevices;
|
|
|
}
|
|
|
- private void createPlan(IotInspectPlanDO iotInspectPlan) {
|
|
|
+ private void createPlan(IotInspectPlanDO iotInspectPlan) throws Exception {
|
|
|
Map<Long, List<IotInspectRouteDO>> generate = generate(iotInspectPlan.getDeviceIds());
|
|
|
generate.forEach((k, v)->{
|
|
|
IotInspectOrderDO iotInspectOrderDO = new IotInspectOrderDO();
|