From 55cb4daf506ad8f3c637f6e3d9bc7df41e538b2e Mon Sep 17 00:00:00 2001 From: liuxm <liuxm@fescotech.com> Date: 星期二, 21 五月 2024 09:14:38 +0800 Subject: [PATCH] 产品和工站导出;不合格原因报废原因添加排序和与产品的关联; --- pms-parent/pms-global/src/main/resources/mapper/PltProductQualityInspectionItemsMapper.xml | 14 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductMapper.java | 8 pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java | 48 ++++ pms-parent/pms-global/src/main/resources/mapper/PltProductScrappingReasonMapper.xml | 52 ++-- pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java | 5 pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ExcelVo.java | 77 +++++++ pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java | 1 pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml | 5 pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proItems/QueryVo.java | 2 pms-parent/pms-global/src/main/resources/mapper/PltProductUnqualifiedReasonMapper.xml | 27 ++ pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java | 5 pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java | 52 ++++ pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java | 37 +++ pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductScrappingReason.java | 16 + pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/QueryVo.java | 2 pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/ExcelVo.java | 77 +++++++ pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductUnqualifiedReason.java | 16 + pms-parent/pms-global/src/main/resources/mapper/PltProductMapper.xml | 147 +++++++------ 18 files changed, 463 insertions(+), 128 deletions(-) diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductMapper.java index 6833a87..330624a 100644 --- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductMapper.java +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductMapper.java @@ -8,15 +8,11 @@ @Mapper public interface PltProductMapper { - int insert(PltProduct record); - int insertSelective(PltProduct record); PltProduct selectByPrimaryKey(Long id); int updateByPrimaryKeySelective(PltProduct record); - - int updateByPrimaryKey(PltProduct record); Long selectSomeCount(Map<String, Object> params); @@ -24,5 +20,7 @@ int deleteLogicById(Long id); - List<PltProduct> selectAll(); + List<PltProduct> selectAll(Map<String, Object> params); + + String selectMaxCode(); } \ No newline at end of file diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java index de60f68..da96e81 100644 --- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java @@ -29,4 +29,5 @@ int deleteLogicById(Long id); + List<PltStation> selectAll(); } diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java index fa31743..feadcae 100644 --- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java @@ -35,6 +35,11 @@ public String name; /** + * 浜у搧鐮� + */ + public String code; + + /** * 鍨嬪彿 */ public String type; diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductScrappingReason.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductScrappingReason.java index 6e2346d..d9a2370 100644 --- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductScrappingReason.java +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductScrappingReason.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.dy.common.po.BaseEntity; import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import lombok.*; /** @@ -35,6 +36,21 @@ public String reason; /** + * 浜у搧ID + */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) + @NotNull(message = "浜у搧id涓嶈兘涓虹┖") + public Long proId; + + @TableField(exist = false) + public String proName; + + /** + * 鎺掑簭(浠庡ぇ鍒板皬) + */ + public int sort; + + /** * 鏄惁绂佺敤锛�1鏄紝0鍚� */ public Boolean disabled; diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductUnqualifiedReason.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductUnqualifiedReason.java index aa5e07d..2d0e612 100644 --- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductUnqualifiedReason.java +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductUnqualifiedReason.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.dy.common.po.BaseEntity; import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import lombok.*; /** @@ -35,6 +36,21 @@ public String reason; /** + * 浜у搧ID + */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) + @NotNull(message = "浜у搧id涓嶈兘涓虹┖") + public Long proId; + + @TableField(exist = false) + public String proName; + + /** + * 鎺掑簭(浠庡ぇ鍒板皬) + */ + public int sort; + + /** * 鏄惁绂佺敤锛�1鏄紝0鍚� */ public Boolean disabled; diff --git a/pms-parent/pms-global/src/main/resources/mapper/PltProductMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PltProductMapper.xml index 0714a04..5c5f0f6 100644 --- a/pms-parent/pms-global/src/main/resources/mapper/PltProductMapper.xml +++ b/pms-parent/pms-global/src/main/resources/mapper/PltProductMapper.xml @@ -5,6 +5,7 @@ <!--@mbg.generated--> <!--@Table plt_product--> <id column="id" jdbcType="BIGINT" property="id" /> + <result column="code" jdbcType="VARCHAR" property="code" /> <result column="name" jdbcType="VARCHAR" property="name" /> <result column="type" jdbcType="VARCHAR" property="type" /> <result column="image" jdbcType="BIGINT" property="image" /> @@ -13,15 +14,20 @@ <result property="deleted" column="deleted" typeHandler="com.dy.common.mybatis.BooleanTypeHandler"/> <result column="dt" jdbcType="TIMESTAMP" property="dt" /> <result column="remark" jdbcType="VARCHAR" property="remark" /> + </resultMap> + + <resultMap id="BaseResultMap2" type="com.dy.pmsGlobal.pojoPlt.PltProduct" extends="BaseResultMap"> <collection property="params" ofType="com.dy.pmsGlobal.pojoPlt.PltProductParams" fetchType="eager" select="selectParams" column="id" /> <collection property="processDocuments" ofType="com.dy.pmsGlobal.pojoPlt.PltProductFile" fetchType="eager" select="selectDocuments" column="id"/> <collection property="userManual" ofType="com.dy.pmsGlobal.pojoPlt.PltProductFile" fetchType="eager" select="selectUserManual" column="id" /> <collection property="materials" ofType="com.dy.pmsGlobal.pojoPlt.PltProductFile" fetchType="eager" select="selectMaterials" column="id"/> </resultMap> - <sql id="Base_Column_List"> <!--@mbg.generated--> - id, `name`, `type`, image, director, d_mobile,deleted, dt, remark + id, code,`name`, `type`, image, director, d_mobile,deleted, dt, remark + </sql> + <sql id="Join_Column_List"> + ${alias}.id,${alias}.code, ${alias}.`name`, ${alias}.`type`, ${alias}.image, ${alias}.director, ${alias}.d_mobile,${alias}.deleted, ${alias}.dt, ${alias}.remark </sql> <select id="selectParams" resultMap="com.dy.pmsGlobal.daoPlt.PltProParamsMapper.BaseResultMap"> select * @@ -44,7 +50,7 @@ where pro_id = #{proId,jdbcType=BIGINT} and file_type = '03' </select> - <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap2"> <!--@mbg.generated--> select <include refid="Base_Column_List" /> @@ -52,63 +58,72 @@ where id = #{id,jdbcType=BIGINT} </select> - <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltProduct" useGeneratedKeys="true"> - <!--@mbg.generated--> - insert into plt_product (`name`, `type`, image, - director, d_mobile,deleted, dt, - remark) - values (#{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{image,jdbcType=BIGINT}, - #{director,jdbcType=BIGINT}, #{dMobile,jdbcType=VARCHAR},#{deleted,jdbcType=TINYINT}, #{dt,jdbcType=TIMESTAMP}, - #{remark,jdbcType=VARCHAR}) - </insert> <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltProduct" useGeneratedKeys="true"> <!--@mbg.generated--> insert into plt_product <trim prefix="(" suffix=")" suffixOverrides=","> - <if test="name != null"> - `name`, - </if> - <if test="type != null"> - `type`, - </if> - <if test="image != null"> - image, - </if> - <if test="director != null"> - director, - </if> - <if test="dMobile != null"> - d_mobile, - </if> - <if test="dt != null"> - dt, - </if> - <if test="remark != null"> - remark, - </if> + <if test="id != null"> + id, + </if> + <if test="code != null"> + `code`, + </if> + <if test="name != null"> + `name`, + </if> + <if test="type != null"> + `type`, + </if> + <if test="image != null"> + image, + </if> + <if test="director != null"> + director, + </if> + <if test="dMobile != null"> + d_mobile, + </if> + <if test="deleted != null"> + deleted, + </if> + <if test="dt != null"> + dt, + </if> + <if test="remark != null"> + remark, + </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> - <if test="name != null"> - #{name,jdbcType=VARCHAR}, - </if> - <if test="type != null"> - #{type,jdbcType=VARCHAR}, - </if> - <if test="image != null"> - #{image,jdbcType=BIGINT}, - </if> - <if test="director != null"> - #{director,jdbcType=BIGINT}, - </if> - <if test="dMobile != null"> - #{dMobile,jdbcType=VARCHAR}, - </if> - <if test="dt != null"> - #{dt,jdbcType=TIMESTAMP}, - </if> - <if test="remark != null"> - #{remark,jdbcType=VARCHAR}, - </if> + <if test="id != null"> + #{id,jdbcType=BIGINT}, + </if> + <if test="code != null"> + #{code,jdbcType=VARCHAR}, + </if> + <if test="name != null"> + #{name,jdbcType=VARCHAR}, + </if> + <if test="type != null"> + #{type,jdbcType=VARCHAR}, + </if> + <if test="image != null"> + #{image,jdbcType=BIGINT}, + </if> + <if test="director != null"> + #{director,jdbcType=BIGINT}, + </if> + <if test="dMobile != null"> + #{dMobile,jdbcType=VARCHAR}, + </if> + <if test="deleted != null"> + #{deleted,jdbcType=VARCHAR }, + </if> + <if test="dt != null"> + #{dt,jdbcType=TIMESTAMP}, + </if> + <if test="remark != null"> + #{remark,jdbcType=VARCHAR}, + </if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoPlt.PltProduct"> @@ -139,27 +154,13 @@ </set> where id = #{id,jdbcType=BIGINT} </update> - <update id="updateByPrimaryKey" parameterType="com.dy.pmsGlobal.pojoPlt.PltProduct"> - <!--@mbg.generated--> - update plt_product - set `name` = #{name,jdbcType=VARCHAR}, - `type` = #{type,jdbcType=VARCHAR}, - image = #{image,jdbcType=BIGINT}, - director = #{director,jdbcType=BIGINT}, - d_mobile = #{dMobile,jdbcType=VARCHAR}, - dt = #{dt,jdbcType=TIMESTAMP}, - remark = #{remark,jdbcType=VARCHAR} - where id = #{id,jdbcType=BIGINT} - </update> <update id="deleteLogicById" parameterType="java.lang.Long"> update plt_product set deleted = 1 where id = #{id} </update> - <sql id="Join_Column_List"> - ${alias}.id, ${alias}.`name`, ${alias}.`type`, ${alias}.image, ${alias}.director, ${alias}.d_mobile,${alias}.deleted, ${alias}.dt, ${alias}.remark - </sql> + <select id="selectSome" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> @@ -193,7 +194,15 @@ <include refid="Base_Column_List" /> from plt_product p where p.deleted!=1 + <trim prefix="and " suffixOverrides="and"> + <if test="type != null and type != ''"> + p.type = #{type,jdbcType=VARCHAR} and + </if> + </trim> order by id desc </select> + <select id="selectMaxCode" resultType="java.lang.String"> + select max(code) from plt_product + </select> </mapper> \ No newline at end of file diff --git a/pms-parent/pms-global/src/main/resources/mapper/PltProductQualityInspectionItemsMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PltProductQualityInspectionItemsMapper.xml index 85197a9..e41e338 100644 --- a/pms-parent/pms-global/src/main/resources/mapper/PltProductQualityInspectionItemsMapper.xml +++ b/pms-parent/pms-global/src/main/resources/mapper/PltProductQualityInspectionItemsMapper.xml @@ -70,15 +70,12 @@ <select id="selectSome" resultMap="BaseResultMap"> select - <include refid="part_Column_List" > - <property name="alias" value="t"/> - </include> + <include refid="Base_Column_List" /> from plt_product_quality_inspection_items t - inner join plt_product p on t.pro_id = p.id where t.deleted!=1 <trim prefix="and" suffixOverrides="and"> - <if test="proName != null and proName != ''"> - p.name like concat('%', #{proName}, '%') and + <if test="proId != null and proId != ''"> + t.pro_id=#{proId} and </if> <if test="item != null and item != ''"> t.item like concat('%', #{item}, '%') and @@ -95,11 +92,10 @@ <select id="selectSomeCount" resultType="java.lang.Long"> select count(1) from plt_product_quality_inspection_items t - inner join plt_product p on t.pro_id = p.id where t.deleted!=1 <trim prefix="and" suffixOverrides="and"> - <if test="proName != null and proName != ''"> - p.name like concat('%', #{proName}, '%') and + <if test="proId != null and proId != ''"> + t.pro_id=#{proId} and </if> <if test="item != null and item != ''"> t.item like concat('%', #{item}, '%') and diff --git a/pms-parent/pms-global/src/main/resources/mapper/PltProductScrappingReasonMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PltProductScrappingReasonMapper.xml index 8a0dbca..e8f1818 100644 --- a/pms-parent/pms-global/src/main/resources/mapper/PltProductScrappingReasonMapper.xml +++ b/pms-parent/pms-global/src/main/resources/mapper/PltProductScrappingReasonMapper.xml @@ -7,21 +7,29 @@ <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPlt.PltProductScrappingReason"> <id property="id" column="id" jdbcType="BIGINT"/> <result property="reason" column="reason" jdbcType="VARCHAR"/> + <result property="proId" column="pro_id" jdbcType="BIGINT"/> + <result property="sort" column="sort" jdbcType="INTEGER"/> <result column="disabled" property="disabled" typeHandler="com.dy.common.mybatis.BooleanTypeHandler"/> <result property="deleted" column="deleted" typeHandler="com.dy.common.mybatis.BooleanTypeHandler"/> + <association property="proName" column="pro_id" javaType="java.lang.Long" + select="selectProNameById" fetchType="eager" /> </resultMap> <sql id="Base_Column_List"> id,reason,disabled, - deleted + deleted,pro_id,sort </sql> <sql id="part_Column_List"> ${alias}.id, ${alias}.reason, + ${alias}.pro_id, + ${alias}.sort, ${alias}.deleted, ${alias}.disabled </sql> - + <select id="selectProNameById" parameterType="java.lang.Long" resultType="java.lang.String"> + select name proName from plt_product where id=#{id} + </select> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> @@ -33,24 +41,22 @@ delete from plt_product_scrapping_reason where id = #{id,jdbcType=BIGINT} </delete> - <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltProductScrappingReason" useGeneratedKeys="true"> - insert into plt_product_scrapping_reason - ( id,pro_id,reason - ,deleted) - values (#{id,jdbcType=BIGINT},#{proId,jdbcType=BIGINT},#{reason,jdbcType=VARCHAR} - ,#{deleted,jdbcType=TINYINT}) - </insert> + <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltProductScrappingReason" useGeneratedKeys="true"> insert into plt_product_scrapping_reason <trim prefix="(" suffix=")" suffixOverrides=","> - <if test="id != null">id,</if> - <if test="reason != null">reason,</if> - <if test="deleted != null">deleted,</if> + <if test="id != null">id,</if> + <if test="reason != null">reason,</if> + <if test="proId != null">pro_id,</if> + <if test="sort != null">sort,</if> + <if test="deleted != null">deleted,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> - <if test="id != null">#{id,jdbcType=BIGINT},</if> - <if test="reason != null">#{reason,jdbcType=VARCHAR},</if> - <if test="deleted != null">#{deleted,jdbcType=TINYINT},</if> + <if test="id != null">#{id,jdbcType=BIGINT},</if> + <if test="reason != null">#{reason,jdbcType=VARCHAR},</if> + <if test="proId != null">#{proId,jdbcType=VARCHAR},</if> + <if test="sort != null">#{sort,jdbcType=VARCHAR},</if> + <if test="deleted != null">#{deleted,jdbcType=TINYINT},</if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoPlt.PltProductScrappingReason"> @@ -58,6 +64,12 @@ <set> <if test="reason != null"> reason = #{reason,jdbcType=VARCHAR}, + </if> + <if test="proId != null"> + pro_id = #{proId,jdbcType=VARCHAR}, + </if> + <if test="sort != null"> + sort = #{sort,jdbcType=VARCHAR}, </if> <if test="disabled != null"> disabled = #{disabled,jdbcType=TINYINT}, @@ -68,14 +80,6 @@ </set> where id = #{id,jdbcType=BIGINT} </update> -<!-- <update id="updateByPrimaryKey" parameterType="com.dy.pmsGlobal.pojoPlt.PltProductScrappingReason">--> -<!-- update plt_product_scrapping_reason--> -<!-- set --> -<!-- pro_id = #{proId,jdbcType=BIGINT},--> -<!-- reason = #{reason,jdbcType=VARCHAR},--> -<!-- deleted = #{deleted,jdbcType=TINYINT}--> -<!-- where id = #{id,jdbcType=BIGINT} --> -<!-- </update>--> <select id="selectSome" resultMap="BaseResultMap"> select @@ -89,7 +93,7 @@ t.reason like concat('%', #{reason}, '%') and </if> </trim> - order by id desc + order by sort desc <trim prefix="limit " > <if test="start != null and count != null"> #{start}, #{count} diff --git a/pms-parent/pms-global/src/main/resources/mapper/PltProductUnqualifiedReasonMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PltProductUnqualifiedReasonMapper.xml index 701bc19..9d73539 100644 --- a/pms-parent/pms-global/src/main/resources/mapper/PltProductUnqualifiedReasonMapper.xml +++ b/pms-parent/pms-global/src/main/resources/mapper/PltProductUnqualifiedReasonMapper.xml @@ -7,14 +7,21 @@ <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPlt.PltProductUnqualifiedReason"> <id property="id" column="id" jdbcType="BIGINT"/> <result property="reason" column="reason" jdbcType="VARCHAR"/> + <result property="proId" column="pro_id" jdbcType="BIGINT"/> + <result property="sort" column="sort" jdbcType="INTEGER"/> <result column="disabled" property="disabled" typeHandler="com.dy.common.mybatis.BooleanTypeHandler"/> <result property="deleted" column="deleted" typeHandler="com.dy.common.mybatis.BooleanTypeHandler"/> + <association property="proName" column="pro_id" javaType="java.lang.Long" + select="selectProNameById" fetchType="eager" /> </resultMap> <sql id="Base_Column_List"> id,pro_id,reason,disabled, - deleted + deleted,pro_id,sort </sql> + <select id="selectProNameById" parameterType="java.lang.Long" resultType="java.lang.String"> + select name proName from plt_product where id=#{id} + </select> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> @@ -25,13 +32,17 @@ <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltProductUnqualifiedReason" useGeneratedKeys="true"> insert into plt_product_unqualified_reason <trim prefix="(" suffix=")" suffixOverrides=","> - <if test="id != null">id,</if> - <if test="reason != null">reason,</if> - <if test="deleted != null">deleted,</if> + <if test="id != null">id,</if> + <if test="reason != null">reason,</if> + <if test="proId != null">pro_id,</if> + <if test="sort != null">sort,</if> + <if test="deleted != null">deleted,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id,jdbcType=BIGINT},</if> <if test="reason != null">#{reason,jdbcType=VARCHAR},</if> + <if test="proId != null">#{proId,jdbcType=VARCHAR},</if> + <if test="sort != null">#{sort,jdbcType=VARCHAR},</if> <if test="deleted != null">#{deleted,jdbcType=TINYINT},</if> </trim> </insert> @@ -43,6 +54,12 @@ </if> <if test="reason != null"> reason = #{reason,jdbcType=VARCHAR}, + </if> + <if test="proId != null"> + pro_id = #{proId,jdbcType=VARCHAR}, + </if> + <if test="sort != null"> + sort = #{sort,jdbcType=VARCHAR}, </if> <if test="deleted != null"> deleted = #{deleted,jdbcType=TINYINT}, @@ -60,7 +77,7 @@ t.reason like concat('%', #{reason}, '%') and </if> </trim> - order by id desc + order by sort desc <trim prefix="limit " > <if test="start != null and count != null"> #{start}, #{count} diff --git a/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml index db8786b..3f19405 100644 --- a/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml +++ b/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml @@ -114,6 +114,11 @@ </if> </trim> </select> + <select id="selectAll" resultMap="BaseResultMap"> + select + <include refid="Base_Column_List" /> + from plt_station where deleted!=1 + </select> <update id="deleteLogicById" parameterType="java.lang.Long"> update plt_station set deleted = 1 diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proItems/QueryVo.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proItems/QueryVo.java index 68b6bb9..d7eb1e8 100644 --- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proItems/QueryVo.java +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proItems/QueryVo.java @@ -11,5 +11,5 @@ @Builder public class QueryVo extends QueryConditionVo { public String item; - public String proName; + public Long proId; } diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ExcelVo.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ExcelVo.java new file mode 100644 index 0000000..9a13849 --- /dev/null +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ExcelVo.java @@ -0,0 +1,77 @@ +package com.dy.pmsPlatform.product; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.*; +import com.alibaba.excel.converters.Converter; +import com.alibaba.excel.converters.WriteConverterContext; +import com.alibaba.excel.enums.BooleanEnum; +import com.alibaba.excel.enums.CellDataTypeEnum; +import com.alibaba.excel.enums.poi.BorderStyleEnum; +import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum; +import com.alibaba.excel.enums.poi.VerticalAlignmentEnum; +import com.alibaba.excel.metadata.GlobalConfiguration; +import com.alibaba.excel.metadata.data.ImageData; +import com.alibaba.excel.metadata.data.WriteCellData; +import com.alibaba.excel.metadata.property.ExcelContentProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +//鍙傝�冿細 https://easyexcel.opensource.alibaba.com/docs/current/quickstart/write +@Data +@HeadRowHeight(40) //璁剧疆鏍囬楂樺害 +@HeadFontStyle(fontName="瀹嬩綋", fontHeightInPoints = 16) +@HeadStyle(wrapped = BooleanEnum.TRUE, shrinkToFit = BooleanEnum.TRUE, + horizontalAlignment = HorizontalAlignmentEnum.CENTER, verticalAlignment = VerticalAlignmentEnum.CENTER, + borderLeft = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN, borderTop = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN, + leftBorderColor = 8, rightBorderColor = 8, topBorderColor = 8, bottomBorderColor = 8) //IndexedColors.BLACK +@ContentRowHeight(220) //璁剧疆鍐呭楂樺害 +@ContentFontStyle(fontName="瀹嬩綋", fontHeightInPoints = 14) +@ContentStyle(wrapped = BooleanEnum.TRUE, shrinkToFit = BooleanEnum.TRUE, + horizontalAlignment = HorizontalAlignmentEnum.CENTER, verticalAlignment = VerticalAlignmentEnum.CENTER, + borderLeft = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN, borderTop = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN, + leftBorderColor = 8, rightBorderColor = 8, topBorderColor = 8, bottomBorderColor = 8) //IndexedColors.BLACK +@ColumnWidth(16) //璁剧疆鍒楀 +public class ExcelVo implements Converter<byte[]> { + + @ExcelProperty("鍚嶇О") + public String name ; //鍚嶇О + + @ExcelProperty("鍨嬪彿") + public String type ; //鍨嬪彿 + + @ExcelProperty("浜у搧鐮�") + public String code ; //鍨嬪彿 + + @ColumnWidth(40) //璁剧疆鍒楀(鍙互淇グ绫�,涔熷彲浠ヤ慨楗板叿浣撳睘鎬�) + @ExcelProperty(value = "浜у搧鐮佷簩缁寸爜", converter = ExcelVo.class) + public byte[] qrCode ; + + + public WriteCellData<?> convertToExcelData(byte[] value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { + WriteCellData cellData = new WriteCellData() ; + if(value != null && value.length >0){ + List<ImageData> list = new ArrayList<>(); + ImageData imd = new ImageData(); + imd.setImage(value); + imd.setImageType(ImageData.ImageType.PICTURE_TYPE_PICT); + imd.setLeft(10); + imd.setTop(10); + imd.setRight(10); + imd.setBottom(10); + list.add(imd) ; + cellData.setImageDataList(list); + cellData.setType(CellDataTypeEnum.EMPTY); + }else{ + cellData.setStringValue(""); + cellData.setType(CellDataTypeEnum.STRING); + } + return cellData; + } + + public WriteCellData<?> convertToExcelData(WriteConverterContext<byte[]> context) throws Exception { + return this.convertToExcelData(context.getValue(), context.getContentProperty(), context.getWriteContext().currentWriteHolder().globalConfiguration()); + } + +} diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java index a3d01fc..28c3c7e 100644 --- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java @@ -1,5 +1,6 @@ package com.dy.pmsPlatform.product; +import com.alibaba.excel.converters.Converter; import com.alibaba.fastjson2.JSON; import com.dy.common.aop.SsoPowerAop; import com.dy.common.webUtil.BaseResponse; @@ -7,12 +8,17 @@ import com.dy.common.webUtil.QueryResultVo; import com.dy.pmsGlobal.aop.Log; import com.dy.pmsGlobal.pojoPlt.PltProduct; +import com.dy.pmsGlobal.util.QrCodeUtil; +import com.google.zxing.WriterException; +import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; +import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -32,7 +38,8 @@ this.proSv = proSv; } - + private static final String fileName = "浜у搧淇℃伅" ; + private static final String sheetName = "浜у搧淇℃伅" ; /** * 淇濆瓨浜у搧淇℃伅 @@ -129,7 +136,7 @@ return BaseResponseUtils.buildSuccess(JSON.toJSON(pro)); }catch (Exception e){ - log.error("鏌ヨ浜у搧寮傚父", e); + log.error("鏍规嵁ID鏌ヨ浜у搧寮傚父", e); return BaseResponseUtils.buildException(e.getMessage()); } } @@ -141,13 +148,13 @@ */ @PostMapping(path="some") @SsoPowerAop(power = "10300000") - @Log("鏌ヨ浜у搧淇℃伅") + @Log("鍒嗛〉鏌ヨ浜у搧淇℃伅") public BaseResponse<QueryResultVo<List<PltProduct>>> some(@RequestBody QueryVo vo){ try { - QueryResultVo<List<PltProduct>> list = proSv.selectSome(vo) ; + QueryResultVo<List<PltProduct>> list = proSv.selectSome(vo); return BaseResponseUtils.buildSuccess(list); }catch (Exception e){ - log.error("鏌ヨ浜у搧寮傚父", e); + log.error("鍒嗛〉鏌ヨ浜у搧寮傚父", e); return BaseResponseUtils.buildException(e.getMessage()); } } @@ -161,11 +168,42 @@ @Log("鏌ヨ鎵�鏈変骇鍝�") public BaseResponse<List<PltProduct>> all(){ try { - List<PltProduct> list = proSv.selectAll() ; - return BaseResponseUtils.buildSuccess(list); + QueryVo vo = new QueryVo(); + return BaseResponseUtils.buildSuccess(proSv.selectAll(vo)); }catch (Exception e){ log.error("鏌ヨ鎵�鏈変骇鍝佸紓甯�", e); return BaseResponseUtils.buildException(e.getMessage()); } } + + @PostMapping(path="export") + @SsoPowerAop(power = "10300000") + @Log("瀵煎嚭浜у搧淇℃伅") + public void export(@RequestBody QueryVo queryVo, HttpServletResponse response){ + try{ + List<Converter> list = new ArrayList<>() ; + + List<PltProduct> porList = proSv.selectAll(queryVo); + // 浣跨敤骞惰娴佹彁楂樻�ц兘 + porList.parallelStream().forEach(pro -> { + ExcelVo vo = new ExcelVo(); + vo.name = pro.name; + vo.type = pro.type; + vo.code = pro.code; + try { + vo.qrCode = QrCodeUtil.genQrCode(pro.code); + } catch (IOException e) { + e.printStackTrace(); + } catch (WriterException e) { + e.printStackTrace(); + } + list.add(vo); + }); + QrCodeUtil.downloadExcel(response, fileName,sheetName,list); + }catch (Exception e){ + log.error("瀵煎嚭浜у搧淇℃伅寮傚父", e); + } + } + + } diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java index 2c1dcaf..0ee58f1 100644 --- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java @@ -1,5 +1,6 @@ package com.dy.pmsPlatform.product; +import com.alibaba.excel.util.StringUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.pmsGlobal.daoOth.OthFileMapper; import com.dy.pmsGlobal.daoPlt.PltProParamsMapper; @@ -15,6 +16,7 @@ import org.apache.dubbo.common.utils.PojoUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.dao.DuplicateKeyException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -35,6 +37,9 @@ @Value("${dy.webFile.fmUrl}") private String fmUrl ; + + private static final String DEFAULT_CODE = "001"; + private static final String CODE_FORMAT = "%03d"; @Autowired public void setFileOperate(FileOperate fileOperate){ @@ -65,12 +70,38 @@ @Transactional public int save(PltProduct p) { - int count = dao.insert(p); - if(count>0){ - saveProRel(p); - } - return count; + int flag=0; + do { + p.code = getNextCode(); + try { + int count = dao.insertSelective(p); + if (count > 0) { + saveProRel(p); + return count; + } + } catch (DuplicateKeyException e) { + // 濡傛灉鍑虹幇鍞竴绾︽潫杩濆弽寮傚父锛屽皾璇曡幏鍙栨柊鐨刢ode骞堕噸璇� + log.warn("鎻掑叆浜у搧鏃堕亣鍒板敮涓�绾︽潫寮傚父锛屽皾璇曡幏鍙栨柊鐨刢ode", e); + } + flag++; + } while (flag<5); + return 0; } + private String getNextCode(){ + log.info("鑾峰彇浜у搧缂栧彿"); + String maxCode = dao.selectMaxCode(); + if (StringUtils.isBlank(maxCode)) { + return DEFAULT_CODE; + } else { + int nextCode = Integer.parseInt(maxCode) + 1; + // 妫�鏌ユ孩鍑� + if (nextCode > 999) { + throw new RuntimeException("浜у搧缂栧彿婧㈠嚭"); + } + return String.format(CODE_FORMAT, nextCode); + } + } + @Transactional public int update(PltProduct p) { int count = dao.updateByPrimaryKeySelective(p); @@ -187,7 +218,10 @@ } - public List<PltProduct> selectAll() { - return dao.selectAll(); + public List<PltProduct> selectAll(QueryVo queryVo) { + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); + return dao.selectAll(params); } + + } diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/QueryVo.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/QueryVo.java index c67d8c3..8866689 100644 --- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/QueryVo.java +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/QueryVo.java @@ -13,5 +13,5 @@ public String name; public String director; public String dMobile; - public String dt; + public String type; } diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/ExcelVo.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/ExcelVo.java new file mode 100644 index 0000000..9d5bc75 --- /dev/null +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/ExcelVo.java @@ -0,0 +1,77 @@ +package com.dy.pmsPlatform.station; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.*; +import com.alibaba.excel.converters.Converter; +import com.alibaba.excel.converters.WriteConverterContext; +import com.alibaba.excel.enums.BooleanEnum; +import com.alibaba.excel.enums.CellDataTypeEnum; +import com.alibaba.excel.enums.poi.BorderStyleEnum; +import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum; +import com.alibaba.excel.enums.poi.VerticalAlignmentEnum; +import com.alibaba.excel.metadata.GlobalConfiguration; +import com.alibaba.excel.metadata.data.ImageData; +import com.alibaba.excel.metadata.data.WriteCellData; +import com.alibaba.excel.metadata.property.ExcelContentProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +//鍙傝�冿細 https://easyexcel.opensource.alibaba.com/docs/current/quickstart/write +@Data +@HeadRowHeight(40) //璁剧疆鏍囬楂樺害 +@HeadFontStyle(fontName="瀹嬩綋", fontHeightInPoints = 16) +@HeadStyle(wrapped = BooleanEnum.TRUE, shrinkToFit = BooleanEnum.TRUE, + horizontalAlignment = HorizontalAlignmentEnum.CENTER, verticalAlignment = VerticalAlignmentEnum.CENTER, + borderLeft = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN, borderTop = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN, + leftBorderColor = 8, rightBorderColor = 8, topBorderColor = 8, bottomBorderColor = 8) //IndexedColors.BLACK +@ContentRowHeight(220) //璁剧疆鍐呭楂樺害 +@ContentFontStyle(fontName="瀹嬩綋", fontHeightInPoints = 14) +@ContentStyle(wrapped = BooleanEnum.TRUE, shrinkToFit = BooleanEnum.TRUE, + horizontalAlignment = HorizontalAlignmentEnum.CENTER, verticalAlignment = VerticalAlignmentEnum.CENTER, + borderLeft = BorderStyleEnum.THIN, borderRight = BorderStyleEnum.THIN, borderTop = BorderStyleEnum.THIN, borderBottom = BorderStyleEnum.THIN, + leftBorderColor = 8, rightBorderColor = 8, topBorderColor = 8, bottomBorderColor = 8) //IndexedColors.BLACK +@ColumnWidth(16) //璁剧疆鍒楀 +public class ExcelVo implements Converter<byte[]> { + + @ExcelProperty("鍚嶇О") + public String name ; + + @ExcelProperty("鐢熶骇绾�") + public String lineName ; + +// @ExcelProperty("缂栫爜") +// public String code ; + + @ColumnWidth(40) //璁剧疆鍒楀(鍙互淇グ绫�,涔熷彲浠ヤ慨楗板叿浣撳睘鎬�) + @ExcelProperty(value = "宸ョ珯浜岀淮鐮�", converter = ExcelVo.class) + public byte[] qrCode ; + + + public WriteCellData<?> convertToExcelData(byte[] value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { + WriteCellData cellData = new WriteCellData() ; + if(value != null && value.length >0){ + List<ImageData> list = new ArrayList<>(); + ImageData imd = new ImageData(); + imd.setImage(value); + imd.setImageType(ImageData.ImageType.PICTURE_TYPE_PICT); + imd.setLeft(10); + imd.setTop(10); + imd.setRight(10); + imd.setBottom(10); + list.add(imd) ; + cellData.setImageDataList(list); + cellData.setType(CellDataTypeEnum.EMPTY); + }else{ + cellData.setStringValue(""); + cellData.setType(CellDataTypeEnum.STRING); + } + return cellData; + } + + public WriteCellData<?> convertToExcelData(WriteConverterContext<byte[]> context) throws Exception { + return this.convertToExcelData(context.getValue(), context.getContentProperty(), context.getWriteContext().currentWriteHolder().globalConfiguration()); + } + +} diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java index 2e191f5..e081b49 100644 --- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java @@ -1,5 +1,6 @@ package com.dy.pmsPlatform.station; +import com.alibaba.excel.converters.Converter; import com.alibaba.fastjson2.JSON; import com.dy.common.aop.SsoPowerAop; import com.dy.common.webUtil.BaseResponse; @@ -7,12 +8,17 @@ import com.dy.common.webUtil.QueryResultVo; import com.dy.pmsGlobal.aop.Log; import com.dy.pmsGlobal.pojoPlt.PltStation; +import com.dy.pmsGlobal.util.QrCodeUtil; +import com.google.zxing.WriterException; +import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; +import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -24,6 +30,9 @@ @RequestMapping(path="station") @SuppressWarnings("unchecked") public class StationCtrl { + private static final String fileName = "宸ョ珯淇℃伅" ; + private static final String sheetName = "宸ョ珯淇℃伅" ; + private static final String stationPrefix = "103" ; private StationSv sv; @Autowired public StationCtrl(StationSv sv){ @@ -161,5 +170,33 @@ return BaseResponseUtils.buildSuccess(true); } } + @PostMapping(path="export") + @SsoPowerAop(power = "10300000") + @Log("瀵煎嚭宸ョ珯淇℃伅") + public void export(HttpServletResponse response){ + try{ + List<Converter> list = new ArrayList<>() ; + + List<PltStation> stations = sv.selectAll(); + // 浣跨敤骞惰娴佹彁楂樻�ц兘 + stations.parallelStream().forEach(station -> { + ExcelVo vo = new ExcelVo(); + vo.name = station.name; +// vo.code = "103"+station.id; + vo.lineName = station.lineName; + try { + vo.qrCode = QrCodeUtil.genQrCode(stationPrefix+station.id); + } catch (IOException e) { + e.printStackTrace(); + } catch (WriterException e) { + e.printStackTrace(); + } + list.add(vo); + }); + QrCodeUtil.downloadExcel(response, fileName,sheetName,list); + }catch (Exception e){ + log.error("瀵煎嚭浜у搧淇℃伅寮傚父", e); + } + } } diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java index 0389ee9..56ed3ac 100644 --- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java @@ -2,6 +2,7 @@ import com.dy.common.webUtil.QueryResultVo; import com.dy.pmsGlobal.daoPlt.PltStationMapper; +import com.dy.pmsGlobal.pojoPlt.PltProduct; import com.dy.pmsGlobal.pojoPlt.PltStation; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.common.utils.PojoUtils; @@ -83,5 +84,9 @@ station.setDisabled(disabled); return dao.updateByPrimaryKeySelective(station); } + + public List<PltStation> selectAll() { + return dao.selectAll(); + } } -- Gitblit v1.8.0