|
@@ -53,36 +53,33 @@ public class InspectCreateOrderJob implements JobHandler {
|
|
@TenantJob
|
|
@TenantJob
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public String execute(String param) throws Exception {
|
|
public String execute(String param) throws Exception {
|
|
- List<IotInspectPlanDO> plans = iotInspectPlanMapper.selectList();
|
|
|
|
- plans.stream().filter(e -> e.getStatus()==0).forEach(plan -> {
|
|
|
|
- if (plan.getLastCreateTime()==null) {
|
|
|
|
- Date date = Date.from(
|
|
|
|
- plan.getCreateTime().atZone(ZoneId.systemDefault()) // 使用系统默认时区
|
|
|
|
- .toInstant() // 转为 Instant(时间戳)
|
|
|
|
- );
|
|
|
|
- try {
|
|
|
|
- deal(plan, date);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- throw new ServiceException();
|
|
|
|
|
|
+ try {
|
|
|
|
+ List<IotInspectPlanDO> plans = iotInspectPlanMapper.selectList();
|
|
|
|
+ plans.stream().filter(e -> e.getStatus()==0).forEach(plan -> {
|
|
|
|
+ if (plan.getLastCreateTime()==null) {
|
|
|
|
+ Date date = Date.from(
|
|
|
|
+ plan.getCreateTime().atZone(ZoneId.systemDefault()) // 使用系统默认时区
|
|
|
|
+ .toInstant() // 转为 Instant(时间戳)
|
|
|
|
+ );
|
|
|
|
+ deal(plan, date);
|
|
|
|
+ } else {
|
|
|
|
+ Date lastdate = Date.from(
|
|
|
|
+ plan.getLastCreateTime().atZone(ZoneId.systemDefault()) // 使用系统默认时区
|
|
|
|
+ .toInstant() // 转为 Instant(时间戳)
|
|
|
|
+ );
|
|
|
|
+ deal(plan, lastdate);
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- Date lastdate = Date.from(
|
|
|
|
- plan.getLastCreateTime().atZone(ZoneId.systemDefault()) // 使用系统默认时区
|
|
|
|
- .toInstant() // 转为 Instant(时间戳)
|
|
|
|
- );
|
|
|
|
- try {
|
|
|
|
- deal(plan, lastdate);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- throw new ServiceException();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ });
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new ServiceException();
|
|
|
|
+ }
|
|
return "创建成功";
|
|
return "创建成功";
|
|
}
|
|
}
|
|
|
|
|
|
- private void deal(IotInspectPlanDO plan, Date date) throws Exception {
|
|
|
|
|
|
+ private void deal(IotInspectPlanDO plan, Date date) {
|
|
Date date1 = new Date();
|
|
Date date1 = new Date();
|
|
if ("hour".equals(plan.getPlanUnit())){
|
|
if ("hour".equals(plan.getPlanUnit())){
|
|
|
|
+ //todo
|
|
DateTime dateTime = DateUtil.offsetMinute(date, Integer.parseInt(StringUtils.substringBeforeLast(String.valueOf(plan.getPlanCycle()),".")));
|
|
DateTime dateTime = DateUtil.offsetMinute(date, Integer.parseInt(StringUtils.substringBeforeLast(String.valueOf(plan.getPlanCycle()),".")));
|
|
if (date1.compareTo(dateTime) > 0){
|
|
if (date1.compareTo(dateTime) > 0){
|
|
createPlan(plan);
|
|
createPlan(plan);
|
|
@@ -116,24 +113,21 @@ public class InspectCreateOrderJob implements JobHandler {
|
|
}
|
|
}
|
|
return personToDevices;
|
|
return personToDevices;
|
|
}
|
|
}
|
|
- private void createPlan(IotInspectPlanDO iotInspectPlan) throws Exception {
|
|
|
|
|
|
+ private void createPlan(IotInspectPlanDO iotInspectPlan) {
|
|
Map<Long, List<IotInspectRouteDO>> generate = generate(iotInspectPlan.getDeviceIds());
|
|
Map<Long, List<IotInspectRouteDO>> generate = generate(iotInspectPlan.getDeviceIds());
|
|
generate.forEach((k, v)->{
|
|
generate.forEach((k, v)->{
|
|
IotInspectOrderDO iotInspectOrderDO = new IotInspectOrderDO();
|
|
IotInspectOrderDO iotInspectOrderDO = new IotInspectOrderDO();
|
|
iotInspectOrderDO.setInspectOrderTitle(iotInspectPlan.getPlanTitle()+"-巡检工单");
|
|
iotInspectOrderDO.setInspectOrderTitle(iotInspectPlan.getPlanTitle()+"-巡检工单");
|
|
iotInspectOrderDO.setInspectOrderCode("IN"+ DateUtil.format(new Date(),"yyyyMMddHHmmss"));
|
|
iotInspectOrderDO.setInspectOrderCode("IN"+ DateUtil.format(new Date(),"yyyyMMddHHmmss"));
|
|
-// String collect = Arrays.stream(iotInspectPlan.getCharge().split(",")).map(charge -> "io" + charge + "io").collect(Collectors.joining(","));
|
|
|
|
iotInspectOrderDO.setCharge(k);
|
|
iotInspectOrderDO.setCharge(k);
|
|
iotInspectOrderDO.setStatus("todo");
|
|
iotInspectOrderDO.setStatus("todo");
|
|
-// iotInspectOrderDO.setDeviceIds(JSON.toJSONString(v));
|
|
|
|
iotInspectOrderDO.setType("计划生成");
|
|
iotInspectOrderDO.setType("计划生成");
|
|
iotInspectOrderDO.setPlanCode(iotInspectPlan.getPlanCode());
|
|
iotInspectOrderDO.setPlanCode(iotInspectPlan.getPlanCode());
|
|
iotInspectOrderDO.setDeleted(false);
|
|
iotInspectOrderDO.setDeleted(false);
|
|
AdminUserRespDTO user = adminUserApi.getUser(k);
|
|
AdminUserRespDTO user = adminUserApi.getUser(k);
|
|
iotInspectOrderDO.setChargeName(Objects.nonNull(user)?user.getNickname():"");
|
|
iotInspectOrderDO.setChargeName(Objects.nonNull(user)?user.getNickname():"");
|
|
- iotInspectOrderDO.setDeptId(iotInspectPlan.getDeptId());
|
|
|
|
|
|
+ iotInspectOrderDO.setDeptId(v.get(0).getDeptId());
|
|
iotInspectOrderMapper.insert(iotInspectOrderDO);
|
|
iotInspectOrderMapper.insert(iotInspectOrderDO);
|
|
- //List<IotInspectRouteDO> routeDOS = JSON.parseArray(v, IotInspectRouteDO.class);
|
|
|
|
List<IotInspectOrderDetailDO> results = new ArrayList<>();
|
|
List<IotInspectOrderDetailDO> results = new ArrayList<>();
|
|
//处理巡检项
|
|
//处理巡检项
|
|
List<IotInspectItemDO> items = iotInspectItemMapper.selectList();
|
|
List<IotInspectItemDO> items = iotInspectItemMapper.selectList();
|