产品和工站导出;不合格原因报废原因添加排序和与产品的关联;
| | |
| | | |
| | | @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); |
| | | |
| | |
| | | |
| | | int deleteLogicById(Long id); |
| | | |
| | | List<PltProduct> selectAll(); |
| | | List<PltProduct> selectAll(Map<String, Object> params); |
| | | |
| | | String selectMaxCode(); |
| | | } |
| | |
| | | |
| | | int deleteLogicById(Long id); |
| | | |
| | | List<PltStation> selectAll(); |
| | | } |
| | |
| | | public String name; |
| | | |
| | | /** |
| | | * 产品码 |
| | | */ |
| | | public String code; |
| | | |
| | | /** |
| | | * 型号 |
| | | */ |
| | | public String type; |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.dy.common.po.BaseEntity; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.*; |
| | | |
| | | /** |
| | |
| | | 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; |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.dy.common.po.BaseEntity; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.*; |
| | | |
| | | /** |
| | |
| | | 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; |
| | |
| | | <!--@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" /> |
| | |
| | | <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 * |
| | |
| | | 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" /> |
| | |
| | | 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"> |
| | |
| | | </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" /> |
| | |
| | | <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> |
| | |
| | | |
| | | <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 |
| | |
| | | <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 |
| | |
| | | <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" /> |
| | |
| | | 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"> |
| | |
| | | <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}, |
| | |
| | | </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 |
| | |
| | | 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} |
| | |
| | | <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" /> |
| | |
| | | <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> |
| | |
| | | </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}, |
| | |
| | | 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} |
| | |
| | | </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 |
| | |
| | | @Builder |
| | | public class QueryVo extends QueryConditionVo { |
| | | public String item; |
| | | public String proName; |
| | | public Long proId; |
| | | } |
New file |
| | |
| | | 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()); |
| | | } |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | |
| | | this.proSv = proSv; |
| | | } |
| | | |
| | | |
| | | private static final String fileName = "产品信息" ; |
| | | private static final String sheetName = "产品信息" ; |
| | | |
| | | /** |
| | | * 保存产品信息 |
| | |
| | | |
| | | return BaseResponseUtils.buildSuccess(JSON.toJSON(pro)); |
| | | }catch (Exception e){ |
| | | log.error("查询产品异常", e); |
| | | log.error("根据ID查询产品异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | |
| | | */ |
| | | @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()); |
| | | } |
| | | } |
| | |
| | | @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); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | |
| | | |
| | | @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){ |
| | |
| | | |
| | | @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) { |
| | | // 如果出现唯一约束违反异常,尝试获取新的code并重试 |
| | | log.warn("插入产品时遇到唯一约束异常,尝试获取新的code", 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); |
| | |
| | | } |
| | | |
| | | |
| | | 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); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | public String name; |
| | | public String director; |
| | | public String dMobile; |
| | | public String dt; |
| | | public String type; |
| | | } |
New file |
| | |
| | | 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()); |
| | | } |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | |
| | | @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){ |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | 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; |
| | |
| | | station.setDisabled(disabled); |
| | | return dao.updateByPrimaryKeySelective(station); |
| | | } |
| | | |
| | | public List<PltStation> selectAll() { |
| | | return dao.selectAll(); |
| | | } |
| | | } |
| | | |