liuxm
2024-05-15 c5f04d7720063b4f7e9e8af1d8bf2c98d69417df
生产线管理
6个文件已添加
519 ■■■■■ 已修改文件
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductionLineMapper.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductionLine.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PltProductionLineMapper.xml 172 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java 132 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineSv.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/QueryVo.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltProductionLineMapper.java
New file
@@ -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 针对表【plt_production_line(生产线表)】的数据库操作Mapper
* @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);
}
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductionLine.java
New file
@@ -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;
    /**
     * 技术负责人
     */
    @NotEmpty(message = "技术负责人不能为空")
    public String director;
    /**
     * 技术负责人手机号
     */
    @NotEmpty(message = "技术负责人手机号不能为空")
    @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;
}
pms-parent/pms-global/src/main/resources/mapper/PltProductionLineMapper.xml
New file
@@ -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>
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java
New file
@@ -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());
        }
    }
}
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineSv.java
New file
@@ -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 ;
    }
}
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/QueryVo.java
New file
@@ -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;
}