Fancy
2024-06-20 279a149dd1ff4ef7a7a9353469532332d3fdcb5f
check user and station relation
9个文件已修改
257 ■■■■ 已修改文件
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoSta/StaAssemblyWorkLastMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductTestInspectionItems.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PltProductTestInspectionItemsMapper.xml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/StaAssemblyWorkLastMapper.xml 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderCtrl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderSv.java 143 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java
@@ -32,4 +32,6 @@
    List<PltStation> selectAll();
    String selectMaxCode();
    List<PltStation> selectStationList(PltStation record);
}
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoSta/StaAssemblyWorkLastMapper.java
@@ -3,6 +3,8 @@
import com.dy.pmsGlobal.pojoSta.StaAssemblyWorkLast;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author User
* @description 针对表【sta_assembly_work_last(生产线生产任务认领表)】的数据库操作Mapper
@@ -24,4 +26,5 @@
    int updateByPrimaryKey(StaAssemblyWorkLast record);
    List<StaAssemblyWorkLast> selectList(StaAssemblyWorkLast record);
}
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductTestInspectionItems.java
@@ -38,6 +38,9 @@
    @NotNull(message = "产品实体编号不能为空")
    public Long proId;
    @TableField(exist = false)
    public String proName;
    /**
     * 测试项目
     */
pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml
@@ -50,6 +50,11 @@
  <select id="selectNameByUserId" parameterType="java.lang.Long" resultType="java.lang.String">
    select name from ba_user where id=#{id}
  </select>
  <select id="selectNameById" parameterType="java.lang.Long" resultType="java.lang.String">
    select name from ba_user where id=#{id}
  </select>
  <select id="selectCount" resultType="java.lang.Long">
    select
      count(*)
@@ -68,9 +73,8 @@
    select 
    <include refid="Base_Column_List" />
    from ba_user
    where id = #{id}
    where id = #{id} and disabled!=1 and deleted!=1
  </select>
  <select id="selectSomeCount" parameterType="java.util.Map" resultType="java.lang.Long">
    select
@@ -122,11 +126,6 @@
      </if>
    </trim>
  </select>
  <select id="selectNameById" parameterType="java.lang.Long" resultType="java.lang.String">
    select name from ba_user where id=#{id}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
pms-parent/pms-global/src/main/resources/mapper/PltProductTestInspectionItemsMapper.xml
@@ -11,6 +11,8 @@
            <result property="deleted" column="deleted" jdbcType="TINYINT"/>
            <result property="disabled" column="disabled" jdbcType="TINYINT"/>
            <result property="sort" column="sort" jdbcType="INTEGER"/>
            <association property="proName" column="pro_id" javaType="java.lang.Long"
                     select="com.dy.pmsGlobal.daoPlt.PltProductMapper.selectProNameById" fetchType="eager" />
    </resultMap>
    <sql id="Base_Column_List">
pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml
@@ -94,6 +94,30 @@
        </trim>
    </select>
    <select id="selectStationList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from plt_station where deleted!=1
        <trim prefix="and" suffixOverrides="and">
            <if test="id != null and id !=''">
                id = #{id,jdbcType=BIGINT} and
            </if>
            <if test="code != null and code !=''">
                code = #{code,jdbcType=VARCHAR} and
            </if>
            <if test="name != null and name !=''">
                name  like concat('%', #{name}, '%') and
            </if>
            <if test="disabled != null and disabled !=''">
                disabled = #{disabled,jdbcType=TINYINT} and
            </if>
            <if test="lineId != null and lineId !=''">
                line_id = #{lineId,jdbcType=BIGINT} and
            </if>
        </trim>
        order by id desc
    </select>
    <select id="selectSomeCount" resultType="java.lang.Long">
        select count(1)
        from plt_station where deleted!=1
pms-parent/pms-global/src/main/resources/mapper/StaAssemblyWorkLastMapper.xml
@@ -33,6 +33,69 @@
        where  id = #{id,jdbcType=BIGINT} 
    </select>
    <select id="selectByUserAndStation" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from plt_station where status ==1
        <trim prefix="and" suffixOverrides="and">
            <if test="id != null and id !=''">
                id = #{id,jdbcType=BIGINT} and
            </if>
            <if test="code != null and code !=''">
                code = #{code,jdbcType=VARCHAR} and
            </if>
            <if test="name != null and name !=''">
                name  like concat('%', #{name}, '%') and
            </if>
            <if test="disabled != null and disabled !=''">
                disabled = #{disabled,jdbcType=TINYINT} and
            </if>
            <if test="lineId != null and lineId !=''">
                line_id = #{lineId,jdbcType=BIGINT} and
            </if>
        </trim>
        order by id desc
    </select>
    <select id="selectList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from sta_assembly_work_last
        <where>
            <if test="userId != null and userId !=''">
              and user_id = #{userId,jdbcType=BIGINT}
            </if>
            <if test="lineId != null and lineId !=''">
              and line_id = #{lineId,jdbcType=BIGINT}
            </if>
            <if test="stationId != null and stationId !=''">
              and station_id = #{stationId,jdbcType=BIGINT}
            </if>
            <if test="planId != null and planId !=''">
              and plan_id = #{planId,jdbcType=BIGINT}
            </if>
            <if test="processId != null and processId !=''">
              and process_id = #{processId,jdbcType=BIGINT}
            </if>
            <if test="nodeId != null and nodeId !=''">
              and node_id = #{nodeId,jdbcType=BIGINT}
            </if>
            <if test="status != null and status !=''">
              and status = #{status,jdbcType=TINYINT}
            </if>
            <if test="startTime != null and startTime !=''">
                and start_time = #{startTime,jdbcType=TIMESTAMP},
            </if>
            <if test="endTime != null and userId !=''">
                and  end_time = #{endTime,jdbcType=TIMESTAMP},
            </if>
            <if test="assistants != null and assistants !=''">
                and assistants = #{assistants,jdbcType=VARCHAR}
            </if>
        </where>
        order by id desc
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from sta_assembly_work_last
        where  id = #{id,jdbcType=BIGINT} 
pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderCtrl.java
@@ -29,8 +29,8 @@
     */
    @GetMapping(path="isStationUsed")
    public BaseResponse<Boolean> isStationUsed(StaAssemblyWorkLast last){
        String message = sv.isStationUsed(last);
        if ("".equals(message)) {
        String message = sv.checkStationIsUsed(last);
        if ("OK".equals(message.split("^")[0])) {
            return BaseResponseUtils.buildSuccess(true);
        } else {
            return BaseResponseUtils.buildFail(message);
pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderSv.java
@@ -2,7 +2,12 @@
import com.alibaba.excel.util.StringUtils;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pmsGlobal.daoBa.BaUserMapper;
import com.dy.pmsGlobal.daoPlt.PltStationMapper;
import com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper;
import com.dy.pmsGlobal.daoSta.StaAssemblyWorkLastMapper;
import com.dy.pmsGlobal.pojoBa.BaUser;
import com.dy.pmsGlobal.pojoPlt.PltStation;
import com.dy.pmsGlobal.pojoPr.PrAssemblyPlan;
import com.dy.pmsGlobal.pojoSta.StaAssemblyWorkLast;
import lombok.extern.slf4j.Slf4j;
@@ -15,42 +20,120 @@
@Service
public class WorkOrderSv {
    private PrAssemblyPlanMapper assemblyDao;
    private BaUserMapper baUserDao;
    private PltStationMapper pltStationDao;
    private StaAssemblyWorkLastMapper assemblyWorkLastDao;
    @Autowired
    public void setAssemblyDao(PrAssemblyPlanMapper assemblyDao) {
        this.assemblyDao = assemblyDao;
    }
    public String isStationUsed(StaAssemblyWorkLast last){
        String stationId = "";
        String userId = "";
        //判断哪个是人员, 哪个是工站信息
       /* if(last.getStationId() != null && last.getStationId().toString().startsWith("103")){
        }
        if(last.getUserId() != null && last.getStationId().toString().startsWith("103")){
        }
        PrAssemblyPlan params = new PrAssemblyPlan();
        params.setStatus(1);
        List<PrAssemblyPlan> list = sv.selectList(params);
        return BaseResponseUtils.buildSuccess(list);
        log.info("获取工站编号");
        String maxCode = dao.selectMaxCode();
        if (StringUtils.isBlank(maxCode)) {
            return DEFAULT_CODE;
        } else {
            int nextCode = Integer.parseInt(maxCode) + 1;
            // 检查溢出
            if (nextCode > 9999) {
                throw new RuntimeException("工站编号溢出");
            }
            return String.format(CODE_FORMAT, nextCode);
        }*/
        return "OK";
    @Autowired
    private void setBaUserDao(BaUserMapper baUserDao){
        this.baUserDao = baUserDao;
    }
    @Autowired
    private void setPltStationDao(PltStationMapper pltStationDao){
        this.pltStationDao = pltStationDao;
    }
    @Autowired
    private void setStaAssemblyWorkLastDao(StaAssemblyWorkLastMapper assemblyWorkLastDao){
        this.assemblyWorkLastDao = assemblyWorkLastDao;
    }
    public String checkUser(Long id){
        Long userId = id;
        String message = "USER";
        //工站103
        if(userId != null && userId.toString().startsWith("103")){
            message = checkStation(id);
            return message;
        }
        if(userId == null){
            message = "FALSE^员工编码不能为空";
            return message;
        }
        //用户101
        if(userId.toString().startsWith("101")){
            userId = Long.parseLong(userId.toString().substring(3));
        }
        BaUser userInfo = baUserDao.selectByPrimaryKey(userId);
        if(userInfo == null){
            message = "FALSE^员工编码不在系统中,请先维护员工信息";
        }
        message += "^"+ userId;
        return message;
    }
    public String checkStation(Long id){
        Long stationId = id;
        String message = "STATION";
        //用户101
        if(stationId != null && stationId.toString().startsWith("101")){
            message = checkUser(id);
            return message;
        }
        if(stationId == null){
            message = "FALSE^工站编码不能为空";
            return message;
        }
        //工站103
        if(stationId.toString().startsWith("103")){
            stationId = Long.parseLong(stationId.toString().substring(3));
        }
        PltStation record = new PltStation();
        record.setId(stationId);
        List<PltStation> stationInfo = pltStationDao.selectStationList(record);
        if(stationInfo.size() == 0){
            message = "FALSE^工站编码不在系统中,请先维护工站信息";
            return message;
        }
       //检查工站
        message += "^"+ stationId;
        return message;
    }
    public String checkStationIsUsed(StaAssemblyWorkLast last){
        String message = "OK";
        Long userId = null;
        Long stationId = null;
        String userMsg = checkUser(last.getUserId());
        String stationMsg = checkStation(last.getStationId());
        if(userMsg.startsWith("FALSE") || stationMsg.startsWith("FALSE")){
            if(userMsg.startsWith("FALSE") && stationMsg.startsWith("FALSE")){
                message = userMsg +","+ stationMsg.split("^")[1];
            }else if(userMsg.startsWith("FALSE")){
                message = userMsg;
            }else if(stationMsg.startsWith("FALSE")){
                message = stationMsg;
            }
            return message;
        }else{//根据结果 找到对应的ID值
            if(userMsg.startsWith("USER")){
                userId =  Long.parseLong(userMsg.split("^")[1]);
            }else if(userMsg.startsWith("STATION")){
                stationId = Long.parseLong(userMsg.split("^")[1]);
            }
            if(stationMsg.startsWith("USER")){
                userId =  Long.parseLong(stationMsg.split("^")[1]);
            }else if(stationMsg.startsWith("STATION")){
                stationId = Long.parseLong(stationMsg.split("^")[1]);
            }
        }
        if(userId == null || stationId == null){
            message = "FALSE^员工编码:"+ last.getUserId() + "或工站编码:" + last.getStationId() + "不正确,请检查";
            return message;
        }
        //检查表中是不是已经存在
        StaAssemblyWorkLast param = new StaAssemblyWorkLast();
        param.setUserId(userId);
        param.setStationId(stationId);
        param.setStatus(1);
        List<StaAssemblyWorkLast> userStationList = assemblyWorkLastDao.selectList(param);
        if(userStationList.size() > 0){
            message = "FALSE^员工编码:"+ userStationList.get(0).getUserId() + "已经绑定该工站编码:" + userStationList.get(0).getStationId() + ".请先让其解绑";
        }//message = "OK^员工编码:"+ userId+ "已经绑定该工站编码:" + stationId + ".验证通过";
        return message;
    }
    public List<PrAssemblyPlan> selectList(PrAssemblyPlan params){
        List<PrAssemblyPlan> planList = assemblyDao.selectList(params);
        return planList;