Fancy
2024-06-20 279a149dd1ff4ef7a7a9353469532332d3fdcb5f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package com.dy.pmsStation.workOrder;
 
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;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Slf4j
@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;
    }
    @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;
    }
}