From 14b0417bca9050a11792248f5c5c7e7c86e4744f Mon Sep 17 00:00:00 2001
From: 刘小明 <liuxm_a@163.com>
Date: 星期三, 21 八月 2024 16:47:45 +0800
Subject: [PATCH] 排班功能

---
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrScheduleMapper.java      |   29 ++
 pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleCtrl.java |  126 +++++++++
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrSchedule.java           |   62 ++++
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java  |    3 
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrScheduleRelMapper.java   |   25 +
 pms-parent/pms-global/src/main/resources/mapper/PrScheduleRelMapper.xml               |  129 +++++++++
 pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ExcelVo.java      |   94 ++++++
 pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/QueryVo.java      |   16 +
 pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleSv.java   |  111 +++++++
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrScheduleRel.java        |   61 ++++
 pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml              |   30 ++
 pms-parent/pms-global/src/main/resources/mapper/PrScheduleMapper.xml                  |  140 ++++++++++
 12 files changed, 826 insertions(+), 0 deletions(-)

diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java
index 07d5ee1..f14d6d1 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java
@@ -38,6 +38,9 @@
 
     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);
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrScheduleMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrScheduleMapper.java
new file mode 100644
index 0000000..333339e
--- /dev/null
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrScheduleMapper.java
@@ -0,0 +1,29 @@
+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);
+}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrScheduleRelMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrScheduleRelMapper.java
new file mode 100644
index 0000000..39efb3a
--- /dev/null
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrScheduleRelMapper.java
@@ -0,0 +1,25 @@
+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);
+}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrSchedule.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrSchedule.java
new file mode 100644
index 0000000..d5c11e3
--- /dev/null
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrSchedule.java
@@ -0,0 +1,62 @@
+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;
+}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrScheduleRel.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrScheduleRel.java
new file mode 100644
index 0000000..ea72fab
--- /dev/null
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrScheduleRel.java
@@ -0,0 +1,61 @@
+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;
+
+}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml
index bb7f745..8a0a22c 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml
@@ -56,6 +56,7 @@
                     column="process_id"/>
     </resultMap>
 
+
     <sql id="Base_Column_List">
         id,order_id
         ,pro_id,batch_id,
@@ -404,4 +405,33 @@
         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>
diff --git a/pms-parent/pms-global/src/main/resources/mapper/PrScheduleMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PrScheduleMapper.xml
new file mode 100644
index 0000000..a225d6d
--- /dev/null
+++ b/pms-parent/pms-global/src/main/resources/mapper/PrScheduleMapper.xml
@@ -0,0 +1,140 @@
+<?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>
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/mapper/PrScheduleRelMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PrScheduleRelMapper.xml
new file mode 100644
index 0000000..ef2a29f
--- /dev/null
+++ b/pms-parent/pms-global/src/main/resources/mapper/PrScheduleRelMapper.xml
@@ -0,0 +1,129 @@
+<?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>
\ No newline at end of file
diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ExcelVo.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ExcelVo.java
new file mode 100644
index 0000000..b4f23b8
--- /dev/null
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ExcelVo.java
@@ -0,0 +1,94 @@
+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());
+    }
+
+}
diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/QueryVo.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/QueryVo.java
new file mode 100644
index 0000000..823ef81
--- /dev/null
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/QueryVo.java
@@ -0,0 +1,16 @@
+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;
+}
diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleCtrl.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleCtrl.java
new file mode 100644
index 0000000..d583cb9
--- /dev/null
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleCtrl.java
@@ -0,0 +1,126 @@
+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);
+    }
+}
diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleSv.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleSv.java
new file mode 100644
index 0000000..a7c5ec4
--- /dev/null
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleSv.java
@@ -0,0 +1,111 @@
+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);
+    }
+}

--
Gitblit v1.8.0