From 067abdd781fd804bf362657f41f23be748977983 Mon Sep 17 00:00:00 2001
From: liuxm <liuxm@fescotech.com>
Date: 星期三, 15 五月 2024 09:00:28 +0800
Subject: [PATCH] 工站管理

---
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltStation.java          |   58 +++++++
 pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java   |   80 ++++++++++
 pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java |  132 ++++++++++++++++
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java     |   38 ++++
 pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml                  |  131 ++++++++++++++++
 pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/QueryVo.java     |   16 ++
 6 files changed, 455 insertions(+), 0 deletions(-)

diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java
new file mode 100644
index 0000000..4e28a65
--- /dev/null
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java
@@ -0,0 +1,38 @@
+package com.dy.pmsGlobal.daoPlt;
+
+import com.dy.pmsGlobal.pojoPlt.PltStation;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+* @author 灏忔槑
+* @description 閽堝琛ㄣ�恜lt_station(宸ョ珯琛�)銆戠殑鏁版嵁搴撴搷浣淢apper
+* @createDate 2024-05-09 17:13:22
+* @Entity com.dy.pmsGlobal.pojoPlt.PltStation
+*/
+@Mapper
+public interface PltStationMapper {
+
+    int deleteByPrimaryKey(Long id);
+
+    int insert(PltStation record);
+
+    int insertSelective(PltStation record);
+
+    PltStation selectByPrimaryKey(Long id);
+
+    long selectByCodeId(Long id,String code);
+
+    int updateByPrimaryKeySelective(PltStation record);
+
+    int updateByPrimaryKey(PltStation record);
+
+    Long selectSomeCount(Map<String,Object> params);
+
+    List<PltStation> selectSome(Map<String,Object> params);
+
+    int deleteLogicById(Long id);
+
+}
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltStation.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltStation.java
new file mode 100644
index 0000000..e7bb85f
--- /dev/null
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltStation.java
@@ -0,0 +1,58 @@
+package com.dy.pmsGlobal.pojoPlt;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import jakarta.validation.constraints.NotEmpty;
+import lombok.*;
+import org.hibernate.validator.constraints.Length;
+
+import java.util.Date;
+
+/**
+ * 宸ョ珯琛�
+ * @TableName plt_station
+ */
+@TableName(value="plt_station", autoResultMap = true)
+@Data
+@Builder
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class PltStation{
+    /**
+     * 
+     */
+    @TableId(type = IdType.AUTO)
+    public Long id;
+
+    /**
+     * 缂栧彿
+     */
+    @NotEmpty(message = "缂栧彿涓嶈兘涓虹┖")
+    @Length(message = "缂栧彿蹇呴』{max}浣嶆暟鎹�", min = 4, max = 4)
+    public String code;
+
+    /**
+     * 鍚嶇О
+     */
+    @NotEmpty(message = "鍚嶇О涓嶈兘涓虹┖")
+    public String name;
+
+    /**
+     * 澶囨敞
+     */
+    public String remark;
+
+    /**
+     * 鍒涘缓鏃堕棿
+     */
+    @TableField(value = "dt", fill = FieldFill.INSERT)
+//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    public Date dt;
+
+    /**
+     * 鏄惁鍒犻櫎锛�1鏄紝0鍚�
+     */
+    public Boolean deleted;
+
+}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml
new file mode 100644
index 0000000..c922b71
--- /dev/null
+++ b/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml
@@ -0,0 +1,131 @@
+<?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.PltStationMapper">
+
+    <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoPlt.PltStation">
+            <id property="id" column="id" jdbcType="BIGINT"/>
+            <result property="code" column="code" jdbcType="VARCHAR"/>
+            <result property="name" column="name" jdbcType="VARCHAR"/>
+            <result property="remark" column="remark" jdbcType="VARCHAR"/>
+            <result property="dt" column="dt" jdbcType="TIMESTAMP"/>
+            <result property="deleted" column="deleted" jdbcType="TINYINT"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,code,name,
+        remark,dt,deleted
+    </sql>
+
+    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />
+        from plt_station
+        where  id = #{id,jdbcType=BIGINT} 
+    </select>
+
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+        delete from plt_station
+        where  id = #{id,jdbcType=BIGINT} 
+    </delete>
+    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltStation" useGeneratedKeys="true">
+        insert into plt_station
+        ( id,code,name
+        ,remark,deleted
+        )
+        values (#{id,jdbcType=BIGINT},#{code,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR}
+        ,#{remark,jdbcType=VARCHAR},#{deleted,jdbcType=TINYINT}
+        )
+    </insert>
+    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltStation" useGeneratedKeys="true">
+        insert into plt_station
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+                <if test="id != null">id,</if>
+                <if test="code != null">code,</if>
+                <if test="name != null">name,</if>
+                <if test="remark != null">remark,</if>
+                <if test="deleted != null">deleted,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+                <if test="id != null">#{id,jdbcType=BIGINT},</if>
+                <if test="code != null">#{code,jdbcType=VARCHAR},</if>
+                <if test="name != null">#{name,jdbcType=VARCHAR},</if>
+                <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
+                <if test="deleted != null">#{deleted,jdbcType=TINYINT},</if>
+        </trim>
+    </insert>
+    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoPlt.PltStation">
+        update plt_station
+        <set>
+                <if test="code != null">
+                    code = #{code,jdbcType=VARCHAR},
+                </if>
+                <if test="name != null">
+                    name = #{name,jdbcType=VARCHAR},
+                </if>
+                <if test="remark != null">
+                    remark = #{remark,jdbcType=VARCHAR},
+                </if>
+                <if test="deleted != null">
+                    deleted = #{deleted,jdbcType=TINYINT},
+                </if>
+        </set>
+        where   id = #{id,jdbcType=BIGINT} 
+    </update>
+    <update id="updateByPrimaryKey" parameterType="com.dy.pmsGlobal.pojoPlt.PltStation">
+        update plt_station
+        set 
+            code =  #{code,jdbcType=VARCHAR},
+            name =  #{name,jdbcType=VARCHAR},
+            remark =  #{remark,jdbcType=VARCHAR},
+            deleted =  #{deleted,jdbcType=TINYINT}
+        where   id = #{id,jdbcType=BIGINT} 
+    </update>
+
+    <select id="selectSome" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />
+        from plt_station where deleted!=1
+        <trim prefix="and" suffixOverrides="and">
+            <if test="code != null and code !=''">
+                code = #{code,jdbcType=VARCHAR} and
+            </if>
+            <if test="name != null and name !=''">
+                name  like concat('%', #{name}, '%')
+            </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_station where deleted!=1
+        <trim prefix="and" suffixOverrides="and">
+            <if test="code != null and code !=''">
+                code = #{code,jdbcType=VARCHAR} and
+            </if>
+            <if test="name != null and name !=''">
+                name  like concat('%', #{name}, '%')
+            </if>
+        </trim>
+    </select>
+    <select id="selectByCodeId" resultType="java.lang.Long">
+        select count(1) from plt_station where code = #{code} and deleted!=1
+        <trim prefix="and" suffixOverrides="and">
+            <if test="id != null">
+                id != #{id}
+            </if>
+        </trim>
+    </select>
+
+    <update id="deleteLogicById" parameterType="java.lang.Long">
+        update plt_station set deleted = 1
+        where id = #{id}
+    </update>
+</mapper>
diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/QueryVo.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/QueryVo.java
new file mode 100644
index 0000000..1aa37ea
--- /dev/null
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/QueryVo.java
@@ -0,0 +1,16 @@
+package com.dy.pmsPlatform.station;
+
+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 code;
+}
diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java
new file mode 100644
index 0000000..40ae28b
--- /dev/null
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java
@@ -0,0 +1,132 @@
+package com.dy.pmsPlatform.station;
+
+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.PltStation;
+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="station")
+@SuppressWarnings("unchecked")
+public class StationCtrl {
+    private StationSv sv;
+    @Autowired
+    public StationCtrl(StationSv sv){
+        this.sv = sv;
+    }
+
+    /**
+     * 淇濆瓨
+     * @param station
+     * @param bindingResult
+     * @return
+     */
+    @PostMapping(path="save")
+    @SsoPowerAop(power = "10300001")
+    @Log("淇濆瓨宸ョ珯")
+    public BaseResponse<PltStation> save(@RequestBody @Valid PltStation station,BindingResult bindingResult){
+        try {
+            if (bindingResult != null && bindingResult.hasErrors()) {
+                return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+            }
+            station.deleted = false;
+            return BaseResponseUtils.buildSuccess(sv.save(station));
+        }catch (Exception e){
+            log.error("淇濆瓨宸ョ珯寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
+
+
+    /**
+     * 鏇存柊
+     * @param station
+     * @param bindingResult
+     * @return
+     */
+    @PostMapping(path="update")
+    @SsoPowerAop(power = "10300001")
+    @Log("鏇存柊宸ョ珯")
+    public BaseResponse<PltStation> update(@RequestBody @Valid PltStation station,BindingResult bindingResult){
+        try {
+            if (bindingResult != null && bindingResult.hasErrors()) {
+                return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+            }
+            return BaseResponseUtils.buildSuccess(sv.update(station));
+        }catch (Exception e){
+            log.error("鏇存柊宸ョ珯寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
+
+    /**
+     * 鍒犻櫎
+     * @param id
+     * @return
+     */
+    @GetMapping(path="delete")
+    @SsoPowerAop(power = "10300001")
+    @Log("鍒犻櫎宸ョ珯")
+    public BaseResponse<PltStation> 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<PltStation> one(String id){
+        try{
+            PltStation 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<PltStation>>> some(@RequestBody QueryVo vo){
+        try {
+            QueryResultVo<List<PltStation>> 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/station/StationSv.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java
new file mode 100644
index 0000000..fafb724
--- /dev/null
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java
@@ -0,0 +1,80 @@
+package com.dy.pmsPlatform.station;
+
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pmsGlobal.daoPlt.PltStationMapper;
+import com.dy.pmsGlobal.pojoPlt.PltStation;
+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 StationSv {
+
+    private PltStationMapper dao;
+
+    @Autowired
+    public void setDao(PltStationMapper dao) {
+        this.dao = dao;
+    }
+
+    @Transactional
+    public int save(PltStation station) throws Exception {
+        if(dao.selectByCodeId(station.id,station.code)>0){
+            throw new Exception("宸ョ珯缂栧彿宸插瓨鍦�");
+        }
+        int count = dao.insertSelective(station);
+        return count;
+    }
+
+    /**
+     * 閫昏緫鍒犻櫎瀹炰綋
+     * @param id 瀹炰綋ID
+     * @return 褰卞搷璁板綍鏁伴噺
+     */
+    @Transactional
+    public int delete(Long id) {
+        return this.dao.deleteLogicById(id);
+    }
+
+
+
+    @Transactional
+    public int update(PltStation station) throws Exception {
+        if(dao.selectByCodeId(station.id,station.code)>0){
+            throw new Exception("宸ョ珯缂栧彿宸插瓨鍦�");
+        }
+        int count = dao.updateByPrimaryKeySelective(station);
+        return count;
+    }
+
+
+    public PltStation selectById(String stationId) {
+        return dao.selectByPrimaryKey(Long.valueOf(stationId));
+    }
+
+    /**
+     * 鑾峰彇鍒楄〃
+     */
+    public QueryResultVo<List<PltStation>> selectSome(QueryVo queryVo) {
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+
+        //鏌ヨ绗﹀悎鏉′欢鐨勮褰曟�绘暟
+        Long itemTotal = this.dao.selectSomeCount(params);
+
+        QueryResultVo<List<PltStation>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ;
+        //璁$畻鍒嗛〉绛変俊鎭�
+        rsVo.calculateAndSet(itemTotal, params);
+
+        //鏌ヨ绗﹀悎鏉′欢鐨勮褰�
+        rsVo.obj = this.dao.selectSome(params) ;
+        return rsVo ;
+    }
+
+}
+

--
Gitblit v1.8.0