Commit 4a0408307efcb3bb2800901b9effdd887f0dbb98
1 parent
05270686
1. 增加MES回传重试
2. 增加wcs 设置物料信息接口,包括长宽高重,在任务完成之前给。
Showing
14 changed files
with
371 additions
and
74 deletions
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mes/entity/MesBackReceipt.java
0 → 100644
1 | +package org.jeecg.modules.wms.api.mes.entity; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +import java.math.BigDecimal; | |
6 | + | |
7 | +/** | |
8 | + * @author 游杰 | |
9 | + */ | |
10 | +@Data | |
11 | +public class MesBackReceipt { | |
12 | + | |
13 | + private String receiptCode; | |
14 | + private String materialCode; | |
15 | + private BigDecimal qty; | |
16 | +} | |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mes/entity/MesBackShipment.java
0 → 100644
1 | +package org.jeecg.modules.wms.api.mes.entity; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +import java.math.BigDecimal; | |
6 | + | |
7 | +/** | |
8 | + * @author 游杰 | |
9 | + */ | |
10 | +@Data | |
11 | +public class MesBackShipment { | |
12 | + | |
13 | + private String shipmentCode; | |
14 | + private String materialCode; | |
15 | + private BigDecimal qty; | |
16 | +} | |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mes/servuce/impl/MesServiceImpl.java
1 | 1 | package org.jeecg.modules.wms.api.mes.servuce.impl; |
2 | 2 | |
3 | -import com.aliyun.oss.ServiceException; | |
4 | -import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
3 | +import java.math.BigDecimal; | |
4 | +import java.util.ArrayList; | |
5 | +import java.util.Collections; | |
6 | +import java.util.List; | |
7 | +import java.util.stream.Collectors; | |
8 | + | |
9 | +import javax.annotation.Resource; | |
10 | + | |
5 | 11 | import org.jeecg.common.api.vo.Result; |
6 | -import org.jeecg.modules.wms.api.mes.entity.MaterialInfo; | |
7 | -import org.jeecg.modules.wms.api.mes.entity.MesReceiptMaterial; | |
8 | -import org.jeecg.modules.wms.api.mes.entity.MesShipmentDetail; | |
9 | -import org.jeecg.modules.wms.api.mes.entity.MesShipmentMaterial; | |
12 | +import org.jeecg.modules.wms.api.mes.entity.*; | |
10 | 13 | import org.jeecg.modules.wms.api.mes.servuce.IMesService; |
14 | +import org.jeecg.modules.wms.config.address.service.IAddressService; | |
11 | 15 | import org.jeecg.modules.wms.receipt.receiptContainerHeader.entity.ReceiptContainerHeader; |
12 | 16 | import org.jeecg.modules.wms.receipt.receiptContainerHeader.service.IReceiptContainerHeaderService; |
13 | 17 | import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptDetail; |
... | ... | @@ -28,18 +32,15 @@ import org.jeecg.modules.wms.shipment.shipmentHeader.service.IShipmentHeaderServ |
28 | 32 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail; |
29 | 33 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; |
30 | 34 | import org.jeecg.modules.wms.task.taskHeader.service.ITaskDetailService; |
35 | +import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService; | |
31 | 36 | import org.jeecg.utils.StringUtils; |
32 | 37 | import org.jeecg.utils.constant.QuantityConstant; |
38 | +import org.jeecg.utils.http.OkHttpUtils; | |
33 | 39 | import org.springframework.stereotype.Service; |
34 | 40 | import org.springframework.transaction.annotation.Transactional; |
35 | 41 | |
36 | -import javax.annotation.Resource; | |
37 | -import java.lang.ref.WeakReference; | |
38 | -import java.math.BigDecimal; | |
39 | -import java.util.ArrayList; | |
40 | -import java.util.Collections; | |
41 | -import java.util.List; | |
42 | -import java.util.stream.Collectors; | |
42 | +import com.alibaba.fastjson.JSON; | |
43 | +import com.aliyun.oss.ServiceException; | |
43 | 44 | |
44 | 45 | /** |
45 | 46 | * @author 游杰 |
... | ... | @@ -67,6 +68,10 @@ public class MesServiceImpl implements IMesService { |
67 | 68 | private IShipmentContainerHeaderService shipmentContainerHeaderService; |
68 | 69 | @Resource |
69 | 70 | private ITaskDetailService taskDetailService; |
71 | + @Resource | |
72 | + private IAddressService addressService; | |
73 | + @Resource | |
74 | + private ITaskHeaderService taskHeaderService; | |
70 | 75 | |
71 | 76 | /** |
72 | 77 | * 要求入库单详情 必须是不重样的 |
... | ... | @@ -214,16 +219,98 @@ public class MesServiceImpl implements IMesService { |
214 | 219 | if (status == QuantityConstant.TASK_STATUS_COMPLETED) { |
215 | 220 | return Result.ok("回传入库信息失败,任务没完成"); |
216 | 221 | } |
222 | + int backMes = taskHeader.getBackMes(); | |
223 | + if (backMes == QuantityConstant.MES_SEND_OK) { | |
224 | + return Result.ok("回传入库信息失败,信息已经回传过"); | |
225 | + } | |
226 | + | |
217 | 227 | List<TaskDetail> taskDetailList = taskDetailService.getTaskDetailListByTaskId(taskId); |
228 | + List<MesBackReceipt> mesBackReceiptList = new ArrayList<>(); | |
218 | 229 | for (TaskDetail taskDetail : taskDetailList) { |
219 | - | |
230 | + int receiptDetailId = taskDetail.getReceiptDetailId(); | |
231 | + ReceiptDetail receiptDetail = receiptDetailService.getById(receiptDetailId); | |
232 | + if (receiptDetail == null) { | |
233 | + throw new ServiceException("回传入库信息失败,没有找到入库单详情"); | |
234 | + } | |
235 | + String materialCode = receiptDetail.getMaterialCode(); | |
236 | + BigDecimal qty = taskDetail.getQty(); | |
237 | + String receiptCode = receiptDetail.getReceiptCode(); | |
238 | + MesBackReceipt mesBackReceipt = new MesBackReceipt(); | |
239 | + mesBackReceipt.setMaterialCode(materialCode); | |
240 | + mesBackReceipt.setReceiptCode(receiptCode); | |
241 | + mesBackReceipt.setQty(qty); | |
242 | + mesBackReceiptList.add(mesBackReceipt); | |
220 | 243 | } |
221 | - return null; | |
244 | + if (mesBackReceiptList.size() == 0) { | |
245 | + return Result.ok("回传入库信息失败,没有回传信息"); | |
246 | + } | |
247 | + taskHeader.setBackMes(QuantityConstant.MES_SEND_OK); | |
248 | + boolean success = taskHeaderService.updateById(taskHeader); | |
249 | + if (!success) { | |
250 | + throw new ServiceException("回传入库信息失败,更新任务失败"); | |
251 | + } | |
252 | + String url = addressService.getUrlByParam(QuantityConstant.ADDRESS_MES_BACK_RECEIPT); | |
253 | + String jsonParam = JSON.toJSONString(mesBackReceiptList); | |
254 | + System.out.println(jsonParam); | |
255 | + String body = OkHttpUtils.bodypost(url, jsonParam); | |
256 | + if (StringUtils.isEmpty(body)) { | |
257 | + throw new ServiceException("接口地址错误或返回为空"); | |
258 | + } | |
259 | + Result result = JSON.parseObject(body, Result.class); | |
260 | + if (result.getCode() != QuantityConstant.HTTP_OK) { | |
261 | + throw new ServiceException(result.getMessage()); | |
262 | + } | |
263 | + return Result.ok("回传MES入库信息成功"); | |
222 | 264 | } |
223 | 265 | |
224 | 266 | @Override |
225 | 267 | @Transactional(rollbackFor = Exception.class) |
226 | 268 | public Result backMesShipment(TaskHeader taskHeader) { |
227 | - return null; | |
269 | + int status = taskHeader.getStatus(); | |
270 | + int taskId = taskHeader.getId(); | |
271 | + if (status == QuantityConstant.TASK_STATUS_COMPLETED) { | |
272 | + return Result.ok("回传出库信息失败,任务没完成"); | |
273 | + } | |
274 | + int backMes = taskHeader.getBackMes(); | |
275 | + if (backMes == QuantityConstant.MES_SEND_OK) { | |
276 | + return Result.ok("回传出库信息失败,信息已经回传过"); | |
277 | + } | |
278 | + List<TaskDetail> taskDetailList = taskDetailService.getTaskDetailListByTaskId(taskId); | |
279 | + List<MesBackShipment> mesBackShipmentList = new ArrayList<>(); | |
280 | + for (TaskDetail taskDetail : taskDetailList) { | |
281 | + int shipmentDetailId = taskDetail.getShipmentDetailId(); | |
282 | + ShipmentDetail shipmentDetail = shipmentDetailService.getById(shipmentDetailId); | |
283 | + if (shipmentDetail == null) { | |
284 | + throw new ServiceException("回传出库信息失败,没有找到出库单详情"); | |
285 | + } | |
286 | + String materialCode = shipmentDetail.getMaterialCode(); | |
287 | + BigDecimal qty = taskDetail.getQty(); | |
288 | + String shipmentCode = shipmentDetail.getShipmentCode(); | |
289 | + MesBackShipment mesBackShipment = new MesBackShipment(); | |
290 | + mesBackShipment.setShipmentCode(shipmentCode); | |
291 | + mesBackShipment.setQty(qty); | |
292 | + mesBackShipment.setMaterialCode(materialCode); | |
293 | + mesBackShipmentList.add(mesBackShipment); | |
294 | + } | |
295 | + if (mesBackShipmentList.size() == 0) { | |
296 | + return Result.ok("回传出库信息失败,没有回传信息"); | |
297 | + } | |
298 | + taskHeader.setBackMes(QuantityConstant.MES_SEND_OK); | |
299 | + boolean success = taskHeaderService.updateById(taskHeader); | |
300 | + if (!success) { | |
301 | + throw new ServiceException("回传出库信息失败,更新任务失败"); | |
302 | + } | |
303 | + String url = addressService.getUrlByParam(QuantityConstant.ADDRESS_MES_BACK_SHIPMENT); | |
304 | + String jsonParam = JSON.toJSONString(mesBackShipmentList); | |
305 | + System.out.println(jsonParam); | |
306 | + String body = OkHttpUtils.bodypost(url, jsonParam); | |
307 | + if (StringUtils.isEmpty(body)) { | |
308 | + throw new ServiceException("接口地址错误或返回为空"); | |
309 | + } | |
310 | + Result result = JSON.parseObject(body, Result.class); | |
311 | + if (result.getCode() != QuantityConstant.HTTP_OK) { | |
312 | + throw new ServiceException(result.getMessage()); | |
313 | + } | |
314 | + return Result.ok("回传出库信息成功"); | |
228 | 315 | } |
229 | 316 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java
... | ... | @@ -6,20 +6,16 @@ import javax.servlet.http.HttpServletRequest; |
6 | 6 | import org.jeecg.common.api.vo.Result; |
7 | 7 | import org.jeecg.common.aspect.annotation.AutoLog; |
8 | 8 | import org.jeecg.modules.wms.api.wcs.entity.ManyEmptyDomain; |
9 | +import org.jeecg.modules.wms.api.wcs.entity.MaterialInfoEntity; | |
9 | 10 | import org.jeecg.modules.wms.api.wcs.entity.TaskFinishEntity; |
10 | 11 | import org.jeecg.modules.wms.api.wcs.entity.WarecellDomain; |
11 | -import org.jeecg.modules.wms.api.wcs.entity.WcsTask; | |
12 | 12 | import org.jeecg.modules.wms.api.wcs.service.WcsService; |
13 | 13 | import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger; |
14 | 14 | import org.jeecg.modules.wms.framework.controller.HuahengBaseController; |
15 | 15 | import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService; |
16 | 16 | import org.jeecg.utils.HuahengJwtUtil; |
17 | 17 | import org.jeecg.utils.StringUtils; |
18 | -import org.springframework.web.bind.annotation.PostMapping; | |
19 | -import org.springframework.web.bind.annotation.RequestBody; | |
20 | -import org.springframework.web.bind.annotation.RequestMapping; | |
21 | -import org.springframework.web.bind.annotation.ResponseBody; | |
22 | -import org.springframework.web.bind.annotation.RestController; | |
18 | +import org.springframework.web.bind.annotation.*; | |
23 | 19 | |
24 | 20 | import io.swagger.annotations.ApiOperation; |
25 | 21 | |
... | ... | @@ -134,4 +130,18 @@ public class WcsController extends HuahengBaseController { |
134 | 130 | }); |
135 | 131 | return result; |
136 | 132 | } |
133 | + | |
134 | + /** | |
135 | + * 设置物料信息 | |
136 | + * @return | |
137 | + */ | |
138 | + @AutoLog(value = "WCS设置物料信息") | |
139 | + @PostMapping("/setMaterialInfo") | |
140 | + @ApiOperation(value = "WCS设置物料信息", notes = "WCS设置物料信息", httpMethod = "POST") | |
141 | + @ResponseBody | |
142 | + @ApiLogger(apiName = "WCS设置物料信息", from = "WCS") | |
143 | + public Result setMaterialInfo(@RequestBody MaterialInfoEntity materialInfoEntity) { | |
144 | + Result result = wcsService.setMaterialInfo(materialInfoEntity); | |
145 | + return result; | |
146 | + } | |
137 | 147 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/entity/MaterialInfoEntity.java
0 → 100644
1 | +package org.jeecg.modules.wms.api.wcs.entity; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +@Data | |
6 | +public class MaterialInfoEntity { | |
7 | + | |
8 | + /** | |
9 | + * 任务号 | |
10 | + */ | |
11 | + private int taskNo; | |
12 | + /** | |
13 | + * 重量 | |
14 | + */ | |
15 | + private int weight; | |
16 | + /** | |
17 | + * 长度 | |
18 | + */ | |
19 | + private int length; | |
20 | + /** | |
21 | + * 宽度 | |
22 | + */ | |
23 | + private int width; | |
24 | + /** | |
25 | + * 高度 | |
26 | + */ | |
27 | + private int height; | |
28 | +} | |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsService.java
1 | 1 | package org.jeecg.modules.wms.api.wcs.service; |
2 | 2 | |
3 | 3 | import org.jeecg.common.api.vo.Result; |
4 | +import org.jeecg.modules.wms.api.wcs.entity.MaterialInfoEntity; | |
4 | 5 | import org.jeecg.modules.wms.api.wcs.entity.WarecellDomain; |
5 | 6 | import org.jeecg.modules.wms.api.wcs.entity.WcsTask; |
6 | 7 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; |
... | ... | @@ -16,4 +17,10 @@ public interface WcsService { |
16 | 17 | Result wcsTaskAssign(TaskHeader taskHeader); |
17 | 18 | |
18 | 19 | WcsTask switchTaskTypeToWcs(WcsTask wcsTask); |
20 | + | |
21 | + /** | |
22 | + * 设置物料信息,包括长、宽、高、重量 | |
23 | + */ | |
24 | + Result setMaterialInfo(MaterialInfoEntity materialInfoEntity); | |
25 | + | |
19 | 26 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java
... | ... | @@ -7,6 +7,7 @@ import java.util.stream.Collectors; |
7 | 7 | import javax.annotation.Resource; |
8 | 8 | |
9 | 9 | import org.jeecg.common.api.vo.Result; |
10 | +import org.jeecg.modules.wms.api.wcs.entity.MaterialInfoEntity; | |
10 | 11 | import org.jeecg.modules.wms.api.wcs.entity.WarecellDomain; |
11 | 12 | import org.jeecg.modules.wms.api.wcs.entity.WcsTask; |
12 | 13 | import org.jeecg.modules.wms.config.address.service.IAddressService; |
... | ... | @@ -303,7 +304,10 @@ public class WcsServiceImpl implements WcsService { |
303 | 304 | } |
304 | 305 | // 移库任务 |
305 | 306 | taskHeader.setPreTaskNo(preTaskNo); |
306 | - taskHeaderService.updateById(taskHeader); | |
307 | + boolean success = taskHeaderService.updateById(taskHeader); | |
308 | + if (!success) { | |
309 | + return Result.error("更新任务状态失败"); | |
310 | + } | |
307 | 311 | return Result.error("先执行移库任务"); |
308 | 312 | } |
309 | 313 | } else { |
... | ... | @@ -319,7 +323,10 @@ public class WcsServiceImpl implements WcsService { |
319 | 323 | } |
320 | 324 | } |
321 | 325 | taskHeader.setPreTaskNo(preTaskNo); |
322 | - taskHeaderService.updateById(taskHeader); | |
326 | + boolean success = taskHeaderService.updateById(taskHeader); | |
327 | + if (!success) { | |
328 | + return Result.error("更新任务状态失败"); | |
329 | + } | |
323 | 330 | } |
324 | 331 | } |
325 | 332 | |
... | ... | @@ -408,4 +415,22 @@ public class WcsServiceImpl implements WcsService { |
408 | 415 | } |
409 | 416 | return wcsTask; |
410 | 417 | } |
418 | + | |
419 | + @Override | |
420 | + public Result setMaterialInfo(MaterialInfoEntity materialInfoEntity) { | |
421 | + int taskNo = materialInfoEntity.getTaskNo(); | |
422 | + TaskHeader taskHeader = taskHeaderService.getById(taskNo); | |
423 | + if (taskHeader == null) { | |
424 | + return Result.error("设置物料信息失败,没有找到对应任务"); | |
425 | + } | |
426 | + taskHeader.setLength(materialInfoEntity.getLength()); | |
427 | + taskHeader.setWidth(materialInfoEntity.getWidth()); | |
428 | + taskHeader.setHeight(materialInfoEntity.getHeight()); | |
429 | + taskHeader.setWeight(materialInfoEntity.getWeight()); | |
430 | + boolean success = taskHeaderService.updateById(taskHeader); | |
431 | + if (!success) { | |
432 | + return Result.error("设置物料信息失败,更新任务信息失败"); | |
433 | + } | |
434 | + return Result.ok("设置物料信息成功"); | |
435 | + } | |
411 | 436 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/material/controller/MaterialController.java
1 | 1 | package org.jeecg.modules.wms.config.material.controller; |
2 | 2 | |
3 | -import java.lang.ref.WeakReference; | |
4 | 3 | import java.util.ArrayList; |
5 | 4 | import java.util.Arrays; |
6 | 5 | import java.util.List; |
7 | -import java.util.Map; | |
8 | -import java.util.stream.Collectors; | |
9 | -import java.io.IOException; | |
10 | -import java.io.UnsupportedEncodingException; | |
11 | -import java.net.URLDecoder; | |
6 | + | |
12 | 7 | import javax.servlet.http.HttpServletRequest; |
13 | 8 | import javax.servlet.http.HttpServletResponse; |
14 | 9 | |
15 | -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
16 | -import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
17 | 10 | import org.apache.shiro.authz.annotation.RequiresPermissions; |
18 | 11 | import org.jeecg.common.api.vo.Result; |
12 | +import org.jeecg.common.aspect.annotation.AutoLog; | |
13 | +import org.jeecg.common.system.base.controller.JeecgController; | |
19 | 14 | import org.jeecg.common.system.query.QueryGenerator; |
20 | -import org.jeecg.utils.HuahengJwtUtil; | |
21 | -import org.jeecg.common.util.oConvertUtils; | |
22 | - | |
23 | -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
24 | -import com.baomidou.mybatisplus.core.metadata.IPage; | |
25 | -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |
26 | -import lombok.extern.slf4j.Slf4j; | |
27 | - | |
28 | -import org.jeecg.modules.system.entity.SysUser; | |
29 | -import org.jeecg.modules.wms.config.location.entity.Location; | |
30 | 15 | import org.jeecg.modules.wms.config.material.entity.Material; |
16 | +import org.jeecg.modules.wms.config.material.entity.SearchDomain; | |
31 | 17 | import org.jeecg.modules.wms.config.material.service.IMaterialService; |
32 | -import org.jeecg.modules.wms.domain.SearchDomain; | |
18 | +import org.jeecg.utils.HuahengJwtUtil; | |
33 | 19 | import org.jeecg.utils.StringUtils; |
34 | -import org.jeecgframework.poi.excel.ExcelImportUtil; | |
35 | -import org.jeecgframework.poi.excel.def.NormalExcelConstants; | |
36 | -import org.jeecgframework.poi.excel.entity.ExportParams; | |
37 | -import org.jeecgframework.poi.excel.entity.ImportParams; | |
38 | -import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; | |
39 | -import org.jeecg.common.system.base.controller.JeecgController; | |
40 | 20 | import org.springframework.beans.factory.annotation.Autowired; |
41 | 21 | import org.springframework.web.bind.annotation.*; |
42 | -import org.springframework.web.multipart.MultipartFile; | |
43 | -import org.springframework.web.multipart.MultipartHttpServletRequest; | |
44 | 22 | import org.springframework.web.servlet.ModelAndView; |
45 | -import com.alibaba.fastjson.JSON; | |
23 | + | |
24 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
25 | +import com.baomidou.mybatisplus.core.metadata.IPage; | |
26 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |
27 | + | |
46 | 28 | import io.swagger.annotations.Api; |
47 | 29 | import io.swagger.annotations.ApiOperation; |
48 | -import org.jeecg.common.aspect.annotation.AutoLog; | |
30 | +import lombok.extern.slf4j.Slf4j; | |
49 | 31 | |
50 | 32 | /** |
51 | 33 | * @Description: 物料管理 |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/domain/SearchDomain.java renamed to huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/material/entity/SearchDomain.java
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/MesTask.java
0 → 100644
1 | +package org.jeecg.modules.wms.monitor.job; | |
2 | + | |
3 | +import java.util.HashMap; | |
4 | +import java.util.List; | |
5 | +import java.util.Map; | |
6 | + | |
7 | +import javax.annotation.Resource; | |
8 | + | |
9 | +import org.apache.commons.collections.MapUtils; | |
10 | +import org.jeecg.modules.wms.api.mes.servuce.IMesService; | |
11 | +import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; | |
12 | +import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService; | |
13 | +import org.jeecg.utils.constant.QuantityConstant; | |
14 | +import org.quartz.Job; | |
15 | +import org.quartz.JobExecutionContext; | |
16 | +import org.quartz.JobExecutionException; | |
17 | + | |
18 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
19 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
20 | + | |
21 | +import lombok.extern.slf4j.Slf4j; | |
22 | + | |
23 | +/** | |
24 | + * @author 游杰 | |
25 | + */ | |
26 | +@Slf4j | |
27 | +public class MesTask implements Job { | |
28 | + | |
29 | + @Resource | |
30 | + private IMesService mesService; | |
31 | + @Resource | |
32 | + private ITaskHeaderService taskHeaderService; | |
33 | + // 并发控制 | |
34 | + Map<String, Boolean> runningTaskMap = new HashMap<>(); | |
35 | + | |
36 | + /** | |
37 | + * 找到完成状态的,没有回传成功的所有任务,然后回传信息给MES | |
38 | + * @param context | |
39 | + * @throws JobExecutionException | |
40 | + */ | |
41 | + @Override | |
42 | + public void execute(JobExecutionContext context) throws JobExecutionException { | |
43 | + String taskKey = "mesBack"; | |
44 | + if (MapUtils.getBoolean(runningTaskMap, taskKey, false)) { | |
45 | + return; | |
46 | + } | |
47 | + try { | |
48 | + runningTaskMap.put(taskKey, true); | |
49 | + LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
50 | + taskHeaderLambdaQueryWrapper.eq(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED).ne(TaskHeader::getBackMes, QuantityConstant.MES_SEND_OK) | |
51 | + .in(TaskHeader::getTaskType, QuantityConstant.TASK_TYPE_WHOLERECEIPT, QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT); | |
52 | + List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderLambdaQueryWrapper); | |
53 | + for (TaskHeader taskHeader : taskHeaderList) { | |
54 | + try { | |
55 | + taskHeaderService.addMesTryTimes(taskHeader); | |
56 | + mesService.backMesReceipt(taskHeader); | |
57 | + } catch (Exception e) { | |
58 | + e.printStackTrace(); | |
59 | + } | |
60 | + } | |
61 | + | |
62 | + taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
63 | + taskHeaderLambdaQueryWrapper.eq(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED).ne(TaskHeader::getBackMes, QuantityConstant.MES_SEND_OK) | |
64 | + .in(TaskHeader::getTaskType, QuantityConstant.TASK_TYPE_WHOLESHIPMENT, QuantityConstant.TASK_TYPE_SORTINGSHIPMENT); | |
65 | + taskHeaderList = taskHeaderService.list(taskHeaderLambdaQueryWrapper); | |
66 | + for (TaskHeader taskHeader : taskHeaderList) { | |
67 | + try { | |
68 | + taskHeaderService.addMesTryTimes(taskHeader); | |
69 | + mesService.backMesShipment(taskHeader); | |
70 | + } catch (Exception e) { | |
71 | + e.printStackTrace(); | |
72 | + } | |
73 | + } | |
74 | + } catch (Exception e) { | |
75 | + e.printStackTrace(); | |
76 | + } finally { | |
77 | + runningTaskMap.put(taskKey, false); | |
78 | + } | |
79 | + } | |
80 | +} | |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskHeader.java
... | ... | @@ -102,7 +102,18 @@ public class TaskHeader implements Serializable { |
102 | 102 | @Excel(name = "目标出入口", width = 15) |
103 | 103 | @ApiModelProperty(value = "目标出入口") |
104 | 104 | private String toPortCode; |
105 | - @Excel(name = "重量", width = 15) | |
105 | + @ApiModelProperty(value = "生成agv任务") | |
106 | + private Integer sendAgv; | |
107 | + @ApiModelProperty(value = "回传MES信息") | |
108 | + private Integer backMes; | |
109 | + @ApiModelProperty(value = "MES提交次数") | |
110 | + private Integer backMesTimes; | |
111 | + @ApiModelProperty(value = "长度") | |
112 | + private Integer length; | |
113 | + @ApiModelProperty(value = "宽度") | |
114 | + private Integer width; | |
115 | + @ApiModelProperty(value = "高度") | |
116 | + private Integer height; | |
106 | 117 | @ApiModelProperty(value = "重量") |
107 | 118 | private Integer weight; |
108 | 119 | /** 备用字段1 */ |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/ITaskHeaderService.java
1 | 1 | package org.jeecg.modules.wms.task.taskHeader.service; |
2 | 2 | |
3 | -import com.baomidou.mybatisplus.extension.service.IService; | |
3 | +import java.io.Serializable; | |
4 | +import java.util.Collection; | |
5 | + | |
4 | 6 | import org.jeecg.common.api.vo.Result; |
5 | 7 | import org.jeecg.modules.wms.config.location.entity.Location; |
6 | 8 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; |
7 | -import org.springframework.beans.factory.annotation.Autowired; | |
8 | -import java.io.Serializable; | |
9 | -import java.util.Collection; | |
10 | -import java.util.List; | |
9 | + | |
10 | +import com.baomidou.mybatisplus.extension.service.IService; | |
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @Description: 任务表 |
... | ... | @@ -179,4 +179,6 @@ public interface ITaskHeaderService extends IService<TaskHeader> { |
179 | 179 | */ |
180 | 180 | Result createManyEmptyOut(String containerCode, String toPortCode, String warehouseCode); |
181 | 181 | |
182 | + Result addMesTryTimes(TaskHeader taskHeader); | |
183 | + | |
182 | 184 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java
1 | 1 | package org.jeecg.modules.wms.task.taskHeader.service.impl; |
2 | 2 | |
3 | -import com.aliyun.oss.ServiceException; | |
4 | -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
5 | -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |
6 | -import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
3 | +import java.io.Serializable; | |
4 | +import java.math.BigDecimal; | |
5 | +import java.util.ArrayList; | |
6 | +import java.util.Collection; | |
7 | +import java.util.Date; | |
8 | +import java.util.List; | |
9 | +import java.util.stream.Collectors; | |
10 | + | |
11 | +import javax.annotation.Resource; | |
12 | + | |
7 | 13 | import org.jeecg.common.api.vo.Result; |
8 | 14 | import org.jeecg.modules.wms.api.wcs.service.LocationAllocationService; |
9 | 15 | import org.jeecg.modules.wms.api.wcs.service.WcsService; |
... | ... | @@ -15,7 +21,6 @@ import org.jeecg.modules.wms.config.locationHigh.entity.LocationHigh; |
15 | 21 | import org.jeecg.modules.wms.config.locationHigh.service.ILocationHighService; |
16 | 22 | import org.jeecg.modules.wms.config.locationType.entity.LocationType; |
17 | 23 | import org.jeecg.modules.wms.config.locationType.service.ILocationTypeService; |
18 | -import org.jeecg.modules.wms.config.material.entity.Material; | |
19 | 24 | import org.jeecg.modules.wms.config.material.service.IMaterialService; |
20 | 25 | import org.jeecg.modules.wms.config.parameterConfiguration.service.IParameterConfigurationService; |
21 | 26 | import org.jeecg.modules.wms.config.port.entity.Port; |
... | ... | @@ -48,16 +53,15 @@ import org.jeecg.modules.wms.task.taskHeader.service.ITaskDetailService; |
48 | 53 | import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService; |
49 | 54 | import org.jeecg.utils.StringUtils; |
50 | 55 | import org.jeecg.utils.constant.QuantityConstant; |
51 | -import org.springframework.stereotype.Service; | |
52 | -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
53 | 56 | import org.springframework.beans.factory.annotation.Autowired; |
57 | +import org.springframework.stereotype.Service; | |
54 | 58 | import org.springframework.transaction.annotation.Transactional; |
55 | 59 | |
56 | -import javax.annotation.Resource; | |
57 | -import java.io.Serializable; | |
58 | -import java.math.BigDecimal; | |
59 | -import java.util.*; | |
60 | -import java.util.stream.Collectors; | |
60 | +import com.aliyun.oss.ServiceException; | |
61 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
62 | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |
63 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
64 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
61 | 65 | |
62 | 66 | /** |
63 | 67 | * @Description: 任务表 |
... | ... | @@ -615,6 +619,18 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
615 | 619 | } |
616 | 620 | |
617 | 621 | @Override |
622 | + public Result addMesTryTimes(TaskHeader taskHeader) { | |
623 | + int mesTryTimes = taskHeader.getBackMesTimes(); | |
624 | + mesTryTimes++; | |
625 | + taskHeader.setBackMesTimes(mesTryTimes); | |
626 | + boolean success = taskHeaderService.updateById(taskHeader); | |
627 | + if (!success) { | |
628 | + return Result.error("MES回传次数增加失败"); | |
629 | + } | |
630 | + return Result.ok("MES回传次数增加成功"); | |
631 | + } | |
632 | + | |
633 | + @Override | |
618 | 634 | public TaskHeader getUnCompleteTaskByFromLocationCode(String fromLocationCode, String warehouseCode) { |
619 | 635 | LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); |
620 | 636 | taskHeaderLambdaQueryWrapper.eq(TaskHeader::getFromLocationCode, fromLocationCode).eq(TaskHeader::getWarehouseCode, warehouseCode).lt(TaskHeader::getStatus, |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/utils/constant/QuantityConstant.java
... | ... | @@ -64,6 +64,9 @@ public class QuantityConstant { |
64 | 64 | // 过账 |
65 | 65 | public static final Integer RECEIPT_HEADER_COMPLETED = 800; |
66 | 66 | |
67 | + // 回传失败 | |
68 | + public static final Integer RECEIPT_HEADER_RETURN_ERROR = 850; | |
69 | + | |
67 | 70 | // 回传 |
68 | 71 | public static final Integer RECEIPT_HEADER_RETURN = 900; |
69 | 72 | |
... | ... | @@ -96,6 +99,9 @@ public class QuantityConstant { |
96 | 99 | // 过账 |
97 | 100 | public static final Integer SHIPMENT_HEADER_COMPLETED = 800; |
98 | 101 | |
102 | + // 回传失败 | |
103 | + public static final Integer SHIPMENT_HEADER_RETURN_ERROR = 850; | |
104 | + | |
99 | 105 | // 回传 |
100 | 106 | public static final Integer SHIPMENT_HEADER_RETURN = 900; |
101 | 107 | |
... | ... | @@ -395,12 +401,14 @@ public class QuantityConstant { |
395 | 401 | // WCS任务更新 |
396 | 402 | public static final String ADDRESS_AGV_TASK_UPDATE = "AGV_TASK_UPDATE"; |
397 | 403 | |
398 | - // ERP | |
399 | - | |
400 | 404 | // 回传ERP入库单 |
401 | 405 | public static final String ADDRESS_ERP_BACK_RECEIPT = "ERP_BACK_RECEIPT"; |
402 | 406 | // 回传ERP出库单 |
403 | 407 | public static final String ADDRESS_ERP_BACK_SHIPMENT = "ERP_BACK_SHIPMENT"; |
408 | + // 回传MES入库单 | |
409 | + public static final String ADDRESS_MES_BACK_RECEIPT = "MES_BACK_RECEIPT"; | |
410 | + // 回传ERP出库单 | |
411 | + public static final String ADDRESS_MES_BACK_SHIPMENT = "MES_BACK_SHIPMENT"; | |
404 | 412 | |
405 | 413 | public static final String PLATFORM_CODING = "赋码系统"; |
406 | 414 | public static final String PLATFORM_ERP = "ERP"; |
... | ... | @@ -408,6 +416,15 @@ public class QuantityConstant { |
408 | 416 | // good |
409 | 417 | public static final String QUALITY_GOOD = "good"; |
410 | 418 | |
419 | + // 发送AGV任务成功 | |
420 | + public static final int AGV_SEND_OK = 1; | |
421 | + // 发送AGV任务异常 | |
422 | + public static final int AGV_SEND_ERROR = 2; | |
423 | + // 回传MES成功 | |
424 | + public static final int MES_SEND_OK = 1; | |
425 | + // 回传MES异常 | |
426 | + public static final int MES_SEND_ERROR = 2; | |
427 | + | |
411 | 428 | public static final int STATION_IN = 1; |
412 | 429 | public static final int STATION_OUT = 2; |
413 | 430 | public static final int STATION_PICK = 3; |
... | ... |