From c5f04d7720063b4f7e9e8af1d8bf2c98d69417df Mon Sep 17 00:00:00 2001
From: liuxm <liuxm@fescotech.com>
Date: 星期三, 15 五月 2024 08:59:52 +0800
Subject: [PATCH] 生产线管理
---
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductionLineMapper.java | 37 ++++
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductionLine.java | 80 ++++++++
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineSv.java | 80 ++++++++
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java | 132 ++++++++++++++
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/QueryVo.java | 18 ++
pms-parent/pms-global/src/main/resources/mapper/PltProductionLineMapper.xml | 172 +++++++++++++++++++
6 files changed, 519 insertions(+), 0 deletions(-)
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductionLineMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductionLineMapper.java
new file mode 100644
index 0000000..a092934
--- /dev/null
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductionLineMapper.java
@@ -0,0 +1,37 @@
+package com.dy.pmsGlobal.daoPlt;
+
+import com.dy.pmsGlobal.pojoPlt.PltProductionLine;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+* @author 灏忔槑
+* @description 閽堝琛ㄣ�恜lt_production_line(鐢熶骇绾胯〃)銆戠殑鏁版嵁搴撴搷浣淢apper
+* @createDate 2024-05-09 19:27:38
+* @Entity com.dy.pmsGlobal.pojoPlt.PltProductionLine
+*/
+@Mapper
+public interface PltProductionLineMapper {
+
+ int deleteByPrimaryKey(Long id);
+
+ int insert(PltProductionLine record);
+
+ int insertSelective(PltProductionLine record);
+
+ PltProductionLine selectByPrimaryKey(Long id);
+ Long selectByNameId(Long id,String name);
+
+ int updateByPrimaryKeySelective(PltProductionLine record);
+
+ int updateByPrimaryKey(PltProductionLine record);
+
+ Long selectSomeCount(Map<String,Object> params);
+
+ List<PltProductionLine> selectSome(Map<String,Object> params);
+
+ int deleteLogicById(Long id);
+
+}
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductionLine.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductionLine.java
new file mode 100644
index 0000000..0d4ba02
--- /dev/null
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductionLine.java
@@ -0,0 +1,80 @@
+package com.dy.pmsGlobal.pojoPlt;
+
+import com.baomidou.mybatisplus.annotation.*;
+
+import java.util.Date;
+
+import jakarta.validation.constraints.NotEmpty;
+import lombok.*;
+import org.hibernate.validator.constraints.Length;
+
+/**
+ * 鐢熶骇绾胯〃
+ * @TableName plt_production_line
+ */
+@TableName(value="plt_production_line", autoResultMap = true)
+@Data
+@Builder
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class PltProductionLine{
+ /**
+ *
+ */
+ @TableId(type = IdType.AUTO)
+ public Long id;
+
+ /**
+ * 鍚嶇О
+ */
+ @NotEmpty(message = "鍚嶇О涓嶈兘涓虹┖")
+ public String name;
+
+ /**
+ * 鍨嬪彿
+ */
+ @NotEmpty(message = "鍨嬪彿涓嶈兘涓虹┖")
+ public String type;
+
+ /**
+ * 鍘傚
+ */
+ @NotEmpty(message = "鍘傚涓嶈兘涓虹┖")
+ public String factory;
+
+ /**
+ * 鎶�鏈礋璐d汉
+ */
+ @NotEmpty(message = "鎶�鏈礋璐d汉涓嶈兘涓虹┖")
+ public String director;
+
+ /**
+ * 鎶�鏈礋璐d汉鎵嬫満鍙�
+ */
+ @NotEmpty(message = "鎶�鏈礋璐d汉鎵嬫満鍙蜂笉鑳戒负绌�")
+ @Length(message = "鎵嬫満鍙峰繀椤粄max}浣嶆暟鎹�", min = 11, max = 11)
+ public String dMobile;
+
+ /**
+ * 瀹夎鏃堕棿
+ */
+ @NotEmpty(message = "瀹夎鏃堕棿涓嶈兘涓虹┖")
+ public String installTime;
+
+ /**
+ * 鏄惁鍒犻櫎锛�1鏄紝0鍚�
+ */
+ public Boolean deleted;
+
+ /**
+ * 鍒涘缓鏃堕棿
+ */
+ public Date dt;
+
+ /**
+ * 澶囨敞
+ */
+ public String remark;
+
+}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/mapper/PltProductionLineMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PltProductionLineMapper.xml
new file mode 100644
index 0000000..1a3b93f
--- /dev/null
+++ b/pms-parent/pms-global/src/main/resources/mapper/PltProductionLineMapper.xml
@@ -0,0 +1,172 @@
+<?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.daoPlt.PltProductionLineMapper">
+
+ <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPlt.PltProductionLine">
+ <id property="id" column="id" jdbcType="BIGINT"/>
+ <result property="name" column="name" jdbcType="VARCHAR"/>
+ <result property="type" column="type" jdbcType="VARCHAR"/>
+ <result property="factory" column="factory" jdbcType="VARCHAR"/>
+ <result property="director" column="director" jdbcType="VARCHAR"/>
+ <result property="dMobile" column="d_mobile" jdbcType="VARCHAR"/>
+ <result property="installTime" column="install_time" jdbcType="VARCHAR"/>
+ <result property="deleted" column="deleted" jdbcType="TINYINT"/>
+ <result property="remark" column="remark" jdbcType="VARCHAR"/>
+ <result property="dt" column="dt" jdbcType="TIMESTAMP"/>
+ </resultMap>
+
+ <sql id="Base_Column_List">
+ id,name,type,
+ factory,director,d_mobile,
+ install_time,deleted,remark,dt
+ </sql>
+
+ <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+ select
+ <include refid="Base_Column_List" />
+ from plt_production_line
+ where id = #{id,jdbcType=BIGINT}
+ </select>
+
+ <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+ delete from plt_production_line
+ where id = #{id,jdbcType=BIGINT}
+ </delete>
+ <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltProductionLine" useGeneratedKeys="true">
+ insert into plt_production_line
+ ( id,name,type
+ ,factory,director,d_mobile
+ ,install_time,deleted,remark
+ )
+ values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR}
+ ,#{factory,jdbcType=VARCHAR},#{director,jdbcType=VARCHAR},#{dMobile,jdbcType=VARCHAR}
+ ,#{installTime,jdbcType=VARCHAR},#{deleted,jdbcType=TINYINT},#{remark,jdbcType=VARCHAR}
+ )
+ </insert>
+ <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltProductionLine" useGeneratedKeys="true">
+ insert into plt_production_line
+ <trim prefix="(" suffix=")" suffixOverrides=",">
+ <if test="id != null">id,</if>
+ <if test="name != null">name,</if>
+ <if test="type != null">type,</if>
+ <if test="factory != null">factory,</if>
+ <if test="director != null">director,</if>
+ <if test="dMobile != null">d_mobile,</if>
+ <if test="installTime != null">install_time,</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="name != null">#{name,jdbcType=VARCHAR},</if>
+ <if test="type != null">#{type,jdbcType=VARCHAR},</if>
+ <if test="factory != null">#{factory,jdbcType=VARCHAR},</if>
+ <if test="director != null">#{director,jdbcType=VARCHAR},</if>
+ <if test="dMobile != null">#{dMobile,jdbcType=VARCHAR},</if>
+ <if test="installTime != null">#{installTime,jdbcType=VARCHAR},</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.pojoPlt.PltProductionLine">
+ update plt_production_line
+ <set>
+ <if test="name != null">
+ name = #{name,jdbcType=VARCHAR},
+ </if>
+ <if test="type != null">
+ type = #{type,jdbcType=VARCHAR},
+ </if>
+ <if test="factory != null">
+ factory = #{factory,jdbcType=VARCHAR},
+ </if>
+ <if test="director != null">
+ director = #{director,jdbcType=VARCHAR},
+ </if>
+ <if test="dMobile != null">
+ d_mobile = #{dMobile,jdbcType=VARCHAR},
+ </if>
+ <if test="installTime != null">
+ install_time = #{installTime,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>
+ <update id="updateByPrimaryKey" parameterType="com.dy.pmsGlobal.pojoPlt.PltProductionLine">
+ update plt_production_line
+ set
+ name = #{name,jdbcType=VARCHAR},
+ type = #{type,jdbcType=VARCHAR},
+ factory = #{factory,jdbcType=VARCHAR},
+ director = #{director,jdbcType=VARCHAR},
+ d_mobile = #{dMobile,jdbcType=VARCHAR},
+ install_time = #{installTime,jdbcType=VARCHAR},
+ deleted = #{deleted,jdbcType=TINYINT},
+ remark = #{remark,jdbcType=VARCHAR}
+ where id = #{id,jdbcType=BIGINT}
+ </update>
+
+ <select id="selectSome" resultMap="BaseResultMap">
+ select
+ <include refid="Base_Column_List" />
+ from plt_production_line where deleted != 1
+ <trim prefix="and" suffixOverrides="and">
+ <if test="name != null">
+ name like concat('%', #{name}, '%') and
+ </if>
+ <if test="factory != null">
+ factory like concat('%', #{factory}, '%') and
+ </if>
+ <if test="director != null">
+ director like concat('%', #{director}, '%') and
+ </if>
+ <if test="dMobile != null">
+ d_mobile = #{dMobile,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 plt_production_line where deleted != 1
+ <trim prefix="and" suffixOverrides="and">
+ <if test="name != null">
+ name like concat('%', #{name}, '%') and
+ </if>
+ <if test="factory != null">
+ factory like concat('%', #{factory}, '%') and
+ </if>
+ <if test="director != null">
+ director like concat('%', #{director}, '%') and
+ </if>
+ <if test="dMobile != null">
+ d_mobile = #{dMobile,jdbcType=VARCHAR} and
+ </if>
+ </trim>
+ </select>
+ <select id="selectByNameId" resultType="java.lang.Long">
+ select count(1) from plt_production_line where name = #{name} and deleted != 1
+ <if test="id != null">
+ and id != #{id}
+ </if>
+ </select>
+
+ <update id="deleteLogicById" parameterType="java.lang.Long">
+ update plt_production_line set deleted = 1
+ where id = #{id}
+ </update>
+</mapper>
diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java
new file mode 100644
index 0000000..cf0b4b5
--- /dev/null
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java
@@ -0,0 +1,132 @@
+package com.dy.pmsPlatform.proLine;
+
+import com.alibaba.fastjson2.JSON;
+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.pojoPlt.PltProductionLine;
+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.Objects;
+
+/**
+ * 鐢熶骇绾�
+ */
+@Slf4j
+@RestController
+@RequestMapping(path="proLine")
+@SuppressWarnings("unchecked")
+public class ProLineCtrl {
+ private ProLineSv sv;
+ @Autowired
+ public ProLineCtrl(ProLineSv sv){
+ this.sv = sv;
+ }
+
+ /**
+ * 淇濆瓨
+ * @param line
+ * @param bindingResult
+ * @return
+ */
+ @PostMapping(path="save")
+ @SsoPowerAop(power = "10300001")
+ @Log("淇濆瓨鐢熶骇绾�")
+ public BaseResponse<PltProductionLine> save(@RequestBody @Valid PltProductionLine line,BindingResult bindingResult){
+ try {
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ line.deleted = false;
+ return BaseResponseUtils.buildSuccess(sv.save(line));
+ }catch (Exception e){
+ log.error("淇濆瓨鐢熶骇绾垮紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+
+ /**
+ * 鏇存柊
+ * @param line
+ * @param bindingResult
+ * @return
+ */
+ @PostMapping(path="update")
+ @SsoPowerAop(power = "10300001")
+ @Log("鏇存柊鐢熶骇绾�")
+ public BaseResponse<PltProductionLine> update(@RequestBody @Valid PltProductionLine line,BindingResult bindingResult){
+ try {
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ return BaseResponseUtils.buildSuccess(sv.update(line));
+ }catch (Exception e){
+ log.error("鏇存柊鐢熶骇绾垮紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ /**
+ * 鍒犻櫎
+ * @param id
+ * @return
+ */
+ @GetMapping(path="delete")
+ @SsoPowerAop(power = "10300001")
+ @Log("鍒犻櫎鐢熶骇绾�")
+ public BaseResponse<PltProductionLine> delete(String id){
+ try {
+ return BaseResponseUtils.buildSuccess(sv.delete(Long.parseLong(id)));
+ }catch (Exception e){
+ log.error("鍒犻櫎鐢熶骇绾垮紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+
+
+ /**
+ * 鏍规嵁ID鏌ヨ
+ * @return
+ */
+ @GetMapping(path="one")
+ @SsoPowerAop(power = "10300000") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ @Log("鏍规嵁ID鏌ヨ鐢熶骇绾�")
+ public BaseResponse<PltProductionLine> one(String id){
+ try{
+ PltProductionLine param=sv.selectById(id);
+ return BaseResponseUtils.buildSuccess(JSON.toJSON(param));
+ }catch (Exception e){
+ log.error("鏍规嵁ID鏌ヨ鐢熶骇绾垮紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ /**
+ * 鍒嗛〉鏌ヨ
+ * @param vo
+ * @return
+ */
+ @PostMapping(path="some")
+ @SsoPowerAop(power = "10300000")
+ @Log("鍒嗛〉鏌ヨ鐢熶骇绾�")
+ public BaseResponse<QueryResultVo<List<PltProductionLine>>> some(@RequestBody QueryVo vo){
+ try {
+ QueryResultVo<List<PltProductionLine>> list = sv.selectSome(vo) ;
+ return BaseResponseUtils.buildSuccess(list);
+ }catch (Exception e){
+ log.error("鍒嗛〉鏌ヨ鐢熶骇绾垮紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+}
+
diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineSv.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineSv.java
new file mode 100644
index 0000000..1c95e56
--- /dev/null
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineSv.java
@@ -0,0 +1,80 @@
+package com.dy.pmsPlatform.proLine;
+
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pmsGlobal.daoPlt.PltProductionLineMapper;
+import com.dy.pmsGlobal.pojoPlt.PltProductionLine;
+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;
+
+@Slf4j
+@Service
+public class ProLineSv {
+
+ private PltProductionLineMapper dao;
+
+ @Autowired
+ public void setDao(PltProductionLineMapper dao) {
+ this.dao = dao;
+ }
+
+ @Transactional
+ public int save(PltProductionLine line) throws Exception {
+ if(dao.selectByNameId(line.id,line.name)>0){
+ throw new Exception("鐢熶骇绾垮悕绉板凡瀛樺湪");
+ }
+ int count = dao.insertSelective(line);
+ return count;
+ }
+
+ /**
+ * 閫昏緫鍒犻櫎瀹炰綋
+ * @param id 瀹炰綋ID
+ * @return 褰卞搷璁板綍鏁伴噺
+ */
+ @Transactional
+ public int delete(Long id) {
+ return this.dao.deleteLogicById(id);
+ }
+
+
+
+ @Transactional
+ public int update(PltProductionLine line) throws Exception {
+ if(dao.selectByNameId(line.id,line.name)>0){
+ throw new Exception("鐢熶骇绾垮悕绉板凡瀛樺湪");
+ }
+ int count = dao.updateByPrimaryKeySelective(line);
+ return count;
+ }
+
+
+ public PltProductionLine selectById(String lineId) {
+ return dao.selectByPrimaryKey(Long.valueOf(lineId));
+ }
+
+ /**
+ * 鑾峰彇鍒楄〃
+ */
+ public QueryResultVo<List<PltProductionLine>> selectSome(QueryVo queryVo) {
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+
+ //鏌ヨ绗﹀悎鏉′欢鐨勮褰曟�绘暟
+ Long itemTotal = this.dao.selectSomeCount(params);
+
+ QueryResultVo<List<PltProductionLine>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ;
+ //璁$畻鍒嗛〉绛変俊鎭�
+ rsVo.calculateAndSet(itemTotal, params);
+
+ //鏌ヨ绗﹀悎鏉′欢鐨勮褰�
+ rsVo.obj = this.dao.selectSome(params) ;
+ return rsVo ;
+ }
+
+}
+
diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/QueryVo.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/QueryVo.java
new file mode 100644
index 0000000..d1e2f84
--- /dev/null
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/QueryVo.java
@@ -0,0 +1,18 @@
+package com.dy.pmsPlatform.proLine;
+
+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 String factory;
+ public String director;
+ public String dMobile;
+}
--
Gitblit v1.8.0