Browse Source

[chg]项目id和名称列表修改,清空维保计划接口

别傲 5 years ago
parent
commit
f7190e1436

+ 4 - 4
lift-business-service/src/main/java/cn/com/ty/lift/business/library/controller/LiftController.java

@@ -10,8 +10,8 @@ import cn.com.ty.lift.business.library.service.PlatformCompanyLiftRelevanceServi
 import cn.com.ty.lift.business.library.service.ProjectLiftRelevanceService;
 import cn.com.ty.lift.common.base.ExportRequest;
 import cn.com.ty.lift.common.constants.ApiConstants;
-import cn.com.ty.lift.common.utils.StringUtils;
 import cn.com.xwy.boot.web.dto.RestResponse;
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.web.bind.annotation.*;
 
@@ -45,7 +45,7 @@ public class LiftController {
     @PostMapping("list")
     public RestResponse list(@RequestBody LiftRequest request) {
         IPage<LiftResponse> page = liftService.list(request);
-        if (!StringUtils.isListEmpty(page.getRecords())) {
+        if (ObjectUtil.isEmpty(page.getRecords())) {
             return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, MessageUtils.get("msg.data.empty"));
         }
         return RestResponse.ok(page, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.query.success"));
@@ -59,7 +59,7 @@ public class LiftController {
     @PostMapping("brand/list")
     public RestResponse list(){
         List<LiftBrand> liftBrandList = liftService.list();
-        if (!StringUtils.isListEmpty(liftBrandList)) {
+        if (ObjectUtil.isEmpty(liftBrandList)) {
             return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, MessageUtils.get("msg.data.empty"));
         }
         return RestResponse.ok(liftBrandList, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.query.success"));
@@ -74,7 +74,7 @@ public class LiftController {
     @PostMapping("project/list")
     public RestResponse liftProjectList(@RequestBody LiftRequest request) {
         IPage<LiftResponse> page = liftService.findLiftListByProjectId(request);
-        if (!StringUtils.isListEmpty(page.getRecords())) {
+        if (ObjectUtil.isEmpty(page.getRecords())) {
             return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, MessageUtils.get("msg.data.empty"));
         }
         return RestResponse.ok(page, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.query.success"));

+ 23 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/controller/MaintenanceController.java

@@ -1,17 +1,20 @@
 package cn.com.ty.lift.business.maintenance.controller;
 
 import cn.com.ty.lift.business.framework.util.MessageUtils;
+import cn.com.ty.lift.business.maintenance.dao.entity.model.BatchMaintenancePlanRequest;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.MaintenancePlanRequest;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.UpdateMaintenancePlanReq;
 import cn.com.ty.lift.business.maintenance.service.MaintenancePlanService;
 import cn.com.ty.lift.common.constants.ApiConstants;
 import cn.com.xwy.boot.web.dto.RestResponse;
+import cn.hutool.core.util.ObjectUtil;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 /**
  * @author bieao
@@ -56,4 +59,24 @@ public class MaintenanceController {
             return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.modify.fail"));
         }
     }
+
+    /**
+     * @param request ids 维保计划id列表
+     * @return 是否成功
+     * @description 清空维保计划
+     * @date 2019/12/17 3:14 PM
+     */
+    @PostMapping("batch/clean")
+    public RestResponse deleteByIds(@RequestBody BatchMaintenancePlanRequest request) {
+        List<Long> ids = request.getIds();
+        if (ObjectUtil.isEmpty(ids)) {
+            return RestResponse.ok(null, ApiConstants.RESULT_NO_PARAM, MessageUtils.get("msg.param.empty"));
+        }
+        boolean result = maintenancePlanService.deleteByIds(request);
+        if (result) {
+            return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.modify.success"));
+        } else {
+            return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.modify.fail"));
+        }
+    }
 }

+ 19 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/BatchMaintenancePlanRequest.java

@@ -0,0 +1,19 @@
+package cn.com.ty.lift.business.maintenance.dao.entity.model;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author bieao
+ * @date 2019/12/17
+ * @description 维保计划请求
+ */
+@Data
+public class BatchMaintenancePlanRequest {
+
+    /**
+     * 维保计划id列表
+     */
+    private List<Long> ids;
+}

+ 14 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/MaintenancePlanService.java

@@ -1,12 +1,14 @@
 package cn.com.ty.lift.business.maintenance.service;
 
 import cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan;
+import cn.com.ty.lift.business.maintenance.dao.entity.model.BatchMaintenancePlanRequest;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.UpdateMaintenancePlanReq;
 import cn.com.ty.lift.business.maintenance.dao.mapper.MaintenancePlanMapper;
 import cn.com.ty.lift.business.project.dao.entity.Project;
 import cn.com.ty.lift.business.project.service.ProjectService;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -18,6 +20,7 @@ import java.util.*;
  * @description 维保计划业务层
  */
 @Service
+@Slf4j
 public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, MaintenancePlan> {
 
     @Resource
@@ -133,4 +136,15 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
         }
        return updateBatchById(resultList, resultList.size());
     }
+
+    /**
+     * @param request ids 维保计划id列表
+     * @return 是否成功
+     * @description 清空维保计划
+     * @date 2019/12/17 3:14 PM
+     */
+    public boolean deleteByIds(BatchMaintenancePlanRequest request) {
+        log.info("批量清空维保计划");
+        return removeByIds(request.getIds());
+    }
 }

+ 12 - 10
lift-business-service/src/main/java/cn/com/ty/lift/business/project/controller/ProjectController.java

@@ -13,7 +13,9 @@ import cn.com.ty.lift.business.project.dao.entity.model.ProjectRequest;
 import cn.com.ty.lift.business.project.service.ProjectService;
 import cn.com.ty.lift.common.base.ExportRequest;
 import cn.com.ty.lift.common.constants.ApiConstants;
+import cn.com.ty.lift.common.model.AreaCode;
 import cn.com.xwy.boot.web.dto.RestResponse;
+import cn.hutool.core.util.ObjectUtil;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -89,12 +91,8 @@ public class ProjectController {
      */
     @PostMapping("projectIDList")
     public RestResponse projectIDList(@RequestBody ProjectRequest request) {
-        Long regionId = request.getRegionId();
-        if (regionId == null) {
-            return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, MessageUtils.get("msg.param.empty"));
-        }
-        List<ProjectIDResponse> projectIDList = projectService.projectIDList(regionId);
-        if (projectIDList.isEmpty()) {
+        List<ProjectIDResponse> projectIDList = projectService.projectIDList(request);
+        if (ObjectUtil.isEmpty(projectIDList)) {
             return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, MessageUtils.get("msg.data.empty"));
         }
         return RestResponse.ok(projectIDList, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.query.success"));
@@ -108,11 +106,11 @@ public class ProjectController {
      */
     @PostMapping("detail")
     public RestResponse detail(@RequestBody ProjectRequest request) {
-        if (request.getProjectId() == null) {
-            return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, MessageUtils.get("msg.param.empty"));
+        if (ObjectUtil.isEmpty(request.getProjectId())) {
+            return RestResponse.ok(null, ApiConstants.RESULT_NO_PARAM, MessageUtils.get("msg.param.empty"));
         }
         Project project = projectService.detail(request.getProjectId());
-        if (project == null) {
+        if (ObjectUtil.isEmpty(project)) {
             return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, MessageUtils.get("msg.data.empty"));
         }
         return RestResponse.ok(project, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.query.detail.success"));
@@ -125,7 +123,11 @@ public class ProjectController {
      */
     @PostMapping("area/list")
     public RestResponse areaList() {
-        return projectService.areaList();
+        List<AreaCode> areaCodeList = projectService.areaList();
+        if (ObjectUtil.isEmpty(areaCodeList)) {
+            return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, MessageUtils.get("msg.data.empty"));
+        }
+        return RestResponse.ok(areaCodeList, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.query.success"));
     }
 
     /**

+ 5 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/project/dao/entity/model/ProjectRequest.java

@@ -50,6 +50,11 @@ public class ProjectRequest {
      */
     private Long ppContactId;
 
+    /**
+     * 维保公司id
+     */
+    private String mtCompanyId;
+
     /**
      * 当前页码
      */

+ 1 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/project/dao/mapper/ProjectMapper.java

@@ -22,6 +22,6 @@ public interface ProjectMapper extends BaseMapper<Project> {
 
     IPage<ProjectResponse> findCompanyListByCondition(IPage<ProjectResponse> page, @Param("request") ProjectRequest request);
 
-    List<ProjectIDResponse> findProjectListByRegionId(Long regionId);
+    List<ProjectIDResponse> findProjectListByRegionId(@Param("request") ProjectRequest request);
 
 }

+ 5 - 6
lift-business-service/src/main/java/cn/com/ty/lift/business/project/service/ProjectService.java

@@ -128,13 +128,13 @@ public class ProjectService {
     }
 
     /**
-     * @param regionId 区域id
+     * @param request 区域id或维保公司id
      * @return List<ProjectIDResponse> 项目ID和名称列表
      * @description 项目ID和名称列表
      * @date 2019/12/16 4:21 PM
      */
-    public List<ProjectIDResponse> projectIDList(Long regionId) {
-        return projectMapper.findProjectListByRegionId(regionId);
+    public List<ProjectIDResponse> projectIDList(ProjectRequest request) {
+        return projectMapper.findProjectListByRegionId(request);
     }
 
     /**
@@ -152,9 +152,8 @@ public class ProjectService {
      * @description 查询省、市、区树形结构列表
      * @date 2019/12/4 10:23 AM
      */
-    public RestResponse areaList() {
-        List<AreaCode> areaCodeList = (List<AreaCode>) redisTemplate.opsForValue().get(RedisConstants.RK_AREA_LIST);
-        return RestResponse.ok(areaCodeList, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.query.success"));
+    public List<AreaCode> areaList() {
+        return (List<AreaCode>) redisTemplate.opsForValue().get(RedisConstants.RK_AREA_LIST);
     }
 
     /**

+ 10 - 4
lift-business-service/src/main/resources/mapper/project/ProjectMapper.xml

@@ -68,7 +68,7 @@
 			and region_id = #{request.regionId,jdbcType=VARCHAR}
 		</if>
 		<if test="request.condition!=null and request.condition!=''">
-			(or project_name like #{request.condition,jdbcType=VARCHAR}
+			and (project_name like #{request.condition,jdbcType=VARCHAR}
 			or project_code like #{request.condition,jdbcType=VARCHAR}
 			or address like #{request.condition,jdbcType=VARCHAR})
 		</if>
@@ -110,13 +110,19 @@
 		</if>
 	</select>
 
-	<!--根据区域id查询项目id和名称列表 -->
-	<select id="findProjectListByRegionId" resultType="cn.com.ty.lift.business.project.dao.entity.model.ProjectIDResponse" parameterType="java.lang.Long">
+	<!--根据区域id或维保公司id查询项目id和名称列表 -->
+	<select id="findProjectListByRegionId" resultType="cn.com.ty.lift.business.project.dao.entity.model.ProjectIDResponse" parameterType="cn.com.ty.lift.business.project.dao.entity.model.ProjectRequest">
 		SELECT
 		  id           AS projectId,
 		  project_name AS projectName
 		FROM project
-		WHERE region_id = #{regionId,jdbcType=BIGINT}
+		WHERE 1=1
+        <if test="request.regionId!=null and request.regionId!=''">
+            AND region_id = #{request.regionId,jdbcType=BIGINT}
+        </if>
+        <if test="request.mtCompanyId!=null and request.mtCompanyId!=''">
+            AND mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
+        </if>
 	</select>
 
 </mapper>

+ 5 - 0
lift-common/src/main/java/cn.com.ty.lift.common/constants/ApiConstants.java

@@ -20,6 +20,11 @@ public class ApiConstants {
      */
     public static final String RESULT_NO_DATA = "9";
 
+    /**
+     * 参数有误 2
+     */
+    public static final String RESULT_NO_PARAM = "2";
+
     /**
      * 程序异常
      */

+ 0 - 18
lift-common/src/main/java/cn.com.ty.lift.common/utils/StringUtils.java

@@ -1,18 +0,0 @@
-package cn.com.ty.lift.common.utils;
-
-import java.util.List;
-
-/**
- * @author bieao
- * @date 2019/12/17
- * @description 字符串工具类
- */
-public class StringUtils {
-
-    /**
-     * 判断List是否为空,空返回true
-     */
-    public static boolean isListEmpty(List list) {
-        return null != list && list.size() > 0;
-    }
-}