刘小明
2024-07-24 623397a394196189057db9c1948fe3b24f7fa4e3
生产线和工站添加启用禁用的校验
5个文件已修改
42 ■■■■■ 已修改文件
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineSv.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java
@@ -36,4 +36,7 @@
    String selectMaxCode();
    List<PltStation> selectStationList(PltStation record);
    long selectByLineAndStatus(Long lineId, boolean disabled);
}
pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml
@@ -153,6 +153,9 @@
    <select id="selectMaxCode" resultType="java.lang.String">
        select max(code) from plt_station
    </select>
    <select id="selectByLineAndStatus" resultType="java.lang.Long">
        select count(1) from plt_station where line_id = #{lineId} and disabled = #{disabled} and deleted!=1
    </select>
    <update id="deleteLogicById" parameterType="java.lang.Long">
        update plt_station set deleted = 1
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineCtrl.java
@@ -74,7 +74,7 @@
    @Log("设置生产线状态")
    //{id: "2", disabled: true}
    public BaseResponse<Boolean> disabled(@RequestBody PltProductionLine line){
        int count = sv.update(line);
        int count = sv.updateStatus(line);
        if (count <= 0) {
            return BaseResponseUtils.buildFail("数据库存储失败");
        } else {
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/proLine/ProLineSv.java
@@ -2,6 +2,7 @@
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pmsGlobal.daoPlt.PltProductionLineMapper;
import com.dy.pmsGlobal.daoPlt.PltStationMapper;
import com.dy.pmsGlobal.pojoPlt.PltProductionLine;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
@@ -17,10 +18,15 @@
public class ProLineSv {
    private PltProductionLineMapper dao;
    private PltStationMapper stationDao;
    @Autowired
    public void setDao(PltProductionLineMapper dao) {
        this.dao = dao;
    }
    @Autowired
    public void setStationDao(PltStationMapper stationDao) {
        this.stationDao = stationDao;
    }
    @Transactional
@@ -79,5 +85,19 @@
    public List<PltProductionLine> selectAll() {
        return dao.selectAll();
    }
    @Transactional
    public int updateStatus(PltProductionLine line) {
        if(line.disabled){
            long count = stationDao.selectByLineAndStatus(line.id,false);
            if(count>0){
                throw new RuntimeException("该生产线还有启用状态的工站");
            }
        }
        PltProductionLine lineParam = new PltProductionLine();
        lineParam.id = line.id;
        lineParam.disabled = line.disabled;
        return dao.updateByPrimaryKeySelective(lineParam);
    }
}
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java
@@ -2,7 +2,9 @@
import com.alibaba.excel.util.StringUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pmsGlobal.daoPlt.PltProductionLineMapper;
import com.dy.pmsGlobal.daoPlt.PltStationMapper;
import com.dy.pmsGlobal.pojoPlt.PltProductionLine;
import com.dy.pmsGlobal.pojoPlt.PltStation;
import com.dy.pmsGlobal.util.QrCodeUtil;
import lombok.extern.slf4j.Slf4j;
@@ -20,6 +22,7 @@
public class StationSv {
    private PltStationMapper dao;
    private PltProductionLineMapper lineDao;
    private static final String stationPrefix = "103" ;
    private static final String DEFAULT_CODE = "0001";
    private static final String CODE_FORMAT = "%04d";
@@ -27,6 +30,10 @@
    @Autowired
    public void setDao(PltStationMapper dao) {
        this.dao = dao;
    }
    @Autowired
    public void setLineDao(PltProductionLineMapper lineDao) {
        this.lineDao = lineDao;
    }
    @Transactional
@@ -125,6 +132,13 @@
    @Transactional
    public int disabled(Long id, Boolean disabled) {
        if(!disabled){
            PltStation station1 = dao.selectByPrimaryKey(id);
            PltProductionLine line = lineDao.selectByPrimaryKey(station1.lineId);
            if(line.disabled){
                throw new RuntimeException("该工站所属生产线已禁用,请先启用该生产线");
            }
        }
        PltStation station = new PltStation();
        station.setId(id);
        station.setDisabled(disabled);