|
@@ -56,7 +56,7 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
public boolean cascadingDeleteByKey(String id) {
|
|
|
int result = mapper.deleteByPrimaryKey(id);
|
|
|
Weekend<CheckProjectStandardRelation> weekend = new Weekend<>(CheckProjectStandardRelation.class);
|
|
|
- weekend.weekendCriteria().andEqualTo(CheckProjectStandardRelation::getStandardId,id);
|
|
|
+ weekend.weekendCriteria().andEqualTo(CheckProjectStandardRelation::getStandardId, id);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -79,13 +79,13 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
public void saveBatchByDTO(SbMeasureLogDTO model) {
|
|
|
List<SbInfo> sbInfos = new ArrayList<>();
|
|
|
// 检定校验 1、是否有非计量设备 2 、是否有未设置检定周期设备
|
|
|
- String info = validateMeasure(model.getSbIds(),sbInfos);
|
|
|
- if(StringUtils.isNotBlank(info)){
|
|
|
+ String info = validateMeasure(model.getSbIds(), sbInfos);
|
|
|
+ if (StringUtils.isNotBlank(info)) {
|
|
|
throw new DeniedException(info);
|
|
|
}
|
|
|
SbInfo updInfo = null;
|
|
|
- String serialNo = "B-"+DateUtils.dateToString(LocalDateTime.now(),DateUtils.PATTERNYMDHMS);
|
|
|
- for(SbInfo sbInfo : sbInfos){
|
|
|
+ String serialNo = "B-" + DateUtils.dateToString(LocalDateTime.now(), DateUtils.PATTERNYMDHMS);
|
|
|
+ for (SbInfo sbInfo : sbInfos) {
|
|
|
// 保存检定记录
|
|
|
model.setSbId(sbInfo.getId());
|
|
|
SbMeasureLog sbMeasureLog = super.saveModelByDTO(model);
|
|
@@ -106,16 +106,16 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private String validateMeasure(List<String> sbIds,List<SbInfo> sbInfos){
|
|
|
+ private String validateMeasure(List<String> sbIds, List<SbInfo> sbInfos) {
|
|
|
String info = "";
|
|
|
- for(String sbId : sbIds){
|
|
|
+ for (String sbId : sbIds) {
|
|
|
SbInfo sbInfo = sbInfoMapper.selectByPrimaryKey(sbId);
|
|
|
- if((!sbInfo.getUseType().equals(SbUseType.BGCL.getValue())) && (!sbInfo.getUseType().equals(SbUseType.TZSB.getValue()))){
|
|
|
- info = "非计量和非特种的设备, 无需填报检定记录,设备名称【"+sbInfo.getName() + "】";
|
|
|
+ if ((!sbInfo.getUseType().equals(SbUseType.BGCL.getValue())) && (!sbInfo.getUseType().equals(SbUseType.TZSB.getValue()))) {
|
|
|
+ info = "非计量和非特种的设备, 无需填报检定记录,设备名称【" + sbInfo.getName() + "】";
|
|
|
break;
|
|
|
}
|
|
|
- if(sbInfo.getCheckPeriod() == null){
|
|
|
- info = "检定设备的检定周期未设置,设备名称【"+sbInfo.getName() + "】";
|
|
|
+ if (sbInfo.getCheckPeriod() == null) {
|
|
|
+ info = "检定设备的检定周期未设置,设备名称【" + sbInfo.getName() + "】";
|
|
|
break;
|
|
|
}
|
|
|
sbInfos.add(sbInfo);
|
|
@@ -126,9 +126,9 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
@Override
|
|
|
public AbstractPageResultBean<SbMeasureLog> selectPageInfo(SbMeasureLogDTO record, int pageNum, int pageSize) {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
- if(record.getType() == null || record.getType() == 1){
|
|
|
+ if (record.getType() == null || record.getType() == 1) {
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
|
|
|
}
|
|
|
AbstractPageResultBean<SbMeasureLog> pageInfo = new MyPage(mapper.selectList(record));
|
|
@@ -142,128 +142,129 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
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);
|
|
|
- return null;
|
|
|
- }else{
|
|
|
- model.setCheckUserId(SecurityUtils.getUserInfo().getUserId()); // 谁操作即是检定记录人
|
|
|
- if(SbUseType.BGCL.getValue().equals(sbInfo.getUseType())){
|
|
|
- model.setType(1);
|
|
|
- }else if(SbUseType.TZSB.getValue().equals(sbInfo.getUseType())){
|
|
|
- model.setType(2);
|
|
|
- }
|
|
|
- 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);
|
|
|
- }
|
|
|
- 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+"】");
|
|
|
- // 位号变动,父设备也有可能变动
|
|
|
+ // 判断设备状态,如果是在库,修改设备状态即可
|
|
|
+
|
|
|
+ model.setCheckUserId(SecurityUtils.getUserInfo().getUserId()); // 谁操作即是检定记录人
|
|
|
+ if (SbUseType.BGCL.getValue().equals(sbInfo.getUseType())) {
|
|
|
+ model.setType(1);
|
|
|
+ } else if (SbUseType.TZSB.getValue().equals(sbInfo.getUseType())) {
|
|
|
+ model.setType(2);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
- List<SbLocation> locations = sbLocationMapper.select(location);
|
|
|
- if(locations != null && locations.size() > 0){
|
|
|
- sbInfo.setParentId(locations.get(0).getSbId());
|
|
|
+ if (sbLocationMapper.selectCount(location) == 0) {
|
|
|
+ insertLocation(model.getSbPositionNo(), sbInfo);
|
|
|
}
|
|
|
- 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);
|
|
|
+ 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());
|
|
|
}
|
|
|
- if(insertZzh){
|
|
|
- handleSbChangeRecord(remark4.toString(),model,tempInfo,CommonConstants.CHANGE_TYPE_SB_ZZH);
|
|
|
- }
|
|
|
- sbInfoMapper.updateByPrimaryKey(sbInfo);
|
|
|
- return sbMeasureLog;
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ // 更新设备状态
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ sbInfoMapper.updateByPrimaryKey(sbInfo);
|
|
|
+ return sbMeasureLog;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- private String getPureString(String info){
|
|
|
+ private String getPureString(String info) {
|
|
|
return StringUtils.isBlank(info) ? "" : info;
|
|
|
}
|
|
|
|
|
|
- private void insertLocation(String sbPositionNo,SbInfo sbInfo){
|
|
|
+ private void insertLocation(String sbPositionNo, SbInfo sbInfo) {
|
|
|
SbLocation location = new SbLocation();
|
|
|
location.setId(IdGeneratorUtils.getObjectId());
|
|
|
location.setNo(sbPositionNo);
|
|
@@ -278,12 +279,13 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
|
|
|
/**
|
|
|
* 保存变更记录
|
|
|
+ *
|
|
|
* @param remark
|
|
|
* @param model
|
|
|
* @param sb
|
|
|
* @param type
|
|
|
*/
|
|
|
- void handleSbChangeRecord(String remark,SbMeasureLogDTO model,SbInfo sb,String type){
|
|
|
+ void handleSbChangeRecord(String remark, SbMeasureLogDTO model, SbInfo sb, String type) {
|
|
|
SbChangeRecord record = new SbChangeRecord();
|
|
|
record.setId(IdGeneratorUtils.getObjectId());
|
|
|
record.setChangeType(Integer.parseInt(type));
|
|
@@ -292,7 +294,7 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
record.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
record.setCreatedUserName(SecurityUtils.getUserInfo().getUsername());
|
|
|
record.setSbId(sb.getId());
|
|
|
- switch (type){
|
|
|
+ switch (type) {
|
|
|
case CommonConstants.CHANGE_TYPE_SB_POSITION:
|
|
|
record.setOldPositionId(sb.getPositionId());
|
|
|
record.setPositionId(model.getSbPositionId());
|
|
@@ -305,7 +307,7 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
dto.setChangeType(record.getChangeType());
|
|
|
dto.setSbNoId(model.getSbPositionNo());
|
|
|
SbChangeRecord oldRecord = sbChangeRecordMapper.getLastOne(dto);
|
|
|
- if(oldRecord != null){
|
|
|
+ if (oldRecord != null) {
|
|
|
oldRecord.setEndTime(LocalDateTime.now());
|
|
|
sbChangeRecordMapper.updateByPrimaryKey(oldRecord);
|
|
|
}
|
|
@@ -328,19 +330,19 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
// 更新设备下次检定日期
|
|
|
SbInfo sbInfo = sbInfoMapper.selectByPrimaryKeyForUpdate(model.getSbId());
|
|
|
sbInfo.setCheckDate(model.getLastDate());
|
|
|
- if(sbInfo.getUseType().equals(SbUseType.BGCL.getValue())){
|
|
|
+ if (sbInfo.getUseType().equals(SbUseType.BGCL.getValue())) {
|
|
|
model.setType(1);
|
|
|
- }else if(sbInfo.getUseType().equals(SbUseType.BGCL.getValue())){
|
|
|
+ } else if (sbInfo.getUseType().equals(SbUseType.BGCL.getValue())) {
|
|
|
model.setType(2);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
throw new BusinessException("非计量和非特种的设备,无需填报检定记录");
|
|
|
}
|
|
|
super.modModelByDTO(model);
|
|
|
|
|
|
Integer checkPeriod = 12;// 默认12个月
|
|
|
- if(sbInfo.getCheckPeriod() != null){
|
|
|
+ if (sbInfo.getCheckPeriod() != null) {
|
|
|
checkPeriod = sbInfo.getCheckPeriod();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
throw new BusinessException("检定设备的检定周期未设置,无法计算下次检定日期,请先设置");
|
|
|
}
|
|
|
sbInfo.setNextCheckDate(model.getLastDate().minusMonths(-checkPeriod).minusDays(1));
|
|
@@ -385,10 +387,10 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
List<SysFile> checkImgList = ListUtils.newArrayList();
|
|
|
List<SysFile> checkFileList = ListUtils.newArrayList();
|
|
|
sysFiles.forEach(item -> {
|
|
|
- if (item.getType().equals( SysFileTypeEnum.Sb_MEASURE_IMGS.getValue())) {
|
|
|
+ if (item.getType().equals(SysFileTypeEnum.Sb_MEASURE_IMGS.getValue())) {
|
|
|
checkImgList.add(item);
|
|
|
}
|
|
|
- if (item.getType().equals( SysFileTypeEnum.Sb_MEASURE_FILES.getValue())) {
|
|
|
+ if (item.getType().equals(SysFileTypeEnum.Sb_MEASURE_FILES.getValue())) {
|
|
|
checkFileList.add(item);
|
|
|
}
|
|
|
});
|
|
@@ -398,16 +400,16 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<MeasureLogReportVO> getMonthReport(SbMeasureLogDTO sbMeasureLogDTO, Integer searchYear , LocalDate startMonth, LocalDate endMonth) {
|
|
|
+ public List<MeasureLogReportVO> getMonthReport(SbMeasureLogDTO sbMeasureLogDTO, Integer searchYear, LocalDate startMonth, LocalDate endMonth) {
|
|
|
List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
|
|
|
LocalDateTime searchStartTime = null;
|
|
|
LocalDateTime searchEndTime = null;
|
|
|
- if(searchYear != null){
|
|
|
+ if (searchYear != null) {
|
|
|
LocalDate localDate = LocalDate.now();
|
|
|
int year = localDate.getYear();
|
|
|
// 如2021-10-15号码,则month=10,需要计算到11月份,需要加1
|
|
|
int month = localDate.getMonthValue();
|
|
|
- if(searchYear<year){
|
|
|
+ if (searchYear < year) {
|
|
|
month = 12;
|
|
|
year = searchYear;
|
|
|
}
|
|
@@ -415,7 +417,7 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
// 当前年份只统计到当前月,历史年份统计全年
|
|
|
searchStartTime = DateUtils.getFirstDayOfThisYear(year);
|
|
|
searchEndTime = DateUtils.getLastDayOfMonth(year, month);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
monthStartAndEndList = DateUtils.getMonthStartAndEndByYear(startMonth, endMonth);
|
|
|
searchStartTime = DateUtils.getFirstDayOfMonth(startMonth);
|
|
|
searchEndTime = DateUtils.getLastDayOfMonth(endMonth);
|
|
@@ -426,7 +428,7 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
List<SbMeasureLogVO> list = mapper.selectList(sbMeasureLogDTO);
|
|
|
|
|
|
List<MeasureLogReportVO> result = new ArrayList<>();
|
|
|
- for(Map<String, LocalDateTime> map: monthStartAndEndList){
|
|
|
+ for (Map<String, LocalDateTime> map : monthStartAndEndList) {
|
|
|
MeasureLogReportVO vo = new MeasureLogReportVO();
|
|
|
List<SbMeasureLogVO> detailList = new ArrayList<>();
|
|
|
vo.setYear(map.get("searchStartTimeMonth").getYear());
|
|
@@ -435,17 +437,17 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
int totalFinishNum = 0;
|
|
|
int totalWaitNum = 0;
|
|
|
double finishRate = 0;
|
|
|
- for(SbMeasureLogVO sbMeasureLogVO: list){
|
|
|
- if(sbMeasureLogVO.getLastDate().isAfter(map.get("searchStartTimeMonth").toLocalDate()) && sbMeasureLogVO.getLastDate().isBefore(map.get("searchEndTimeMonth").toLocalDate())){
|
|
|
- totalNum ++;
|
|
|
- totalFinishNum ++;
|
|
|
+ for (SbMeasureLogVO sbMeasureLogVO : list) {
|
|
|
+ if (sbMeasureLogVO.getLastDate().isAfter(map.get("searchStartTimeMonth").toLocalDate()) && sbMeasureLogVO.getLastDate().isBefore(map.get("searchEndTimeMonth").toLocalDate())) {
|
|
|
+ totalNum++;
|
|
|
+ totalFinishNum++;
|
|
|
detailList.add(sbMeasureLogVO);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(totalNum != 0){
|
|
|
+ if (totalNum != 0) {
|
|
|
totalWaitNum = totalNum - totalFinishNum;
|
|
|
- finishRate = BigDecimalUtil.decimal(BigDecimalUtil.div(totalFinishNum*100, totalNum),2);
|
|
|
+ finishRate = BigDecimalUtil.decimal(BigDecimalUtil.div(totalFinishNum * 100, totalNum), 2);
|
|
|
}
|
|
|
vo.setTotalNum(totalNum);
|
|
|
// vo.setTotalFinishNum(totalFinishNum);
|
|
@@ -459,7 +461,7 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
|
|
|
@Override
|
|
|
public void saveBatchMeasureLog(BatchSbMeasureLog batchSbMeasureLog) {
|
|
|
- if(batchSbMeasureLog.getSbMeasureLogDTOList() != null && batchSbMeasureLog.getSbMeasureLogDTOList().size() > 0){
|
|
|
+ if (batchSbMeasureLog.getSbMeasureLogDTOList() != null && batchSbMeasureLog.getSbMeasureLogDTOList().size() > 0) {
|
|
|
batchSbMeasureLog.getSbMeasureLogDTOList().forEach(item -> {
|
|
|
this.saveModelByDTO(item);
|
|
|
});
|