浏览代码

机车表修改

gao.qiang 6 月之前
父节点
当前提交
b586a39a4d

+ 2 - 0
business-service/src/main/java/com/ozs/entity/BaseVehicleTerminal.java

@@ -65,4 +65,6 @@ public class BaseVehicleTerminal implements Serializable {
      * 备注
      */
     private String remark;
+    
+    private String ends;
 }

+ 5 - 1
business-service/src/main/java/com/ozs/entity/MsgAlarmExt.java

@@ -1,9 +1,11 @@
 package com.ozs.entity;
 
 import java.io.Serializable;
+import java.util.Date;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -46,5 +48,7 @@ public class MsgAlarmExt implements Serializable {
      */
     private String alarmAttPath;
 
-
+    /** 创建时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
 }

+ 2 - 0
business-service/src/main/java/com/ozs/entity/vo/BaseVehicleVo.java

@@ -62,4 +62,6 @@ public class BaseVehicleVo extends PageVo {
      * 挂载终端ID terminal_id
      */
     private long terminalId;
+    
+    private String ends;
 }

+ 1 - 1
business-service/src/main/java/com/ozs/mapper/BaseVehicleTerminalMapper.java

@@ -18,5 +18,5 @@ public interface BaseVehicleTerminalMapper extends BaseMapper<BaseVehicleTermina
 
     List<String> selectMountCode(@Param("vehicleCode") String vehicleCode);
 
-    BaseVehicleTerminal selectTerminal(@Param("vehicleCode") String vehicleCode);
+    BaseVehicleTerminal selectTerminal(@Param("vehicleCode") String vehicleCode,@Param("ends") String ends);
 }

+ 5 - 8
business-service/src/main/java/com/ozs/service/impl/BaseTerminalServiceImpl.java

