From 3a24dda899fcde40e2edb90c319eb5644805a639 Mon Sep 17 00:00:00 2001 From: liuxm <liuxm_a@163.com> Date: 星期二, 28 五月 2024 16:13:54 +0800 Subject: [PATCH] 生产流程相关接口 --- pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/QueryVo.java | 15 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrProductionNodeMapper.java | 30 + pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrWorkingInstruction.java | 53 ++ pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrProductionProcess.java | 78 +++ pms-parent/pms-common/src/main/java/com/dy/common/mybatis/AutoGenerateIdInterceptor.java | 23 + pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java | 176 ++++++++ pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/WebListenerConfiguration.java | 50 ++ pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/WebFilterConfiguration.java | 41 + pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java | 6 pms-parent/pms-global/src/main/resources/mapper/PrProductionProcessMapper.xml | 180 ++++++++ pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltMaterial.java | 8 pms-parent/pms-global/src/main/resources/mapper/PrProductionNodeMapper.xml | 152 +++++++ pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrProductionProcessMapper.java | 35 + pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrWorkingInstructionMapper.java | 28 + pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessCtrl.java | 136 ++++++ pms-parent/pms-global/src/main/resources/mapper/PrWorkingInstructionMapper.xml | 74 +++ pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/util/UserUtil.java | 52 ++ pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrProductionNode.java | 83 +++ 18 files changed, 1,217 insertions(+), 3 deletions(-) diff --git a/pms-parent/pms-common/src/main/java/com/dy/common/mybatis/AutoGenerateIdInterceptor.java b/pms-parent/pms-common/src/main/java/com/dy/common/mybatis/AutoGenerateIdInterceptor.java index b9bba45..5c3b4e0 100644 --- a/pms-parent/pms-common/src/main/java/com/dy/common/mybatis/AutoGenerateIdInterceptor.java +++ b/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){ + //褰揺ntityClass娌℃湁setId鏂规硶鏃讹紝浼氭姏鍑哄紓甯� + } + } + }); + }catch (Exception e){ + + } } } return invocation.proceed(); diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrProductionNodeMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrProductionNodeMapper.java new file mode 100644 index 0000000..71176a2 --- /dev/null +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrProductionNodeMapper.java @@ -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 閽堝琛ㄣ�恜r_production_node(鐢熶骇鑺傜偣琛�)銆戠殑鏁版嵁搴撴搷浣淢apper +* @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); +} diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrProductionProcessMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrProductionProcessMapper.java new file mode 100644 index 0000000..2fcc57f --- /dev/null +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrProductionProcessMapper.java @@ -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 閽堝琛ㄣ�恜r_production_process(鐢熶骇娴佺▼琛�)銆戠殑鏁版嵁搴撴搷浣淢apper +* @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(); +} diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrWorkingInstructionMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrWorkingInstructionMapper.java new file mode 100644 index 0000000..416dcf3 --- /dev/null +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrWorkingInstructionMapper.java @@ -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 閽堝琛ㄣ�恜r_working_instruction(浣滀笟鎸囧涔﹀叧鑱旇〃)銆戠殑鏁版嵁搴撴搷浣淢apper +* @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); + +} diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltMaterial.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltMaterial.java index 8c7f10f..d263f18 100644 --- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltMaterial.java +++ b/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 { /** * 缂栧彿 diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java index 8b43eb7..503318c 100644 --- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProduct.java +++ b/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; + /** + * 鍏稿瀷鍥剧墖缂╃暐鍥緒eb璺緞 + */ @TableField(exist = false) public String imageWebPathZip; /** diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrProductionNode.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrProductionNode.java new file mode 100644 index 0000000..9fc4736 --- /dev/null +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrProductionNode.java @@ -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; + +} \ No newline at end of file diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrProductionProcess.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrProductionProcess.java new file mode 100644 index 0000000..0cca70a --- /dev/null +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrProductionProcess.java @@ -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; + +} \ No newline at end of file diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrWorkingInstruction.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrWorkingInstruction.java new file mode 100644 index 0000000..a7b6c10 --- /dev/null +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrWorkingInstruction.java @@ -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; +} \ No newline at end of file diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/util/UserUtil.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/util/UserUtil.java new file mode 100644 index 0000000..488cefd --- /dev/null +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/util/UserUtil.java @@ -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; + } +} diff --git a/pms-parent/pms-global/src/main/resources/mapper/PrProductionNodeMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PrProductionNodeMapper.xml new file mode 100644 index 0000000..7f4b6e1 --- /dev/null +++ b/pms-parent/pms-global/src/main/resources/mapper/PrProductionNodeMapper.xml @@ -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> diff --git a/pms-parent/pms-global/src/main/resources/mapper/PrProductionProcessMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PrProductionProcessMapper.xml new file mode 100644 index 0000000..e8dfbc1 --- /dev/null +++ b/pms-parent/pms-global/src/main/resources/mapper/PrProductionProcessMapper.xml @@ -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> diff --git a/pms-parent/pms-global/src/main/resources/mapper/PrWorkingInstructionMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PrWorkingInstructionMapper.xml new file mode 100644 index 0000000..29742ce --- /dev/null +++ b/pms-parent/pms-global/src/main/resources/mapper/PrWorkingInstructionMapper.xml @@ -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> diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/WebFilterConfiguration.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/WebFilterConfiguration.java new file mode 100644 index 0000000..458ff95 --- /dev/null +++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/WebFilterConfiguration.java @@ -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; + } + +} diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/WebListenerConfiguration.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/WebListenerConfiguration.java new file mode 100644 index 0000000..62e88e9 --- /dev/null +++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/WebListenerConfiguration.java @@ -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 ; + + /* + * 瑙f瀽鍚勭***config.xml閰嶇疆鐨凜onfigListener锛屽綋鍓峴pringboot宸ョ▼鏆傛椂涓嶉噰鐢ㄦ绉嶉厤缃柟寮� + * + @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; + } + +} diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessCtrl.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessCtrl.java new file mode 100644 index 0000000..f29263e --- /dev/null +++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessCtrl.java @@ -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()); + } + } +} diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java new file mode 100644 index 0000000..613a8a1 --- /dev/null +++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java @@ -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; + } + + // 鎻愬彇鍏遍�氶�昏緫鍒板崟鐙柟娉曚互鍑忓皯浠g爜閲嶅 + 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; + } +} diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/QueryVo.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/QueryVo.java new file mode 100644 index 0000000..b06bd00 --- /dev/null +++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/QueryVo.java @@ -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; +} -- Gitblit v1.8.0