liuxm
2024-05-28 3a24dda899fcde40e2edb90c319eb5644805a639
生产流程相关接口
3个文件已修改
15个文件已添加
1220 ■■■■■ 已修改文件
pms-parent/pms-common/src/main/java/com/dy/common/mybatis/AutoGenerateIdInterceptor.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrProductionNodeMapper.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrProductionProcessMapper.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrWorkingInstructionMapper.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltMaterial.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrProductionNode.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrProductionProcess.java 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrWorkingInstruction.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/util/UserUtil.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PrProductionNodeMapper.xml 152 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PrProductionProcessMapper.xml 180 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PrWorkingInstructionMapper.xml 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/WebFilterConfiguration.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/WebListenerConfiguration.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessCtrl.java 136 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java 176 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/QueryVo.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-common/src/main/java/com/dy/common/mybatis/AutoGenerateIdInterceptor.java
@@ -9,6 +9,8 @@
import org.apache.ibatis.plugin.*;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
@Intercepts(
    {
@@ -38,7 +40,7 @@
            Object entity = invocation.getArgs()[PARAMETER_INDEX];
            if (entity instanceof BaseEntity) {
                Class<?> entityClass = entity.getClass();
                Method setIdMt = null ;
                 Method setIdMt = null ;
                try{
                    setIdMt = entityClass.getMethod(BASE_FIELD_SET_PRIMARY_KEY_FUNTION_NAME, Long.class) ;
                }catch (Exception e){
@@ -49,6 +51,25 @@
                }
                invocation.getArgs()[PARAMETER_INDEX] = entity;
            }else if(entity instanceof Map){
                try {
                    ((List)((Map<?, ?>) entity).get("list")).forEach(e -> {
                        if (e instanceof BaseEntity) {
                            Class<?> entityClass = e.getClass();
                            Method setIdMt = null ;
                            try{
                                setIdMt = entityClass.getMethod(BASE_FIELD_SET_PRIMARY_KEY_FUNTION_NAME, Long.class) ;
                                if(setIdMt != null){
                                    setIdMt.invoke(e, new IDLongGenerator().generate());
                                }
                            }catch (Exception e1){
                                //当entityClass没有setId方法时,会抛出异常
                            }
                        }
                    });
                }catch (Exception e){
                }
            }
        }
        return invocation.proceed();
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrProductionNodeMapper.java
New file
@@ -0,0 +1,30 @@
package com.dy.pmsGlobal.daoPr;
import com.dy.pmsGlobal.pojoPr.PrProductionNode;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author 小明
* @description 针对表【pr_production_node(生产节点表)】的数据库操作Mapper
* @createDate 2024-05-25 09:22:03
* @Entity com.dy.pmsGlobal.pojoPr.PrProductionNode
*/
@Mapper
public interface PrProductionNodeMapper {
    int deleteByPrimaryKey(Long id);
    int insertSelective(PrProductionNode record);
    int insertMany(List<PrProductionNode> nodes);
    PrProductionNode selectByPrimaryKey(Long id);
    int updateByPrimaryKeySelective(PrProductionNode record);
    List<PrProductionNode> selectByProcess(Long processId);
    void deleteByProcessId(Long id);
}
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrProductionProcessMapper.java
New file
@@ -0,0 +1,35 @@
package com.dy.pmsGlobal.daoPr;
import com.dy.pmsGlobal.pojoPr.PrProductionProcess;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
/**
* @author 小明
* @description 针对表【pr_production_process(生产流程表)】的数据库操作Mapper
* @createDate 2024-05-25 09:22:03
* @Entity com.dy.pmsGlobal.pojoPr.PrProductionProcess
*/
@Mapper
public interface PrProductionProcessMapper {
    int deleteByPrimaryKey(Long id);
    int insertSelective(PrProductionProcess record);
    PrProductionProcess selectByPrimaryKey(Long id);
    int updateByPrimaryKeySelective(PrProductionProcess record);
    Long selectSomeCount(Map<String,Object> params);
    List<PrProductionProcess> selectSome(Map<String,Object> params);
    int deleteLogicById(Long id);
    @MapKey("id")
    List<Map<String,String>> queryAll();
}
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrWorkingInstructionMapper.java
New file
@@ -0,0 +1,28 @@
package com.dy.pmsGlobal.daoPr;
import com.dy.pmsGlobal.pojoPr.PrWorkingInstruction;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author 小明
* @description 针对表【pr_working_instruction(作业指导书关联表)】的数据库操作Mapper
* @createDate 2024-05-25 09:22:03
* @Entity com.dy.pmsGlobal.pojoPr.PrWorkingInstruction
*/
@Mapper
public interface PrWorkingInstructionMapper {
    int deleteByPrimaryKey(Long id);
    int insertSelective(PrWorkingInstruction record);
    int insertMany(List<PrWorkingInstruction> records);
    PrWorkingInstruction selectByPrimaryKey(Long id);
    int updateByPrimaryKeySelective(PrWorkingInstruction record);
    int deleteByNodeId(List<Long> ids);
}
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltMaterial.java
@@ -7,14 +7,18 @@
import com.baomidou.mybatisplus.annotation.TableName;
import com.dy.common.po.BaseEntity;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import lombok.*;
/**
 * 物料表
 * @TableName plt_material
 */
@TableName(value ="plt_material")
@TableName(value="plt_material", autoResultMap = true)
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class PltMaterial  implements BaseEntity {
    /**
     * 编号
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java
@@ -50,9 +50,15 @@
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    public Long image;
    /**
     * 典型图片web路径
     */
    @TableField(exist = false)
    public String imageWebPath;
    /**
     * 典型图片缩略图web路径
     */
    @TableField(exist = false)
    public String imageWebPathZip;
    /**
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrProductionNode.java
New file
@@ -0,0 +1,83 @@
package com.dy.pmsGlobal.pojoPr;
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import com.dy.common.po.BaseEntity;
import jakarta.validation.constraints.NotEmpty;
import lombok.*;
/**
 * 生产节点表
 * @TableName pr_production_node
 */
@TableName(value="pr_production_node", autoResultMap = true)
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class PrProductionNode implements BaseEntity {
    /**
     *
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableId
    public Long id;
    /**
     * 流程编号
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    public Long processId;
    /**
     * 排序
     */
    @NotEmpty(message = "节点顺序不能为空")
    public Integer sort;
    /**
     * 节点作业内容
     */
    public String content;
    /**
     * 是否开始节点,1是,0否
     */
    public Boolean isStart;
    /**
     * 是否结束节点,1是,0否
     */
    public Boolean isEnd;
    /**
     * 是否记录设备周期,1是,0否
     */
    public Boolean isRecord;
    /**
     * 记录设备周期内容
     */
    public String equipCycleContent;
    /**
     * 是否删除,1是,0否
     */
    public Boolean deleted;
    /**
     * 备注
     */
    public String remark;
    @TableField(exist = false)
    public PrWorkingInstruction instruction;
}
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrProductionProcess.java
New file
@@ -0,0 +1,78 @@
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.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dy.common.po.BaseEntity;
import lombok.*;
import java.util.Date;
import java.util.List;
/**
 * 生产流程表
 * @TableName pr_production_process
 */
@TableName(value="pr_production_process", autoResultMap = true)
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class PrProductionProcess implements BaseEntity {
    /**
     *
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableId
    public Long id;
    /**
     * 产品实体编号
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    public Long proId;
    /**
     * 产品名称
     */
    @TableField(exist = false)
    public String proName;
    /**
     * 名称
     */
    public String name;
    /**
     * 创建人
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    public Long creator;
    /**
     * 创建时间
     */
    public Date dt;
    /**
     * 是否禁用,1是,0否
     */
    public Boolean disabled;
    /**
     * 是否删除,1是,0否
     */
    public Boolean deleted;
    /**
     * 备注
     */
    public String remark;
    @TableField(exist = false)
    public List<PrProductionNode> nodes;
}
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrWorkingInstruction.java
New file
@@ -0,0 +1,53 @@
package com.dy.pmsGlobal.pojoPr;
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.*;
/**
 * 作业指导书关联表
 * @TableName pr_working_instruction
 */
@TableName(value="pr_working_instruction", autoResultMap = true)
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class PrWorkingInstruction implements Serializable {
    /**
     *
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableId(type = IdType.AUTO)
    public Long id;
    /**
     * 节点实体编号
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    public Long nodeId;
    /**
     * 文件编号
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    public Long fileId;
    /**
     * 文件下载地址
     */
    @TableField(exist = false)
    public String webUrl;
    @TableField(exist = false)
    public String orgName;
    @TableField(exist = false)
    public String extName;
}
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/util/UserUtil.java
New file
@@ -0,0 +1,52 @@
package com.dy.pmsGlobal.util;
import com.alibaba.excel.util.StringUtils;
import com.dy.pmsGlobal.pojoBa.BaUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
@Slf4j
@Component
public class UserUtil {
    @Value("${pms.sso.curUserUrl}")
    public String SsoCurUserUrl ;
    private RestTemplate restTemplate;
    @Autowired
    public void setRestTemplate(RestTemplate restTemplate){
        this.restTemplate = restTemplate ;
    }
    public BaUser getUser(String token) {
        if(StringUtils.isBlank(token) || StringUtils.isBlank(SsoCurUserUrl)){
            return null;
        }
        try{
            String url = UriComponentsBuilder.fromUriString(SsoCurUserUrl)
                    .queryParam("token", token)
                    .build()
                    .toUriString();
            HttpHeaders headers = new HttpHeaders();
            HttpEntity<?> httpEntity = new HttpEntity<>(headers);
            ResponseEntity<BaUser> myResponse = null;
            try {
                // 通过Get方式调用接口
                myResponse = restTemplate.exchange(url, HttpMethod.GET, httpEntity, BaUser.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
            assert myResponse != null;
            return myResponse.getBody();
        }catch (Exception e){
        }
        return null;
    }
}
pms-parent/pms-global/src/main/resources/mapper/PrProductionNodeMapper.xml
New file
@@ -0,0 +1,152 @@
<?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.PrProductionNodeMapper">
    <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPr.PrProductionNode">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="processId" column="process_id" jdbcType="BIGINT"/>
        <result property="sort" column="sort" jdbcType="INTEGER"/>
        <result property="content" column="content" jdbcType="VARCHAR"/>
        <result property="isStart" column="is_start" jdbcType="TINYINT"/>
        <result property="isEnd" column="is_end" jdbcType="TINYINT"/>
        <result property="isRecord" column="is_record" jdbcType="TINYINT"/>
        <result property="equipCycleContent" column="equip_cycle_content" jdbcType="VARCHAR"/>
        <result property="deleted" column="deleted" jdbcType="TINYINT"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <association property="instruction"
            column="id" javaType="java.lang.Long" select="selectProNameById" fetchType="eager" />
    </resultMap>
    <sql id="Base_Column_List">
        id,process_id,sort,
        content,is_start,is_end,
        is_record,equip_cycle_content,deleted,
        remark
    </sql>
    <select id="selectProNameById" resultMap="com.dy.pmsGlobal.daoPr.PrWorkingInstructionMapper.BaseResultMap">
        select *
        from pr_working_instruction
        where node_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from pr_production_node
        where  id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from pr_production_node
        where  id = #{id,jdbcType=BIGINT}
    </delete>
    <delete id="deleteByProcessId">
        delete from pr_production_node
        where  process_id = #{processId,jdbcType=BIGINT}
    </delete>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPr.PrProductionNode" useGeneratedKeys="true">
        insert into pr_production_node
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">id,</if>
                <if test="processId != null">process_id,</if>
                <if test="sort != null">sort,</if>
                <if test="content != null">content,</if>
                <if test="isStart != null">is_start,</if>
                <if test="isEnd != null">is_end,</if>
                <if test="isRecord != null">is_record,</if>
                <if test="equipCycleContent != null">equip_cycle_content,</if>
                <if test="deleted != null">deleted,</if>
                <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=BIGINT},</if>
                <if test="processId != null">#{processId,jdbcType=BIGINT},</if>
                <if test="sort != null">#{sort,jdbcType=INTEGER},</if>
                <if test="content != null">#{content,jdbcType=VARCHAR},</if>
                <if test="isStart != null">#{isStart,jdbcType=TINYINT},</if>
                <if test="isEnd != null">#{isEnd,jdbcType=TINYINT},</if>
                <if test="isRecord != null">#{isRecord,jdbcType=TINYINT},</if>
                <if test="equipCycleContent != null">#{equipCycleContent,jdbcType=VARCHAR},</if>
                <if test="deleted != null">#{deleted,jdbcType=TINYINT},</if>
                <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <insert id="insertMany" parameterType="java.util.List">
       INSERT INTO pr_production_node (id,process_id,sort,
        content,is_start,is_end,
        is_record,equip_cycle_content,deleted,
        remark) VALUES
       <foreach item="item" index="index" collection="list" open="(" separator="),(" close=")">
           #{item.id},
           #{item.processId},
           #{item.sort},
           #{item.content},
           #{item.isStart},
           #{item.isEnd},
           #{item.isRecord},
           #{item.equipCycleContent},
           #{item.deleted},
           #{item.remark}
       </foreach>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoPr.PrProductionNode">
        update pr_production_node
        <set>
                <if test="processId != null">
                    process_id = #{processId,jdbcType=BIGINT},
                </if>
                <if test="sort != null">
                    sort = #{sort,jdbcType=INTEGER},
                </if>
                <if test="content != null">
                    content = #{content,jdbcType=VARCHAR},
                </if>
                <if test="isStart != null">
                    is_start = #{isStart,jdbcType=TINYINT},
                </if>
                <if test="isEnd != null">
                    is_end = #{isEnd,jdbcType=TINYINT},
                </if>
                <if test="isRecord != null">
                    is_record = #{isRecord,jdbcType=TINYINT},
                </if>
                <if test="equipCycleContent != null">
                    equip_cycle_content = #{equipCycleContent,jdbcType=VARCHAR},
                </if>
                <if test="deleted != null">
                    deleted = #{deleted,jdbcType=TINYINT},
                </if>
                <if test="remark != null">
                    remark = #{remark,jdbcType=VARCHAR},
                </if>
        </set>
        where   id = #{id,jdbcType=BIGINT}
    </update>
    <select id="selectByProcess" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from pr_production_node
        <trim prefix="where" suffixOverrides="and">
            <if test="processId != null">
                process_id = #{processId,jdbcType=BIGINT} and
            </if>
        </trim>
        order by sort asc
        <trim prefix="limit " >
            <if test="start != null and count != null">
                #{start}, #{count}
            </if>
        </trim>
    </select>
    <update id="deleteLogicById" parameterType="java.lang.Long">
        update pr_production_node set deleted = 1
        where id = #{id}
    </update>
</mapper>
pms-parent/pms-global/src/main/resources/mapper/PrProductionProcessMapper.xml
New file
@@ -0,0 +1,180 @@
<?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.PrProductionProcessMapper">
    <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPr.PrProductionProcess">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="proId" column="pro_id" jdbcType="BIGINT"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="creator" column="creator" jdbcType="VARCHAR"/>
        <result property="dt" column="dt" jdbcType="TIMESTAMP"/>
        <result property="disabled" column="disabled" jdbcType="TINYINT"/>
        <result property="deleted" column="deleted" jdbcType="TINYINT"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <association property="proName" column="pro_id" javaType="java.lang.Long"
                     select="selectProNameById" fetchType="eager" />
        <collection property="nodes" ofType="com.dy.pmsGlobal.pojoPr.PrProductionNode"
                      select="selectByProcess" fetchType="eager" column="id" />
    </resultMap>
    <sql id="Base_Column_List">
        id,pro_id,name,
        creator,dt,disabled,
        deleted,remark
    </sql>
    <select id="selectProNameById" parameterType="java.lang.Long" resultType="java.lang.String">
        select name proName from plt_product where id=#{id}
    </select>
    <select id="selectByProcess" resultMap="com.dy.pmsGlobal.daoPr.PrProductionNodeMapper.BaseResultMap">
        select *
        from pr_production_node
        where process_id = #{processId,jdbcType=BIGINT}
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from pr_production_process
        where  id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from pr_production_process
        where  id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPr.PrProductionProcess" useGeneratedKeys="true">
        insert into pr_production_process
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">id,</if>
                <if test="proId != null">pro_id,</if>
                <if test="name != null">name,</if>
                <if test="creator != null">creator,</if>
                <if test="dt != null">dt,</if>
                <if test="disabled != null">disabled,</if>
                <if test="deleted != null">deleted,</if>
                <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=BIGINT},</if>
                <if test="proId != null">#{proId,jdbcType=BIGINT},</if>
                <if test="name != null">#{name,jdbcType=VARCHAR},</if>
                <if test="creator != null">#{creator,jdbcType=VARCHAR},</if>
                <if test="dt != null">#{dt,jdbcType=TIMESTAMP},</if>
                <if test="disabled != null">#{disabled,jdbcType=TINYINT},</if>
                <if test="deleted != null">#{deleted,jdbcType=TINYINT},</if>
                <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoPr.PrProductionProcess">
        update pr_production_process
        <set>
                <if test="proId != null">
                    pro_id = #{proId,jdbcType=BIGINT},
                </if>
                <if test="name != null">
                    name = #{name,jdbcType=VARCHAR},
                </if>
                <if test="creator != null">
                    creator = #{creator,jdbcType=VARCHAR},
                </if>
                <if test="dt != null">
                    dt = #{dt,jdbcType=TIMESTAMP},
                </if>
                <if test="disabled != null">
                    disabled = #{disabled,jdbcType=TINYINT},
                </if>
                <if test="deleted != null">
                    deleted = #{deleted,jdbcType=TINYINT},
                </if>
                <if test="remark != null">
                    remark = #{remark,jdbcType=VARCHAR},
                </if>
        </set>
        where   id = #{id,jdbcType=BIGINT}
    </update>
    <select id="selectSome" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from pr_production_process
        <trim prefix="where" suffixOverrides="and">
            <!--                <if test="id != null">-->
            <!--                    id = #{id,jdbcType=BIGINT} and-->
            <!--                </if>-->
            <if test="proId != null">
                pro_id = #{proId,jdbcType=BIGINT} and
            </if>
<!--            <if test="name != null">-->
<!--                name = #{name,jdbcType=VARCHAR} and-->
<!--            </if>-->
            <!--                <if test="creator != null">-->
            <!--                    creator = #{creator,jdbcType=VARCHAR} and-->
            <!--                </if>-->
            <!--                <if test="dt != null">-->
            <!--                    dt = #{dt,jdbcType=TIMESTAMP} and-->
            <!--                </if>-->
            <!--                <if test="disabled != null">-->
            <!--                    disabled = #{disabled,jdbcType=TINYINT} and-->
            <!--                </if>-->
            <!--                <if test="deleted != null">-->
            <!--                    deleted = #{deleted,jdbcType=TINYINT} and-->
            <!--                </if>-->
            <!--                <if test="remark != null">-->
            <!--                    remark = #{remark,jdbcType=VARCHAR} and-->
            <!--                </if>-->
        </trim>
        order by id desc
        <trim prefix="limit " >
            <if test="start != null and count != null">
                #{start}, #{count}
            </if>
        </trim>
    </select>
    <select id="selectSomeCount" resultType="java.lang.Long">
        select count(1)
        from pr_production_process
        <trim prefix="where" suffixOverrides="and">
<!--                <if test="id != null">-->
<!--                    id = #{id,jdbcType=BIGINT} and-->
<!--                </if>-->
            <if test="proId != null">
                pro_id = #{proId,jdbcType=BIGINT} and
            </if>
<!--                <if test="name != null">-->
<!--                    name = #{name,jdbcType=VARCHAR} and-->
<!--                </if>-->
<!--                <if test="creator != null">-->
<!--                    creator = #{creator,jdbcType=VARCHAR} and-->
<!--                </if>-->
<!--                <if test="dt != null">-->
<!--                    dt = #{dt,jdbcType=TIMESTAMP} and-->
<!--                </if>-->
<!--                <if test="disabled != null">-->
<!--                    disabled = #{disabled,jdbcType=TINYINT} and-->
<!--                </if>-->
<!--                <if test="deleted != null">-->
<!--                    deleted = #{deleted,jdbcType=TINYINT} and-->
<!--                </if>-->
<!--                <if test="remark != null">-->
<!--                    remark = #{remark,jdbcType=VARCHAR} and-->
<!--                </if>-->
        </trim>
    </select>
    <select id="queryAll" resultType="map">
        select
            CAST(id AS CHAR) AS id,name
        from pr_production_process
        where deleted = 0
    </select>
    <update id="deleteLogicById" parameterType="java.lang.Long">
        update pr_production_process set deleted = 1
        where id = #{id}
    </update>
</mapper>
pms-parent/pms-global/src/main/resources/mapper/PrWorkingInstructionMapper.xml
New file
@@ -0,0 +1,74 @@
<?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.PrWorkingInstructionMapper">
    <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPr.PrWorkingInstruction">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="nodeId" column="node_id" jdbcType="BIGINT"/>
        <result property="fileId" column="file_id" jdbcType="BIGINT"/>
    </resultMap>
    <sql id="Base_Column_List">
        id,node_id,file_id
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from pr_working_instruction
        where  id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from pr_working_instruction
        where  id = #{id,jdbcType=BIGINT}
    </delete>
    <delete id="deleteByNodeId" parameterType="arraylist">
        delete from pr_working_instruction
        where  node_id in
        <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPr.PrWorkingInstruction" useGeneratedKeys="true">
        insert into pr_working_instruction
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">id,</if>
                <if test="nodeId != null">node_id,</if>
                <if test="fileId != null">file_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=BIGINT},</if>
                <if test="nodeId != null">#{nodeId,jdbcType=BIGINT},</if>
                <if test="fileId != null">#{fileId,jdbcType=BIGINT},</if>
        </trim>
    </insert>
    <insert id="insertMany" parameterType="java.util.List">
        insert into pr_working_instruction
        <trim prefix="(" suffix=")" suffixOverrides=",">
                id,node_id,file_id
        </trim>
        values
        <foreach collection="list" item="item" separator=",">
            (
            #{item.id,jdbcType=BIGINT},
            #{item.nodeId,jdbcType=BIGINT},
            #{item.fileId,jdbcType=BIGINT}
            )
        </foreach>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoPr.PrWorkingInstruction">
        update pr_working_instruction
        <set>
                <if test="nodeId != null">
                    node_id = #{nodeId,jdbcType=BIGINT},
                </if>
                <if test="fileId != null">
                    file_id = #{fileId,jdbcType=BIGINT},
                </if>
        </set>
        where   id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/WebFilterConfiguration.java
New file
@@ -0,0 +1,41 @@
package com.dy.pmsProduct.config;
import com.dy.common.webFilter.DevStageFilter;
import com.dy.common.webFilter.UserTokenFilter;
import jakarta.servlet.Filter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class WebFilterConfiguration {
    @Value("${pms.global.dev}")
    public String isDevStage ;//是否为开发阶段
    /**
     * 启动顺序
     */
    private static final int order_UserTokenFilter = 1 ;
    private static final int order_DevStageFilter = 100 ;
    @Bean
    public FilterRegistrationBean<? extends Filter> regFilter() {
        FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>();
        if(this.isDevStage != null && !this.isDevStage.trim().equals("") && this.isDevStage.trim().equalsIgnoreCase("true")){
            filterRegistrationBean.setFilter(new DevStageFilter());
            filterRegistrationBean.addUrlPatterns("/*");//配置过滤规则
            filterRegistrationBean.setName("devStageFilter");//设置过滤器名称
            filterRegistrationBean.setOrder(order_DevStageFilter);//执行次序
        }else{
            filterRegistrationBean.setFilter(new UserTokenFilter());
            filterRegistrationBean.addUrlPatterns("/*");//配置过滤规则
            filterRegistrationBean.setName("UserTokenFilter");//设置过滤器名称
            filterRegistrationBean.setOrder(order_UserTokenFilter);//执行次序
        }
        return filterRegistrationBean;
    }
}
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/WebListenerConfiguration.java
New file
@@ -0,0 +1,50 @@
package com.dy.pmsProduct.config;
import com.dy.common.webListener.GenerateIdSetSuffixListener;
import jakarta.servlet.ServletContextListener;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class WebListenerConfiguration {
    /**
     * 启动顺序
     */
    //private static final int order_config = 0 ;
    private static final int order_idSetSuffix = 1 ;
    /*
    * 解析各种***config.xml配置的ConfigListener,当前springboot工程暂时不采用此种配置方式
    *
    @Bean
    public ConfigListener getGlConfigListener(){
        return new ConfigListener() ;
    }
    /**
     * 外部提供Listener
     * @param listener 外部提供Listener
     * @return 注册Bean
    @Bean
    public ServletListenerRegistrationBean<? extends ServletContextListener> regConfigListener(ConfigListener listener) {
        ServletListenerRegistrationBean<ConfigListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>();
        listenerRegistrationBean.setListener(listener);
        listenerRegistrationBean.setOrder(order_config);
        return listenerRegistrationBean;
    }
    */
    /**
     * 内部提供listener,该listener在系统启动时,根据配置 设置ID产生器的后缀
     * @return 注册Bean
     */
    @Bean
    public ServletListenerRegistrationBean<? extends ServletContextListener> regIdSuffixListener() {
        ServletListenerRegistrationBean<GenerateIdSetSuffixListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>();
        listenerRegistrationBean.setListener(new GenerateIdSetSuffixListener());
        listenerRegistrationBean.setOrder(order_idSetSuffix);
        return listenerRegistrationBean;
    }
}
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessCtrl.java
New file
@@ -0,0 +1,136 @@
package com.dy.pmsProduct.process;
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.PrProductionProcess;
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.util.List;
import java.util.Map;
import java.util.Objects;
/**
 * 生产流程
 */
@Slf4j
@RestController
@RequestMapping(path="process")
public class ProcessCtrl {
    private ProcessSv sv;
    @Autowired
    public void setSv(ProcessSv processSv){
        sv = processSv;
    }
    /**
     * 保存
     * @param  process
     * @param bindingResult
     * @return
     */
    @PostMapping(path="save")
    @SsoPowerAop(power = "-1")
    @Log("保存生产流程")
    public BaseResponse<Boolean> save(@RequestBody @Valid PrProductionProcess process, BindingResult bindingResult){
        if (bindingResult != null && bindingResult.hasErrors()) {
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        int count;
        try {
            count = sv.save(process);
        }catch (Exception e){
            log.error("保存生产流程异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        if (count <= 0) {
            return BaseResponseUtils.buildFail("数据库存储失败");
        } else {
            return BaseResponseUtils.buildSuccess(true);
        }
    }
    /**
     * 更新
     * @param process
     * @param bindingResult
     * @return
     */
    @PostMapping(path="update")
    @SsoPowerAop(power = "-1")
    @Log("更新生产流程")
    public BaseResponse<Boolean> update(@RequestBody @Valid PrProductionProcess process, BindingResult bindingResult){
        int count;
        try {
            if (bindingResult != null && bindingResult.hasErrors()) {
                return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
            }
            count = sv.update(process);
        }catch (Exception e){
            log.error("更新生产流程异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        if (count <= 0) {
            return BaseResponseUtils.buildFail("数据库存储失败");
        } else {
            return BaseResponseUtils.buildSuccess(true);
        }
    }
    /**
     * 根据ID查询
     * @return
     */
    @GetMapping(path="one")
    @SsoPowerAop(power = "-1")
    @Log("根据ID查询生产流程")
    public BaseResponse<PrProductionProcess> one(Long id){
        try{
            PrProductionProcess process=sv.selectById(id);
            return BaseResponseUtils.buildSuccess(process);
        }catch (Exception e){
            log.error("根据ID查询生产流程异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
    /**
     * 分页查询
     * @param vo
     * @return
     */
    @PostMapping(path="some")
    @SsoPowerAop(power = "-1")
    @Log("分页查询生产流程")
    public BaseResponse<QueryResultVo<List<PrProductionProcess>>> some(@RequestBody QueryVo vo){
        try {
            QueryResultVo<List<PrProductionProcess>> list = sv.selectSome(vo) ;
            return BaseResponseUtils.buildSuccess(list);
        }catch (Exception e){
            log.error("分页查询生产流程异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
    /**
     * 查询所有
     * @return
     */
    @GetMapping(path="queryAll")
    @SsoPowerAop(power = "-1")
    @Log("查询所有生产流程")
    public BaseResponse<List<Map<String,String>>> queryAll(){
        try {
            return BaseResponseUtils.buildSuccess(sv.queryAll());
        }catch (Exception e){
            log.error("查询所有生产流程异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
}
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java
New file
@@ -0,0 +1,176 @@
package com.dy.pmsProduct.process;
import com.dy.common.webFilter.UserTokenContext;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pmsGlobal.daoOth.OthFileMapper;
import com.dy.pmsGlobal.daoPr.PrProductionNodeMapper;
import com.dy.pmsGlobal.daoPr.PrProductionProcessMapper;
import com.dy.pmsGlobal.daoPr.PrWorkingInstructionMapper;
import com.dy.pmsGlobal.dyFile.FileOperate;
import com.dy.pmsGlobal.dyFile.FileRestVo;
import com.dy.pmsGlobal.pojoBa.BaUser;
import com.dy.pmsGlobal.pojoOth.OthFile;
import com.dy.pmsGlobal.pojoPr.PrProductionNode;
import com.dy.pmsGlobal.pojoPr.PrProductionProcess;
import com.dy.pmsGlobal.pojoPr.PrWorkingInstruction;
import com.dy.pmsGlobal.util.UserUtil;
import lombok.extern.slf4j.Slf4j;
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;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Service
public class ProcessSv {
    private PrProductionProcessMapper processDao;
    private PrProductionNodeMapper nodeDao;
    private PrWorkingInstructionMapper workDao;
    private UserUtil userUtil;
    private FileOperate fileOperate;
    private OthFileMapper othFileMapper;
    @Value("${dy.webFile.fmUrl}")
    private String fmUrl ;
    @Autowired
    public void setProcessDao(PrProductionProcessMapper dao){
        processDao = dao;
    }
    @Autowired
    public void setNodeDao(PrProductionNodeMapper dao){
        nodeDao = dao;
    }
    @Autowired
    public void setWorkDao(PrWorkingInstructionMapper dao){
        workDao = dao;
    }
    @Autowired
    public void setUserUtil(UserUtil userUtil){
        this.userUtil = userUtil;
    }
    @Autowired
    public void setFileOperate(FileOperate fileOperate){
        this.fileOperate = fileOperate;
    }
    @Autowired
    public void setOthFileMapper(OthFileMapper othFileMapper){
        this.othFileMapper = othFileMapper;
    }
    @Transactional
    public int save(PrProductionProcess process){
        prepareProcess(process);
        int count = processDao.insertSelective(process);
        saveNodesAndInstructions(process);
        return count;
    }
    @Transactional
    public int update(PrProductionProcess process){
        prepareProcess(process);
        int count = processDao.updateByPrimaryKeySelective(process);
        // 优化:只有当节点有变更时才删除并重新插入
        if (!process.nodes.isEmpty()) {
            List<Long> nodeIdsToDelete = process.getNodes().stream()
                    .map(PrProductionNode::getId) // 映射节点到其ID
                    .collect(Collectors.toList());
            workDao.deleteByNodeId(nodeIdsToDelete);
            nodeDao.deleteByProcessId(process.id);
        }
        saveNodesAndInstructions(process);
        return count;
    }
    // 提取共通逻辑到单独方法以减少代码重复
    private void prepareProcess(PrProductionProcess process){
        process.disabled = false;
        process.deleted = false;
        BaUser loginUser = userUtil.getUser(UserTokenContext.get());
        if(loginUser!=null){
            process.creator = loginUser.id;
        }
        process.nodes.forEach(node -> {
            node.processId = process.id;
            node.deleted= false;
        });
    }
    // 将节点和工作指示的保存逻辑封装到一个方法中
    private void saveNodesAndInstructions(PrProductionProcess process){
        try{
            nodeDao.insertMany(process.nodes);
        }catch (DuplicateKeyException e){
            throw new RuntimeException("节点顺序重复");
        }
        List<PrWorkingInstruction> workList = process.nodes.stream().map(node -> {
            if(node.instruction !=null){
                node.instruction.nodeId = node.id;
                return node.instruction;
            }
            return null;
        }).filter(work -> work != null).toList();
        workDao.insertMany(workList);
    }
    public int delete(Long id){
        return processDao.deleteLogicById(id);
    }
    public PrProductionProcess selectById(Long id){
        PrProductionProcess process = processDao.selectByPrimaryKey(id);
        if(process != null){
            process.nodes.forEach(node -> {
                if(node.instruction != null){
                    addUrl(node.instruction);
                }
            });
        }
        return process;
    }
    public QueryResultVo<List<PrProductionProcess>> selectSome(QueryVo queryVo){
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
        //查询符合条件的记录总数
        Long itemTotal = processDao.selectSomeCount(params);
        QueryResultVo<List<PrProductionProcess>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ;
        //计算分页等信息
        rsVo.calculateAndSet(itemTotal, params);
        //查询符合条件的记录
        rsVo.obj = processDao.selectSome(params);
        rsVo.obj.stream().forEach(process -> {
            process.nodes.forEach(node -> {
                if(node.instruction != null){
                    addUrl(node.instruction);
                }
            });
        });
        return rsVo ;
    }
    public List<Map<String,String>> queryAll(){
        return processDao.queryAll();
    }
    private void addUrl(PrWorkingInstruction ins){
        if (ins == null || ins.fileId == null) {
            return;
        }
        OthFile file = othFileMapper.selectByPrimaryKey(ins.fileId);
        if (file == null) {
            return;
        }
        FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, file.hash);
        ins.webUrl = fileRestVo.fileSysRestUrl + fileRestVo.fileWebDownloadPath + ins.fileId;
        ins.orgName = file.orgName;
        ins.extName = file.extName;
    }
}
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/QueryVo.java
New file
@@ -0,0 +1,15 @@
package com.dy.pmsProduct.process;
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 name;
    public Long proId;
}