|
@@ -7,27 +7,22 @@ import com.platform.common.exception.BusinessException;
|
|
|
import com.platform.common.exception.DeniedException;
|
|
|
import com.platform.common.util.*;
|
|
|
import com.platform.dao.bean.MyPage;
|
|
|
-import com.platform.dao.dto.activiti.SbAllocateFormActiviti;
|
|
|
-import com.platform.dao.dto.check.CheckJobDTO;
|
|
|
import com.platform.dao.dto.sb.BatchSbMeasureLog;
|
|
|
+import com.platform.dao.dto.sb.SbChangeRecordDTO;
|
|
|
import com.platform.dao.dto.sb.SbMeasureLogDTO;
|
|
|
import com.platform.dao.entity.check.CheckProjectStandardRelation;
|
|
|
-import com.platform.dao.entity.customize.CustomFieldTemplate;
|
|
|
-import com.platform.dao.entity.customize.CustomFieldTemplateData;
|
|
|
+import com.platform.dao.entity.sb.SbChangeRecord;
|
|
|
import com.platform.dao.entity.sb.SbInfo;
|
|
|
+import com.platform.dao.entity.sb.SbLocation;
|
|
|
import com.platform.dao.entity.sb.SbMeasureLog;
|
|
|
import com.platform.dao.entity.upms.SysFile;
|
|
|
-import com.platform.dao.enums.*;
|
|
|
-import com.platform.dao.mapper.customize.CustomFieldTemplateDataMapper;
|
|
|
-import com.platform.dao.mapper.sb.SbInfoMapper;
|
|
|
-import com.platform.dao.mapper.sb.SbMeasureLogMapper;
|
|
|
-import com.platform.dao.mapper.sb.SbPositionMapper;
|
|
|
-import com.platform.dao.vo.query.check.CheckJobVO;
|
|
|
+import com.platform.dao.enums.SbUseType;
|
|
|
+import com.platform.dao.enums.SysFileTypeEnum;
|
|
|
+import com.platform.dao.enums.YesNoEnum;
|
|
|
+import com.platform.dao.mapper.sb.*;
|
|
|
import com.platform.dao.vo.query.sb.SbMeasureLogVO;
|
|
|
-import com.platform.dao.vo.report.CheckJobReportVO;
|
|
|
import com.platform.dao.vo.report.MeasureLogReportVO;
|
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
|
-import com.platform.service.repair.strategy.impl.AllocateRepairBaseStrategy;
|
|
|
import com.platform.service.sb.SbMeasureLogService;
|
|
|
import com.platform.service.upms.SysFileService;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -53,7 +48,9 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
private SbInfoMapper sbInfoMapper;
|
|
|
private final SysFileService sysFileService;
|
|
|
private final SbPositionMapper sbPositionMapper;
|
|
|
- private final CustomFieldTemplateDataMapper customFieldTemplateDataMapper;
|
|
|
+ private final SbLocationMapper sbLocationMapper;
|
|
|
+ private final SbChangeRecordMapper sbChangeRecordMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public boolean cascadingDeleteByKey(String id) {
|
|
|
int result = mapper.deleteByPrimaryKey(id);
|
|
@@ -145,6 +142,10 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
model.setId(sbMeasureLog.getId());
|
|
|
// 更新设备下次检定日期
|
|
|
SbInfo sbInfo = sbInfoMapper.selectByPrimaryKey(model.getSbId());
|
|
|
+ SbInfo tempInfo = new SbInfo();
|
|
|
+ tempInfo.setId(sbInfo.getId());
|
|
|
+ tempInfo.setParentId(sbInfo.getParentId());
|
|
|
+ tempInfo.setPositionId(sbInfo.getPositionId());
|
|
|
if(sbInfo.getUseType().equals(SbUseType.BGCL.getValue())){
|
|
|
model.setType(1);
|
|
|
}else if(sbInfo.getUseType().equals(SbUseType.BGCL.getValue())){
|
|
@@ -166,40 +167,59 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
sbInfo.setDph(model.getRequirement());// 检定人
|
|
|
sbInfo.setMeasureStatus(YesNoEnum.NO.getValue());// 每次检定后, 检定状态改为正常
|
|
|
sbInfo.setCheckPeriod(model.getCheckPeriod()); // 检定周期
|
|
|
- // sbInfo.setStatus(model.getSbStatus());// 每次检定后,状态变更也要更新
|
|
|
// 设备位置变动
|
|
|
StringBuilder remark = new StringBuilder();
|
|
|
- boolean insertAllocate = Boolean.FALSE;
|
|
|
+ boolean insertAllocate = Boolean.FALSE; // 设备位置
|
|
|
+ boolean insertParent = Boolean.FALSE; // 父设备
|
|
|
+ boolean insertNo = Boolean.FALSE; // 设备位号
|
|
|
String oldPositionId = getPureString(sbInfo.getPositionId());
|
|
|
String oldParentId = getPureString(sbInfo.getParentId());
|
|
|
String positionId = getPureString(model.getSbPositionId());
|
|
|
String parentId = getPureString(model.getSbParentId());
|
|
|
+ String oldSbPositionNo = getPureString(sbInfo.getPositionNo()); // 设备位号
|
|
|
+ String positionNo = getPureString(model.getSbPositionNo());
|
|
|
if(!oldPositionId.equals(positionId)){
|
|
|
insertAllocate = Boolean.TRUE;
|
|
|
sbInfo.setPositionId(positionId);
|
|
|
- remark.append("设备位置变动【" + sbPositionMapper.selectNameById(oldPositionId)).append("】-》");
|
|
|
- remark.append("【" + sbPositionMapper.selectNameById(positionId) + "】\n");
|
|
|
+ String before = oldPositionId == "" ? oldPositionId : sbPositionMapper.selectNameById(oldPositionId);
|
|
|
+ remark.append("设备位置变动【" + before).append("】 ---> ");
|
|
|
+ String after = positionId == "" ? positionId : sbPositionMapper.selectNameById(positionId);
|
|
|
+ remark.append("【" + after + "】");
|
|
|
}
|
|
|
if(!oldParentId.equals(parentId)){
|
|
|
- insertAllocate = Boolean.TRUE;
|
|
|
+ insertParent = Boolean.TRUE;
|
|
|
sbInfo.setParentId(parentId);
|
|
|
- remark.append("父设备变动【" + sbInfo.getName()).append("】-》");
|
|
|
- remark.append("【" + sbInfoMapper.selectNameById(parentId) + "】\n");
|
|
|
+ remark.append("父设备变动【" + sbInfo.getName()).append("】 ---> ");
|
|
|
+ String after = parentId == "" ? parentId : sbInfoMapper.selectNameById(parentId);
|
|
|
+ remark.append("【" + after + "】");
|
|
|
+ }
|
|
|
+ if(!oldSbPositionNo.equals(positionNo)){
|
|
|
+ insertNo = Boolean.TRUE;
|
|
|
+ remark.append("设备位号变动【"+sbInfo.getPositionNo()).append("】 ---> ");
|
|
|
+ remark.append("【"+positionNo+"】");
|
|
|
+ // 位号变动,父设备也有可能变动
|
|
|
+ SbLocation location = new SbLocation();
|
|
|
+ location.setNo(positionNo);
|
|
|
+ List<SbLocation> locations = sbLocationMapper.select(location);
|
|
|
+ if(locations != null && locations.size() > 0){
|
|
|
+ sbInfo.setParentId(locations.get(0).getSbId());
|
|
|
+ }
|
|
|
+ sbInfo.setPositionNo(model.getSbPositionNo()); // 设备位号
|
|
|
}
|
|
|
- sbInfoMapper.updateByPrimaryKey(sbInfo);
|
|
|
// 保存文件
|
|
|
sysFileService.saveFile(model.getId(), SysFileTypeEnum.Sb_MEASURE_IMGS.getValue(), model.getCheckImgList());
|
|
|
sysFileService.saveFile(model.getId(), SysFileTypeEnum.Sb_MEASURE_FILES.getValue(), model.getCheckFileList());
|
|
|
// 写入调拨记录
|
|
|
if(insertAllocate){
|
|
|
- handleSbInfoAllocate(remark.toString(),model,sbInfo.getName());
|
|
|
+ handleSbChangeRecord(remark.toString(),model,tempInfo,CommonConstants.CHANGE_TYPE_SB_POSITION);
|
|
|
}
|
|
|
- // 保存参数
|
|
|
- /* List<CheckStandardParamDTO> paramList = model.getParamList();
|
|
|
- paramList.forEach(item -> {
|
|
|
- item.setStandardId(sbMeasureLog.getId());
|
|
|
- });
|
|
|
- paramService.saveModelListByDTO(paramList);*/
|
|
|
+ if(insertParent){
|
|
|
+ handleSbChangeRecord(remark.toString(),model,tempInfo,CommonConstants.CHANGE_TYPE_SB_PARENT);
|
|
|
+ }
|
|
|
+ if(insertNo){
|
|
|
+ handleSbChangeRecord(remark.toString(),model,tempInfo,CommonConstants.CHANGE_TYPE_SB_NO);
|
|
|
+ }
|
|
|
+ sbInfoMapper.updateByPrimaryKey(sbInfo);
|
|
|
return sbMeasureLog;
|
|
|
}
|
|
|
|
|
@@ -207,25 +227,46 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
return StringUtils.isBlank(info) ? "" : info;
|
|
|
}
|
|
|
|
|
|
- void handleSbInfoAllocate(String remark,SbMeasureLogDTO model,String sbName){
|
|
|
- CustomFieldTemplateData data = new CustomFieldTemplateData();
|
|
|
- data.setId(IdGeneratorUtils.getObjectId());
|
|
|
- data.setCreatedTime(LocalDateTime.now());
|
|
|
- data.setCreatedUserName(SecurityUtils.getUserInfo().getUsername());
|
|
|
- data.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
- data.setObjId(model.getSbId());
|
|
|
- data.setRemark(CommonConstants.SB_ALLOCATE_FORM);
|
|
|
- data.setStatus(CustomFieldTemplateDataStatusEnum.SUCCESS.getValue());
|
|
|
- data.setType(CustomFieldTemplateDataTypeEnum.ACTIVITY_FORM.getValue());
|
|
|
- // 封装具体data
|
|
|
- SbAllocateFormActiviti allocate = new SbAllocateFormActiviti();
|
|
|
- allocate.setStartTime(LocalDateTime.now());
|
|
|
- allocate.setEndTime(LocalDateTime.now());
|
|
|
- allocate.setRemark(remark);
|
|
|
- allocate.setTitle("计量记录【"+sbName+"】");
|
|
|
- data.setData(JsonUtils.objectToJson(allocate));
|
|
|
- data.setDelFlag(0);
|
|
|
- customFieldTemplateDataMapper.insert(data);
|
|
|
+ /**
|
|
|
+ * 保存变更记录
|
|
|
+ * @param remark
|
|
|
+ * @param model
|
|
|
+ * @param sb
|
|
|
+ * @param type
|
|
|
+ */
|
|
|
+ void handleSbChangeRecord(String remark,SbMeasureLogDTO model,SbInfo sb,String type){
|
|
|
+ SbChangeRecord record = new SbChangeRecord();
|
|
|
+ record.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ record.setChangeType(Integer.parseInt(type));
|
|
|
+ record.setContent(remark);
|
|
|
+ record.setCreatedTime(LocalDateTime.now());
|
|
|
+ record.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
+ record.setCreatedUserName(SecurityUtils.getUserInfo().getUsername());
|
|
|
+ record.setSbId(sb.getId());
|
|
|
+ switch (type){
|
|
|
+ case CommonConstants.CHANGE_TYPE_SB_POSITION:
|
|
|
+ record.setOldPositionId(sb.getPositionId());
|
|
|
+ record.setPositionId(model.getSbPositionId());
|
|
|
+ break;
|
|
|
+ case CommonConstants.CHANGE_TYPE_SB_NO:
|
|
|
+ record.setSbNoId(model.getSbPositionNo());
|
|
|
+ record.setStartTime(LocalDateTime.now());
|
|
|
+ // 将之前位置编号的结束时间修正
|
|
|
+ SbChangeRecordDTO dto = new SbChangeRecordDTO();
|
|
|
+ dto.setChangeType(record.getChangeType());
|
|
|
+ dto.setSbNoId(model.getSbPositionNo());
|
|
|
+ SbChangeRecord oldRecord = sbChangeRecordMapper.getLastOne(dto);
|
|
|
+ if(oldRecord != null){
|
|
|
+ oldRecord.setEndTime(LocalDateTime.now());
|
|
|
+ sbChangeRecordMapper.updateByPrimaryKey(oldRecord);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case CommonConstants.CHANGE_TYPE_SB_PARENT:
|
|
|
+ record.setOldParentId(sb.getParentId());
|
|
|
+ record.setParentId(model.getSbParentId());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ sbChangeRecordMapper.insert(record);
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -327,7 +368,6 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
searchStartTime = DateUtils.getFirstDayOfMonth(startMonth);
|
|
|
searchEndTime = DateUtils.getLastDayOfMonth(endMonth);
|
|
|
}
|
|
|
-
|
|
|
// 总数
|
|
|
sbMeasureLogDTO.setSearchStartTime(searchStartTime);
|
|
|
sbMeasureLogDTO.setSearchEndTime(searchEndTime);
|