Przeglądaj źródła

机车信息 挂载终端列表,保存挂载

sunhh 1 rok temu
rodzic
commit
4fffd4b6cd

+ 1 - 1
.idea/compiler.xml

@@ -8,8 +8,8 @@
         <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
         <outputRelativeToContentRoot value="true" />
         <module name="vehicle-admin" />
-        <module name="hazard-admin" />
         <module name="business-service" />
+        <module name="hazard-admin" />
       </profile>
     </annotationProcessing>
     <bytecodeTargetLevel>

+ 2 - 0
.idea/encodings.xml

@@ -3,6 +3,8 @@
   <component name="Encoding">
     <file url="file://$PROJECT_DIR$/business-service/src/main/java" charset="UTF-8" />
     <file url="file://$PROJECT_DIR$/business-service/src/main/resources" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
     <file url="file://$PROJECT_DIR$/vehicle-admin/src/main/java" charset="UTF-8" />
     <file url="file://$PROJECT_DIR$/vehicle-admin/src/main/resources" charset="UTF-8" />
   </component>

+ 12 - 12
.idea/jarRepositories.xml

@@ -1,16 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="RemoteRepositoriesConfiguration">
-    <remote-repository>
-      <option name="id" value="central" />
-      <option name="name" value="Central Repository" />
-      <option name="url" value="https://maven.aliyun.com/repository/public" />
-    </remote-repository>
-    <remote-repository>
-      <option name="id" value="central" />
-      <option name="name" value="Central Repository" />
-      <option name="url" value="https://repo.maven.apache.org/maven2" />
-    </remote-repository>
     <remote-repository>
       <option name="id" value="public" />
       <option name="name" value="aliyun nexus" />
@@ -18,8 +8,8 @@
     </remote-repository>
     <remote-repository>
       <option name="id" value="central" />
-      <option name="name" value="Maven Central repository" />
-      <option name="url" value="https://repo1.maven.org/maven2" />
+      <option name="name" value="Central Repository" />
+      <option name="url" value="https://repo.maven.apache.org/maven2" />
     </remote-repository>
     <remote-repository>
       <option name="id" value="central" />
@@ -36,6 +26,11 @@
       <option name="name" value="Central Repository" />
       <option name="url" value="http://maven.aliyun.com/nexus/content/repositories/central/" />
     </remote-repository>
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Maven Central repository" />
+      <option name="url" value="https://repo1.maven.org/maven2" />
+    </remote-repository>
     <remote-repository>
       <option name="id" value="custom_group" />
       <option name="name" value="Nexus Repository" />
@@ -46,5 +41,10 @@
       <option name="name" value="JBoss Community repository" />
       <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
     </remote-repository>
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Central Repository" />
+      <option name="url" value="https://maven.aliyun.com/repository/public" />
+    </remote-repository>
   </component>
 </project>

+ 3 - 5
business-service/src/main/java/com/ozs/entity/BaseTerminal.java

@@ -2,12 +2,12 @@ package com.ozs.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
-import java.io.Serializable;
-import java.util.Date;
-
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.io.Serializable;
+import java.util.Date;
+
 /**
  * <p>
  * 机车车载终端关联表
@@ -62,6 +62,4 @@ public class BaseTerminal implements Serializable {
      * 备注
      */
     private String remark;
-
-
 }

+ 4 - 0
business-service/src/main/java/com/ozs/entity/vo/BaseVehicleTerminalVo.java

