Sfoglia il codice sorgente

任务提交 优化停泊点策略自动增加序号

qinguocai 1 anno fa
parent
commit
26b01367f5

+ 11 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/BerthingPointConfigMapper.java

@@ -31,6 +31,16 @@ public interface BerthingPointConfigMapper {
      */
     BerthingPointConfig queryByPlanid(@Param("siteId")Long siteId, @Param("planid")Long planid);
 
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param stopId 主键
+     * @return 实例对象
+     */
+    BerthingPointConfig queryMaxPlanid(Long stopId);
+
+
     /**
      * 查询指定行数据
      *
@@ -40,6 +50,7 @@ public interface BerthingPointConfigMapper {
      */
     Page<BerthingPointConfig> queryAllByLimit(@Param("stopPointQuery") StopPointQuery stopPointQuery , Page page);
 
+
     /**
      * 统计总行数
      *

+ 6 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BerthingServiceImpl.java

@@ -238,11 +238,16 @@ public class BerthingServiceImpl implements BerthingService {
                 if (count > 0){
                     throw new BaseException("起测水位已存在");
                 }
+                BerthingPointConfig maxPlanid = berthingPointConfigMapper.queryMaxPlanid(berthingPointConfigDTO.getSiteId());
+                if (maxPlanid == null) {
+                    maxPlanid = new BerthingPointConfig();
+                    maxPlanid.setPlanid(1L);
+                }
                 berthingPointConfig.setStopId(0L);
                 berthingPointConfig.setSiteId(siteInfo.getSiteId());
                 berthingPointConfig.setBerthingId(berthingPoint.getBerthingId());
                 berthingPointConfig.setPositions(JSONUtil.toJsonStr(positions));
-                berthingPointConfig.setPlanid(0L);
+                berthingPointConfig.setPlanid(maxPlanid.getPlanid() + 1);
                 berthingPointConfig.setWlevel(berthingPointConfigDTO.getWlevel());
                 berthingPointConfig.setFactors(JSONUtil.toJsonStr(berthingPointConfigDTO.getFactors()));
                 berthingPointConfig.setCreateTime(new Date());
@@ -256,7 +261,6 @@ public class BerthingServiceImpl implements BerthingService {
                 berthingPointConfigMapper.update(berthingPointConfig);
                 berthingPointConfig.setStopId(0L);
                 berthingPointConfig.setPositions(JSONUtil.toJsonStr(positions));
-                berthingPointConfig.setPlanid(0L);
                 berthingPointConfig.setWlevel(berthingPointConfigDTO.getWlevel());
                 berthingPointConfig.setFactors(JSONUtil.toJsonStr(berthingPointConfigDTO.getFactors()));
                 res =  berthingPointConfigMapper.insert(berthingPointConfig) > 0;

+ 9 - 0
ruoyi-system/src/main/resources/mapper/BerthingPointConfigMapper.xml

@@ -33,6 +33,15 @@
         where site_id = #{siteId} and planid = #{planid}
     </select>
 
+
+    <!--查询单个-->
+    <select id="queryMaxPlanid" resultMap="BerthingPointConfigMap">
+        select
+            MAX(planid) as planid
+        from berthing_point_config
+        where site_id = #{siteId}
+    </select>
+
     <!--查询指定行数据-->
     <select id="queryAllByLimit" resultMap="BerthingPointConfigMap">
         select