|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
package com.op.device.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
|
import com.op.common.core.utils.uuid.IdUtils;
|
|
|
|
|
import com.op.common.core.web.domain.AjaxResult;
|
|
|
|
|
import com.op.common.security.utils.SecurityUtils;
|
|
|
|
|
import com.op.device.domain.*;
|
|
|
|
@ -10,8 +12,10 @@ import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static com.op.common.core.web.domain.AjaxResult.error;
|
|
|
|
@ -32,6 +36,26 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private EquOrderMapper equOrderMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private EquOrderDetailMapper equOrderDetailMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private EquPlanDetailMapper equPlanDetailMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private EquPlanEquMapper equPlanEquMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private EquOrderEquMapper equOrderEquMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private EquPlanStandardMapper equPlanStandardMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private EquOrderStandardMapper equOrderStandardMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private EquPlanPersonMapper equPlanPersonMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private EquOrderPersonMapper equOrderPersonMapper;
|
|
|
|
|
/**
|
|
|
|
|
* 根据点检计划生成点检任务
|
|
|
|
|
* **/
|
|
|
|
@ -42,13 +66,12 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
|
|
|
|
|
equPlan.setPlanType("spotInspection");
|
|
|
|
|
List<EquPlan> plans = deviceTaskMapper.getPlans(equPlan);
|
|
|
|
|
for(EquPlan plan:plans){
|
|
|
|
|
if("day".equals(plan.getPlanLoopType())){
|
|
|
|
|
EquOrder order = new EquOrder();
|
|
|
|
|
order.setPlanType("spotInspection");
|
|
|
|
|
EquOrder hasTask = deviceTaskMapper.getNewTaskOrder(order);
|
|
|
|
|
if(hasTask==null || Integer.parseInt(plan.getPlanLoop())<= hasTask.getDays()){
|
|
|
|
|
//生成点检计划
|
|
|
|
|
this.createSpotCheckPlan(plan);
|
|
|
|
|
EquOrder hasTask = deviceTaskMapper.getNewTaskOrder(plan);
|
|
|
|
|
if(hasTask==null || Integer.parseInt(plan.getPlanLoop())<= hasTask.getDays()){
|
|
|
|
|
//生成点检计划
|
|
|
|
|
int m = this.createSpotCheckPlan(plan);
|
|
|
|
|
if(m==0){
|
|
|
|
|
error("equ_order相关添加失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -57,13 +80,95 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int createSpotCheckPlan(EquPlan plan){
|
|
|
|
|
/**equ_order**/
|
|
|
|
|
Date nowtime = DateUtils.getNowDate();
|
|
|
|
|
String createBy = SecurityUtils.getUsername();
|
|
|
|
|
int sce = 0;
|
|
|
|
|
/**equ_plan->equ_order********************************************************************/
|
|
|
|
|
EquOrder order = new EquOrder();
|
|
|
|
|
//源->目标
|
|
|
|
|
BeanUtils.copyProperties(plan,order);
|
|
|
|
|
equOrderMapper.insertEquOrder(order);
|
|
|
|
|
/**equ_order_detail**/
|
|
|
|
|
List<EquOrderDetail> details = new ArrayList<>();
|
|
|
|
|
order.setOrderId(IdUtils.fastSimpleUUID());
|
|
|
|
|
order.setCreateBy(createBy);
|
|
|
|
|
order.setCreateTime(nowtime);
|
|
|
|
|
// 流水号
|
|
|
|
|
String serialNum = String.format("%03d",equOrderMapper.selectSerialNumber());
|
|
|
|
|
String orderCode = "O"+DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+serialNum;
|
|
|
|
|
order.setOrderCode(orderCode);
|
|
|
|
|
/**equ_order**/
|
|
|
|
|
sce = equOrderMapper.insertEquOrder(order);
|
|
|
|
|
|
|
|
|
|
/**equ_plan_equ->equ_order_equ*************************************************************/
|
|
|
|
|
EquPlanEqu equPlanEqu = new EquPlanEqu();
|
|
|
|
|
equPlanEqu.setId(plan.getPlanEquId());
|
|
|
|
|
List<EquPlanEqu> equs = equPlanEquMapper.selectEquPlanEquList(equPlanEqu);
|
|
|
|
|
if(CollectionUtils.isEmpty(equs)){
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
String orderEquId = IdUtils.fastSimpleUUID();
|
|
|
|
|
//equs一定就一个实值
|
|
|
|
|
for(EquPlanEqu equ:equs){
|
|
|
|
|
equ.setId(orderEquId);
|
|
|
|
|
equ.setCreateTime(nowtime);
|
|
|
|
|
equ.setCreateBy(createBy);
|
|
|
|
|
equ.setDelFlag("0");
|
|
|
|
|
equ.setCode(orderCode);
|
|
|
|
|
}
|
|
|
|
|
sce = equOrderEquMapper.insertEquOrderEqus(equs);
|
|
|
|
|
/**equ_plan_detail->equ_order_detail*******************************************************/
|
|
|
|
|
EquPlanDetail itqo = new EquPlanDetail();
|
|
|
|
|
itqo.setParentCode(plan.getPlanEquId());
|
|
|
|
|
itqo.setDelFlag("0");
|
|
|
|
|
List<EquPlanDetail> details = equPlanDetailMapper.selectEquPlanDetailList(itqo);
|
|
|
|
|
if(CollectionUtils.isEmpty(details)){
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
List<EquPlanStandard> standards = new ArrayList<>();
|
|
|
|
|
List<EquPlanStandard> standards0 = null;
|
|
|
|
|
for(EquPlanDetail itme:details){
|
|
|
|
|
String detailId = IdUtils.fastSimpleUUID();
|
|
|
|
|
EquPlanStandard standardqo = new EquPlanStandard();
|
|
|
|
|
//equ_plan_detail的id
|
|
|
|
|
standardqo.setParentCode(itme.getId());
|
|
|
|
|
standards0 = equPlanStandardMapper.selectEquPlanStandardList(standardqo);
|
|
|
|
|
for(EquPlanStandard standard:standards0) {
|
|
|
|
|
standard.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
standard.setCreateTime(nowtime);
|
|
|
|
|
standard.setCreateBy(createBy);
|
|
|
|
|
standard.setDelFlag("0");
|
|
|
|
|
standard.setPlanCode(orderCode);
|
|
|
|
|
standard.setParentCode(detailId);
|
|
|
|
|
}
|
|
|
|
|
standards.addAll(standards0);
|
|
|
|
|
|
|
|
|
|
itme.setId(detailId);
|
|
|
|
|
itme.setCreateTime(nowtime);
|
|
|
|
|
itme.setCreateBy(createBy);
|
|
|
|
|
itme.setDelFlag("0");
|
|
|
|
|
itme.setParentCode(orderEquId);
|
|
|
|
|
}
|
|
|
|
|
sce = equOrderDetailMapper.insertEquOrderDetails(details);
|
|
|
|
|
/**equ_plan_standard->equ_order_standard*******************************************************/
|
|
|
|
|
if(CollectionUtils.isEmpty(standards)){
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
sce = equOrderStandardMapper.insertEquOrderStandards(standards);
|
|
|
|
|
/**equ_plan_person->equ_order_person*********************************************************/
|
|
|
|
|
EquPlanPerson equPlanPerson = new EquPlanPerson();
|
|
|
|
|
equPlanPerson.setPlanCode(plan.getPlanCode());
|
|
|
|
|
List<EquPlanPerson> persons = equPlanPersonMapper.selectEquPlanPersonList(equPlanPerson);
|
|
|
|
|
if(CollectionUtils.isEmpty(persons)){
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(EquPlanPerson person:persons){
|
|
|
|
|
person.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
person.setCreateTime(nowtime);
|
|
|
|
|
person.setCreateBy(createBy);
|
|
|
|
|
person.setDelFlag("0");
|
|
|
|
|
person.setPlanCode(orderCode);
|
|
|
|
|
}
|
|
|
|
|
sce = equOrderPersonMapper.insertEquOrderPlans(persons);
|
|
|
|
|
return sce;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|