liuxm
2024-05-08 d2701bff9dbe8d8d0592cea1695107793c15be30
物料管理
6个文件已添加
491 ■■■■■ 已修改文件
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltMaterialMapper.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltMaterial.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PltMaterialMapper.xml 166 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/MaterialCtrl.java 132 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/MaterialSv.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/QueryVo.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltMaterialMapper.java
New file
@@ -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 针对表【plt_material(物料表)】的数据库操作Mapper
* @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);
}
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltMaterial.java
New file
@@ -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;
}
pms-parent/pms-global/src/main/resources/mapper/PltMaterialMapper.xml
New file
@@ -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>
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/MaterialCtrl.java
New file
@@ -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());
        }
    }
}
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/MaterialSv.java
New file
@@ -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 ;
    }
}
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/material/QueryVo.java
New file
@@ -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;
}