|
|
@ -6,14 +6,22 @@ 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.context.SecurityContextHolder;
|
|
|
|
|
|
|
|
import com.op.common.core.domain.BaseFileData;
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
|
|
|
|
import com.op.common.core.utils.StringUtils;
|
|
|
|
|
|
|
|
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.common.security.utils.SecurityUtils;
|
|
|
|
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.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.IEquOrderService;
|
|
|
|
import com.op.device.service.IEquOrderService;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
@ -39,6 +47,8 @@ public class EquOrderServiceImpl implements IEquOrderService {
|
|
|
|
private PersonMapper personMapper;
|
|
|
|
private PersonMapper personMapper;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private EquOrderEquSpareMapper equOrderEquSpareMapper;
|
|
|
|
private EquOrderEquSpareMapper equOrderEquSpareMapper;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private EquRepairOrderMapper equRepairOrderMapper;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询计划工单
|
|
|
|
* 查询计划工单
|
|
|
@ -125,25 +135,102 @@ public class EquOrderServiceImpl implements IEquOrderService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@DS("#header.poolName")
|
|
|
|
@DS("#header.poolName")
|
|
|
|
public AjaxResult updateEquOrder(EquOrder equOrder) {
|
|
|
|
public AjaxResult updateEquOrder(EquOrder equOrder) {
|
|
|
|
// 更新工单信息
|
|
|
|
boolean hasError = false;
|
|
|
|
equOrder.setOrderStart(equOrder.getTimeArray().get(0));
|
|
|
|
|
|
|
|
equOrder.setOrderEnd(equOrder.getTimeArray().get(1));
|
|
|
|
|
|
|
|
equOrder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
equOrder.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
equOrder.setPlanPerson(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
equOrderMapper.updateEquOrder(equOrder);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新标准信息
|
|
|
|
|
|
|
|
EquOrderEqu equ = equOrder.getEqu();
|
|
|
|
EquOrderEqu equ = equOrder.getEqu();
|
|
|
|
List<EquOrderDetail> detailList = equ.getDetailList();
|
|
|
|
List<EquOrderDetail> detailList = equ.getDetailList();
|
|
|
|
for (EquOrderDetail detail : detailList) {
|
|
|
|
for (EquOrderDetail detail : detailList) {
|
|
|
|
List<EquOrderStandard> standardList = detail.getStandardList();
|
|
|
|
List<EquOrderStandard> standardList = detail.getStandardList();
|
|
|
|
for (EquOrderStandard standard : standardList) {
|
|
|
|
for (EquOrderStandard standard : standardList) {
|
|
|
|
standard.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
|
|
|
|
//上传附件
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(standard.getPicturePath())) {
|
|
|
|
|
|
|
|
String[] ids = standard.getPicturePath().split(",");
|
|
|
|
|
|
|
|
List<BaseFileData> files = new ArrayList<>();
|
|
|
|
|
|
|
|
BaseFileData file = null;
|
|
|
|
|
|
|
|
for (String id : ids) {
|
|
|
|
|
|
|
|
file = new BaseFileData();
|
|
|
|
|
|
|
|
file.setFileId(IdUtils.fastSimpleUUID());
|
|
|
|
|
|
|
|
file.setFileName(id.split("&fileName=")[1]);
|
|
|
|
|
|
|
|
file.setFileAddress(id);
|
|
|
|
|
|
|
|
file.setSourceId(standard.getId());
|
|
|
|
|
|
|
|
file.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
|
|
|
file.setCreateTime(new Date());
|
|
|
|
|
|
|
|
files.add(file);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
equOrderStandardMapper.insertBaseFileBatch(files);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 校验标准信息-是否申请报修
|
|
|
|
|
|
|
|
if (standard.getStandardType().equals("quantify")) {
|
|
|
|
|
|
|
|
int up = standard.getActualValue().compareTo(standard.getDetailUpLimit());
|
|
|
|
|
|
|
|
int down = standard.getActualValue().compareTo(standard.getDetailDownLimit());
|
|
|
|
|
|
|
|
if (!(up != 1 && down != -1)) {
|
|
|
|
|
|
|
|
hasError = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
// TODO 未达标
|
|
|
|
|
|
|
|
if (standard.getDetailReach().equals("1")) {
|
|
|
|
|
|
|
|
hasError = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新标准
|
|
|
|
standard.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
standard.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
equOrderStandardMapper.updateEquOrderStandard(standard);
|
|
|
|
equOrderStandardMapper.updateEquOrderStandard(standard);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新工单信息
|
|
|
|
|
|
|
|
equOrder.setOrderStatus("1"); // 状态为已完成
|
|
|
|
|
|
|
|
equOrder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
equOrder.setUpdateBy(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
equOrder.setPlanPerson(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
equOrder.setPlanPerson(SecurityContextHolder.getUserName());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean checkRepair = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (equOrder.getRepairCode() == null){
|
|
|
|
|
|
|
|
checkRepair = true;
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
if (equOrder.getRepairCode().isEmpty()){
|
|
|
|
|
|
|
|
checkRepair = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (checkRepair && hasError ) {
|
|
|
|
|
|
|
|
// 获取故障报修流水号
|
|
|
|
|
|
|
|
EquRepairOrder equRepairOrder = new EquRepairOrder();
|
|
|
|
|
|
|
|
String serialNum = String.format("%03d", equRepairOrderMapper.selectOrderCodeSerialNumber());
|
|
|
|
|
|
|
|
String equipmentCode = equOrder.getEquipmentCode();
|
|
|
|
|
|
|
|
//报修单号
|
|
|
|
|
|
|
|
equRepairOrder.setOrderCode("BX"+DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + equipmentCode + serialNum);
|
|
|
|
|
|
|
|
//在主表中存入报修单号信息
|
|
|
|
|
|
|
|
equOrder.setRepairCode(equRepairOrder.getOrderCode());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//新增报修记录
|
|
|
|
|
|
|
|
equRepairOrder.setOrderId(IdUtils.fastSimpleUUID());
|
|
|
|
|
|
|
|
equRepairOrder.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
equRepairOrder.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
|
|
|
// 报修来源
|
|
|
|
|
|
|
|
if (equOrder.getPlanType().equals("inspection")){
|
|
|
|
|
|
|
|
equRepairOrder.setOrderSource("巡检");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (equOrder.getPlanType().equals("spotInspection")){
|
|
|
|
|
|
|
|
equRepairOrder.setOrderSource("点检");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (equOrder.getPlanType().equals("maintenance")){
|
|
|
|
|
|
|
|
equRepairOrder.setOrderSource("保养");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
equRepairOrder.setOrderStatus("待审核");
|
|
|
|
|
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
|
|
|
|
|
String key = "#header.poolName";
|
|
|
|
|
|
|
|
equRepairOrder.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_",""));
|
|
|
|
|
|
|
|
equRepairOrderMapper.insertEquRepairOrder(equRepairOrder);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新工单信息
|
|
|
|
|
|
|
|
equOrderMapper.updateEquOrder(equOrder);
|
|
|
|
return success();
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|