提交 | 用户 | 时间
|
e57a89
|
1 |
package com.jcdm.main.om.productionOrde.service.impl; |
懒 |
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.stream.Collectors; |
|
5 |
|
a759f5
|
6 |
import cn.hutool.core.util.ObjectUtil; |
a75d86
|
7 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
0ce25f
|
8 |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
e57a89
|
9 |
import com.jcdm.common.core.domain.AjaxResult; |
懒 |
10 |
import com.jcdm.common.utils.DateUtils; |
|
11 |
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; |
|
12 |
import com.jcdm.main.om.productionOrde.mapper.OmProductionOrdeInfoMapper; |
|
13 |
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
e70fb4
|
14 |
import com.jcdm.main.restful.factoryMes.service.RestfulService; |
8cfe20
|
15 |
import lombok.extern.slf4j.Slf4j; |
A |
16 |
import org.slf4j.Logger; |
|
17 |
import org.slf4j.LoggerFactory; |
e57a89
|
18 |
import org.springframework.beans.factory.annotation.Autowired; |
懒 |
19 |
import org.springframework.stereotype.Service; |
|
20 |
|
|
21 |
/** |
|
22 |
* 生产工单Service业务层处理 |
|
23 |
* |
|
24 |
* @author ruimin |
|
25 |
* @date 2023-12-11 |
|
26 |
*/ |
8cfe20
|
27 |
@Slf4j |
e57a89
|
28 |
@Service |
0ce25f
|
29 |
public class OmProductionOrdeInfoServiceImpl extends ServiceImpl<OmProductionOrdeInfoMapper,OmProductionOrdeInfo> implements IOmProductionOrdeInfoService |
e57a89
|
30 |
{ |
8cfe20
|
31 |
private static final Logger logger = LoggerFactory.getLogger("sys-user"); |
A |
32 |
|
e57a89
|
33 |
@Autowired |
懒 |
34 |
private OmProductionOrdeInfoMapper omProductionOrdeInfoMapper; |
|
35 |
|
|
36 |
@Autowired |
|
37 |
private IOmProductionOrdeInfoService omProductionOrdeInfoService; |
|
38 |
|
|
39 |
/** |
|
40 |
* 查询生产工单 |
|
41 |
* |
|
42 |
* @param id 生产工单主键 |
|
43 |
* @return 生产工单 |
|
44 |
*/ |
|
45 |
@Override |
|
46 |
public OmProductionOrdeInfo selectOmProductionOrdeInfoById(Long id) |
|
47 |
{ |
|
48 |
return omProductionOrdeInfoMapper.selectOmProductionOrdeInfoById(id); |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* 查询生产工单列表 |
|
53 |
* |
|
54 |
* @param omProductionOrdeInfo 生产工单 |
|
55 |
* @return 生产工单 |
|
56 |
*/ |
|
57 |
@Override |
|
58 |
public List<OmProductionOrdeInfo> selectOmProductionOrdeInfoList(OmProductionOrdeInfo omProductionOrdeInfo) |
|
59 |
{ |
|
60 |
return omProductionOrdeInfoMapper.selectOmProductionOrdeInfoList(omProductionOrdeInfo); |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* 新增生产工单 |
|
65 |
* |
|
66 |
* @param omProductionOrdeInfo 生产工单 |
|
67 |
* @return 结果 |
|
68 |
*/ |
|
69 |
@Override |
|
70 |
public int insertOmProductionOrdeInfo(OmProductionOrdeInfo omProductionOrdeInfo) |
|
71 |
{ |
|
72 |
omProductionOrdeInfo.setCreateTime(DateUtils.getNowDate()); |
|
73 |
Integer streamNumber = omProductionOrdeInfoMapper.getMaxStreamNumber(); |
|
74 |
omProductionOrdeInfo.setStreamNumber(String.valueOf(streamNumber+1)); |
|
75 |
return omProductionOrdeInfoMapper.insertOmProductionOrdeInfo(omProductionOrdeInfo); |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* 修改生产工单 |
|
80 |
* |
|
81 |
* @param omProductionOrdeInfo 生产工单 |
|
82 |
* @return 结果 |
|
83 |
*/ |
|
84 |
@Override |
|
85 |
public int updateOmProductionOrdeInfo(OmProductionOrdeInfo omProductionOrdeInfo) |
|
86 |
{ |
|
87 |
omProductionOrdeInfo.setUpdateTime(DateUtils.getNowDate()); |
|
88 |
return omProductionOrdeInfoMapper.updateOmProductionOrdeInfo(omProductionOrdeInfo); |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* 批量删除生产工单 |
|
93 |
* |
|
94 |
* @param ids 需要删除的生产工单主键 |
|
95 |
* @return 结果 |
|
96 |
*/ |
|
97 |
@Override |
|
98 |
public int deleteOmProductionOrdeInfoByIds(Long[] ids) |
|
99 |
{ |
|
100 |
return omProductionOrdeInfoMapper.deleteOmProductionOrdeInfoByIds(ids); |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* 删除生产工单信息 |
|
105 |
* |
|
106 |
* @param id 生产工单主键 |
|
107 |
* @return 结果 |
|
108 |
*/ |
|
109 |
@Override |
|
110 |
public int deleteOmProductionOrdeInfoById(Long id) |
|
111 |
{ |
|
112 |
return omProductionOrdeInfoMapper.deleteOmProductionOrdeInfoById(id); |
|
113 |
} |
|
114 |
|
|
115 |
@Override |
|
116 |
public AjaxResult upDownMove(OmProductionOrdeInfo omProductionOrdeInfo) { |
|
117 |
long currentId = omProductionOrdeInfo.getFrontEndId(); |
|
118 |
List<OmProductionOrdeInfo> omProductionOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo); |
|
119 |
List<Long> idList = omProductionOrdeInfos.stream() |
|
120 |
.map(OmProductionOrdeInfo::getId) // 提取id属性 |
|
121 |
.collect(Collectors.toList()); |
|
122 |
int index = idList.indexOf(currentId); |
|
123 |
long moveId = 0L; |
|
124 |
try { |
|
125 |
if(omProductionOrdeInfo.getFlag().equals("up")){ |
|
126 |
moveId = idList.get(index - 1); |
|
127 |
}else { |
|
128 |
moveId = idList.get(index + 1); |
|
129 |
} |
|
130 |
}catch (Exception e){ |
|
131 |
return AjaxResult.error("当前工单为最后一个或第一个,无法移动"); |
|
132 |
} |
|
133 |
OmProductionOrdeInfo currentInfo = new OmProductionOrdeInfo(); |
|
134 |
currentInfo.setId(currentId); |
|
135 |
List<OmProductionOrdeInfo> currentOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(currentInfo); |
|
136 |
String currentStreamNumber = currentOrdeInfos.get(0).getStreamNumber(); |
|
137 |
OmProductionOrdeInfo moveInfo = new OmProductionOrdeInfo(); |
|
138 |
moveInfo.setId(moveId); |
|
139 |
List<OmProductionOrdeInfo> moveOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(moveInfo); |
|
140 |
String moveStreamNumber = moveOrdeInfos.get(0).getStreamNumber(); |
|
141 |
moveOrdeInfos.get(0).setStreamNumber(currentStreamNumber); |
|
142 |
omProductionOrdeInfoService.updateOmProductionOrdeInfo(moveOrdeInfos.get(0)); |
|
143 |
currentOrdeInfos.get(0).setStreamNumber(moveStreamNumber); |
|
144 |
omProductionOrdeInfoService.updateOmProductionOrdeInfo(currentOrdeInfos.get(0)); |
|
145 |
return AjaxResult.success("移动成功"); |
|
146 |
} |
42cfe3
|
147 |
|
懒 |
148 |
@Override |
|
149 |
public void overrideSaveBatch(List<OmProductionOrdeInfo> omProductionOrdeInfoList) { |
|
150 |
try { |
|
151 |
this.saveBatch(omProductionOrdeInfoList); |
|
152 |
}catch (Exception e){ |
|
153 |
return; |
|
154 |
} |
|
155 |
} |
e70fb4
|
156 |
|
A |
157 |
@Override |
|
158 |
public AjaxResult receivingWorkOrders() { |
|
159 |
return null; |
|
160 |
} |
a75d86
|
161 |
|
A |
162 |
@Override |
|
163 |
public AjaxResult trolleyYardBinDing(OmProductionOrdeInfo omProductionOrdeInfo) { |
a759f5
|
164 |
OmProductionOrdeInfo clearTrolleyYard = omProductionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getTrolleyYard, omProductionOrdeInfo.getTrolleyYard())); |
A |
165 |
if(clearTrolleyYard!=null){ |
|
166 |
clearTrolleyYard.setTrolleyYard(""); |
|
167 |
omProductionOrdeInfoService.saveOrUpdate(clearTrolleyYard); |
|
168 |
} |
a75d86
|
169 |
OmProductionOrdeInfo one = omProductionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, omProductionOrdeInfo.getProductNum())); |
A |
170 |
one.setTrolleyYard(omProductionOrdeInfo.getTrolleyYard()); |
|
171 |
omProductionOrdeInfoService.saveOrUpdate(one); |
8cfe20
|
172 |
logger.info("绑定pack码{}到小车:{}",omProductionOrdeInfo.getProductNum(),omProductionOrdeInfo.getTrolleyYard()); |
A |
173 |
|
a75d86
|
174 |
return AjaxResult.success(); |
A |
175 |
} |
|
176 |
|
|
177 |
@Override |
|
178 |
public AjaxResult getCarCodeSize(OmProductionOrdeInfo omProductionOrdeInfo) { |
|
179 |
// omProductionOrdeInfo. |
|
180 |
return null; |
|
181 |
} |
|
182 |
|
|
183 |
@Override |
|
184 |
public AjaxResult findBytrolleyYardGetOne(OmProductionOrdeInfo omProductionOrdeInfo) { |
4a5f2a
|
185 |
String str = ""; |
a75d86
|
186 |
OmProductionOrdeInfo one = omProductionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getTrolleyYard, omProductionOrdeInfo.getTrolleyYard())); |
4a5f2a
|
187 |
if(one == null){ |
A |
188 |
str = "2"; |
|
189 |
}else { |
|
190 |
str = one.getProductNum(); |
|
191 |
} |
|
192 |
return AjaxResult.success(str); |
a75d86
|
193 |
} |
237733
|
194 |
|
A |
195 |
@Override |
|
196 |
public List<OmProductionOrdeInfo> checkCarCode(OmProductionOrdeInfo omProductionOrdeInfo) { |
|
197 |
List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, omProductionOrdeInfo.getProductNum()).isNotNull(OmProductionOrdeInfo::getTrolleyYard)); |
|
198 |
return list; |
|
199 |
} |
e57a89
|
200 |
} |