@@ -75,14 +75,11 @@ public class BaseTerminalServiceImpl extends ServiceImpl<BaseTerminalMapper, Bas
             List<BaseTerminal> dto1 = pageR.getRecords().stream().map(o -> {
                 LambdaQueryWrapper<BaseVehicleTerminal> wrapper1 = new LambdaQueryWrapper<>();
                 wrapper1.eq(BaseVehicleTerminal::getTerminalCode, o.getTerminalCode());
-                BaseVehicleTerminal baseVehicleTerminal = baseVehicleTerminalMapper.selectOne(wrapper1);
-                if (!ObjectUtils.isEmpty(baseVehicleTerminal)) {
-                    LambdaQueryWrapper<BaseVehicle> wrapper2 = new LambdaQueryWrapper<>();
-                    wrapper2.eq(BaseVehicle::getVehicleCode, baseVehicleTerminal.getVehicleCode());
-                    BaseVehicle baseVehicle = baseVehicleMapper.selectOne(wrapper2);
-                    if (!ObjectUtils.isEmpty(baseVehicle)) {
-                        o.setVehicleCode(baseVehicle.getVehicleCode());
-                        o.setEnd(baseVehicle.getEnds());
+                List<BaseVehicleTerminal> baseVehicleTerminals = baseVehicleTerminalMapper.selectList(wrapper1);
+                if (!ObjectUtils.isEmpty(baseVehicleTerminals)) {
+                    for (BaseVehicleTerminal baseVehicleTerminal : baseVehicleTerminals) {
+                        o.setVehicleCode(baseVehicleTerminal.getVehicleCode());
+                        o.setEnd(baseVehicleTerminal.getEnds());
                     }
                 }
                 return o;

+ 35 - 33
business-service/src/main/java/com/ozs/service/impl/BaseVehicleServiceImpl.java

@@ -71,7 +71,7 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
                 .doSelectPage(() -> baseVehicleMapper.selectList(wrapper));
         if (!StringUtils.isEmptySunhh(page) && page.getResult().size() > 0) {
             List<BaseVehicle> dto1 = page.getResult().stream().map(o -> {
-                BaseVehicleTerminal baseVehicleTerminal = baseVehicleTerminalMapper.selectTerminal(o.getVehicleCode());
+                BaseVehicleTerminal baseVehicleTerminal = baseVehicleTerminalMapper.selectTerminal(o.getVehicleCode(),o.getEnds());
                 if (!StringUtils.isEmptySunhh(baseVehicleTerminal) && !StringUtils.isEmptySunhh(baseVehicleTerminal.getVehicleCode())) {
                     LambdaQueryWrapper<BaseTerminal> wrapperBaseTerminal = new LambdaQueryWrapper<>();
                     if (!StringUtils.isEmptySunhh(baseVehicleTerminal) && !StringUtils.isEmptySunhh(baseVehicleTerminal.getTerminalCode())) {
@@ -94,14 +94,14 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
 
     @Override
     public AjaxResult vehicleAdd(BaseVehicle baseVehicle, String userId) {
-        LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<BaseVehicle>();
-        if (!StringUtils.isEmptySunhh(baseVehicle) && !StringUtils.isEmptySunhh(baseVehicle.getVehicleCode())) {
-            wrapper.eq(BaseVehicle::getVehicleCode, baseVehicle.getVehicleCode());
-        }
-        List<BaseVehicle> baseVehicles = baseVehicleMapper.selectList(wrapper);
-        if (baseVehicles.size() > 0) {
-            return AjaxResult.error("机车号已存在!");
-        }
+//        LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<BaseVehicle>();
+//        if (!StringUtils.isEmptySunhh(baseVehicle) && !StringUtils.isEmptySunhh(baseVehicle.getVehicleCode())) {
+//            wrapper.eq(BaseVehicle::getVehicleCode, baseVehicle.getVehicleCode());
+//        }
+//        List<BaseVehicle> baseVehicles = baseVehicleMapper.selectList(wrapper);
+//        if (baseVehicles.size() > 0) {
+//            return AjaxResult.error("机车号已存在!");
+//        }
         Date date = new Date();
         baseVehicle.setCreateBy(userId);
         baseVehicle.setUpdateBy(userId);
@@ -117,17 +117,17 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
 
     @Override
     public AjaxResult vehicleUpdate(BaseVehicle baseVehicle, String userId) {
-        LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<>();
-        if (!StringUtils.isEmptySunhh(baseVehicle) && !StringUtils.isEmptySunhh(baseVehicle.getVehicleCode())) {
-            wrapper.eq(BaseVehicle::getVehicleCode, baseVehicle.getVehicleCode());
-        }
-        if (!StringUtils.isEmptySunhh(baseVehicle) && !StringUtils.isEmptySunhh(baseVehicle.getId())) {
-            wrapper.ne(BaseVehicle::getId, baseVehicle.getId());
-        }
-        List<BaseVehicle> baseVehicles = baseVehicleMapper.selectList(wrapper);
-        if (baseVehicles.size() > 0) {
-            return AjaxResult.error("机车号已存在!");
-        }
+//        LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<>();
+//        if (!StringUtils.isEmptySunhh(baseVehicle) && !StringUtils.isEmptySunhh(baseVehicle.getVehicleCode())) {
+//            wrapper.eq(BaseVehicle::getVehicleCode, baseVehicle.getVehicleCode());
+//        }
+//        if (!StringUtils.isEmptySunhh(baseVehicle) && !StringUtils.isEmptySunhh(baseVehicle.getId())) {
+//            wrapper.ne(BaseVehicle::getId, baseVehicle.getId());
+//        }
+//        List<BaseVehicle> baseVehicles = baseVehicleMapper.selectList(wrapper);
+//        if (baseVehicles.size() > 0) {
+//            return AjaxResult.error("机车号已存在!");
+//        }
         baseVehicle.setUpdateBy(userId);
         baseVehicle.setUpdateTime(new Date());
         int update = baseVehicleMapper.updateById(baseVehicle);
@@ -149,12 +149,12 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
                 BaseVehicle baseVehicle = new BaseVehicle();
                 BeanUtils.copyProperties(baseVehicle2, baseVehicle);
                 // 判断机车号是否存在
-                LambdaQueryWrapper<BaseVehicle> lw = new LambdaQueryWrapper<BaseVehicle>();
-                if (!StringUtils.isEmptySunhh(baseVehicle.getVehicleCode())) {
-                    lw.eq(BaseVehicle::getVehicleCode, baseVehicle.getVehicleCode());
-                }
-                BaseVehicle baseVehicle1 = baseVehicleMapper.selectOne(lw);
-                if (ObjectUtils.isEmpty(baseVehicle1)) {
+//                LambdaQueryWrapper<BaseVehicle> lw = new LambdaQueryWrapper<BaseVehicle>();
+//                if (!StringUtils.isEmptySunhh(baseVehicle.getVehicleCode())) {
+//                    lw.eq(BaseVehicle::getVehicleCode, baseVehicle.getVehicleCode());
+//                }
+//                BaseVehicle baseVehicle1 = baseVehicleMapper.selectOne(lw);
+//                if (ObjectUtils.isEmpty(baseVehicle1)) {
                     BeanValidators.validateWithException(validator, baseVehicle);
                     baseVehicle.setUpdateBy(userId);
                     baseVehicle.setCreateBy(userId);
@@ -178,10 +178,10 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
 //                        baseVehicleMapper.updateById(baseVehicle);
 //                        successNum++;
 //                        successMsg.append(successNum + "、机车号 " + baseVehicle.getVehicleCode() + " 更新成功");
-                } else {
-                    failureNum++;
-                    failureMsg.append(failureNum + "、机车号 " + baseVehicle.getVehicleCode() + "已存在");
-                }
+//                } else {
+//                    failureNum++;
+//                    failureMsg.append(failureNum + "、机车号 " + baseVehicle.getVehicleCode() + "已存在");
+//                }
             } catch (Exception e) {
                 String msg = null;
                 failureNum++;
@@ -223,7 +223,7 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
         }
         List<BaseVehicle> baseVehicles = baseVehicleMapper.selectList(wrapper);
         for (BaseVehicle baseVehicle1 : baseVehicles) {
-            BaseVehicleTerminal baseTerminal = baseVehicleTerminalMapper.selectTerminal(baseVehicle1.getVehicleCode());
+            BaseVehicleTerminal baseTerminal = baseVehicleTerminalMapper.selectTerminal(baseVehicle1.getVehicleCode(),baseVehicle1.getEnds());
             if (!StringUtils.isEmptySunhh(baseTerminal) && !StringUtils.isEmptySunhh(baseTerminal.getVehicleCode())) {
                 LambdaQueryWrapper<BaseTerminal> wrapperBaseVehicleTerminal = new LambdaQueryWrapper<>();
                 if (!StringUtils.isEmptySunhh(baseTerminal) && !StringUtils.isEmptySunhh(baseTerminal.getTerminalCode())) {
@@ -242,7 +242,7 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
 
     @Override
     public IPage<BaseVehicleTerminalVo> vehicleTerminal(BaseVehicleVo baseVehicleVo) {
-        BaseVehicleTerminal baseTerminal = baseVehicleTerminalMapper.selectTerminal(baseVehicleVo.getVehicleCode());
+        BaseVehicleTerminal baseTerminal = baseVehicleTerminalMapper.selectTerminal(baseVehicleVo.getVehicleCode(),baseVehicleVo.getEnds());
         List<String> terminalCodeList = baseVehicleTerminalMapper.selectMountCode(baseVehicleVo.getVehicleCode());
         // List<String> collect = terminalCodeList.stream().map(BaseTerminal::getTerminalCode).collect(Collectors.toList());
         LambdaQueryWrapper<BaseTerminal> wrapper = new LambdaQueryWrapper<>();
@@ -302,6 +302,7 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
             baseTerminal2.setTerminalCode(baseTerminal1.getTerminalCode());
             baseTerminal2.setCreateBy(userId);
             baseTerminal2.setUpdateBy(userId);
+            baseTerminal2.setEnds(baseTerminal1.getEnds());
             Date date = new Date();
             baseTerminal2.setCreateTime(date);
             baseTerminal2.setUpdateTime(date);
@@ -311,6 +312,7 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
             baseTerminal.setUpdateTime(new Date());
             baseTerminal.setVehicleCode(baseTerminal1.getVehicleCode());
             baseTerminal.setTerminalCode(baseTerminal1.getTerminalCode());
+            baseTerminal.setEnds(baseTerminal1.getEnds());
             int updateById = baseVehicleTerminalMapper.updateById(baseTerminal);
         }
         return AjaxResult.success();
@@ -360,7 +362,7 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
             List<String> terminalCodeList = new ArrayList<>();
             baseVehicles = baseVehicles.stream().map(o -> {
                 //查到已保存的关联信息
-                BaseVehicleTerminal baseVehicleTerminal = baseVehicleTerminalMapper.selectTerminal(o.getVehicleCode());
+                BaseVehicleTerminal baseVehicleTerminal = baseVehicleTerminalMapper.selectTerminal(o.getVehicleCode(),o.getEnds());
                 if (!StringUtils.isEmptySunhh(baseVehicleTerminal) && !StringUtils.isEmptySunhh(baseVehicleTerminal.getVehicleCode())) {
                     terminalCodeList.add(baseVehicleTerminal.getVehicleCode());
                     LambdaQueryWrapper<BaseTerminal> wrapperBaseVehicleTerminal = new LambdaQueryWrapper<>();

+ 1 - 1
business-service/src/main/resources/mapper/BaseVehicleTerminalMapper.xml

@@ -7,6 +7,6 @@
     </select>
 
     <select id="selectTerminal" parameterType="java.lang.String" resultType="com.ozs.entity.BaseVehicleTerminal">
-        select * from base_vehicle_terminal where vehicle_code = #{vehicleCode} limit 1
+        select * from base_vehicle_terminal where vehicle_code = #{vehicleCode} and ends=#{ends} limit 1
     </select>
 </mapper>