|
|
@ -4,14 +4,21 @@ import java.text.SimpleDateFormat;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
|
|
|
|
import com.op.common.core.context.SecurityContextHolder;
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
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.core.web.domain.AjaxResult;
|
|
|
|
import com.op.device.domain.*;
|
|
|
|
import com.op.device.domain.*;
|
|
|
|
import com.op.device.mapper.*;
|
|
|
|
import com.op.device.mapper.*;
|
|
|
|
import com.op.system.api.domain.SysUser;
|
|
|
|
import com.op.system.api.domain.SysUser;
|
|
|
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import com.op.device.service.IEquPlanService;
|
|
|
|
import com.op.device.service.IEquPlanService;
|
|
|
|
|
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
|
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
|
|
|
|
import static com.op.common.core.web.domain.AjaxResult.success;
|
|
|
|
import static com.op.common.core.web.domain.AjaxResult.success;
|
|
|
|
|
|
|
|
|
|
|
@ -83,7 +90,100 @@ public class EquPlanServiceImpl implements IEquPlanService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@DS("#header.poolName")
|
|
|
|
@DS("#header.poolName")
|
|
|
|
public AjaxResult insertEquPlan(EquPlan equPlan) {
|
|
|
|
public AjaxResult insertEquPlan(EquPlan equPlan) {
|
|
|
|
|
|
|
|
// 处理计划信息
|
|
|
|
|
|
|
|
// 获取计划流水号
|
|
|
|
|
|
|
|
String planSerialNum = String.format("%03d", equPlanMapper.selectSerialNumber());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取当前所选工厂
|
|
|
|
|
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
|
|
|
|
|
String key = "#header.poolName";
|
|
|
|
|
|
|
|
String str = request.getHeader(key.substring(8));
|
|
|
|
|
|
|
|
int index = str.indexOf("_");
|
|
|
|
|
|
|
|
String factory = str.substring(index + 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
equPlan.setPlanId(IdUtils.fastSimpleUUID());
|
|
|
|
|
|
|
|
equPlan.setPlanCode((DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + planSerialNum));
|
|
|
|
|
|
|
|
equPlan.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));
|
|
|
|
|
|
|
|
equPlan.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));
|
|
|
|
|
|
|
|
equPlan.setFactoryCode(factory);
|
|
|
|
|
|
|
|
equPlan.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
equPlan.setCreateTime(DateUtils.getNowDate());
|
|
|
|
equPlan.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
equPlan.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
equPlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("1");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO:处理计划-巡检人员信息
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理计划1-n设备信息
|
|
|
|
|
|
|
|
List<EquPlanEqu> equipmentItemList = equPlan.getEquipmentItem();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计划-设备流水号
|
|
|
|
|
|
|
|
int equipmentCodeTemp = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (EquPlanEqu equipment : equipmentItemList) {
|
|
|
|
|
|
|
|
equipment.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
|
|
|
equipment.setCode("E"+equPlan.getPlanCode()+String.format("%02d", ++equipmentCodeTemp));
|
|
|
|
|
|
|
|
equipment.setParentCode(equPlan.getPlanCode());
|
|
|
|
|
|
|
|
equipment.setFactoryCode(factory);
|
|
|
|
|
|
|
|
equipment.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
equipment.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
equipment.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
equipment.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("2");
|
|
|
|
|
|
|
|
// 处理检查项信息
|
|
|
|
|
|
|
|
List<EquCheckItem> equCheckItemList = equipment.getEquCheckItemList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计划检查项流水号
|
|
|
|
|
|
|
|
int itemCodeTemp = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (EquCheckItem item : equCheckItemList) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EquPlanDetail planDetail = new EquPlanDetail();
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(item,planDetail);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
planDetail.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
|
|
|
planDetail.setCode("C"+equPlan.getPlanCode()+String.format("%02d", ++itemCodeTemp));
|
|
|
|
|
|
|
|
planDetail.setParentCode(equipment.getCode());
|
|
|
|
|
|
|
|
planDetail.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
planDetail.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
planDetail.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
planDetail.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("3");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理检查项详情
|
|
|
|
|
|
|
|
List<EquCheckItemDetail> equCheckItemDetailList = item.getEquCheckItemDetailList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 检查项详情流水号
|
|
|
|
|
|
|
|
int detailCodeTemp = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (EquCheckItemDetail detail : equCheckItemDetailList) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EquPlanStandard planStandard = new EquPlanStandard();
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(detail,planStandard);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
planStandard.setId(IdUtils.fastSimpleUUID());
|
|
|
|
|
|
|
|
planStandard.setCode("D"+equPlan.getPlanCode()+String.format("%02d", ++detailCodeTemp));
|
|
|
|
|
|
|
|
planStandard.setCreateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
planStandard.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
planStandard.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
planStandard.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO 详情插入数据库
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("4");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO 检查项详情为空则不生成检查项信息-检查项插入数据库
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO 设备插入数据库
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
return success();
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|