| | |
| | | |
| | | PrAssemblyPlan selectByDeviceNo(@Param("proCode") String proCode,@Param("batchNumber") String batchNumber); |
| | | |
| | | Long countByPlanIdAndNodeId(@Param("planId") Long planId,@Param("nodeId") Long nodeId); |
| | | List<Map<String,Object>> selectByPlanName(@Param("planName") String planName); |
| | | |
| | | List<PrAssemblyPlan> selectAssyPlanList(PrAssemblyPlan params); |
| | | |
| | | List<PrAssemblyPlan> selectAssyPlanSimplify(PrAssemblyPlan params); |
New file |
| | |
| | | package com.dy.pmsGlobal.daoPr; |
| | | |
| | | import com.dy.pmsGlobal.pojoPr.PrSchedule; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Mapper |
| | | public interface PrScheduleMapper { |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(PrSchedule record); |
| | | |
| | | int insertSelective(PrSchedule record); |
| | | |
| | | PrSchedule selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(PrSchedule record); |
| | | |
| | | int updateByPrimaryKey(PrSchedule record); |
| | | |
| | | Long selectSomeCount(Map<String, Object> params); |
| | | |
| | | List<PrSchedule> selectSome(Map<String, Object> params); |
| | | |
| | | List<PrSchedule> selectAll(@Param("scheduleDate") String scheduleDate,@Param("userId") String userId); |
| | | } |
New file |
| | |
| | | package com.dy.pmsGlobal.daoPr; |
| | | |
| | | import com.dy.pmsGlobal.pojoPr.PrScheduleRel; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | public interface PrScheduleRelMapper { |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(PrScheduleRel record); |
| | | |
| | | int insertSelective(PrScheduleRel record); |
| | | |
| | | PrScheduleRel selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(PrScheduleRel record); |
| | | |
| | | int updateByPrimaryKey(PrScheduleRel record); |
| | | |
| | | void deleteByScheduleId(Long scheduleId); |
| | | |
| | | List<PrScheduleRel> selectByScheduleId(Long scheduleId); |
| | | } |
New file |
| | |
| | | package com.dy.pmsGlobal.pojoPr; |
| | | |
| | | import com.alibaba.fastjson2.annotation.JSONField; |
| | | import com.alibaba.fastjson2.writer.ObjectWriterImplToString; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.dy.common.po.BaseEntity; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import jakarta.validation.Valid; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.*; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 排班表 |
| | | */ |
| | | @TableName(value="pr_schedule", autoResultMap = true) |
| | | @Data |
| | | @Builder |
| | | @ToString |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class PrSchedule implements BaseEntity { |
| | | |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | public Long id; |
| | | |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @NotNull(message="用户id不能为空") |
| | | public Long userId; |
| | | @TableField(exist = false) |
| | | public String userName; |
| | | |
| | | |
| | | /** |
| | | * 排班日期 |
| | | */ |
| | | @NotEmpty(message="排班日期不能为空") |
| | | public String scheduleDate; |
| | | |
| | | /** |
| | | * 是否删除,1是,0否 |
| | | */ |
| | | @JSONField(serialize = false) |
| | | public Byte deleted; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | public Date dt; |
| | | |
| | | @Valid |
| | | @NotEmpty(message = "排班内容不能为空") |
| | | public List<PrScheduleRel> relList; |
| | | } |
New file |
| | |
| | | package com.dy.pmsGlobal.pojoPr; |
| | | |
| | | import com.alibaba.fastjson2.annotation.JSONField; |
| | | import com.alibaba.fastjson2.writer.ObjectWriterImplToString; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.dy.common.po.BaseEntity; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import lombok.*; |
| | | |
| | | /** |
| | | * 排班子表 |
| | | */ |
| | | @TableName(value="pr_schedule_rel", autoResultMap = true) |
| | | @Data |
| | | @Builder |
| | | @ToString |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class PrScheduleRel implements BaseEntity { |
| | | |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | public Long id; |
| | | |
| | | /** |
| | | * 排班id |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | public Long scheduleId; |
| | | |
| | | /** |
| | | * 任务计划id |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | public Long planId; |
| | | @TableField(exist = false) |
| | | public String planName; |
| | | |
| | | /** |
| | | * 节点id |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | public Long nodeId; |
| | | @TableField(exist = false) |
| | | public String nodeName; |
| | | |
| | | /** |
| | | * 工站id |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | public Long stationId; |
| | | @TableField(exist = false) |
| | | public String stationName; |
| | | |
| | | /** |
| | | * 工作内容 |
| | | */ |
| | | @NotEmpty(message="工作内容不能为空") |
| | | public String workDetails; |
| | | |
| | | } |
| | |
| | | column="process_id"/> |
| | | </resultMap> |
| | | |
| | | |
| | | <sql id="Base_Column_List"> |
| | | id,order_id |
| | | ,pro_id,batch_id, |
| | |
| | | set deleted = 1 |
| | | where id = #{id} |
| | | </update> |
| | | |
| | | <select id="countByPlanIdAndNodeId" resultType="java.lang.Long"> |
| | | select count(1) from pr_assembly_plan ap |
| | | left join pr_production_node pn on ap.process_id = pn.process_id |
| | | where ap.id = #{planId} and pn.id= #{nodeId} |
| | | </select> |
| | | |
| | | |
| | | <resultMap id="jsonResultMap" type="java.util.HashMap"> |
| | | <id column="planId" property="planId"/> |
| | | <result column="planName" property="planName"/> |
| | | <result column="status" property="status"/> |
| | | |
| | | <collection property="nodes" javaType="java.util.HashMap"> |
| | | <result column="content" property="content"/> |
| | | <result column="nodeId" property="nodeId"/> |
| | | </collection> |
| | | </resultMap> |
| | | <select id="selectByPlanName" resultMap="jsonResultMap"> |
| | | select ap.id planId,ap.name planName,ap.`status`,pn.id nodeId,pn.content from pr_assembly_plan ap |
| | | left join pr_production_node pn on ap.process_id = pn.process_id |
| | | where status != -1 |
| | | <if test="planName != null and planName!= null"> |
| | | and ap.name like concat('%', #{planName}, '%') |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.dy.pmsGlobal.daoPr.PrScheduleMapper"> |
| | | <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPr.PrSchedule"> |
| | | <!--@mbg.generated--> |
| | | <!--@Table pr_schedule--> |
| | | <id column="id" jdbcType="BIGINT" property="id" /> |
| | | <result column="user_id" jdbcType="BIGINT" property="userId" /> |
| | | <result column="schedule_date" jdbcType="VARCHAR" property="scheduleDate" /> |
| | | <result column="deleted" jdbcType="TINYINT" property="deleted" /> |
| | | <result column="dt" jdbcType="TIMESTAMP" property="dt" /> |
| | | <association property="userName" column="user_id" javaType="java.lang.Long" |
| | | select="com.dy.pmsGlobal.daoBa.BaUserMapper.selectNameByUserId" fetchType="eager"/> |
| | | <collection column="id" ofType="com.dy.pmsGlobal.pojoPr.PrScheduleRel" property="relList" |
| | | select="com.dy.pmsGlobal.daoPr.PrScheduleRelMapper.selectByScheduleId" fetchType="eager" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, user_id, schedule_date, deleted,dt |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from pr_schedule |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | | <!--@mbg.generated--> |
| | | delete from pr_schedule |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.dy.pmsGlobal.pojoPr.PrSchedule"> |
| | | <!--@mbg.generated--> |
| | | insert into pr_schedule (id, user_id, schedule_date, |
| | | deleted,dt) |
| | | values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{scheduleDate,jdbcType=VARCHAR}, |
| | | #{deleted,jdbcType=TINYINT},now()) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pmsGlobal.pojoPr.PrSchedule"> |
| | | <!--@mbg.generated--> |
| | | insert into pr_schedule |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="userId != null"> |
| | | user_id, |
| | | </if> |
| | | <if test="scheduleDate != null"> |
| | | schedule_date, |
| | | </if> |
| | | <if test="deleted != null"> |
| | | deleted, |
| | | </if> |
| | | <if test="dt != null"> |
| | | dt, |
| | | </if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="userId != null"> |
| | | #{userId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="scheduleDate != null"> |
| | | #{scheduleDate,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="deleted != null"> |
| | | #{deleted,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="dt != null"> |
| | | #{dt,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoPr.PrSchedule"> |
| | | <!--@mbg.generated--> |
| | | update pr_schedule |
| | | <set> |
| | | <if test="userId != null"> |
| | | user_id = #{userId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="scheduleDate != null"> |
| | | schedule_date = #{scheduleDate,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="deleted != null"> |
| | | deleted = #{deleted,jdbcType=TINYINT}, |
| | | </if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKey" parameterType="com.dy.pmsGlobal.pojoPr.PrSchedule"> |
| | | <!--@mbg.generated--> |
| | | update pr_schedule |
| | | set user_id = #{userId,jdbcType=BIGINT}, |
| | | schedule_date = #{scheduleDate,jdbcType=VARCHAR}, |
| | | deleted = #{deleted,jdbcType=TINYINT} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <select id="selectSomeCount" resultType="java.lang.Long"> |
| | | select count(1) |
| | | from pr_schedule |
| | | where deleted = 0 |
| | | <if test="userId != null"> |
| | | and user_id = #{userId,jdbcType=BIGINT} |
| | | </if> |
| | | <if test="scheduleDate != null"> |
| | | and schedule_date = #{scheduleDate,jdbcType=VARCHAR} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="selectSome" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from pr_schedule |
| | | where deleted = 0 |
| | | <if test="userId != null"> |
| | | and user_id = #{userId} |
| | | </if> |
| | | <if test="scheduleDate != null"> |
| | | and schedule_date = #{scheduleDate} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="selectAll" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from pr_schedule |
| | | where deleted = 0 |
| | | <if test="userId != null"> |
| | | and user_id = #{userId} |
| | | </if> |
| | | <if test="scheduleDate != null"> |
| | | and schedule_date = #{scheduleDate} |
| | | </if> |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.dy.pmsGlobal.daoPr.PrScheduleRelMapper"> |
| | | <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPr.PrScheduleRel"> |
| | | <!--@mbg.generated--> |
| | | <!--@Table pr_schedule_rel--> |
| | | <id column="id" jdbcType="BIGINT" property="id" /> |
| | | <result column="schedule_id" jdbcType="BIGINT" property="scheduleId" /> |
| | | <result column="plan_id" jdbcType="BIGINT" property="planId" /> |
| | | <result column="node_id" jdbcType="BIGINT" property="nodeId" /> |
| | | <result column="station_id" jdbcType="BIGINT" property="stationId" /> |
| | | <result column="work_details" jdbcType="VARCHAR" property="workDetails" /> |
| | | <association property="nodeName" column="node_id" javaType="java.lang.String" |
| | | select="com.dy.pmsGlobal.daoPr.PrProductionNodeMapper.selectNameByNodeId" fetchType="eager"/> |
| | | <association property="planName" column="plan_id" javaType="java.lang.String" |
| | | select="com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper.selectNameByPlanId" fetchType="eager"/> |
| | | <association property="stationName" column="station_id" javaType="java.lang.String" |
| | | select="com.dy.pmsGlobal.daoPlt.PltStationMapper.selectNameByStationId" fetchType="eager"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, schedule_id, plan_id, node_id, station_id, work_details |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from pr_schedule_rel |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | | <!--@mbg.generated--> |
| | | delete from pr_schedule_rel |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.dy.pmsGlobal.pojoPr.PrScheduleRel"> |
| | | <!--@mbg.generated--> |
| | | insert into pr_schedule_rel (id, schedule_id, plan_id, |
| | | node_id, station_id, work_details |
| | | ) |
| | | values (#{id,jdbcType=BIGINT}, #{scheduleId,jdbcType=BIGINT}, #{planId,jdbcType=BIGINT}, |
| | | #{nodeId,jdbcType=BIGINT}, #{stationId,jdbcType=BIGINT}, #{workDetails,jdbcType=VARCHAR} |
| | | ) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pmsGlobal.pojoPr.PrScheduleRel"> |
| | | <!--@mbg.generated--> |
| | | insert into pr_schedule_rel |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="scheduleId != null"> |
| | | schedule_id, |
| | | </if> |
| | | <if test="planId != null"> |
| | | plan_id, |
| | | </if> |
| | | <if test="nodeId != null"> |
| | | node_id, |
| | | </if> |
| | | <if test="stationId != null"> |
| | | station_id, |
| | | </if> |
| | | <if test="workDetails != null"> |
| | | work_details, |
| | | </if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="scheduleId != null"> |
| | | #{scheduleId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="planId != null"> |
| | | #{planId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="nodeId != null"> |
| | | #{nodeId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="stationId != null"> |
| | | #{stationId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="workDetails != null"> |
| | | #{workDetails,jdbcType=VARCHAR}, |
| | | </if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoPr.PrScheduleRel"> |
| | | <!--@mbg.generated--> |
| | | update pr_schedule_rel |
| | | <set> |
| | | <if test="scheduleId != null"> |
| | | schedule_id = #{scheduleId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="planId != null"> |
| | | plan_id = #{planId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="nodeId != null"> |
| | | node_id = #{nodeId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="stationId != null"> |
| | | station_id = #{stationId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="workDetails != null"> |
| | | work_details = #{workDetails,jdbcType=VARCHAR}, |
| | | </if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKey" parameterType="com.dy.pmsGlobal.pojoPr.PrScheduleRel"> |
| | | <!--@mbg.generated--> |
| | | update pr_schedule_rel |
| | | set schedule_id = #{scheduleId,jdbcType=BIGINT}, |
| | | plan_id = #{planId,jdbcType=BIGINT}, |
| | | node_id = #{nodeId,jdbcType=BIGINT}, |
| | | station_id = #{stationId,jdbcType=BIGINT}, |
| | | work_details = #{workDetails,jdbcType=VARCHAR} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <delete id="deleteByScheduleId"> |
| | | delete from pr_schedule_rel where schedule_id=#{scheduleId} |
| | | </delete> |
| | | |
| | | <select id="selectByScheduleId" resultMap="BaseResultMap"> |
| | | select * from pr_schedule_rel where schedule_id=#{scheduleId} |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | package com.dy.pmsProduct.schedule; |
| | | |
| | | 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.Date; |
| | | 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(100) //设置内容高度 |
| | | @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[]> { |
| | | @ColumnWidth(40) |
| | | // @ContentLoopMerge(eachRow=2) |
| | | @ExcelProperty("用户名") |
| | | public String userName ; |
| | | |
| | | @ColumnWidth(40) |
| | | @ExcelProperty("排班日期") |
| | | // @ContentLoopMerge(eachRow=2) |
| | | public String scheduleDate ; |
| | | |
| | | @ColumnWidth(40) |
| | | @ExcelProperty("创建时间") |
| | | // @ContentLoopMerge(eachRow=2) |
| | | public Date dt ; |
| | | |
| | | @ColumnWidth(40) |
| | | @ExcelProperty({"排班内容","任务计划"}) |
| | | public String planName ; |
| | | |
| | | @ColumnWidth(40) |
| | | @ExcelProperty({"排班内容","节点"}) |
| | | public String nodeName ; |
| | | |
| | | @ColumnWidth(40) |
| | | @ExcelProperty({"排班内容","工站"}) |
| | | public String stationName ; |
| | | |
| | | @ColumnWidth(40) |
| | | @ExcelProperty({"排班内容","工作内容"}) |
| | | public String workDetails ; |
| | | |
| | | 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()); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pmsProduct.schedule; |
| | | |
| | | import com.dy.common.webUtil.QueryConditionVo; |
| | | import lombok.*; |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ToString(callSuper = true) |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Builder |
| | | public class QueryVo extends QueryConditionVo { |
| | | public String planName; |
| | | public String scheduleDate; |
| | | public String userId; |
| | | } |
New file |
| | |
| | | package com.dy.pmsProduct.schedule; |
| | | |
| | | import com.alibaba.excel.converters.Converter; |
| | | import com.dy.common.aop.SsoPowerAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pmsGlobal.aop.Log; |
| | | import com.dy.pmsGlobal.pojoPr.PrSchedule; |
| | | import com.dy.pmsGlobal.util.QrCodeUtil; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.Valid; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 排班 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping(path="schedule") |
| | | public class ScheduleCtrl { |
| | | private static final String fileName = "排班信息" ; |
| | | private static final String sheetName = "排班信息" ; |
| | | private ScheduleSv sv; |
| | | @Autowired |
| | | public void setScheduleSv(ScheduleSv scheduleSv) { |
| | | this.sv = scheduleSv; |
| | | } |
| | | |
| | | @PostMapping(path="save") |
| | | @SsoPowerAop(power = "-1") |
| | | @Log("保存排班") |
| | | public BaseResponse<Boolean> save(@RequestBody @Valid PrSchedule schedule){ |
| | | int count = sv.save(schedule); |
| | | if (count <= 0) { |
| | | return BaseResponseUtils.buildFail("数据库存储失败"); |
| | | } else { |
| | | return BaseResponseUtils.buildSuccess(true); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新 |
| | | * @param schedule |
| | | * @return |
| | | */ |
| | | @PostMapping(path="update") |
| | | @SsoPowerAop(power = "-1") |
| | | @Log("更新排班") |
| | | public BaseResponse<Boolean> update(@RequestBody @Valid PrSchedule schedule){ |
| | | int count = sv.update(schedule); |
| | | if (count <= 0) { |
| | | return BaseResponseUtils.buildFail("数据库存储失败"); |
| | | } else { |
| | | return BaseResponseUtils.buildSuccess(true); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询任务计划列表 |
| | | * @param vo |
| | | * @return |
| | | */ |
| | | @PostMapping(path="selectPlan") |
| | | @SsoPowerAop(power = "-1") |
| | | @Log("查询任务计划列表") |
| | | public BaseResponse<List<Map<String,Object>>> selectPlan(@RequestBody QueryVo vo){ |
| | | List<Map<String,Object>> list = sv.selectPlan(vo) ; |
| | | return BaseResponseUtils.buildSuccess(list); |
| | | } |
| | | /** |
| | | * 根据ID查询 |
| | | * @return |
| | | */ |
| | | @GetMapping(path="one") |
| | | @SsoPowerAop(power = "-1") |
| | | @Log("根据ID查询排班") |
| | | public BaseResponse<PrSchedule> one(Long id){ |
| | | PrSchedule schedule=sv.selectById(id); |
| | | return BaseResponseUtils.buildSuccess(schedule); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param vo |
| | | * @return |
| | | */ |
| | | @PostMapping(path="some") |
| | | @SsoPowerAop(power = "-1") |
| | | @Log("分页查询排班") |
| | | public BaseResponse<QueryResultVo<List<PrSchedule>>> some(@RequestBody com.dy.pmsProduct.schedule.QueryVo vo){ |
| | | QueryResultVo<List<PrSchedule>> list = sv.selectSome(vo) ; |
| | | return BaseResponseUtils.buildSuccess(list); |
| | | } |
| | | |
| | | |
| | | @PostMapping(path="export") |
| | | @SsoPowerAop(power = "-1") |
| | | @Log("导出排班") |
| | | public void exportSchedule(@RequestBody QueryVo queryVo, HttpServletResponse response){ |
| | | List<Converter> list = new ArrayList<>() ; |
| | | |
| | | List<PrSchedule> schList = sv.selectAll(queryVo); |
| | | // 使用并行流提高性能 |
| | | schList.parallelStream().forEach(sch -> { |
| | | sch.relList.forEach(rel -> { |
| | | ExcelVo vo = new ExcelVo(); |
| | | vo.userName = sch.userName; |
| | | vo.scheduleDate = sch.scheduleDate; |
| | | vo.dt = sch.dt; |
| | | vo.planName = rel.planName; |
| | | vo.nodeName = rel.nodeName; |
| | | vo.stationName = rel.stationName; |
| | | vo.workDetails = rel.workDetails; |
| | | list.add(vo); |
| | | }); |
| | | }); |
| | | QrCodeUtil.downloadExcel(response, fileName,sheetName,list); |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pmsProduct.schedule; |
| | | |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pmsGlobal.daoPlt.PltStationMapper; |
| | | import com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper; |
| | | import com.dy.pmsGlobal.daoPr.PrScheduleMapper; |
| | | import com.dy.pmsGlobal.daoPr.PrScheduleRelMapper; |
| | | import com.dy.pmsGlobal.pojoPlt.PltStation; |
| | | import com.dy.pmsGlobal.pojoPr.PrSchedule; |
| | | import com.dy.pmsGlobal.pojoPr.PrScheduleRel; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class ScheduleSv { |
| | | private PrScheduleMapper scheduleDao; |
| | | private PrScheduleRelMapper scheduleRelDao; |
| | | private PrAssemblyPlanMapper assemblyPlanDao; |
| | | private PltStationMapper stationDao; |
| | | @Autowired |
| | | public void setStationDao(PltStationMapper stationDao) { |
| | | this.stationDao = stationDao; |
| | | } |
| | | @Autowired |
| | | public void setScheduleRelDao(PrScheduleRelMapper scheduleRelDao) { |
| | | this.scheduleRelDao = scheduleRelDao; |
| | | } |
| | | @Autowired |
| | | public void setAssemblyPlanDao(PrAssemblyPlanMapper assemblyPlanDao) { |
| | | this.assemblyPlanDao = assemblyPlanDao; |
| | | } |
| | | @Autowired |
| | | public void setScheduleDao(PrScheduleMapper scheduleDao) { |
| | | this.scheduleDao = scheduleDao; |
| | | } |
| | | @Transactional |
| | | public int save(PrSchedule schedule) { |
| | | int count = scheduleDao.insertSelective(schedule); |
| | | saveRel(schedule); |
| | | return count; |
| | | } |
| | | @Transactional |
| | | public int update(PrSchedule schedule) { |
| | | scheduleRelDao.deleteByScheduleId(schedule.id); |
| | | saveRel(schedule); |
| | | return scheduleDao.updateByPrimaryKeySelective(schedule); |
| | | } |
| | | private void saveRel(PrSchedule schedule) { |
| | | schedule.relList.forEach(rel ->validateRelData(rel, schedule)); |
| | | schedule.relList.forEach(rel -> scheduleRelDao.insertSelective(rel)); |
| | | } |
| | | private void validateRelData(PrScheduleRel rel,PrSchedule schedule) { |
| | | validatePlan(rel); |
| | | validateStation(rel); |
| | | rel.scheduleId = schedule.id; |
| | | } |
| | | |
| | | private void validatePlan(PrScheduleRel rel) { |
| | | if (rel.planId != null && rel.nodeId != null) { |
| | | long countPlan = assemblyPlanDao.countByPlanIdAndNodeId(rel.planId, rel.nodeId); |
| | | if (countPlan == 0) { |
| | | log.error("排班数据不匹配, planId:{}, nodeId:{}", rel.planId, rel.nodeId); |
| | | throw new RuntimeException("排班数据不匹配, planId:" + rel.planId + ", nodeId:" + rel.nodeId); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void validateStation(PrScheduleRel rel) { |
| | | if (rel.stationId != null) { |
| | | Optional<PltStation> stationOpt = Optional.ofNullable(stationDao.selectByPrimaryKey(rel.stationId)); |
| | | stationOpt.orElseThrow(() -> { |
| | | log.error("工站信息不存在, stationId:{}", rel.stationId); |
| | | return new RuntimeException("工站信息不存在, stationId:" + rel.stationId); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | public PrSchedule selectById(Long id) { |
| | | return scheduleDao.selectByPrimaryKey(id); |
| | | } |
| | | |
| | | public QueryResultVo<List<PrSchedule>> selectSome(QueryVo vo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(vo); |
| | | //查询符合条件的记录总数 |
| | | Long itemTotal = scheduleDao.selectSomeCount(params); |
| | | QueryResultVo<List<PrSchedule>> rsVo = new QueryResultVo<>(vo.pageSize, vo.pageCurr) ; |
| | | //计算分页等信息 |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | //查询符合条件的记录 |
| | | rsVo.obj = scheduleDao.selectSome(params); |
| | | return rsVo; |
| | | } |
| | | |
| | | public List<Map<String, Object>> selectPlan(QueryVo vo) { |
| | | List<Map<String,Object>> list = assemblyPlanDao.selectByPlanName(vo.planName); |
| | | |
| | | return list; |
| | | } |
| | | |
| | | public List<PrSchedule> selectAll(QueryVo queryVo) { |
| | | return scheduleDao.selectAll(queryVo.scheduleDate, queryVo.userId); |
| | | } |
| | | } |