KeyBoxVoServiceImpl.java
6.84 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package com.ruoyi.service.impl.dss;
import cn.hutool.core.convert.Convert;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.ResponseResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.caiinfo.CarInfo;
import com.ruoyi.domain.equipment.linke.log.LingangEquipmentLinkeLog;
import com.ruoyi.domain.key.info.KeyInfo;
import com.ruoyi.domain.key.info.box.dto.KeyBoxQueryDTO;
import com.ruoyi.domain.key.info.box.vo.KeyBoxVo;
import com.ruoyi.domain.lin.gang.LingangScheduling;
import com.ruoyi.equipment.domain.Equipment;
import com.ruoyi.equipment.service.IEquipmentService;
import com.ruoyi.in.domain.SignIn;
import com.ruoyi.in.service.ISignInService;
import com.ruoyi.service.carinfo.CarInfoService;
import com.ruoyi.service.dss.KeyBoxVoService;
import com.ruoyi.service.equipment.linke.log.LingangEquipmentLinkeLogService;
import com.ruoyi.service.key.info.KeyInfoService;
import com.ruoyi.service.lin.gang.LingangSchedulingService;
import com.ruoyi.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.MessageFormat;
import java.util.Objects;
/**
* @author liujun
* @date 2024年06月25日 15:18
*/
@Service
public class KeyBoxVoServiceImpl implements KeyBoxVoService {
@Autowired
private KeyInfoService keyInfoService;
@Autowired
private LingangSchedulingService lingangSchedulingService;
@Autowired
private ISignInService signInService;
@Autowired
private IEquipmentService iEquipmentService;
@Autowired
private CarInfoService carInfoService;
@Autowired
private LingangEquipmentLinkeLogService lingangEquipmentLinkeLogService;
@Override
public ResponseResult<KeyBoxVo> listSelect(KeyBoxQueryDTO request, LingangEquipmentLinkeLog linkeLog) {
LingangScheduling lingangScheduling = queryScheduling(request);
if (Objects.isNull(lingangScheduling)) {
String msg = MessageFormat.format("工号[{0}]在[{1}]没有排班信息", request.getStaffCode(), request.getTime());
linkeLog.setStatus(HttpStatus.ERROR);
linkeLog.setResult(msg);
lingangEquipmentLinkeLogService.updateByPrimaryKey(linkeLog);
return ResponseResult.error(msg);
}
SignIn signIn = querySignIn(lingangScheduling.getSignInId());
if (Objects.isNull(signIn)) {
lingangEquipmentLinkeLogService.updateByPrimaryKey(linkeLog, MessageFormat.format("工号[{0}]在[{1}]没有签到或签退信息;[{2}]", request.getStaffCode(), request.getTime(), lingangScheduling.getSignInId()), HttpStatus.ERROR);
return ResponseResult.error(MessageFormat.format("工号[{0}]在[{1}]没有签到或签退信息", request.getStaffCode(), request.getTime()));
}
KeyInfo keyInfo = queryKeyInfo(lingangScheduling.getKeyInfoId());
if (Objects.isNull(keyInfo)) {
lingangEquipmentLinkeLogService.updateByPrimaryKey(linkeLog, MessageFormat.format("工号[{0}]在[{1}]没有分配钥匙;[{2}]", request.getStaffCode(), request.getTime(), lingangScheduling.getKeyInfoId()), HttpStatus.ERROR);
return ResponseResult.error(MessageFormat.format("工号[{0}]在[{1}]没有分配钥匙", request.getStaffCode(), request.getTime()));
}
Equipment equipment = queryEquipment(Convert.toLong(signIn.getDeviceId()));
if (Objects.isNull(equipment)) {
lingangEquipmentLinkeLogService.updateByPrimaryKey(linkeLog, MessageFormat.format("工号[{0}]在[{1}]找不到设备信息;[{2}]", request.getStaffCode(), request.getTime(), signIn.getDeviceId()), HttpStatus.ERROR);
return ResponseResult.error(MessageFormat.format("工号[{0}]在[{1}]找不到设备信息", request.getStaffCode(), request.getTime()));
}
CarInfo carInfo = queryCarInfo(lingangScheduling.getNbbm());
if (Objects.isNull(carInfo)) {
lingangEquipmentLinkeLogService.updateByPrimaryKey(linkeLog, MessageFormat.format("工号[{0}]在[{1}]找不到设备信息;[{2}]", request.getStaffCode(), request.getTime(), lingangScheduling.getNbbm()), HttpStatus.ERROR);
return ResponseResult.error(MessageFormat.format("工号[{0}]在[{1}]找不到车辆信息", request.getStaffCode(), request.getTime()));
}
KeyBoxVo keyBoxVo = new KeyBoxVo();
//keyBoxVo.setCabinetNo(Convert.toStr(keyInfo.getCabinetno()));
// keyBoxVo.setDevice("");
keyBoxVo.setDeviceName(equipment.getName());
// keyBoxVo.setYardId(Convert.toStr(keyInfo.getYardId()));
// keyBoxVo.setYardName(Convert.toStr(keyInfo.getS()));
keyBoxVo.setPlateNum(lingangScheduling.getNbbm());
keyBoxVo.setParkingNo(carInfo.getParkingNo());
keyBoxVo.setKeyCode(keyInfo.getKeyCode());
lingangEquipmentLinkeLogService.updateByPrimaryKey(linkeLog, null, HttpStatus.SUCCESS);
return ResponseResult.success(keyBoxVo);
}
/***
* 根据时间和司机工号查询排班信息
* @author liujun
* @date 2024/6/25 14:07
* @param request
* @return com.ruoyi.domain.lin.gang.LingangScheduling
*/
private LingangScheduling queryScheduling(KeyBoxQueryDTO request) {
LingangScheduling lingangScheduling = new LingangScheduling();
lingangScheduling.setScheduleDate(DateUtil.parseLocalDate(request.getTime()));
lingangScheduling.setJobCode(request.getStaffCode());
if(StringUtils.equals(request.getEventType(), "0")){
lingangScheduling.setSignType(1);
}else if(StringUtils.equals(request.getEventType(), "1")){
lingangScheduling.setSignType(2);
}
return lingangSchedulingService.getOne(lingangScheduling);
}
/***
* 查询签到信息
* @author liujun
* @date 2024/6/25 14:30
* @param signInId 签到ID
* @return com.ruoyi.in.domain.SignIn
*/
private SignIn querySignIn(Long signInId) {
return signInService.selectSignInById(signInId);
}
/***
* 根据钥匙ID查询钥匙信息
* @author liujun
* @date 2024/6/25 14:39
* @param keyInfoId
* @return com.ruoyi.domain.keyInfo.KeyInfo
*/
private KeyInfo queryKeyInfo(Integer keyInfoId) {
return keyInfoService.getById(keyInfoId);
}
/***
* 查询设备信息
* @author liujun
* @date 2024/6/25 14:43
* @param equipmentId
* @return com.ruoyi.equipment.domain.Equipment
*/
private Equipment queryEquipment(long equipmentId) {
return iEquipmentService.selectEquipmentById(equipmentId);
}
/***
* 根据车牌号查询车辆信息
* @author liujun
* @date 2024/6/25 15:00
* @param plateNum
* @return com.ruoyi.domain.caiinfo.CarInfo
*/
private CarInfo queryCarInfo(String plateNum) {
return carInfoService.getOneByPlateNum(plateNum);
}
}