@@ -11,6 +11,10 @@ import java.util.Date;
  */
 @Data
 public class BaseVehicleTerminalVo extends PageVo {
+    /**
+     * 是否挂载 0未挂载,1挂载
+     */
+    private String isMount;
 
     /**
      * 主键ID

+ 6 - 0
business-service/src/main/java/com/ozs/mapper/BaseTerminalMapper.java

@@ -2,6 +2,9 @@ package com.ozs.mapper;
 
 import com.ozs.entity.BaseTerminal;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +16,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface BaseTerminalMapper extends BaseMapper<BaseTerminal> {
 
+    List<String> selectMountCode(@Param("vehicleCode") String vehicleCode);
+
+    BaseTerminal selectTerminal(@Param("vehicleCode") String vehicleCode);
 }

+ 6 - 0
business-service/src/main/java/com/ozs/service/BaseVehicleService.java

@@ -3,7 +3,9 @@ package com.ozs.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ozs.common.core.domain.AjaxResult;
+import com.ozs.entity.BaseTerminal;
 import com.ozs.entity.BaseVehicle;
+import com.ozs.entity.vo.BaseVehicleTerminalVo;
 import com.ozs.entity.vo.BaseVehicleVo;
 
 import java.util.List;
@@ -29,4 +31,8 @@ public interface BaseVehicleService extends IService<BaseVehicle> {
     AjaxResult vehicleDetails(BaseVehicle baseVehicle);
 
     List<BaseVehicle> exportBaseVehicle(BaseVehicle baseVehicle);
+
+    IPage<BaseVehicleTerminalVo> vehicleTerminal(BaseVehicleVo baseVehicle);
+
+    AjaxResult vehicleTerminalAdd(BaseTerminal baseTerminal, String userId);
 }

+ 69 - 2
business-service/src/main/java/com/ozs/service/impl/BaseVehicleServiceImpl.java

@@ -9,17 +9,23 @@ import com.ozs.common.exception.ServiceException;
 import com.ozs.common.utils.StringUtils;
 import com.ozs.common.utils.bean.BeanUtils;
 import com.ozs.common.utils.bean.BeanValidators;
+import com.ozs.entity.BaseTerminal;
 import com.ozs.entity.BaseVehicle;
+import com.ozs.entity.BaseVehicleTerminal;
+import com.ozs.entity.vo.BaseVehicleTerminalVo;
 import com.ozs.entity.vo.BaseVehicleVo;
+import com.ozs.mapper.BaseTerminalMapper;
 import com.ozs.mapper.BaseVehicleMapper;
 import com.ozs.mapper.BaseVehicleTerminalMapper;
 import com.ozs.service.BaseVehicleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
 
 import javax.validation.Validator;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -35,6 +41,8 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
     @Autowired
     private BaseVehicleMapper baseVehicleMapper;
     @Autowired
+    private BaseTerminalMapper baseTerminalMapper;
+    @Autowired
     private BaseVehicleTerminalMapper baseVehicleTerminalMapper;
     @Autowired
     protected Validator validator;
@@ -84,7 +92,7 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
 
     @Override
     public AjaxResult vehicleUpdate(BaseVehicle baseVehicle, String userId) {
-        LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<BaseVehicle>();
+        LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<>();
         if (!StringUtils.isEmptySunhh(baseVehicle) && !StringUtils.isEmptySunhh(baseVehicle.getVehicleCode())) {
             wrapper.eq(BaseVehicle::getVehicleCode, baseVehicle.getVehicleCode());
         }
@@ -171,7 +179,7 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
 
     @Override
     public List<BaseVehicle> exportBaseVehicle(BaseVehicle baseVehicle) {
-        LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<BaseVehicle>();
+        LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<>();
         if (!StringUtils.isEmptySunhh(baseVehicle) && !StringUtils.isEmptySunhh(baseVehicle.getVehicleName())) {
             wrapper.eq(BaseVehicle::getVehicleName, baseVehicle.getVehicleName());
         }
@@ -181,4 +189,63 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
         List<BaseVehicle> baseVehicles = baseVehicleMapper.selectList(wrapper);
         return baseVehicles;
     }
+
+    @Override
+    public IPage<BaseVehicleTerminalVo> vehicleTerminal(BaseVehicleVo baseVehicleVo) {
+        BaseTerminal baseTerminal = baseTerminalMapper.selectTerminal(baseVehicleVo.getVehicleCode());
+        List<String> terminalCodeList = baseTerminalMapper.selectMountCode(baseVehicleVo.getVehicleCode());
+        // List<String> collect = terminalCodeList.stream().map(BaseTerminal::getTerminalCode).collect(Collectors.toList());
+        LambdaQueryWrapper<BaseVehicleTerminal> wrapper = new LambdaQueryWrapper<>();
+        if (!StringUtils.isEmptySunhh(terminalCodeList) && terminalCodeList.size() > 0) {
+            wrapper.notIn(BaseVehicleTerminal::getTerminalCode, terminalCodeList);
+        }
+//        List<BaseVehicleTerminal> baseVehicleTerminalList = baseVehicleTerminalMapper.selectList(wrapper);
+        int pageNum = Integer.parseInt(baseVehicleVo.getPageNum().toString());
+        int pageSize = Integer.parseInt(baseVehicleVo.getPageSize().toString());
+        com.github.pagehelper.Page<BaseVehicleTerminal> page = PageHelper
+                .startPage(pageNum, pageSize).doSelectPage(() -> baseVehicleTerminalMapper.selectList(wrapper));
+        com.baomidou.mybatisplus.extension.plugins.pagination.Page<BaseVehicleTerminalVo> pageR =
+                new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageNum, pageSize);
+        if (!ObjectUtils.isEmpty(page) && page.getResult().size() > 0) {
+            List<BaseVehicleTerminalVo> dto1 = page.getResult().stream().map(o -> {
+                BaseVehicleTerminalVo baseVehicleTerminalVo = new BaseVehicleTerminalVo();
+                BeanUtils.copyProperties(o, baseVehicleTerminalVo);
+                if (baseTerminal.getTerminalCode().equals(o.getTerminalCode())) {
+                    baseVehicleTerminalVo.setIsMount("1");
+                } else {
+                    baseVehicleTerminalVo.setIsMount("0");
+                }
+                return baseVehicleTerminalVo;
+            }).collect(Collectors.toList());
+            pageR.setRecords(dto1);
+        }
+        return pageR;
+    }
+
+    @Override
+    public AjaxResult vehicleTerminalAdd(BaseTerminal baseTerminal1, String userId) {
+        LambdaQueryWrapper<BaseTerminal> wrapper = new LambdaQueryWrapper<>();
+        if (!StringUtils.isEmptySunhh(baseTerminal1) && !StringUtils.isEmptySunhh(baseTerminal1.getVehicleCode())) {
+            wrapper.eq(BaseTerminal::getVehicleCode, baseTerminal1.getVehicleCode());
+        }
+        BaseTerminal baseTerminal = baseTerminalMapper.selectOne(wrapper);
+        if (StringUtils.isEmptySunhh(baseTerminal)) {
+            BaseTerminal baseTerminal2 = new BaseTerminal();
+            baseTerminal2.setVehicleCode(baseTerminal1.getVehicleCode());
+            baseTerminal2.setTerminalCode(baseTerminal1.getTerminalCode());
+            baseTerminal2.setCreateBy(userId);
+            baseTerminal2.setUpdateBy(userId);
+            Date date = new Date();
+            baseTerminal2.setCreateTime(date);
+            baseTerminal2.setUpdateTime(date);
+            int insert = baseTerminalMapper.insert(baseTerminal2);
+        } else {
+            baseTerminal.setUpdateBy(userId);
+            baseTerminal.setUpdateTime(new Date());
+            baseTerminal.setVehicleCode(baseTerminal1.getVehicleCode());
+            baseTerminal.setTerminalCode(baseTerminal1.getTerminalCode());
+            int updateById = baseTerminalMapper.updateById(baseTerminal);
+        }
+        return AjaxResult.success();
+    }
 }

+ 7 - 0
business-service/src/main/resources/mapper/BaseTerminalMapper.xml

@@ -2,4 +2,11 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ozs.mapper.BaseTerminalMapper">
 
+    <select id="selectMountCode" parameterType="java.lang.String" resultType="java.lang.String">
+        select terminal_code terminalCode from base_terminal where vehicle_code != #{vehicleCode}
+    </select>
+
+    <select id="selectTerminal" parameterType="java.lang.String" resultType="com.ozs.entity.BaseTerminal">
+        select * from base_terminal where vehicle_code = #{vehicleCode} limit 1
+    </select>
 </mapper>

+ 36 - 0
vehicle-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseVehicleController.java

@@ -8,7 +8,9 @@ import com.ozs.common.enums.BusinessType;
 import com.ozs.common.utils.StringUtils;
 import com.ozs.common.utils.file.FileUtils;
 import com.ozs.common.utils.poi.ExcelUtil;
+import com.ozs.entity.BaseTerminal;
 import com.ozs.entity.BaseVehicle;
+import com.ozs.entity.vo.BaseVehicleTerminalVo;
 import com.ozs.entity.vo.BaseVehicleVo;
 import com.ozs.service.BaseVehicleService;
 import io.swagger.annotations.ApiOperation;
@@ -43,6 +45,40 @@ public class BaseVehicleController extends BaseController {
         System.out.println(new Date().getTime());
     }
 
+    /**
+     * 车载终端挂载列表
+     *
+     * @param baseVehicleVo
+     * @return
+     */
+    @ApiOperation(value = "车载终端挂载列表")
+    @PostMapping("/vehicleTerminal")
+    @Log(title = "机车信息管理", businessType = BusinessType.SELECT)
+    public AjaxResult vehicleTerminal(@RequestBody BaseVehicleVo baseVehicleVo) {
+        if (StringUtils.isEmptySunhh(baseVehicleVo) || StringUtils.isEmptySunhh(baseVehicleVo.getVehicleCode())) {
+            return AjaxResult.error("机车编码不能为空!");
+        }
+        IPage<BaseVehicleTerminalVo> baseVehicleTerminalVoIPage = baseVehicleService.vehicleTerminal(baseVehicleVo);
+        return AjaxResult.success(baseVehicleTerminalVoIPage);
+    }
+
+    /**
+     * 车载终端挂载 保存
+     *
+     * @param baseTerminal
+     * @return
+     */
+    @ApiOperation(value = "车载终端挂载 保存")
+    @PostMapping("/vehicleTerminalAdd")
+    @Log(title = "机车信息管理", businessType = BusinessType.INSERT)
+    public AjaxResult vehicleTerminalAdd(@RequestBody BaseTerminal baseTerminal) {
+        if (StringUtils.isEmptySunhh(baseTerminal) || StringUtils.isEmptySunhh(baseTerminal.getVehicleCode())
+                || StringUtils.isEmptySunhh(baseTerminal.getTerminalCode())) {
+            return AjaxResult.error("机车编码、终端编码不能为空!");
+        }
+        return baseVehicleService.vehicleTerminalAdd(baseTerminal, getUserId());
+    }
+
     /**
      * 机车信息表 分页查询
      *