liuxm
2024-05-21 55cb4daf506ad8f3c637f6e3d9bc7df41e538b2e
产品和工站导出;不合格原因报废原因添加排序和与产品的关联;
16个文件已修改
2个文件已添加
591 ■■■■ 已修改文件
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductScrappingReason.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductUnqualifiedReason.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PltProductMapper.xml 147 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PltProductQualityInspectionItemsMapper.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PltProductScrappingReasonMapper.xml 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PltProductUnqualifiedReasonMapper.xml 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proItems/QueryVo.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ExcelVo.java 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductCtrl.java 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/QueryVo.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/ExcelVo.java 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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();
}
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java
@@ -29,4 +29,5 @@
    int deleteLogicById(Long id);
    List<PltStation> selectAll();
}
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;
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;
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;
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>
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
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}
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}
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
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;
}
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ExcelVo.java
New file
@@ -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());
    }
}
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);
        }
    }
}
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) {
                // 如果出现唯一约束违反异常,尝试获取新的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);
@@ -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);
    }
}
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;
}
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/ExcelVo.java
New file
@@ -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());
    }
}
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);
        }
    }
}
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();
    }
}