3254194295 1 年間 前
コミット
bba0f95842

+ 21 - 9
platform-service/src/main/java/com/platform/service/sb/impl/SbStatusLogServiceImpl.java

@@ -74,6 +74,16 @@ public class SbStatusLogServiceImpl extends BaseServiceImpl<SbStatusLogMapper, S
         sbInfo.setUpdateUserName(realName);
         sbInfoMapper.updateByPrimaryKeySelective(sbInfo);
 
+        SbInfoDTO info = new SbInfoDTO();
+        info.setId(model.getSbId());
+        SbInfo sbInfoVOS = sbInfoMapper.selectByPrimaryKey(model.getSbId());
+        if (sbInfoVOS.getPositionId()!=null){
+            SbPosition position = sbPositionMapper.selectByPrimaryKey(sbInfoVOS.getPositionId());
+            if (position!=null){
+                sbInfoVOS.setPositionName(position.getName());
+            }
+        }
+
         SbStatusLog sbStatusLog = super.saveModelByDTO(model);
         // 新增停机记录
         if(model.getAfterStatus() !=null && model.getAfterStatus().equals(SbInfoStatusEnum.IN_STOP.getValue())){
@@ -90,15 +100,7 @@ public class SbStatusLogServiceImpl extends BaseServiceImpl<SbStatusLogMapper, S
             stopLog.setUpdateUserId(userId);
             sbStopLogMapper.insert(stopLog);
             if (model.getSbId()!=null) {
-                SbInfoDTO info = new SbInfoDTO();
-                info.setId(model.getSbId());
-                SbInfo sbInfoVOS = sbInfoMapper.selectByPrimaryKey(model.getSbId());
-                if (sbInfoVOS.getPositionId()!=null){
-                    SbPosition position = sbPositionMapper.selectByPrimaryKey(sbInfoVOS.getPositionId());
-                    if (position!=null){
-                        sbInfoVOS.setPositionName(position.getName());
-                    }
-                }
+
                     List<SbMeasureLog> measureLogs = new ArrayList<>();
                     if (sbInfoVOS != null ) {
 //                        for (SbInfoVO vo : sbInfoVOS) {
@@ -137,6 +139,16 @@ public class SbStatusLogServiceImpl extends BaseServiceImpl<SbStatusLogMapper, S
                 stopLog.setUpdateUserId(userId);
                 sbStopLogMapper.updateByPrimaryKey(stopLog);
             }
+            SbMeasureLog log = new SbMeasureLog();
+            log.setOtherType(SbMeasureLogOtherTypeEnum.IN_USE.getValue());
+            log.setId(IdGeneratorUtils.getObjectId());
+            setCreateUserInfo(log);
+            log.setSbId(sbInfo.getId());
+            String str = "设备位号为:" + (sbInfoVOS.getPositionNo() == null ? "" : sbInfoVOS.getPositionNo() )+ ",设备位置为:" + (sbInfoVOS.getPositionName() == null ? "" : sbInfoVOS.getPositionName()) + "的设备:" + sbInfoVOS.getName() + "于" + log.getCreatedTime() + "被" + log.getCreatedUserName() + "启用";
+//                            stringBuffer.append("设备位号为:" + vo.getPositionNo() == null ? "" : vo.getPositionNo() + ",设备位置为:" + vo.getPositionName() == null ? "" : vo.getPositionName() + "的设备:" + vo.getName() + "于" + log.getCreatedTime() + "被" + log.getCreatedUserName() + "停用");
+//                            log.setContent(stringBuffer.toString());
+            log.setContent(str);
+            sbMeasureLogMapper.insert(log);
         }
         return sbStatusLog;
     }