Kaynağa Gözat

巡检计划查询

wangbo 4 yıl önce
ebeveyn
işleme
c24b155d2f

+ 28 - 3
operation_manager/src/main/java/com/huaxu/task/controller/PlanManageController.java

@@ -11,6 +11,9 @@ import io.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/workflow/task/")
@@ -46,7 +49,8 @@ public class PlanManageController {
                                @ApiParam(value = "任务内容", required = true) @RequestParam(required = true) String taskContent,
                                @ApiParam(value = "任务区域坐标", required = true) @RequestParam(required = true) String taskAreaShape,
                                @ApiParam(value = "任务区域名称", required = true) @RequestParam(required = true) String taskAreaName,
-                               @ApiParam(value = "创建者ID", required = true) @RequestParam(required = true) String createBy) {
+                               @ApiParam(value = "创建者ID", required = true) @RequestParam(required = true) String createBy,
+                               @ApiParam(value = "租户编号", required = true) @RequestParam(required = true) String tenantId) {
         String planId=DatesUtil.formatDate(new Date(),"yyyyMMddHHmmss")+String.valueOf((int) (Math.random()*(9999-1000)+1000));
         PlanManage record = new PlanManage();
         record.setUserId(userId);
@@ -61,11 +65,32 @@ public class PlanManageController {
         record.setTaskAreaShape(taskAreaShape);
         record.setTaskAreaName(taskAreaName);
         record.setCreateBy(createBy);
-        record.setDateCreate(new Date(System.currentTimeMillis()));
+        record.setTenantId(tenantId);
+        record.setDateCreate(DatesUtil.parseDate(DatesUtil.formatNow(),"yyyy-MM-dd HH:mm:ss"));
         int rows = planManageService.insertSelective(record);
         if(rows > 0) {
             return new AjaxMessage(ResultStatus.OK);
         }
         return new AjaxMessage(ResultStatus.ERROR);
     }
-}
+
+
+    @GetMapping("/plan/select")
+    @ApiOperation(value = "查询巡检计划")
+    public AjaxMessage<List<PlanManage>> selectPlan(
+            @ApiParam(value = "租户编号", required = true) @RequestParam(required = true) String tenantId,
+            @ApiParam(value = "计划单号或计划名称", required = true) @RequestParam(required = false) String key,
+            @ApiParam(value = "计划安排起始日期", required = true) @RequestParam(required = false) String startDate,
+            @ApiParam(value = "计划安排截至日期", required = true) @RequestParam(required = false) String endDate){
+
+        Map<String,Object> map =new HashMap<String,Object>();
+        map.put("tenantId",tenantId);
+        map.put("key",key);
+        map.put("startDate",startDate);
+        map.put("endDate",endDate);
+        List<PlanManage> list = planManageService.selectPlanByIdAndDate(map);
+
+        return new AjaxMessage<List<PlanManage>>(ResultStatus.OK,list);
+    }
+
+}

+ 5 - 0
operation_manager/src/main/java/com/huaxu/task/dao/PlanManageMapper.java

@@ -3,6 +3,9 @@ package com.huaxu.task.dao;
 import com.huaxu.task.entity.PlanManage;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+import java.util.Map;
+
 @Mapper
 public interface PlanManageMapper {
 
@@ -13,4 +16,6 @@ public interface PlanManageMapper {
     PlanManage selectByPrimaryKey(Integer id);
 
     int updateByPrimaryKeySelective(PlanManage record);
+
+    List<PlanManage> selectPlanByIdAndDate(Map<String,Object> map);
 }

+ 10 - 0
operation_manager/src/main/java/com/huaxu/task/service/PlanManageService.java

@@ -2,6 +2,9 @@ package com.huaxu.task.service;
 
 import com.huaxu.task.entity.PlanManage;
 
+import java.util.List;
+import java.util.Map;
+
 public interface PlanManageService {
     /**
      * 新增任务单
@@ -12,4 +15,11 @@ public interface PlanManageService {
      * 更新任务单
      */
     int updateByPrimaryKeySelective(PlanManage record);
+
+    /**
+     * 按计划单号或计划名称及时间查询巡检计划
+     * @param map
+     * @return
+     */
+    List<PlanManage> selectPlanByIdAndDate(Map<String,Object> map);
 }

+ 8 - 0
operation_manager/src/main/java/com/huaxu/task/service/impl/PlanManageServiceImpl.java

@@ -6,6 +6,9 @@ import com.huaxu.task.service.PlanManageService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.Map;
+
 @Service
 public class PlanManageServiceImpl implements PlanManageService {
 
@@ -22,5 +25,10 @@ public class PlanManageServiceImpl implements PlanManageService {
         return planManageMapper.updateByPrimaryKeySelective(record);
     }
 
+    @Override
+    public List<PlanManage> selectPlanByIdAndDate(Map<String, Object> map) {
+        return planManageMapper.selectPlanByIdAndDate(map);
+    }
+
 
 }

+ 20 - 6
operation_manager/src/main/resources/mapper/task/PlanManageMapper.xml

@@ -26,7 +26,7 @@
     <result column="update_by" property="updateBy" jdbcType="VARCHAR" />
     <result column="date_update" property="dateUpdate" jdbcType="TIMESTAMP" />
 
-  <!--  <association property="planUser" javaType="com.huaxu.entity.UserEntity">
+   <association property="planUser" javaType="com.huaxu.entity.UserEntity">
       <id column="plan_user_id" property="id" jdbcType="INTEGER"/>
       <result column="plan_user_name" property="username"/>
     </association>
@@ -45,7 +45,9 @@
       <id column="update_by_id" property="id" jdbcType="INTEGER"/>
       <result column="update_by_name" property="username"/>
     </association>
--->
+
+
+
   </resultMap>
   <sql id="Base_Column_List" >
     id, plan_id, plan_name, plan_user_id, user_id, plan_date, plan_start_date, plan_end_date, 
@@ -60,6 +62,7 @@
     from sc_plan_manage
     where id = #{id,jdbcType=INTEGER}
   </select>
+
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
     delete from sc_plan_manage
     where id = #{id,jdbcType=INTEGER}
@@ -210,6 +213,7 @@
       </if>
     </trim>
   </insert>
+
   <update id="updateByPrimaryKeySelective" parameterType="com.huaxu.task.entity.PlanManage" >
     update sc_plan_manage
     <set >
@@ -283,10 +287,20 @@
     where id = #{id,jdbcType=INTEGER}
   </update>
 
-  <select id="selectPlanTagId" resultType="java.lang.String" parameterType="java.lang.String" >
-    select plan_id
+  <select id="selectPlanByIdAndDate" resultMap="BaseResultMap" parameterType="java.lang.String" >
+    select
+    <include refid="Base_Column_List"/>
     from sc_plan_manage
-    where plan_id like "%" || #{planId,jdbcType=VARCHAR} || "%" and rownum=1
-    order by plan_id desc
+    where
+    tenant_id = #{tenantId, jdbcType = VARCHAR}
+    and plan_user_id in
+    <foreach collection="userIdList" item="item" index="index" open="(" separator="," close=")">
+      #{item,jdbcType=VARCHAR}
+    </foreach>
+    <if test="key != null and key != ''">
+       and plan_id like "%" || #{planId,jdbcType=VARCHAR} || "%" or plan_name like "%" || #{planName,jdbcType=VARCHAR} || "%"
+    </if>
+    order by date_create desc
   </select>
+
 </mapper>