Browse Source

[chg]添加电梯扩展

别傲 5 years ago
parent
commit
9bafe2936c

+ 2 - 1
lift-manager-service/src/main/java/cn/com/ty/lift/manager/library/dao/entity/Lift.java

@@ -3,6 +3,7 @@ package cn.com.ty.lift.manager.library.dao.entity;
 import java.math.BigDecimal;
 import java.util.Date;
 
+import cn.com.ty.lift.manager.library.dao.entity.model.LiftExtensionRequest;
 import lombok.Data;
 
 /**
@@ -11,7 +12,7 @@ import lombok.Data;
  * @since 2019-11-25 17:37:16
  */
 @Data
-public class Lift {
+public class Lift extends LiftExtensionRequest {
 
     /**
      * 电梯id

+ 88 - 0
lift-manager-service/src/main/java/cn/com/ty/lift/manager/library/dao/entity/LiftExtension.java

@@ -0,0 +1,88 @@
+package cn.com.ty.lift.manager.library.dao.entity;
+
+import java.util.Date;
+
+import lombok.Data;
+
+/**
+ * 实体类 - 表:lift_extension
+ *
+ * @since 2019-12-03 14:09:55
+ */
+@Data
+public class LiftExtension {
+    /**
+     * 电梯ID
+     */
+    private Long id;
+
+    /**
+     * 维保公司ID
+     */
+    private Long mtCompanyId;
+
+    /**
+     * 项目ID
+     */
+    private Long projectId;
+
+    /**
+     * 维保工ID
+     */
+    private Long workerId;
+
+    /**
+     * 首保时间
+     */
+    private Date firstTime;
+
+    /**
+     * 停保日期
+     */
+    private Date outServiceDate;
+
+    /**
+     * 年检日期
+     */
+    private Date annualInspectionDate;
+
+    /**
+     * 行政区划代码
+     */
+    private String areaCode;
+
+    /**
+     * 电梯状态 0:删除,1:停保,2:正常,3:保养中 4:维修中
+     */
+    private Byte liftStatus;
+
+    /**
+     * 是否认证 '0 未认证(默认); 1是已认证
+     */
+    private Byte isCertificated;
+
+    /**
+     * 是否锁定 0-正常;1-锁定
+     */
+    private Byte isLocked;
+
+    /**
+     * 临时停梯时间
+     */
+    private Date stopDate;
+
+    /**
+     * 维保间隔
+     */
+    private Byte planInterval;
+
+    /**
+     * 设备ID
+     */
+    private String deviceId;
+
+    /**
+     * 设备类型
+     */
+    private Byte deviceType;
+}

+ 23 - 0
lift-manager-service/src/main/java/cn/com/ty/lift/manager/library/dao/entity/model/LiftExtensionRequest.java

@@ -0,0 +1,23 @@
+package cn.com.ty.lift.manager.library.dao.entity.model;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author bieao
+ * @date 2019/12/3
+ * @description 电梯扩展请求体
+ */
+@Data
+public class LiftExtensionRequest {
+    /**
+     * 年检日期
+     */
+    private Date annualInspectionDate;
+
+    /**
+     * 电梯维保负责人
+     */
+    private Long workerId;
+}

+ 22 - 0
lift-manager-service/src/main/java/cn/com/ty/lift/manager/library/dao/mapper/LiftExtensionMapper.java

@@ -0,0 +1,22 @@
+package cn.com.ty.lift.manager.library.dao.mapper;
+
+import cn.com.ty.lift.manager.library.dao.entity.LiftExtension;
+
+/**
+ * @author bieao
+ * @description 电梯扩展数据层
+ * @date 2019/12/3 2:32 PM
+ */
+public interface LiftExtensionMapper {
+    int deleteByPrimaryKey(Long id);
+
+    int insert(LiftExtension record);
+
+    int insertSelective(LiftExtension record);
+
+    LiftExtension selectByPrimaryKey(Long id);
+
+    int updateByPrimaryKeySelective(LiftExtension record);
+
+    int updateByPrimaryKey(LiftExtension record);
+}

+ 1 - 1
lift-manager-service/src/main/java/cn/com/ty/lift/manager/library/dao/mapper/LiftMapper.java

@@ -17,7 +17,7 @@ import java.util.List;
 public interface LiftMapper extends BaseMapper<Lift> {
     int deleteByPrimaryKey(Long id);
 
-    int insertSelective(Lift record);
+    Long insertSelective(Lift record);
 
     List<Lift> findByCondition(IPage page, @Param("request") LiftRequest request);
 

+ 33 - 11
lift-manager-service/src/main/java/cn/com/ty/lift/manager/library/service/LibraryService.java

@@ -5,18 +5,18 @@ import cn.com.ty.lift.common.constants.ApiConstants;
 import cn.com.ty.lift.common.export.ExportUtils;
 import cn.com.ty.lift.manager.framework.util.MessageUtils;
 import cn.com.ty.lift.manager.library.dao.entity.Lift;
+import cn.com.ty.lift.manager.library.dao.entity.LiftExtension;
+import cn.com.ty.lift.manager.library.dao.mapper.LiftExtensionMapper;
 import cn.com.ty.lift.manager.library.dao.mapper.LiftMapper;
 import cn.com.ty.lift.manager.library.dao.entity.model.LiftRequest;
 import cn.com.xwy.boot.web.dto.RestResponse;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @author bieao
@@ -27,7 +27,10 @@ import java.util.Map;
 public class LibraryService {
 
     @Resource
-    private LiftMapper mapper;
+    private LiftMapper liftMapper;
+
+    @Resource
+    private LiftExtensionMapper liftExtensionMapper;
 
     private Map<String, String> paramMap = new HashMap<String, String>() {{
         put("liftCode", "电梯号");
@@ -45,7 +48,7 @@ public class LibraryService {
      */
     public RestResponse<IPage<Lift>> list(LiftRequest request) {
         IPage<Lift> page = new Page<>(request.getPageNum(), request.getPageSize());
-        List<Lift> lifts = mapper.findByCondition(page, request);
+        List<Lift> lifts = liftMapper.findByCondition(page, request);
         if (lifts.isEmpty()) {
             page.setRecords(new ArrayList<>());
             return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, MessageUtils.get("msg.data.empty"));
@@ -54,16 +57,35 @@ public class LibraryService {
         return RestResponse.ok(page, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.query.success"));
     }
 
+    /**
+     * @param lift 电梯
+     * @return 电梯扩展实体
+     * @description 初始化电梯扩展实体
+     * @date 2019/12/3 3:25 PM
+     */
+    private LiftExtension init(Lift lift) {
+        LiftExtension extension = new LiftExtension();
+        extension.setId(lift.getId());
+        extension.setAnnualInspectionDate(lift.getAnnualInspectionDate());
+        extension.setWorkerId(lift.getWorkerId());
+        return extension;
+    }
+
     /**
      * @param lift 新增项目数据项
      * @return RestResponse 状态码和返回消息
      * @description 新增电梯
      * @date 2019/11/27 2:22 PM
      */
+    @Transactional
     public RestResponse add(Lift lift) {
-        Integer result = mapper.insertSelective(lift);
-        if (result > 0) {
-            return RestResponse.ok(result, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.add.success"));
+        Long id = liftMapper.insertSelective(lift);
+        if (id != null) {
+            LiftExtension extension = init(lift);
+            Integer result = liftExtensionMapper.insertSelective(extension);
+            if (result > 0) {
+                return RestResponse.ok(result, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.add.success"));
+            }
         }
         return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
     }
@@ -75,7 +97,7 @@ public class LibraryService {
      * @date 2019/11/27 2:22 PM
      */
     public RestResponse modify(Lift lift) {
-        Integer result = mapper.updateByPrimaryKeySelective(lift);
+        Integer result = liftMapper.updateByPrimaryKeySelective(lift);
         if (result > 0) {
             return RestResponse.ok(result, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.modify.success"));
         }
@@ -89,7 +111,7 @@ public class LibraryService {
      * @date 2019/11/27 2:22 PM
      */
     public void export(ExportRequest request) {
-        List<Lift> liftList = mapper.selectBatchIds(request.getIds());
+        List<Lift> liftList = liftMapper.selectBatchIds(request.getIds());
         ExportUtils utils = new ExportUtils();
         utils.export(liftList, paramMap, request.getExportPath());
     }

+ 221 - 0
lift-manager-service/src/main/resources/mapper/LiftExtensionMapper.xml

@@ -0,0 +1,221 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="cn.com.ty.lift.manager.library.dao.mapper.LiftExtensionMapper" >
+	<resultMap id="BaseResultMap" type="cn.com.ty.lift.manager.library.dao.entity.LiftExtension" >
+		<id column="id" property="id" jdbcType="BIGINT" />
+		<result column="mt_company_id" property="mtCompanyId" jdbcType="BIGINT" />
+		<result column="project_id" property="projectId" jdbcType="BIGINT" />
+		<result column="worker_id" property="workerId" jdbcType="BIGINT" />
+		<result column="first_time" property="firstTime" jdbcType="DATE" />
+		<result column="out_service_date" property="outServiceDate" jdbcType="DATE" />
+		<result column="annual_inspection_date" property="annualInspectionDate" jdbcType="DATE" />
+		<result column="area_code" property="areaCode" jdbcType="CHAR" />
+		<result column="lift_status" property="liftStatus" jdbcType="TINYINT" />
+		<result column="is_certificated" property="isCertificated" jdbcType="TINYINT" />
+		<result column="is_locked" property="isLocked" jdbcType="TINYINT" />
+		<result column="stop_date" property="stopDate" jdbcType="TIMESTAMP" />
+		<result column="plan_interval" property="planInterval" jdbcType="TINYINT" />
+		<result column="device_id" property="deviceId" jdbcType="VARCHAR" />
+		<result column="device_type" property="deviceType" jdbcType="TINYINT" />
+	</resultMap>
+
+	<sql id="Base_Column_List" >
+		id, mt_company_id, project_id, worker_id, first_time, out_service_date, annual_inspection_date, 
+		area_code, lift_status, is_certificated, is_locked, stop_date, plan_interval, device_id, 
+		device_type
+	</sql>
+
+	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
+		select 
+		<include refid="Base_Column_List" />
+		from lift_extension
+		where id = #{id,jdbcType=BIGINT}
+	</select>
+
+	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
+		delete from lift_extension
+		where id = #{id,jdbcType=BIGINT}
+	</delete>
+
+	<insert id="insert" parameterType="cn.com.ty.lift.manager.library.dao.entity.LiftExtension" >
+		insert into lift_extension (id, mt_company_id, project_id, 
+			worker_id, first_time, out_service_date, 
+			annual_inspection_date, area_code, lift_status, 
+			is_certificated, is_locked, stop_date, 
+			plan_interval, device_id, device_type
+			)
+		values (#{id,jdbcType=BIGINT}, #{mtCompanyId,jdbcType=BIGINT}, #{projectId,jdbcType=BIGINT}, 
+			#{workerId,jdbcType=BIGINT}, #{firstTime,jdbcType=DATE}, #{outServiceDate,jdbcType=DATE}, 
+			#{annualInspectionDate,jdbcType=DATE}, #{areaCode,jdbcType=CHAR}, #{liftStatus,jdbcType=TINYINT}, 
+			#{isCertificated,jdbcType=TINYINT}, #{isLocked,jdbcType=TINYINT}, #{stopDate,jdbcType=TIMESTAMP}, 
+			#{planInterval,jdbcType=TINYINT}, #{deviceId,jdbcType=VARCHAR}, #{deviceType,jdbcType=TINYINT}
+			)
+	</insert>
+
+	<insert id="insertSelective" parameterType="cn.com.ty.lift.manager.library.dao.entity.LiftExtension" >
+		insert into lift_extension
+		<trim prefix="(" suffix=")" suffixOverrides="," >
+			<if test="id != null" >
+				id,
+			</if>
+			<if test="mtCompanyId != null" >
+				mt_company_id,
+			</if>
+			<if test="projectId != null" >
+				project_id,
+			</if>
+			<if test="workerId != null" >
+				worker_id,
+			</if>
+			<if test="firstTime != null" >
+				first_time,
+			</if>
+			<if test="outServiceDate != null" >
+				out_service_date,
+			</if>
+			<if test="annualInspectionDate != null" >
+				annual_inspection_date,
+			</if>
+			<if test="areaCode != null" >
+				area_code,
+			</if>
+			<if test="liftStatus != null" >
+				lift_status,
+			</if>
+			<if test="isCertificated != null" >
+				is_certificated,
+			</if>
+			<if test="isLocked != null" >
+				is_locked,
+			</if>
+			<if test="stopDate != null" >
+				stop_date,
+			</if>
+			<if test="planInterval != null" >
+				plan_interval,
+			</if>
+			<if test="deviceId != null" >
+				device_id,
+			</if>
+			<if test="deviceType != null" >
+				device_type,
+			</if>
+		</trim>
+		<trim prefix="values (" suffix=")" suffixOverrides="," >
+			<if test="id != null" >
+				#{id,jdbcType=BIGINT},
+			</if>
+			<if test="mtCompanyId != null" >
+				#{mtCompanyId,jdbcType=BIGINT},
+			</if>
+			<if test="projectId != null" >
+				#{projectId,jdbcType=BIGINT},
+			</if>
+			<if test="workerId != null" >
+				#{workerId,jdbcType=BIGINT},
+			</if>
+			<if test="firstTime != null" >
+				#{firstTime,jdbcType=DATE},
+			</if>
+			<if test="outServiceDate != null" >
+				#{outServiceDate,jdbcType=DATE},
+			</if>
+			<if test="annualInspectionDate != null" >
+				#{annualInspectionDate,jdbcType=DATE},
+			</if>
+			<if test="areaCode != null" >
+				#{areaCode,jdbcType=CHAR},
+			</if>
+			<if test="liftStatus != null" >
+				#{liftStatus,jdbcType=TINYINT},
+			</if>
+			<if test="isCertificated != null" >
+				#{isCertificated,jdbcType=TINYINT},
+			</if>
+			<if test="isLocked != null" >
+				#{isLocked,jdbcType=TINYINT},
+			</if>
+			<if test="stopDate != null" >
+				#{stopDate,jdbcType=TIMESTAMP},
+			</if>
+			<if test="planInterval != null" >
+				#{planInterval,jdbcType=TINYINT},
+			</if>
+			<if test="deviceId != null" >
+				#{deviceId,jdbcType=VARCHAR},
+			</if>
+			<if test="deviceType != null" >
+				#{deviceType,jdbcType=TINYINT},
+			</if>
+		</trim>
+	</insert>
+
+	<update id="updateByPrimaryKeySelective" parameterType="cn.com.ty.lift.manager.library.dao.entity.LiftExtension" >
+		update lift_extension
+		<set >
+			<if test="mtCompanyId != null" >
+				mt_company_id = #{mtCompanyId,jdbcType=BIGINT},
+			</if>
+			<if test="projectId != null" >
+				project_id = #{projectId,jdbcType=BIGINT},
+			</if>
+			<if test="workerId != null" >
+				worker_id = #{workerId,jdbcType=BIGINT},
+			</if>
+			<if test="firstTime != null" >
+				first_time = #{firstTime,jdbcType=DATE},
+			</if>
+			<if test="outServiceDate != null" >
+				out_service_date = #{outServiceDate,jdbcType=DATE},
+			</if>
+			<if test="annualInspectionDate != null" >
+				annual_inspection_date = #{annualInspectionDate,jdbcType=DATE},
+			</if>
+			<if test="areaCode != null" >
+				area_code = #{areaCode,jdbcType=CHAR},
+			</if>
+			<if test="liftStatus != null" >
+				lift_status = #{liftStatus,jdbcType=TINYINT},
+			</if>
+			<if test="isCertificated != null" >
+				is_certificated = #{isCertificated,jdbcType=TINYINT},
+			</if>
+			<if test="isLocked != null" >
+				is_locked = #{isLocked,jdbcType=TINYINT},
+			</if>
+			<if test="stopDate != null" >
+				stop_date = #{stopDate,jdbcType=TIMESTAMP},
+			</if>
+			<if test="planInterval != null" >
+				plan_interval = #{planInterval,jdbcType=TINYINT},
+			</if>
+			<if test="deviceId != null" >
+				device_id = #{deviceId,jdbcType=VARCHAR},
+			</if>
+			<if test="deviceType != null" >
+				device_type = #{deviceType,jdbcType=TINYINT},
+			</if>
+		</set>
+		where id = #{id,jdbcType=BIGINT}
+	</update>
+
+	<update id="updateByPrimaryKey" parameterType="cn.com.ty.lift.manager.library.dao.entity.LiftExtension" >
+		update lift_extension
+		set mt_company_id = #{mtCompanyId,jdbcType=BIGINT},
+			project_id = #{projectId,jdbcType=BIGINT},
+			worker_id = #{workerId,jdbcType=BIGINT},
+			first_time = #{firstTime,jdbcType=DATE},
+			out_service_date = #{outServiceDate,jdbcType=DATE},
+			annual_inspection_date = #{annualInspectionDate,jdbcType=DATE},
+			area_code = #{areaCode,jdbcType=CHAR},
+			lift_status = #{liftStatus,jdbcType=TINYINT},
+			is_certificated = #{isCertificated,jdbcType=TINYINT},
+			is_locked = #{isLocked,jdbcType=TINYINT},
+			stop_date = #{stopDate,jdbcType=TIMESTAMP},
+			plan_interval = #{planInterval,jdbcType=TINYINT},
+			device_id = #{deviceId,jdbcType=VARCHAR},
+			device_type = #{deviceType,jdbcType=TINYINT}
+		where id = #{id,jdbcType=BIGINT}
+	</update>
+
+</mapper>

+ 1 - 1
lift-manager-service/src/main/resources/mapper/LiftMapper.xml

@@ -120,7 +120,7 @@
 			#{innerFloor,jdbcType=TINYINT})
 	</insert>
 
-	<insert id="insertSelective" parameterType="cn.com.ty.lift.manager.library.dao.entity.Lift" >
+	<insert id="insertSelective" keyProperty="id" parameterType="cn.com.ty.lift.manager.library.dao.entity.Lift" >
 		insert into lift
 		<trim prefix="(" suffix=")" suffixOverrides="," >
 			<if test="id != null" >