Browse Source

[chg]项目电梯sql修改

别傲 5 years ago
parent
commit
9ee347a79b

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

@@ -88,7 +88,11 @@ public class LiftController {
      */
     @PostMapping("detail")
     public RestResponse detail(@RequestBody LiftRequest request ) {
-        return liftService.detail(request.getLiftId());
+        Lift lift = liftService.detail(request.getLiftId());
+        if (ObjectUtil.isEmpty(lift)) {
+            return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, MessageUtils.get("msg.data.empty"));
+        }
+        return RestResponse.ok(lift, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.query.success"));
     }
 
     /**
@@ -110,7 +114,11 @@ public class LiftController {
      */
     @PostMapping("modify")
     public RestResponse modify(@RequestBody Lift lift) {
-        return liftService.modify(lift);
+        Integer result = liftService.modify(lift);
+        if (result > 0) {
+            return RestResponse.ok(result, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.modify.success"));
+        }
+        return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.modify.fail"));
     }
 
     /**

+ 4 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/Lift.java

@@ -2,6 +2,7 @@ package cn.com.ty.lift.business.library.dao.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.math.BigDecimal;
@@ -44,6 +45,7 @@ public class Lift {
     /**
      * 出厂日期
      */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private Date manufactureDate;
 
     /**
@@ -219,11 +221,13 @@ public class Lift {
     /**
      * 设备改造日期
      */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private Date reformDate;
 
     /**
      * 设备安装日期
      */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private Date installDate;
 
     /**

+ 2 - 2
lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/model/LiftResponse.java

@@ -13,10 +13,10 @@ public class LiftResponse {
     /**
      * 电梯ID
      */
-    private String liftId;
+    private String id;
 
     /**
-     * 电梯号
+     * 电梯
      */
     private String liftCode;
 

+ 5 - 13
lift-business-service/src/main/java/cn/com/ty/lift/business/library/service/LiftService.java

@@ -94,16 +94,12 @@ public class LiftService {
 
     /**
      * @param id 电梯id
-     * @return RestResponse 电梯详情
+     * @return Lift 电梯详情
      * @description 查询电梯详情
      * @date 2019/12/6 10:51 AM
      */
-    public RestResponse detail(Long id) {
-        Lift lift = liftMapper.selectById(id);
-        if (lift == null) {
-            return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, MessageUtils.get("msg.data.empty"));
-        }
-        return RestResponse.ok(lift, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.query.success"));
+    public Lift detail(Long id) {
+        return liftMapper.selectById(id);
     }
 
     /**
@@ -198,12 +194,8 @@ public class LiftService {
      * @description 修改电梯
      * @date 2019/11/27 2:22 PM
      */
-    public RestResponse modify(Lift lift) {
-        Integer result = liftMapper.updateById(lift);
-        if (result > 0) {
-            return RestResponse.ok(result, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.modify.success"));
-        }
-        return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.modify.fail"));
+    public Integer modify(Lift lift) {
+        return liftMapper.updateById(lift);
     }
 
     /**

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

@@ -33,6 +33,10 @@ public class ProjectResponse {
      * 区
      */
     private String district;
+    /**
+     * 区编码
+     */
+    private String districtCode;
     /**
      * 台量
      */

+ 36 - 31
lift-business-service/src/main/resources/mapper/lift/LiftMapper.xml

@@ -60,57 +60,62 @@
 	<!-- 根据区域,项目,电梯号,电梯品牌,电梯类型,维保工查询电梯列表信息-->
 	<select id="findByCondition" resultType="cn.com.ty.lift.business.library.dao.entity.model.LiftResponse" parameterType="cn.com.ty.lift.business.library.dao.entity.model.LiftRequest" >
         SELECT
-        l.lift_code         as liftCode,
-        l.registration_code as registrationCode,
-        lb.name             as liftBrand,
-        l.lift_type         as liftType,
-        l.device_position   as devicePosition,
-        pclr.lift_company_status as liftStatus,
-        le.first_time as firstMaintenanceTime
+		l.id                     AS id,
+		l.lift_code              AS liftCode,
+		l.registration_code      AS registrationCode,
+		l.lift_type              AS liftType,
+		l.device_position        AS devicePosition,
+		lb.name                  AS liftBrand,
+		pclr.lift_company_status AS liftStatus,
+		le.first_time            AS firstMaintenanceTime,
+		p.project_name           AS projectName
         FROM platform_company_lift_relevance pclr
-        LEFT JOIN lift l on l.id = pclr.lift_id
-        LEFT JOIN lift_brand lb on l.lift_brand = lb.code
-        LEFT JOIN lift_extension le on le.id = pclr.lift_id and le.mt_company_id = pclr.company_id
-        where 1=1
+        LEFT JOIN lift l ON l.id = pclr.lift_id
+		LEFT JOIN project p ON pclr.company_id = p.mt_company_id
+        LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
+        LEFT JOIN lift_extension le ON le.id = pclr.lift_id AND le.mt_company_id = pclr.company_id
+        WHERE 1=1
         <if test="request.companyId!=null and request.companyId!=''">
-            and pclr.company_id = #{request.companyId,jdbcType=BIGINT}
+			AND pclr.company_id = #{request.companyId,jdbcType=BIGINT}
         </if>
-		<if test="request.liftStatus == 1">
-			and pclr.lift_company_status != 1
+		<if test="request.liftStatus != null and request.liftStatus != '' and request.liftStatus == 1">
+			AND pclr.lift_company_status != 1
 		</if>
-		<if test="request.liftStatus == 0">
-			and pclr.lift_company_status = 1
+		<if test="request.liftStatus != null and request.liftStatus != '' and request.liftStatus == 0">
+			AND pclr.lift_company_status = 1
 		</if>
 		<if test="request.liftType!=null and request.liftType!=''">
-			and l.lift_type = #{request.liftType,jdbcType=VARCHAR}
+			AND l.lift_type = #{request.liftType,jdbcType=VARCHAR}
 		</if>
         <if test="request.liftBrand!=null and request.liftBrand!=''">
-            and lb.code = #{request.liftBrand,jdbcType=VARCHAR}
+			AND lb.code = #{request.liftBrand,jdbcType=VARCHAR}
         </if>
 		<if test="request.registrationCode!=null and request.registrationCode!=''">
-		   and l.registration_code like #{request.registrationCode,jdbcType=VARCHAR}
+			AND l.registration_code LIKE #{request.registrationCode,jdbcType=VARCHAR}
 		</if>
 	</select>
 
 	<!-- 查询项目下电梯列表 -->
     <select id="findLiftListByProjectId" resultType="cn.com.ty.lift.business.library.dao.entity.model.LiftResponse" parameterType="cn.com.ty.lift.business.library.dao.entity.model.LiftRequest">
         SELECT
-          l.id                      as liftId,
-          l.lift_code               as liftCode,
-          l.registration_code       as registrationCode,
-          l.lift_type               as liftType,
-          l.device_position         as devicePosition,
-          lb.name                   as liftBrand,
-          le.annual_inspection_date as annualInspectionDate,
-          pclr.lift_company_status  as liftStatus
+          l.id                      AS id,
+          l.lift_code               AS liftCode,
+          l.registration_code       AS registrationCode,
+          l.lift_type               AS liftType,
+          l.device_position         AS devicePosition,
+          lb.name                   AS liftBrand,
+          le.annual_inspection_date AS annualInspectionDate,
+          pclr.lift_company_status  AS liftStatus,
+		  ui.name                   AS workerName
         FROM project_lift_relevance plr
           LEFT JOIN lift l ON l.id = plr.lift_id
           LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
-          LEFT JOIN lift_extension le ON le.id = plr.lift_id and le.mt_company_id = plr.company_id
-          LEFT JOIN platform_company_lift_relevance pclr on plr.lift_id = pclr.lift_id and pclr.id = plr.relevance_id
-        where 1=1
+          LEFT JOIN lift_extension le ON le.id = plr.lift_id AND le.mt_company_id = plr.company_id
+		  LEFT JOIN user_info ui ON le.worker_id = ui.user_id
+          LEFT JOIN platform_company_lift_relevance pclr ON plr.lift_id = pclr.lift_id AND pclr.id = plr.relevance_id
+        WHERE 1=1
         <if test="request.projectId!=null and request.projectId!=''">
-            and plr.project_id = #{request.projectId,jdbcType=BIGINT}
+            AND plr.project_id = #{request.projectId,jdbcType=BIGINT}
         </if>
     </select>
 

+ 29 - 28
lift-business-service/src/main/resources/mapper/project/ProjectMapper.xml

@@ -42,52 +42,53 @@
 	<!-- 根据省,市,区,区域,区域主管,项目名称、项目编号、甲方名称、项目地址查询项目管理列表-->
 	<select id="findByCondition" resultType="cn.com.ty.lift.business.project.dao.entity.model.ProjectResponse" parameterType="cn.com.ty.lift.business.project.dao.entity.model.ProjectRequest" >
         SELECT
-        p.id            as id,
-        p.project_code  as projectCode,
-        p.project_name  as projectName,
-        p.project_usage as projectUsage,
-        p.province      as province,
-        p.city          as city,
-        p.district      as district,
-        p.num           as num,
-        p.actual_num    as actualNum,
-        p.address       as address,
-        p.start_date    as startDate,
-        p.end_date      as endDate,
-		p.region_id     as regionId,
-		p.pp_company_id as ppCompanyId,
-		p.pp_contact_id as ppContactId,
-		p.save          as save,
-        r.area_name     as regionName,
-        ui.name         as userName,
-        pc.name         as companyName
+        p.id            AS id,
+        p.project_code  AS projectCode,
+        p.project_name  AS projectName,
+        p.project_usage AS projectUsage,
+        p.province      AS province,
+        p.city          AS city,
+        p.district      AS district,
+		p.district_code AS districtCode,
+        p.num           AS num,
+        p.actual_num    AS actualNum,
+        p.address       AS address,
+        p.start_date    AS startDate,
+        p.end_date      AS endDate,
+		p.region_id     AS regionId,
+		p.pp_company_id AS ppCompanyId,
+		p.pp_contact_id AS ppContactId,
+		p.save          AS save,
+        r.area_name     AS regionName,
+        ui.name         AS userName,
+        pc.name         AS companyName
         FROM project p
         LEFT JOIN region r ON p.region_id = r.id
         LEFT JOIN user_info ui ON r.user_id = ui.user_id
         LEFT JOIN property_company pc ON p.pp_company_id = pc.id
         WHERE 1 = 1
 		<if test="request.provinceCode!=null and request.provinceCode!=''">
-			and p.province_code= #{request.provinceCode,jdbcType=VARCHAR}
+			AND p.province_code= #{request.provinceCode,jdbcType=VARCHAR}
 		</if>
 		<if test="request.cityCode!=null and request.cityCode!=''">
-			and p.city_code = #{request.cityCode,jdbcType=VARCHAR}
+			AND p.city_code = #{request.cityCode,jdbcType=VARCHAR}
 		</if>
 		<if test="request.districtCode!=null and request.districtCode!=''">
-			and p.district_code = #{request.districtCode,jdbcType=VARCHAR}
+			AND p.district_code = #{request.districtCode,jdbcType=VARCHAR}
 		</if>
 		<if test="request.regionId!=null and request.regionId!=''">
-			and p.region_id = #{request.regionId,jdbcType=BIGINT}
+			AND p.region_id = #{request.regionId,jdbcType=BIGINT}
 		</if>
         <if test="request.userId!=null and request.userId!=''">
-            and r.user_id = #{request.userId,jdbcType=BIGINT}
+			AND r.user_id = #{request.userId,jdbcType=BIGINT}
         </if>
 		<if test="request.condition!=null and request.condition!=''">
-			and (p.project_name like #{request.condition,jdbcType=VARCHAR}
-			or p.project_code like #{request.condition,jdbcType=VARCHAR}
-			or p.address like #{request.condition,jdbcType=VARCHAR})
+			AND (p.project_name LIKE #{request.condition,jdbcType=VARCHAR}
+			OR p.project_code LIKE #{request.condition,jdbcType=VARCHAR}
+			OR p.address LIKE #{request.condition,jdbcType=VARCHAR})
 		</if>
 		<if test="request.projectStatus!=null and request.projectStatus!=''">
-			and p.project_status = #{request.projectStatus,jdbcType=VARCHAR}
+			AND p.project_status = #{request.projectStatus,jdbcType=VARCHAR}
 		</if>
 	</select>