From d2701bff9dbe8d8d0592cea1695107793c15be30 Mon Sep 17 00:00:00 2001
From: liuxm <liuxm@fescotech.com>
Date: 星期三, 08 五月 2024 15:41:14 +0800
Subject: [PATCH] 物料管理
---
pms-parent/pms-global/src/main/resources/mapper/PltMaterialMapper.xml | 166 ++++++++++++++++++
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/MaterialCtrl.java | 132 ++++++++++++++
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltMaterial.java | 64 +++++++
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltMaterialMapper.java | 36 ++++
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/QueryVo.java | 19 ++
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/MaterialSv.java | 74 ++++++++
6 files changed, 491 insertions(+), 0 deletions(-)
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltMaterialMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltMaterialMapper.java
new file mode 100644
index 0000000..8096317
--- /dev/null
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltMaterialMapper.java
@@ -0,0 +1,36 @@
+package com.dy.pmsGlobal.daoPlt;
+
+import com.dy.pmsGlobal.pojoPlt.PltMaterial;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+* @author 灏忔槑
+* @description 閽堝琛ㄣ�恜lt_material(鐗╂枡琛�)銆戠殑鏁版嵁搴撴搷浣淢apper
+* @createDate 2024-05-08 14:16:19
+* @Entity com.dy.pmsGlobal.pojoPlt.PltMaterial
+*/
+@Mapper
+public interface PltMaterialMapper {
+
+ int deleteByPrimaryKey(Long id);
+
+ int insert(PltMaterial record);
+
+ int insertSelective(PltMaterial record);
+
+ PltMaterial selectByPrimaryKey(Long id);
+
+ int updateByPrimaryKeySelective(PltMaterial record);
+
+ int updateByPrimaryKey(PltMaterial record);
+
+ Long selectSomeCount(Map<String,Object> params);
+
+ List<PltMaterial> selectSome(Map<String,Object> params);
+
+ int deleteLogicById(Long id);
+
+}
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
new file mode 100644
index 0000000..5090086
--- /dev/null
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltMaterial.java
@@ -0,0 +1,64 @@
+package com.dy.pmsGlobal.pojoPlt;
+
+import com.alibaba.fastjson2.annotation.JSONField;
+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 jakarta.validation.constraints.NotEmpty;
+import lombok.Data;
+
+/**
+ * 鐗╂枡琛�
+ * @TableName plt_material
+ */
+@TableName(value ="plt_material")
+@Data
+public class PltMaterial implements Serializable {
+ /**
+ * 缂栧彿
+ */
+ @TableId(type = IdType.AUTO)
+ public Integer id;
+
+ /**
+ * 浜у搧瀹炰綋缂栧彿
+ */
+ @NotEmpty(message = "浜у搧瀹炰綋缂栧彿涓嶈兘涓虹┖")
+ public Long proId;
+
+ /**
+ * 鍚嶇О
+ */
+ @NotEmpty(message = "鍚嶇О涓嶈兘涓虹┖")
+ public String name;
+
+ /**
+ * 鍨嬪彿
+ */
+ @NotEmpty(message = "鍨嬪彿涓嶈兘涓虹┖")
+ public String type;
+
+ /**
+ * 闀垮害
+ */
+ public String length;
+
+ /**
+ * 鍘傚
+ */
+ public String factory;
+
+ /**
+ * 鏄惁鍒犻櫎锛�1鏄紝0鍚�
+ */
+ @JSONField(serialize = false)
+ public Boolean deleted;
+
+ /**
+ * 澶囨敞
+ */
+ public String remark;
+}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/mapper/PltMaterialMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PltMaterialMapper.xml
new file mode 100644
index 0000000..eae3f27
--- /dev/null
+++ b/pms-parent/pms-global/src/main/resources/mapper/PltMaterialMapper.xml
@@ -0,0 +1,166 @@
+<?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.PltMaterialMapper">
+
+ <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPlt.PltMaterial">
+ <id property="id" column="id" jdbcType="INTEGER"/>
+ <result property="proId" column="pro_id" jdbcType="BIGINT"/>
+ <result property="name" column="name" jdbcType="VARCHAR"/>
+ <result property="type" column="type" jdbcType="VARCHAR"/>
+ <result property="length" column="length" jdbcType="VARCHAR"/>
+ <result property="factory" column="factory" jdbcType="VARCHAR"/>
+ <result property="deleted" column="deleted" jdbcType="TINYINT"/>
+ <result property="remark" column="remark" jdbcType="VARCHAR"/>
+ </resultMap>
+
+ <sql id="Base_Column_List">
+ id,pro_id,name,
+ type,length,factory,
+ deleted,remark
+ </sql>
+ <sql id="part_Column_List">
+ ${alias}.id,
+ ${alias}.pro_id,
+ ${alias}.name,
+ ${alias}.type,
+ ${alias}.length,
+ ${alias}.factory,
+ ${alias}.deleted,
+ ${alias}.remark
+ </sql>
+
+ <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+ select
+ <include refid="Base_Column_List" />
+ from plt_material
+ where id = #{id,jdbcType=INTEGER}
+ </select>
+
+ <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+ delete from plt_material
+ where id = #{id,jdbcType=INTEGER}
+ </delete>
+ <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltMaterial" useGeneratedKeys="true">
+ insert into plt_material
+ ( id,pro_id,name
+ ,type,length,factory
+ ,deleted,remark)
+ values (#{id,jdbcType=INTEGER},#{proId,jdbcType=BIGINT},#{name,jdbcType=VARCHAR}
+ ,#{type,jdbcType=VARCHAR},#{length,jdbcType=VARCHAR},#{factory,jdbcType=VARCHAR}
+ ,#{deleted,jdbcType=TINYINT},#{remark,jdbcType=VARCHAR})
+ </insert>
+ <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltMaterial" useGeneratedKeys="true">
+ insert into plt_material
+ <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="type != null">type,</if>
+ <if test="length != null">length,</if>
+ <if test="factory != null">factory,</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=INTEGER},</if>
+ <if test="proId != null">#{proId,jdbcType=BIGINT},</if>
+ <if test="name != null">#{name,jdbcType=VARCHAR},</if>
+ <if test="type != null">#{type,jdbcType=VARCHAR},</if>
+ <if test="length != null">#{length,jdbcType=VARCHAR},</if>
+ <if test="factory != null">#{factory,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.PltMaterial">
+ update plt_material
+ <set>
+ <if test="proId != null">
+ pro_id = #{proId,jdbcType=BIGINT},
+ </if>
+ <if test="name != null">
+ name = #{name,jdbcType=VARCHAR},
+ </if>
+ <if test="type != null">
+ type = #{type,jdbcType=VARCHAR},
+ </if>
+ <if test="length != null">
+ length = #{length,jdbcType=VARCHAR},
+ </if>
+ <if test="factory != null">
+ factory = #{factory,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=INTEGER}
+ </update>
+ <update id="updateByPrimaryKey" parameterType="com.dy.pmsGlobal.pojoPlt.PltMaterial">
+ update plt_material
+ set
+ pro_id = #{proId,jdbcType=BIGINT},
+ name = #{name,jdbcType=VARCHAR},
+ type = #{type,jdbcType=VARCHAR},
+ length = #{length,jdbcType=VARCHAR},
+ factory = #{factory,jdbcType=VARCHAR},
+ deleted = #{deleted,jdbcType=TINYINT},
+ remark = #{remark,jdbcType=VARCHAR}
+ where id = #{id,jdbcType=INTEGER}
+ </update>
+
+ <select id="selectSome" resultMap="BaseResultMap">
+ select
+ <include refid="part_Column_List" >
+ <property name="alias" value="m"/>
+ </include>
+ from plt_material m
+ inner join plt_product p on m.pro_id = p.id
+ where m.deleted!=1
+ <trim prefix="and" suffixOverrides="and">
+ <if test="proName != null and proName != ''">
+ p.name like concat('%', #{proName}, '%') and
+ </if>
+ <if test="name != null and name != '' ">
+ m.name like concat('%', #{name}, '%') and
+ </if>
+ <if test="type != null and type != ''">
+ m.type = #{type,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_material m
+ inner join plt_product p on m.pro_id = p.id
+ where m.deleted!=1
+ <trim prefix="and" suffixOverrides="and">
+ <if test="proName != null and proName != ''">
+ p.name like concat('%', #{proName}, '%') and
+ </if>
+ <if test="name != null and name != '' ">
+ m.name like concat('%', #{name}, '%') and
+ </if>
+ <if test="type != null and type != ''">
+ m.type = #{type,jdbcType=VARCHAR} and
+ </if>
+ </trim>
+ </select>
+
+ <update id="deleteLogicById" parameterType="java.lang.Long">
+ update plt_material set deleted = 1
+ where id = #{id}
+ </update>
+</mapper>
diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/MaterialCtrl.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/MaterialCtrl.java
new file mode 100644
index 0000000..db3bf6f
--- /dev/null
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/MaterialCtrl.java
@@ -0,0 +1,132 @@
+package com.dy.pmsPlatform.material;
+
+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.PltMaterial;
+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="material")
+@SuppressWarnings("unchecked")
+public class MaterialCtrl {
+ private MaterialSv sv;
+ @Autowired
+ public MaterialCtrl(MaterialSv sv){
+ this.sv = sv;
+ }
+
+ /**
+ * 淇濆瓨鐗╂枡淇℃伅
+ * @param material
+ * @param bindingResult
+ * @return
+ */
+ @PostMapping(path="save")
+ @SsoPowerAop(power = "10300001")
+ @Log("淇濆瓨鐗╂枡淇℃伅")
+ public BaseResponse<PltMaterial> save(@RequestBody @Valid PltMaterial material,BindingResult bindingResult){
+ try {
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ material.deleted = false;
+ return BaseResponseUtils.buildSuccess(sv.save(material));
+ }catch (Exception e){
+ log.error("淇濆瓨鐗╂枡寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+
+ /**
+ * 鏇存柊鐗╂枡淇℃伅
+ * @param material
+ * @param bindingResult
+ * @return
+ */
+ @PostMapping(path="update")
+ @SsoPowerAop(power = "10300001")
+ @Log("鏇存柊鐗╂枡淇℃伅")
+ public BaseResponse<PltMaterial> update(@RequestBody @Valid PltMaterial material,BindingResult bindingResult){
+ try {
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ return BaseResponseUtils.buildSuccess(sv.update(material));
+ }catch (Exception e){
+ log.error("鏇存柊鐗╂枡寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ /**
+ * 鍒犻櫎鐗╂枡淇℃伅
+ * @param id
+ * @return
+ */
+ @GetMapping(path="delete")
+ @SsoPowerAop(power = "10300001")
+ @Log("鍒犻櫎鐗╂枡淇℃伅")
+ public BaseResponse<PltMaterial> 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<PltMaterial> one(String id){
+ try{
+ PltMaterial material=sv.selectById(id);
+ return BaseResponseUtils.buildSuccess(JSON.toJSON(material));
+ }catch (Exception e){
+ log.error("鏌ヨ鐗╂枡寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ /**
+ * 鏌ヨ鐗╂枡淇℃伅
+ * @param vo
+ * @return
+ */
+ @PostMapping(path="some")
+ @SsoPowerAop(power = "10300000")
+ @Log("鏌ヨ鐗╂枡淇℃伅")
+ public BaseResponse<QueryResultVo<List<PltMaterial>>> some(@RequestBody QueryVo vo){
+ try {
+ QueryResultVo<List<PltMaterial>> 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/material/MaterialSv.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/MaterialSv.java
new file mode 100644
index 0000000..d09f551
--- /dev/null
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/MaterialSv.java
@@ -0,0 +1,74 @@
+package com.dy.pmsPlatform.material;
+
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pmsGlobal.daoPlt.PltMaterialMapper;
+import com.dy.pmsGlobal.pojoPlt.PltMaterial;
+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 MaterialSv {
+
+ private PltMaterialMapper dao;
+
+ @Autowired
+ public void setDao(PltMaterialMapper dao) {
+ this.dao = dao;
+ }
+
+ @Transactional
+ public int save(PltMaterial material) {
+ int count = dao.insert(material);
+ return count;
+ }
+
+ /**
+ * 閫昏緫鍒犻櫎瀹炰綋
+ * @param id 瀹炰綋ID
+ * @return 褰卞搷璁板綍鏁伴噺
+ */
+ @Transactional
+ public int delete(Long id) {
+ return this.dao.deleteLogicById(id);
+ }
+
+
+
+ @Transactional
+ public int update(PltMaterial material) {
+ int count = dao.updateByPrimaryKeySelective(material);
+ return count;
+ }
+
+
+ public PltMaterial selectById(String materialId) {
+ return dao.selectByPrimaryKey(Long.valueOf(materialId));
+ }
+
+ /**
+ * 鑾峰彇鍙傛暟鍒楄〃
+ */
+ public QueryResultVo<List<PltMaterial>> selectSome(QueryVo queryVo) {
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+
+ //鏌ヨ绗﹀悎鏉′欢鐨勮褰曟�绘暟
+ Long itemTotal = this.dao.selectSomeCount(params);
+
+ QueryResultVo<List<PltMaterial>> 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/material/QueryVo.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/QueryVo.java
new file mode 100644
index 0000000..212d318
--- /dev/null
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/QueryVo.java
@@ -0,0 +1,19 @@
+package com.dy.pmsPlatform.material;
+
+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 type;
+ /**
+ * 浜у搧鍚嶇О
+ */
+ public String proName;
+}
--
Gitblit v1.8.0