|
@@ -159,8 +159,6 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
model.setType(1);
|
|
|
}else if(sbInfo.getUseType().equals(SbUseType.BGCL.getValue())){
|
|
|
model.setType(2);
|
|
|
- }else{
|
|
|
- throw new BusinessException("非计量和非特种的设备, 无需填报检定记录");
|
|
|
}
|
|
|
sbInfo.setCheckDate(model.getLastDate());
|
|
|
Integer checkPeriod = 0;// 默认12个月
|
|
@@ -462,4 +460,122 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /*@Override
|
|
|
+ public void saveTZSBByDTTO(SbMeasureLogDTO model) {
|
|
|
+ // 更新设备下次检定日期
|
|
|
+ SbInfo sbInfo = sbInfoMapper.selectByPrimaryKey(model.getSbId());
|
|
|
+ SbInfo tempInfo = new SbInfo();
|
|
|
+ tempInfo.setId(sbInfo.getId());
|
|
|
+ // 判断设备状态,如果是在库,直接修改设备状态即可
|
|
|
+ if(model.getSbStatus()){
|
|
|
+ sbInfo.setStatus(SbInfoStatusEnum.IN_STORE.getValue());
|
|
|
+ String remark = "设备状态由【"+SbInfoStatusEnum.getNameByValue(sbInfo.getStatus())+"】 ---> 【";
|
|
|
+ remark += "在库】";
|
|
|
+ handleSbChangeRecord(remark,model,tempInfo,CommonConstants.CHANGE_TYPE_SB_STATUS);
|
|
|
+ }else{
|
|
|
+ model.setCheckUserId(SecurityUtils.getUserInfo().getUserId()); // 谁操作即是检定记录人
|
|
|
+ SbMeasureLog sbMeasureLog = super.saveModelByDTO(model);
|
|
|
+ model.setId(sbMeasureLog.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())){
|
|
|
+ model.setType(2);
|
|
|
+ }else{
|
|
|
+ throw new BusinessException("非计量和非特种的设备, 无需填报检定记录");
|
|
|
+ }
|
|
|
+ sbInfo.setCheckDate(model.getLastDate());
|
|
|
+ Integer checkPeriod = 0;// 默认12个月
|
|
|
+ if(model.getCheckPeriod() != null){
|
|
|
+ checkPeriod = model.getCheckPeriod();
|
|
|
+ }else{
|
|
|
+ throw new BusinessException("检定设备的检定周期未设置,无法计算下次检定日期,请先设置");
|
|
|
+ }
|
|
|
+ sbInfo.setNextCheckDate(model.getLastDate().minusMonths(-checkPeriod).minusDays(1));
|
|
|
+ sbInfo.setZaiz(model.getName());// 检定单位
|
|
|
+ sbInfo.setSbdh(model.getNo());// 检定编号
|
|
|
+ sbInfo.setRemark(model.getRemark());// 备注
|
|
|
+ sbInfo.setDph(model.getRequirement());// 检定人
|
|
|
+ sbInfo.setMeasureStatus(YesNoEnum.NO.getValue());// 每次检定后, 检定状态改为正常
|
|
|
+ sbInfo.setCheckPeriod(model.getCheckPeriod()); // 检定周期
|
|
|
+ // 设备位置变动
|
|
|
+ boolean insertAllocate = Boolean.FALSE; // 设备位置
|
|
|
+ boolean insertParent = Boolean.FALSE; // 父设备
|
|
|
+ boolean insertNo = Boolean.FALSE; // 设备位号
|
|
|
+ boolean insertZzh = 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());
|
|
|
+ String oldZzh = getPureString(sbInfo.getZzh()); // 原出厂编码
|
|
|
+ String zzh = getPureString(model.getZzh()); // 出厂编码
|
|
|
+ StringBuilder remark1 = new StringBuilder();
|
|
|
+ StringBuilder remark2 = new StringBuilder();
|
|
|
+ StringBuilder remark3 = new StringBuilder();
|
|
|
+ if(!oldPositionId.equals(positionId)){
|
|
|
+ insertAllocate = Boolean.TRUE;
|
|
|
+ sbInfo.setPositionId(positionId);
|
|
|
+ String before = oldPositionId == "" ? oldPositionId : sbPositionMapper.selectNameById(oldPositionId);
|
|
|
+ remark1.append("设备位置变动【" + before).append("】 ---> ");
|
|
|
+ String after = positionId == "" ? positionId : sbPositionMapper.selectNameById(positionId);
|
|
|
+ remark1.append("【" + after + "】");
|
|
|
+ }
|
|
|
+ if(!oldParentId.equals(parentId)){
|
|
|
+ insertParent = Boolean.TRUE;
|
|
|
+ sbInfo.setParentId(parentId);
|
|
|
+ remark2.append("父设备变动【" + sbInfo.getName()).append("】 ---> ");
|
|
|
+ String after = parentId == "" ? parentId : sbInfoMapper.selectNameById(parentId);
|
|
|
+ remark2.append("【" + after + "】");
|
|
|
+ }
|
|
|
+ if(!oldSbPositionNo.equals(positionNo)){
|
|
|
+ if(StringUtils.isNotBlank(sbInfo.getParentId())){
|
|
|
+ // 子设备判断,传输过来的位号,是否存在于sb_location
|
|
|
+ SbLocation location = new SbLocation();
|
|
|
+ location.setNo(positionNo);
|
|
|
+ if(sbLocationMapper.selectCount(location) == 0){
|
|
|
+ insertLocation(model.getSbPositionNo(),sbInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ insertNo = Boolean.TRUE;
|
|
|
+ remark3.append("设备位号变动【"+sbInfo.getPositionNo()).append("】 ---> ");
|
|
|
+ remark3.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()); // 设备位号
|
|
|
+ }
|
|
|
+ StringBuilder remark4 = new StringBuilder();
|
|
|
+ if(!oldZzh.equals(zzh)){
|
|
|
+ insertZzh = Boolean.TRUE;
|
|
|
+ remark4.append("设备原号变动【"+oldZzh).append("】 ---> ");
|
|
|
+ remark4.append("【"+zzh+"】");
|
|
|
+ sbInfo.setZzh(zzh);
|
|
|
+ }
|
|
|
+ // 保存文件
|
|
|
+ sysFileService.saveFile(model.getId(), SysFileTypeEnum.Sb_MEASURE_IMGS.getValue(), model.getCheckImgList());
|
|
|
+ sysFileService.saveFile(model.getId(), SysFileTypeEnum.Sb_MEASURE_FILES.getValue(), model.getCheckFileList());
|
|
|
+ // 写入调拨记录
|
|
|
+ if(insertAllocate){
|
|
|
+ handleSbChangeRecord(remark1.toString(),model,tempInfo,CommonConstants.CHANGE_TYPE_SB_POSITION);
|
|
|
+ }
|
|
|
+ if(insertParent){
|
|
|
+ handleSbChangeRecord(remark2.toString(),model,tempInfo,CommonConstants.CHANGE_TYPE_SB_PARENT);
|
|
|
+ }
|
|
|
+ if(insertNo){
|
|
|
+ handleSbChangeRecord(remark3.toString(),model,tempInfo,CommonConstants.CHANGE_TYPE_SB_NO);
|
|
|
+ }
|
|
|
+ if(insertZzh){
|
|
|
+ handleSbChangeRecord(remark4.toString(),model,tempInfo,CommonConstants.CHANGE_TYPE_SB_ZZH);
|
|
|
+ }
|
|
|
+ sbInfoMapper.updateByPrimaryKey(sbInfo);
|
|
|
+ }
|
|
|
+ }*/
|
|
|
}
|