代码更新
This commit is contained in:
parent
e6e8e0217e
commit
fe2beacfc6
|
|
@ -215,11 +215,13 @@ public class ExcelController {
|
|||
// 先移除之前last表中的内容
|
||||
kateOrdersLastService.remove(new LambdaQueryWrapper<>());
|
||||
// 将当前工单表的数据存进Last表
|
||||
kateOrdersLastService.saveBatch(BeanUtil.copyToList(kateOrdersService.list(), KateOrdersLast.class));
|
||||
List<KateOrdersLast> kateOrdersLastList = BeanUtil.copyToList(kateOrdersService.list(), KateOrdersLast.class);
|
||||
kateOrdersLastService.saveBatch(kateOrdersLastList);
|
||||
// 移库工单表中的内容
|
||||
kateOrdersService.remove(new LambdaQueryWrapper<>());
|
||||
// 导入excel
|
||||
EasyExcel.read(file.getInputStream(), KateOrdersExcelVo.class, new UploadKateOrdersListener(kateOrdersService, kateOrdersLastService, fileVo.getUserName())).sheet().doRead();
|
||||
// TODO
|
||||
EasyExcel.read(file.getInputStream(), KateOrdersExcelVo.class, new UploadKateOrdersListener(kateOrdersLastList, kateOrdersService, fileVo.getUserName())).sheet().doRead();
|
||||
// 添加导入记录
|
||||
uploadRecordService.save(UploadRecord.ofFileVo(fileVo, "ORDERS"));
|
||||
uploadFileHashStringList.remove(fileVo.getHash());
|
||||
|
|
@ -266,12 +268,12 @@ public class ExcelController {
|
|||
response.setMessage("导入物料成功。");
|
||||
return convertJsonString(response);
|
||||
} catch (Exception e) {
|
||||
logger.error("导入物料异常:{}", convertJsonString(e));
|
||||
logger.error("导入物料异常:{}", e.getMessage());
|
||||
// 回滚事务
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
uploadFileHashStringList.remove(fileVo.getHash());
|
||||
response.setCode(ResponseCode.ERROR.getCode());
|
||||
response.setMessage("导入物料异常。");
|
||||
response.setMessage("导入物料异常:" + e.getMessage());
|
||||
return convertJsonString(response);
|
||||
}
|
||||
}
|
||||
|
|
@ -435,7 +437,7 @@ public class ExcelController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 导出入库记录
|
||||
* 导出出库记录
|
||||
*
|
||||
* @param response 请求
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -90,26 +90,26 @@ public class GoodsController {
|
|||
/**
|
||||
* 更新物料信息
|
||||
*
|
||||
* @param goods 物料信息
|
||||
* @param goodsQuery 物料信息
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/updateGoodsInfo")
|
||||
@ResponseBody
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
@MyLog(logTitle = "更新物料信息", logMethod = "updateGoodsInfo")
|
||||
public String updateGoodsInfo(@RequestBody GoodsDto goods) {
|
||||
logger.info("接收到更新物料信息请求:{},请求ip:{}", convertJsonString(goods), HttpUtils.getIpAddr(servletRequest));
|
||||
public String updateGoodsInfo(@RequestBody GoodsQuery goodsQuery) {
|
||||
logger.info("接收到更新物料信息请求:{},请求ip:{}", convertJsonString(goodsQuery), HttpUtils.getIpAddr(servletRequest));
|
||||
// 创建响应信息
|
||||
ResponseEntity rsp = new ResponseEntity();
|
||||
try {
|
||||
if (StringUtils.isEmpty(goods.getGoodsId())) {// 物料编码为空,不执行
|
||||
if (StringUtils.isEmpty(goodsQuery.getGoodsId())) {// 物料编码为空,不执行
|
||||
logger.error("请求更新的物料编号为空");
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage("请求更新的物料编号为空");
|
||||
return convertJsonString(rsp);
|
||||
}
|
||||
if (goodsService.update(BeanUtil.copyProperties(goods, Goods.class),
|
||||
new LambdaUpdateWrapper<Goods>().eq(Goods::getGoodsId, goods.getGoodsId()))) {
|
||||
if (goodsService.update(BeanUtil.copyProperties(goodsQuery, Goods.class),
|
||||
new LambdaUpdateWrapper<Goods>().eq(Goods::getGoodsId, goodsQuery.getGoodsId()))) {
|
||||
// 返回成功
|
||||
logger.info("更新物料信息成功");
|
||||
rsp.setCode(ResponseCode.OK.getCode());
|
||||
|
|
@ -175,20 +175,16 @@ public class GoodsController {
|
|||
@ResponseBody
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
public String getGoodsInfoByGoodsId(@RequestBody GoodsQuery goodsQuery) {
|
||||
logger.info("接收到查询物料信息请求:{},请求ip地址:{}", convertJsonString(goodsQuery), HttpUtils.getIpAddr(servletRequest));
|
||||
ResponseEntity rsp = new ResponseEntity();
|
||||
if (goodsQuery == null || StringUtils.isEmpty(goodsQuery.getGoodsId())) {
|
||||
// 返回其他异常
|
||||
rsp.setCode(ResponseCode.OK.getCode());
|
||||
rsp.setMessage("请求查询的参数为空");
|
||||
return convertJsonString(rsp);
|
||||
}
|
||||
try {
|
||||
LambdaQueryWrapper<Goods> goodsLambdaQueryWrapper = new LambdaQueryWrapper<Goods>()
|
||||
.like(Goods::getGoodsId, goodsQuery.getGoodsId());
|
||||
.select(Goods::getGoodsId, Goods::getGoodsName)
|
||||
.like(StringUtils.isNotEmpty(goodsQuery.getGoodsId()), Goods::getGoodsId, goodsQuery.getGoodsId());
|
||||
List<GoodsVo> goodsList = BeanUtil.copyToList(goodsService.list(goodsLambdaQueryWrapper), GoodsVo.class);
|
||||
// 返回成功
|
||||
rsp.setCode(ResponseCode.OK.getCode());
|
||||
rsp.setMessage("查询成功");
|
||||
rsp.setReturnData(goodsService.list(goodsLambdaQueryWrapper));
|
||||
rsp.setMessage("查询物料信息成功");
|
||||
rsp.setReturnData(goodsList);
|
||||
return convertJsonString(rsp);
|
||||
} catch (Exception e) {
|
||||
// 回滚事务
|
||||
|
|
@ -197,7 +193,7 @@ public class GoodsController {
|
|||
logger.error("查询物料信息发生错误:{}", e.getMessage());
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage("查询物料发生异常");
|
||||
return JSON.toJSONString(rsp);
|
||||
return convertJsonString(rsp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +224,7 @@ public class GoodsController {
|
|||
rsp.setMessage("删除物料信息成功");
|
||||
} else {
|
||||
// 返回其他异常
|
||||
logger.error("删除物料信息成功");
|
||||
logger.error("删除物料信息失败");
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage("删除物料信息失败");
|
||||
}
|
||||
|
|
@ -236,7 +232,7 @@ public class GoodsController {
|
|||
} catch (Exception e) {
|
||||
// 回滚事务
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
logger.error("发生异常:{}", e.getMessage());
|
||||
logger.error("删除物料信息发生异常:{}", e.getMessage());
|
||||
// 返回其他异常
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage("删除物料信息发生异常");
|
||||
|
|
|
|||
|
|
@ -377,6 +377,7 @@ public class KateWorkQueryController {
|
|||
boolean updateResult = workStationConfigService.update(new LambdaUpdateWrapper<WorkStationConfig>()
|
||||
.set(WorkStationConfig::getLastUpdateUser, stationConfigQuery.getUserName())
|
||||
.set(WorkStationConfig::getLastUpdateTime, LocalDateTime.now())
|
||||
.set(stationConfigQuery.getOrderQuantity() != null && stationConfigQuery.getOrderQuantity() > 0, WorkStationConfig::getOrderQuantity, stationConfigQuery.getOrderQuantity())
|
||||
.set(StringUtils.isNotEmpty(stationConfigQuery.getWorkStation()), WorkStationConfig::getWorkStation, stationConfigQuery.getWorkStation())
|
||||
.set(stationConfigQuery.getStartDateAdjust() != null, WorkStationConfig::getStartDateAdjust, stationConfigQuery.getStartDateAdjust())
|
||||
.eq(WorkStationConfig::getConfigId, stationConfigQuery.getConfigId()));
|
||||
|
|
|
|||
|
|
@ -3,16 +3,20 @@ package com.wms.controller;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.wms.annotation.MyLog;
|
||||
import com.wms.constants.enums.ResponseCode;
|
||||
import com.wms.entity.app.dto.PageDto;
|
||||
import com.wms.entity.app.request.ELocationConfigQuery;
|
||||
import com.wms.entity.app.request.ELocationQuery;
|
||||
import com.wms.entity.app.request.LocationQuery;
|
||||
import com.wms.entity.app.request.VehicleQuery;
|
||||
import com.wms.entity.app.ResponseEntity;
|
||||
import com.wms.entity.app.vo.ELocationVo;
|
||||
import com.wms.entity.app.vo.LocationVo;
|
||||
import com.wms.entity.app.vo.VehicleVO;
|
||||
import com.wms.entity.app.wcs.WcsETaskFeedbackRequest;
|
||||
import com.wms.entity.table.ELocationConfig;
|
||||
import com.wms.entity.table.ETagLocation;
|
||||
import com.wms.entity.table.Location;
|
||||
|
|
@ -37,6 +41,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.wms.utils.StringUtils.convertJsonString;
|
||||
|
||||
|
|
@ -64,7 +69,14 @@ public class LocationController {
|
|||
* 电子标签库位服务
|
||||
*/
|
||||
private final ETagLocationService etagLocationService;
|
||||
/**
|
||||
* 电子标签库位配置信息
|
||||
*/
|
||||
private final ELocationConfigService eLocationConfigService;
|
||||
/**
|
||||
* 任务类
|
||||
*/
|
||||
private final TaskController taskController;
|
||||
/**
|
||||
* 请求头部信息
|
||||
*/
|
||||
|
|
@ -398,21 +410,138 @@ public class LocationController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询电子标签库位信息
|
||||
* @param eLocationQuery 查询参数
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/getELocationsByPage")
|
||||
@ResponseBody
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
@MyLog(logTitle = "查询电子标签库位信息", logMethod = "getELocationsByPage")
|
||||
public String getELocationsByPage(@RequestBody ELocationQuery eLocationQuery) {
|
||||
logger.info("接收到查询电子标签库位信息请求:{},请求ip:{}", convertJsonString(eLocationQuery), HttpUtils.getIpAddr(servletRequest));
|
||||
ResponseEntity response = new ResponseEntity();
|
||||
try {
|
||||
Page<ETagLocation> page = eLocationQuery.toMpPage();
|
||||
Page<ETagLocation> eLocationsPage = etagLocationService.page(page, new LambdaQueryWrapper<ETagLocation>()
|
||||
.like(StringUtils.isNotEmpty(eLocationQuery.getELocationId()), ETagLocation::getELocationId, eLocationQuery.getELocationId())
|
||||
.like(StringUtils.isNotEmpty(eLocationQuery.getWorkStation()), ETagLocation::getWorkStation, eLocationQuery.getWorkStation())
|
||||
.eq(eLocationQuery.getELocationStatus() != null, ETagLocation::getELocationStatus, eLocationQuery.getELocationStatus())
|
||||
.eq(eLocationQuery.getPickStatus() != null, ETagLocation::getPickStatus, eLocationQuery.getPickStatus())
|
||||
.orderByDesc(ETagLocation::getPickStatus));
|
||||
|
||||
PageDto<ELocationVo> pageDto = PageDto.of(eLocationsPage, eLocation -> BeanUtil.copyProperties(eLocation, ELocationVo.class));
|
||||
response.setCode(ResponseCode.OK.getCode());
|
||||
response.setMessage("查询成功");
|
||||
response.setReturnData(pageDto);
|
||||
return convertJsonString(response);
|
||||
} catch (Exception e) {
|
||||
// 回滚事务
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
logger.error("查询电子标签库位信息发生异常: {}", convertJsonString(e));
|
||||
response.setCode(ResponseCode.ERROR.getCode());
|
||||
response.setMessage("查询电子标签库位信息发生异常");
|
||||
return convertJsonString(response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新电子标签库位信息
|
||||
*
|
||||
* @param eLocationQuery 料箱
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/updateELocationInfo")
|
||||
@ResponseBody
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
@MyLog(logTitle = "更新电子标签库位信息", logMethod = "updateELocationInfo")
|
||||
public String updateELocationInfo(@RequestBody ELocationQuery eLocationQuery) {
|
||||
logger.info("接收到更新电子标签库位信息请求:{},请求ip:{}", convertJsonString(eLocationQuery), HttpUtils.getIpAddr(servletRequest));
|
||||
// 创建响应信息
|
||||
ResponseEntity rsp = new ResponseEntity();
|
||||
try {
|
||||
if (StringUtils.isEmpty(eLocationQuery.getELocationId())) {// 电子标签库位号为空
|
||||
logger.error("缺少库位号");
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage("缺少库位号");
|
||||
return convertJsonString(rsp);
|
||||
}
|
||||
|
||||
// 判断拣货状态的变更
|
||||
if (eLocationQuery.getPickStatus() != null) {
|
||||
// 查询原来的电子标签库位信息
|
||||
ETagLocation eTagLocationBefore = etagLocationService.getOne(new LambdaQueryWrapper<ETagLocation>()
|
||||
.eq(ETagLocation::getELocationId, eLocationQuery.getELocationId()).last("limit 1"));
|
||||
if (Objects.equals(eTagLocationBefore.getPickStatus(), eLocationQuery.getPickStatus())) {
|
||||
// 返回失败
|
||||
logger.error("请勿重复更新拣货状态。");
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage("请勿重复更新拣货状态。");
|
||||
return convertJsonString(rsp);
|
||||
}
|
||||
if (eLocationQuery.getPickStatus() == 1) {
|
||||
// 如果要设定为拣货中,需设定其他信息
|
||||
// TODO
|
||||
// if (StringUtils.isEmpty(eLocationQuery.getVehicleNo())
|
||||
// || ) {
|
||||
//
|
||||
// }
|
||||
} else if (eLocationQuery.getPickStatus() == 0) {
|
||||
// 此时要模拟拍灯反馈
|
||||
WcsETaskFeedbackRequest wcsETaskFeedbackRequest = new WcsETaskFeedbackRequest();
|
||||
wcsETaskFeedbackRequest.setLocation(eTagLocationBefore.getELocationId());
|
||||
wcsETaskFeedbackRequest.setTaskId(eTagLocationBefore.getTaskId());
|
||||
wcsETaskFeedbackRequest.setTaskType(eTagLocationBefore.getTaskType());
|
||||
wcsETaskFeedbackRequest.setVehicleNo(eTagLocationBefore.getVehicleNo());
|
||||
wcsETaskFeedbackRequest.setConfirmNum(eLocationQuery.getConfirmNum() != null ? eLocationQuery.getConfirmNum() : eTagLocationBefore.getNeedNum());
|
||||
wcsETaskFeedbackRequest.setNeedNum(eTagLocationBefore.getNeedNum());
|
||||
wcsETaskFeedbackRequest.setUserName(eLocationQuery.getUserName());
|
||||
ResponseEntity result = JSON.parseObject(taskController.getETaskFeedBack(wcsETaskFeedbackRequest), ResponseEntity.class);
|
||||
if (result != null && Objects.equals(result.getCode(), ResponseCode.OK.getCode())) {
|
||||
logger.info("更新电子标签库位拣货状态成功。");
|
||||
rsp.setCode(ResponseCode.OK.getCode());
|
||||
rsp.setMessage("更新电子标签库位拣货状态成功。");
|
||||
} else {
|
||||
logger.error("更新电子标签库位拣货状态失败");
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage(result == null ? "更新电子标签库位拣货状态失败" : "更新电子标签库位拣货状态失败," + result.getMessage());
|
||||
}
|
||||
return convertJsonString(rsp);
|
||||
}
|
||||
} else {
|
||||
LambdaUpdateWrapper<ETagLocation> updateWrapper = new LambdaUpdateWrapper<ETagLocation>()
|
||||
.set(eLocationQuery.getELocationStatus() != null, ETagLocation::getELocationStatus, eLocationQuery.getELocationStatus())
|
||||
.set(eLocationQuery.getPickStatus() != null, ETagLocation::getPickStatus, eLocationQuery.getPickStatus());
|
||||
}
|
||||
|
||||
return convertJsonString(rsp);
|
||||
} catch (Exception e) {
|
||||
// 回滚事务
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
logger.info("更新载具信息发生异常:{}", convertJsonString(e));
|
||||
// 返回其他异常
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage("更新载具信息发生异常");
|
||||
return JSON.toJSONString(rsp);
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 查询电子标签库位信息
|
||||
// * @param eLocationQuery 查询参数
|
||||
// * 查询电子标签库位分配信息
|
||||
// * @param eLocationConfigQuery 查询参数
|
||||
// * @return 结果
|
||||
// */
|
||||
// @PostMapping("/getELocationsByPage")
|
||||
// @PostMapping("/getELocationConfigsByPage")
|
||||
// @ResponseBody
|
||||
// @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
// @MyLog(logTitle = "查询电子标签库位信息", logMethod = "getVehiclesByPage")
|
||||
// public String getVehiclesByPage(@RequestBody ELocationQuery eLocationQuery) {
|
||||
// logger.info("接收到查询电子标签库位信息请求:{},请求ip:{}", convertJsonString(eLocationQuery), HttpUtils.getIpAddr(servletRequest));
|
||||
// @MyLog(logTitle = "查询电子标签库位分配信息", logMethod = "getELocationConfigsByPage")
|
||||
// public String getELocationConfigsByPage(@RequestBody ELocationConfigQuery eLocationConfigQuery) {
|
||||
// logger.info("接收到查询电子标签库位分配信息请求:{},请求ip:{}", convertJsonString(eLocationConfigQuery), HttpUtils.getIpAddr(servletRequest));
|
||||
// ResponseEntity response = new ResponseEntity();
|
||||
// try {
|
||||
// Page<ETagLocation> page = eLocationQuery.toMpPage();
|
||||
// Page<Vehicle> vehiclePage = vehicleService.page(page, new LambdaQueryWrapper<Vehicle>()
|
||||
// Page<ETagLocation> eLocationsPage = etagLocationService.page(page, new LambdaQueryWrapper<ETagLocation>()
|
||||
// .like(StringUtils.isNotEmpty(vehicleQuery.getVehicleId()), Vehicle::getVehicleId, vehicleQuery.getVehicleId())
|
||||
// .eq(vehicleQuery.getVehicleStatus() != null, Vehicle::getVehicleStatus, vehicleQuery.getVehicleStatus())
|
||||
// .eq(vehicleQuery.getIsEmpty() != null, Vehicle::getIsEmpty, vehicleQuery.getIsEmpty())
|
||||
|
|
@ -434,17 +563,17 @@ public class LocationController {
|
|||
// }
|
||||
//
|
||||
// /**
|
||||
// * 更新料箱信息
|
||||
// * 更新电子库位分配信息
|
||||
// *
|
||||
// * @param vehicleQuery 料箱
|
||||
// * @param eLocationConfigQuery 参数
|
||||
// * @return 结果
|
||||
// */
|
||||
// @PostMapping("/updateVehicleInfo")
|
||||
// @PostMapping("/updateELocationConfigInfo")
|
||||
// @ResponseBody
|
||||
// @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
// @MyLog(logTitle = "更新载具信息", logMethod = "updateVehicleInfo")
|
||||
// public String updateVehicleInfo(@RequestBody VehicleQuery vehicleQuery) {
|
||||
// logger.info("接收到更新载具信息信息请求:{},请求ip:{}", convertJsonString(vehicleQuery), HttpUtils.getIpAddr(servletRequest));
|
||||
// @MyLog(logTitle = "更新电子库位分配信息", logMethod = "updateELocationConfigInfo")
|
||||
// public String updateELocationConfigInfo(@RequestBody ELocationConfigQuery eLocationConfigQuery) {
|
||||
// logger.info("接收到更新电子库位分配信息请求:{},请求ip:{}", convertJsonString(eLocationConfigQuery), HttpUtils.getIpAddr(servletRequest));
|
||||
// // 创建响应信息
|
||||
// ResponseEntity rsp = new ResponseEntity();
|
||||
// try {
|
||||
|
|
|
|||
|
|
@ -1160,6 +1160,15 @@ public class TaskController {
|
|||
return convertJsonString(response);
|
||||
}
|
||||
if (eTaskFeedbackRequest.getTaskType() == 1) {// 拣选任务
|
||||
// 查询到对应的库位,如果不是亮灯状态,不接受反馈
|
||||
if (!etagLocationService.exists(new LambdaQueryWrapper<ETagLocation>()
|
||||
.eq(ETagLocation::getELocationId, eTaskFeedbackRequest.getLocation())
|
||||
.eq(ETagLocation::getPickStatus, 1))) {
|
||||
logger.error("当前位置无亮灯信息。");
|
||||
response.setCode(ResponseCode.ERROR.getCode());
|
||||
response.setMessage("当前位置无亮灯信息。");
|
||||
return convertJsonString(response);
|
||||
}
|
||||
// 根据taskId查找对应的workFlow
|
||||
WorkFlow workFlow = workFlowService.getOne(new LambdaQueryWrapper<WorkFlow>().eq(WorkFlow::getWorkFlowId, eTaskFeedbackRequest.getTaskId()).last("limit 1"));
|
||||
if (workFlow == null) {
|
||||
|
|
@ -1167,6 +1176,13 @@ public class TaskController {
|
|||
response.setCode(ResponseCode.ERROR.getCode());
|
||||
response.setMessage("反馈的任务号查找不到对应的工作信息。");
|
||||
return convertJsonString(response);
|
||||
} else {
|
||||
if (workFlow.getPickedNum().compareTo(workFlow.getNeedNum()) >= 0) {
|
||||
logger.error("当前工作拣货数量已足够,请勿重复拍灯。");
|
||||
response.setCode(ResponseCode.ERROR.getCode());
|
||||
response.setMessage("当前工作拣货数量已足够,请勿重复拍灯。");
|
||||
return convertJsonString(response);
|
||||
}
|
||||
}
|
||||
// 更新实际拣选数量
|
||||
workFlow.setPickedNum(workFlow.getPickedNum().add(BigDecimal.valueOf(eTaskFeedbackRequest.getConfirmNum())));
|
||||
|
|
@ -1228,8 +1244,6 @@ public class TaskController {
|
|||
.set(ETagLocation::getNeedNum, null)
|
||||
.set(ETagLocation::getConfirmNum, null)
|
||||
.eq(ETagLocation::getELocationId, eTaskFeedbackRequest.getLocation()));
|
||||
response.setCode(ResponseCode.OK.getCode());
|
||||
response.setMessage("处理反馈成功");
|
||||
} else {// 小盒子放入大盒子
|
||||
// 根据location查询到对应的配置
|
||||
ELocationConfigLast eLocationConfigLast = eLocationConfigLastService.getOne(new LambdaQueryWrapper<ELocationConfigLast>()
|
||||
|
|
@ -1241,6 +1255,8 @@ public class TaskController {
|
|||
eLocationConfigLastService.updateById(eLocationConfigLast);
|
||||
}
|
||||
}
|
||||
response.setCode(ResponseCode.OK.getCode());
|
||||
response.setMessage("处理反馈成功");
|
||||
return convertJsonString(response);
|
||||
} catch (Exception e) {
|
||||
// 回滚事务
|
||||
|
|
@ -1827,6 +1843,7 @@ public class TaskController {
|
|||
// 生成料箱出库任务
|
||||
int needNum = callEmptyVehicleRequest.getNeedNum();
|
||||
List<Task> vehicleOutTasks = new ArrayList<>();
|
||||
// TODO
|
||||
while (needNum > 0) {
|
||||
// 先找空箱
|
||||
Vehicle emptyVehicle = vehicleService.getOne(new LambdaQueryWrapper<Vehicle>()
|
||||
|
|
@ -1855,11 +1872,11 @@ public class TaskController {
|
|||
// 更新料箱信息
|
||||
emptyVehicle.setVehicleStatus(VehicleStatus.OUT.getCode());
|
||||
vehicleService.updateById(emptyVehicle);
|
||||
needNum--;
|
||||
} else {// 已经没有空箱可用了
|
||||
// TODO 这里后续增加出不出带料箱子的配置
|
||||
break;
|
||||
}
|
||||
needNum--;
|
||||
}
|
||||
taskService.saveBatch(vehicleOutTasks);
|
||||
if (needNum <= 0) {
|
||||
|
|
@ -2337,7 +2354,6 @@ public class TaskController {
|
|||
goodsRelated.setRemainNum(goodsRelated.getRemainNum().subtract(needNum));
|
||||
tempStock.setGoodsRelated(goodsRelated);
|
||||
waitForOutStockList.add(tempStock);
|
||||
break;
|
||||
} else {
|
||||
// 当前箱子物料剩余数量少于需求数量
|
||||
needNum = needNum.subtract(tempStock.getGoodsRelated().getRemainNum());
|
||||
|
|
@ -2375,7 +2391,6 @@ public class TaskController {
|
|||
goodsRelated.setRemainNum(goodsRelated.getRemainNum().subtract(needNum));
|
||||
tempStock.setGoodsRelated(goodsRelated);
|
||||
waitForOutStockList.add(tempStock);
|
||||
break;
|
||||
} else {
|
||||
// 当前箱子物料剩余数量少于需求数量
|
||||
needNum = needNum.subtract(tempStock.getGoodsRelated().getRemainNum());
|
||||
|
|
@ -2395,6 +2410,7 @@ public class TaskController {
|
|||
return convertJsonString(response);
|
||||
}
|
||||
// 添加出库任务
|
||||
if (!outTasks.isEmpty()) {
|
||||
taskService.saveBatch(outTasks);
|
||||
List<String> vehicleIds = outTasks.stream().map(Task::getVehicleId).distinct().toList();
|
||||
// 更新库存状态
|
||||
|
|
@ -2407,6 +2423,7 @@ public class TaskController {
|
|||
.set(Vehicle::getVehicleStatus, VehicleStatus.OUT.getCode())
|
||||
.in(Vehicle::getVehicleId, vehicleIds)
|
||||
.eq(Vehicle::getVehicleStatus, VehicleStatus.ON.getCode()));
|
||||
}
|
||||
// 非计划领料记录生成
|
||||
NoPlanRecord noPlanRecord = new NoPlanRecord();
|
||||
noPlanRecord.setRecordId(generateId("CLC-NO-PLAN_"));
|
||||
|
|
@ -2607,9 +2624,9 @@ public class TaskController {
|
|||
} catch (Exception e) {
|
||||
// 回滚事务
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
logger.error("处理整理盒子请求异常,{}", convertJsonString(e));
|
||||
logger.error("处理确认回库请求异常,{}", convertJsonString(e));
|
||||
response.setCode(ResponseCode.ERROR.getCode());
|
||||
response.setMessage("处理整理盒子请求异常。");
|
||||
response.setMessage("处理确认回库请求异常。");
|
||||
return convertJsonString(response);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
package com.wms.entity.app.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ELocationConfigQuery extends PageQuery {
|
||||
/**
|
||||
* 电子标签库位
|
||||
*/
|
||||
@JsonProperty("eLocationId")
|
||||
private String eLocationId;
|
||||
/**
|
||||
* 工站
|
||||
*/
|
||||
@JsonProperty("workStation")
|
||||
private String workStation;
|
||||
/**
|
||||
* 工单
|
||||
*/
|
||||
@JsonProperty("workOrder")
|
||||
private String workOrder;
|
||||
/**
|
||||
* 工位
|
||||
*/
|
||||
@JsonProperty("workCenter")
|
||||
private String workCenter;
|
||||
/**
|
||||
* 盒子号
|
||||
*/
|
||||
@JsonProperty("orderBoxNo")
|
||||
private String orderBoxNo;
|
||||
/**
|
||||
* 是否打印
|
||||
*/
|
||||
@JsonProperty("printStatus")
|
||||
private Integer printStatus;
|
||||
/**
|
||||
* 打印次数
|
||||
*/
|
||||
@JsonProperty("printCounts")
|
||||
private Integer printCounts;
|
||||
}
|
||||
|
|
@ -29,6 +29,11 @@ public class StationConfigQuery extends PageQuery {
|
|||
*/
|
||||
@JsonProperty("smallBox")
|
||||
private String smallBox;
|
||||
/**
|
||||
* 工单数/大盒子
|
||||
*/
|
||||
@JsonProperty("orderQuantity")
|
||||
private Integer orderQuantity;
|
||||
/**
|
||||
* 机型
|
||||
*/
|
||||
|
|
|
|||
43
src/main/java/com/wms/entity/app/vo/ELocationConfigVo.java
Normal file
43
src/main/java/com/wms/entity/app/vo/ELocationConfigVo.java
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package com.wms.entity.app.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ELocationConfigVo {
|
||||
/**
|
||||
* 电子标签库位
|
||||
*/
|
||||
@JsonProperty("eLocationId")
|
||||
private String eLocationId;
|
||||
/**
|
||||
* 工站
|
||||
*/
|
||||
@JsonProperty("workStation")
|
||||
private String workStation;
|
||||
/**
|
||||
* 工单
|
||||
*/
|
||||
@JsonProperty("workOrder")
|
||||
private String workOrder;
|
||||
/**
|
||||
* 工位
|
||||
*/
|
||||
@JsonProperty("workCenter")
|
||||
private String workCenter;
|
||||
/**
|
||||
* 盒子号
|
||||
*/
|
||||
@JsonProperty("orderBoxNo")
|
||||
private String orderBoxNo;
|
||||
/**
|
||||
* 是否打印
|
||||
*/
|
||||
@JsonProperty("printStatus")
|
||||
private Integer printStatus;
|
||||
/**
|
||||
* 打印次数
|
||||
*/
|
||||
@JsonProperty("printCounts")
|
||||
private Integer printCounts;
|
||||
}
|
||||
70
src/main/java/com/wms/entity/app/vo/ELocationVo.java
Normal file
70
src/main/java/com/wms/entity/app/vo/ELocationVo.java
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
package com.wms.entity.app.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 电子标签库位Vo
|
||||
*/
|
||||
@Data
|
||||
public class ELocationVo {
|
||||
/**
|
||||
* 库位id
|
||||
*/
|
||||
@JsonProperty("eLocationId")
|
||||
private String eLocationId;
|
||||
/**
|
||||
* 库区id
|
||||
*/
|
||||
@JsonProperty("areaId")
|
||||
private String areaId;
|
||||
/**
|
||||
* 顺序号
|
||||
*/
|
||||
@JsonProperty("sequenceId")
|
||||
private Integer sequenceId;
|
||||
/**
|
||||
* 电子标签状态
|
||||
* 0:可用
|
||||
* 1:不可用
|
||||
*/
|
||||
@JsonProperty("eLocationStatus")
|
||||
private Integer eLocationStatus;
|
||||
/**
|
||||
* 工作站台
|
||||
*/
|
||||
@JsonProperty("workStation")
|
||||
private String workStation;
|
||||
/**
|
||||
* 任务号
|
||||
*/
|
||||
@JsonProperty("taskId")
|
||||
private String taskId;
|
||||
/**
|
||||
* 箱号
|
||||
*/
|
||||
@JsonProperty("vehicleNo")
|
||||
private String vehicleNo;
|
||||
/**
|
||||
* 需求数量
|
||||
*/
|
||||
@JsonProperty("needNum")
|
||||
private Integer needNum;
|
||||
/**
|
||||
* 确认数量
|
||||
*/
|
||||
@JsonProperty("confirmNum")
|
||||
private Integer confirmNum;
|
||||
/**
|
||||
* 任务类型
|
||||
*/
|
||||
@JsonProperty("taskType")
|
||||
private Integer taskType;
|
||||
/**
|
||||
* 拣货状态
|
||||
* 0:未亮灯
|
||||
* 1:亮灯中
|
||||
*/
|
||||
@JsonProperty("pickStatus")
|
||||
private Integer pickStatus;
|
||||
}
|
||||
|
|
@ -29,6 +29,11 @@ public class StationConfigVo {
|
|||
*/
|
||||
@JsonProperty("smallBox")
|
||||
private String smallBox;
|
||||
/**
|
||||
* 工单数/大盒子
|
||||
*/
|
||||
@JsonProperty("orderQuantity")
|
||||
private Integer orderQuantity;
|
||||
/**
|
||||
* 机型
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@ public class WorkStationConfig {
|
|||
*/
|
||||
@TableField("small_box")
|
||||
private String smallBox;
|
||||
/**
|
||||
* 工单数/大盒子
|
||||
*/
|
||||
@TableField("order_quantity")
|
||||
private Integer orderQuantity;
|
||||
/**
|
||||
* 机型
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -7,14 +7,8 @@ import com.wms.constants.enums.*;
|
|||
import com.wms.entity.app.ResponseEntity;
|
||||
import com.wms.entity.app.wcs.WcsStandTaskRequest;
|
||||
import com.wms.entity.app.wcs.WcsTaskRequest;
|
||||
import com.wms.entity.table.OutsideVehicles;
|
||||
import com.wms.entity.table.PickTask;
|
||||
import com.wms.entity.table.Task;
|
||||
import com.wms.entity.table.WmsLog;
|
||||
import com.wms.service.LogService;
|
||||
import com.wms.service.OutsideVehiclesService;
|
||||
import com.wms.service.PickTaskService;
|
||||
import com.wms.service.TaskService;
|
||||
import com.wms.entity.table.*;
|
||||
import com.wms.service.*;
|
||||
import com.wms.service.business.IWmsJobService;
|
||||
import com.wms.utils.HttpUtils;
|
||||
import com.wms.utils.StringUtils;
|
||||
|
|
@ -46,6 +40,7 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
private final TaskService taskService;// 任务服务
|
||||
private final PickTaskService pickTaskService;// 拣选任务服务
|
||||
private final OutsideVehiclesService outsideVehiclesService;// 流转中箱子服务
|
||||
private final StandService standService;// 站台服务
|
||||
|
||||
/**
|
||||
* 发送正常的任务
|
||||
|
|
@ -82,6 +77,13 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
List<PickTask> standPickTasks = pickTaskService.list();
|
||||
// 生成一个Map,计算每个站台已经出库的拣选任务
|
||||
Map<String, Integer> outPickTaskMap = new HashMap<>();
|
||||
// 轮询工作站台,判断是否需要下发任务
|
||||
List<Stand> stands = standService.list(new LambdaQueryWrapper<Stand>()
|
||||
.eq(Stand::getIsLock, 0).eq(Stand::getStandStatus, 0)
|
||||
.eq(Stand::getStandType, 2));
|
||||
for (Stand workStation : stands) {
|
||||
outPickTaskMap.put(workStation.getStandId(), 0);
|
||||
}
|
||||
standPickTasks.forEach(pickTask -> {
|
||||
if (!Objects.equals(pickTask.getPickStatus(), PickTaskStatusEnum.TEMP.getCode())) {
|
||||
outPickTaskMap.put(pickTask.getStandId(),
|
||||
|
|
@ -168,6 +170,9 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
.max(Comparator.comparingInt(Map.Entry::getValue))
|
||||
.map(Map.Entry::getKey)
|
||||
.orElse("");
|
||||
if (StringUtils.isEmpty(vehicleId)) {
|
||||
continue;
|
||||
}
|
||||
// 更新每个站台的拣选箱数量
|
||||
List<String> standIds = standPickTasks.stream()
|
||||
.filter(pickTask -> pickTask.getVehicleId().equals(vehicleId))
|
||||
|
|
|
|||
|
|
@ -55,9 +55,21 @@ public class StockServiceImplements extends ServiceImpl<StockMapper, Stock> impl
|
|||
*/
|
||||
@Override
|
||||
public List<StockOfGoodsDto> selectSumOfGoods(List<String> goodsIdList) {
|
||||
LambdaQueryWrapper<Stock> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (goodsIdList != null && !goodsIdList.isEmpty()) {
|
||||
StringBuilder goodsSqlString = new StringBuilder();
|
||||
for (String goodsId : goodsIdList) {
|
||||
if (goodsSqlString.toString().equals("")) {
|
||||
goodsSqlString.append("(goods_related ->> '$.goodsId' in (\"").append(goodsId).append("\"");
|
||||
} else {
|
||||
goodsSqlString.append(",\"").append(goodsId).append("\"");
|
||||
}
|
||||
}
|
||||
goodsSqlString.append("))");
|
||||
queryWrapper.apply(goodsSqlString + MYSQL_JSON_CI);
|
||||
}
|
||||
// 先查询库存
|
||||
List<Stock> stocks = stockMapper.selectList(new LambdaQueryWrapper<Stock>()
|
||||
.apply(goodsIdList != null && !goodsIdList.isEmpty(), "goods_related ->> '$.goodsId' in {0}" + MYSQL_JSON_CI, goodsIdList));
|
||||
List<Stock> stocks = stockMapper.selectList(queryWrapper);
|
||||
if (stocks == null || stocks.isEmpty()) {
|
||||
// 查不到对应物料的库存
|
||||
return Collections.emptyList();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import java.util.Date;
|
|||
|
||||
/**
|
||||
* WMS工具类
|
||||
*
|
||||
* @author 梁州
|
||||
* @date 2023/2/13
|
||||
*/
|
||||
|
|
@ -21,8 +22,11 @@ public class WmsUtils {
|
|||
// id用的时间格式
|
||||
public static final SimpleDateFormat idTimeFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
||||
public static volatile Long lastTimestamp = -1L;
|
||||
public static int id = 0;
|
||||
|
||||
/**
|
||||
* 生成唯一的编号
|
||||
*
|
||||
* @param code 插入字符串
|
||||
* @return 唯一id
|
||||
*/
|
||||
|
|
@ -36,20 +40,23 @@ public class WmsUtils {
|
|||
public synchronized static String generateUUIDString() {
|
||||
long timeStamp = System.currentTimeMillis();
|
||||
if (timeStamp == lastTimestamp) {
|
||||
if (id < 9999) {
|
||||
id++;
|
||||
} else {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e){
|
||||
timeStamp = System.currentTimeMillis();
|
||||
lastTimestamp = timeStamp;
|
||||
return idTimeFormat.format(new Date()).concat(String.valueOf(timeStamp));
|
||||
id = 0;
|
||||
} catch (InterruptedException e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
timeStamp = System.currentTimeMillis();
|
||||
lastTimestamp = timeStamp;
|
||||
return idTimeFormat.format(new Date()).concat(String.valueOf(timeStamp));
|
||||
} else {
|
||||
lastTimestamp = timeStamp;
|
||||
return idTimeFormat.format(new Date()).concat(String.valueOf(timeStamp));
|
||||
id = 0;
|
||||
}
|
||||
|
||||
return idTimeFormat.format(new Date()).concat(String.valueOf(timeStamp)) + StringUtils.padLeft(String.valueOf(id), 4, "0");
|
||||
}
|
||||
|
||||
// 方法接收一个字符参数,返回对应的1-26之间的数字
|
||||
|
|
@ -65,6 +72,7 @@ public class WmsUtils {
|
|||
|
||||
/**
|
||||
* 时间字符串转时间格式
|
||||
*
|
||||
* @param time 时间
|
||||
*/
|
||||
public static Date timeStringToTime(String time) throws ParseException {
|
||||
|
|
@ -73,6 +81,7 @@ public class WmsUtils {
|
|||
|
||||
/**
|
||||
* 日期字符串
|
||||
*
|
||||
* @param date 日期
|
||||
*/
|
||||
public static Date dateStringToDate(String date) throws ParseException {
|
||||
|
|
@ -81,6 +90,7 @@ public class WmsUtils {
|
|||
|
||||
/**
|
||||
* 生成时间戳,格式yyyy-MM-dd HH:mm:ss
|
||||
*
|
||||
* @return 时间戳
|
||||
*/
|
||||
public static String createCurrentTimeString() {
|
||||
|
|
@ -89,6 +99,7 @@ public class WmsUtils {
|
|||
|
||||
/**
|
||||
* 生成日期字符串,格式yyyy-MM-dd
|
||||
*
|
||||
* @return 时间戳
|
||||
*/
|
||||
public static String createCurrentDateString() {
|
||||
|
|
@ -97,6 +108,7 @@ public class WmsUtils {
|
|||
|
||||
/**
|
||||
* 格式化日期,格式yyyy-MM-dd
|
||||
*
|
||||
* @param date 日期
|
||||
* @return 时间戳
|
||||
*/
|
||||
|
|
@ -106,6 +118,7 @@ public class WmsUtils {
|
|||
|
||||
/**
|
||||
* 格式化时间,格式yyyy-MM-dd HH:mm:ss
|
||||
*
|
||||
* @param date 日期
|
||||
* @return 时间戳
|
||||
*/
|
||||
|
|
@ -115,11 +128,12 @@ public class WmsUtils {
|
|||
|
||||
/**
|
||||
* 获得指定日期之后指定天数的日期
|
||||
*
|
||||
* @param beginDay 开始日期
|
||||
* @param days 天数
|
||||
* @return 日期
|
||||
*/
|
||||
public static Date calculationDate(Date beginDay, int days){
|
||||
public static Date calculationDate(Date beginDay, int days) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(beginDay);
|
||||
calendar.add(Calendar.DATE, days);
|
||||
|
|
@ -128,11 +142,12 @@ public class WmsUtils {
|
|||
|
||||
/**
|
||||
* 获得指定日期之后指定月数的日期
|
||||
*
|
||||
* @param beginDay 开始日期
|
||||
* @param months 月数
|
||||
* @return 日期
|
||||
*/
|
||||
public static Date calculationMonth(Date beginDay, int months){
|
||||
public static Date calculationMonth(Date beginDay, int months) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(beginDay);
|
||||
calendar.add(Calendar.MONTH, months);
|
||||
|
|
@ -141,11 +156,12 @@ public class WmsUtils {
|
|||
|
||||
/**
|
||||
* 获得指定日期之后指定年数的日期
|
||||
*
|
||||
* @param beginDay 开始日期
|
||||
* @param years 年数
|
||||
* @return 日期
|
||||
*/
|
||||
public static Date calculationYear(Date beginDay, int years){
|
||||
public static Date calculationYear(Date beginDay, int years) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(beginDay);
|
||||
calendar.add(Calendar.YEAR, years);
|
||||
|
|
@ -154,10 +170,11 @@ public class WmsUtils {
|
|||
|
||||
/**
|
||||
* 获取指定天数后的日期
|
||||
*
|
||||
* @param day 天数
|
||||
* @return 日期
|
||||
*/
|
||||
public static Date getDay(int day){
|
||||
public static Date getDay(int day) {
|
||||
return calculationDate(new Date(), day);
|
||||
}
|
||||
|
||||
|
|
@ -166,16 +183,17 @@ public class WmsUtils {
|
|||
* @Params: mon 1表示后一个月 -1表示前一个月
|
||||
* @Return
|
||||
*/
|
||||
public static Date getMon(int mon){
|
||||
public static Date getMon(int mon) {
|
||||
return calculationMonth(new Date(), mon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任意年之后的日期
|
||||
*
|
||||
* @param year 年
|
||||
* @return 日期
|
||||
*/
|
||||
public static Date getYear(int year){
|
||||
public static Date getYear(int year) {
|
||||
return calculationYear(new Date(), year);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import java.time.LocalDateTime;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.wms.utils.StringUtils.convertJsonString;
|
||||
import static com.wms.utils.WmsUtils.generateId;
|
||||
|
||||
/**
|
||||
|
|
@ -45,8 +44,9 @@ public class UploadDbsListener implements ReadListener<KateDbsExcelVo> {
|
|||
|
||||
@Override
|
||||
public void onException(Exception exception, AnalysisContext context) throws Exception {
|
||||
logger.error("处理Dbs数据发生异常:{}", convertJsonString(exception));
|
||||
ReadListener.super.onException(exception, context);
|
||||
int rowCount = context.readRowHolder().getRowIndex() + 1;
|
||||
logger.error("处理Dbs数据发生异常,第{}行发生异常。", rowCount);
|
||||
throw new Exception("第" + rowCount + "行数据异常。");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@ import java.time.LocalDateTime;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.wms.utils.StringUtils.convertJsonString;
|
||||
|
||||
/**
|
||||
* 上传DBS监听
|
||||
*/
|
||||
|
|
@ -41,8 +39,9 @@ public class UploadGoodsListener implements ReadListener<GoodsExcelVo> {
|
|||
|
||||
@Override
|
||||
public void onException(Exception exception, AnalysisContext context) throws Exception {
|
||||
logger.error("处理物料数据发生异常:{}", convertJsonString(exception));
|
||||
ReadListener.super.onException(exception, context);
|
||||
int rowCount = context.readRowHolder().getRowIndex() + 1;
|
||||
logger.error("处理物料数据发生异常,第{}行发生异常。", rowCount);
|
||||
throw new Exception("第" + rowCount + "行数据异常。");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.wms.utils.excel.listener;
|
|||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.read.listener.ReadListener;
|
||||
import com.alibaba.excel.util.ListUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.wms.constants.enums.ConfigMapKeyEnum;
|
||||
import com.wms.entity.table.*;
|
||||
import com.wms.service.*;
|
||||
|
|
@ -13,12 +12,9 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
import static com.wms.config.InitLocalConfig.configMap;
|
||||
import static com.wms.utils.StringUtils.convertJsonString;
|
||||
import static com.wms.utils.WmsUtils.generateId;
|
||||
|
||||
/**
|
||||
|
|
@ -29,25 +25,35 @@ public class UploadKateOrdersListener implements ReadListener<KateOrdersExcelVo>
|
|||
/**
|
||||
* 每隔5条存储数据库,实际使用中可以1000条,然后清理list ,方便内存回收
|
||||
*/
|
||||
private static final int BATCH_COUNT = 1000;
|
||||
private static final int BATCH_COUNT = 5000;
|
||||
/**
|
||||
* 保存数据总数
|
||||
*/
|
||||
private int SAVE_COUNT = 0;
|
||||
private List<KateOrdersExcelVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
|
||||
/**
|
||||
* 优化导入速度的变量---开始
|
||||
*/
|
||||
private int MAP_INDEX = 0;
|
||||
private int LAST_SHOT_INDEX = 0;
|
||||
private final Map<Integer, Map<String, KateOrders>> doneMap = new HashMap<>();
|
||||
private final List<KateOrdersLast> kateOrdersLastList;// 所有之前的工单列表;
|
||||
/**
|
||||
* 优化导入速度的变量---结束
|
||||
*/
|
||||
private final KateOrdersService kateOrdersService;// Dbs服务
|
||||
private final KateOrdersLastService kateOrdersLastService;// DbsLast服务
|
||||
private final String uploadUser;// 用户
|
||||
public UploadKateOrdersListener(KateOrdersService kateOrdersService, KateOrdersLastService kateOrdersLastService, String uploadUser) {
|
||||
public UploadKateOrdersListener(List<KateOrdersLast> kateOrdersLastList, KateOrdersService kateOrdersService, String uploadUser) {
|
||||
this.kateOrdersLastList = kateOrdersLastList;
|
||||
this.kateOrdersService = kateOrdersService;
|
||||
this.kateOrdersLastService = kateOrdersLastService;
|
||||
this.uploadUser = uploadUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onException(Exception exception, AnalysisContext context) throws Exception {
|
||||
logger.error("处理工单数据发生异常:{}", convertJsonString(exception));
|
||||
ReadListener.super.onException(exception, context);
|
||||
int rowCount = context.readRowHolder().getRowIndex() + 1;
|
||||
logger.error("处理工单数据发生异常,第{}行发生异常。", rowCount);
|
||||
throw new Exception("第" + rowCount + "行数据异常。");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -95,6 +101,7 @@ public class UploadKateOrdersListener implements ReadListener<KateOrdersExcelVo>
|
|||
*/
|
||||
private void saveData() {
|
||||
List<KateOrders> kateOrdersList = new ArrayList<>();
|
||||
Map<String, KateOrders> tempDoneMap = new HashMap<>();
|
||||
for (KateOrdersExcelVo kateOrdersExcelVo : cachedDataList) {
|
||||
// 查看当前List中是否有该工单
|
||||
List<KateOrders> currentOrdersList = kateOrdersList.stream().filter(kateOrders ->
|
||||
|
|
@ -117,25 +124,38 @@ public class UploadKateOrdersListener implements ReadListener<KateOrdersExcelVo>
|
|||
continue;
|
||||
}
|
||||
// 查询数据库是否存在重复数据
|
||||
KateOrders existsKateOrders = kateOrdersService.getOne(new LambdaQueryWrapper<KateOrders>()
|
||||
.eq(KateOrders::getWorkOrder, kateOrdersExcelVo.getWorkOrder())
|
||||
.eq(KateOrders::getGoodsId, kateOrdersExcelVo.getGoodsId())
|
||||
.eq(KateOrders::getSupplyArea, kateOrdersExcelVo.getSupplyArea())
|
||||
.last("limit 1"));
|
||||
if (existsKateOrders != null) {
|
||||
KateOrders existsKateOrder = null;
|
||||
String key = kateOrdersExcelVo.getWorkOrder() + kateOrdersExcelVo.getGoodsId() + kateOrdersExcelVo.getSupplyArea();
|
||||
if (LAST_SHOT_INDEX > 0) {
|
||||
if (doneMap.get(LAST_SHOT_INDEX).containsKey(key)) {
|
||||
existsKateOrder = doneMap.get(LAST_SHOT_INDEX).get(key);
|
||||
System.out.println("命中");
|
||||
}
|
||||
} else {
|
||||
for (Integer keyIndex : doneMap.keySet()) {
|
||||
if (doneMap.get(keyIndex).containsKey(key)) {
|
||||
LAST_SHOT_INDEX = keyIndex;
|
||||
existsKateOrder = doneMap.get(keyIndex).get(key);
|
||||
System.out.println("命中");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (existsKateOrder != null) {
|
||||
// 数据重复
|
||||
existsKateOrders.setRequirementQuantity(existsKateOrders.getRequirementQuantity().add(kateOrdersExcelVo.getRequirementQuantity()));
|
||||
existsKateOrders.setLackQuantity(existsKateOrders.getLackQuantity().add(kateOrdersExcelVo.getRequirementQuantity()));
|
||||
kateOrdersList.add(existsKateOrders);
|
||||
existsKateOrder.setRequirementQuantity(existsKateOrder.getRequirementQuantity().add(kateOrdersExcelVo.getRequirementQuantity()));
|
||||
existsKateOrder.setLackQuantity(existsKateOrder.getLackQuantity().add(kateOrdersExcelVo.getRequirementQuantity()));
|
||||
kateOrdersList.add(existsKateOrder);
|
||||
continue;
|
||||
}
|
||||
KateOrdersLast kateOrdersLast = kateOrdersLastService.getOne(new LambdaQueryWrapper<KateOrdersLast>()
|
||||
.eq(KateOrdersLast::getWorkOrder, kateOrdersExcelVo.getWorkOrder())
|
||||
.eq(KateOrdersLast::getGoodsId, kateOrdersExcelVo.getGoodsId())
|
||||
.eq(KateOrdersLast::getSupplyArea, kateOrdersExcelVo.getSupplyArea())
|
||||
.last("limit 1"));
|
||||
if (kateOrdersLast != null) {
|
||||
List<KateOrdersLast> kateOrdersLastList = this.kateOrdersLastList.stream().filter(kateOrdersLast ->
|
||||
Objects.equals(kateOrdersExcelVo.getWorkOrder(), kateOrdersLast.getWorkOrder())
|
||||
&& Objects.equals(kateOrdersExcelVo.getGoodsId(), kateOrdersLast.getGoodsId())
|
||||
&& Objects.equals(kateOrdersExcelVo.getSupplyArea(), kateOrdersLast.getSupplyArea())
|
||||
).toList();
|
||||
if (!kateOrdersLastList.isEmpty()) {
|
||||
// 之前存在过
|
||||
KateOrdersLast kateOrdersLast = kateOrdersLastList.get(0);
|
||||
KateOrders oldKateOrders = new KateOrders();
|
||||
oldKateOrders.setOrderId(kateOrdersLast.getOrderId());
|
||||
oldKateOrders.setWorkOrder(kateOrdersExcelVo.getWorkOrder());
|
||||
|
|
@ -155,6 +175,7 @@ public class UploadKateOrdersListener implements ReadListener<KateOrdersExcelVo>
|
|||
oldKateOrders.setFinishTime(kateOrdersLast.getFinishTime());
|
||||
oldKateOrders.setUserName(uploadUser);
|
||||
kateOrdersList.add(oldKateOrders);
|
||||
tempDoneMap.put(kateOrdersExcelVo.getWorkOrder() + kateOrdersExcelVo.getGoodsId() + kateOrdersExcelVo.getSupplyArea(), oldKateOrders);
|
||||
} else {
|
||||
// 之前没存在过
|
||||
KateOrders newKateOrders = new KateOrders();
|
||||
|
|
@ -175,9 +196,11 @@ public class UploadKateOrdersListener implements ReadListener<KateOrdersExcelVo>
|
|||
newKateOrders.setPickedQuantity(BigDecimal.ZERO);
|
||||
newKateOrders.setUserName(uploadUser);
|
||||
kateOrdersList.add(newKateOrders);
|
||||
tempDoneMap.put(kateOrdersExcelVo.getWorkOrder() + kateOrdersExcelVo.getGoodsId() + kateOrdersExcelVo.getSupplyArea(), newKateOrders);
|
||||
}
|
||||
}
|
||||
kateOrdersService.saveOrUpdateBatch(kateOrdersList);
|
||||
SAVE_COUNT += kateOrdersList.size();
|
||||
doneMap.put(MAP_INDEX++, tempDoneMap);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,9 @@ import com.alibaba.excel.context.AnalysisContext;
|
|||
import com.alibaba.excel.read.listener.ReadListener;
|
||||
import com.alibaba.excel.util.ListUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.wms.entity.table.KateDBS;
|
||||
import com.wms.entity.table.KateDBSLast;
|
||||
import com.wms.entity.table.WorkStationConfig;
|
||||
import com.wms.service.KateDBSLastService;
|
||||
import com.wms.service.KateDBSService;
|
||||
import com.wms.service.WorkStationConfigService;
|
||||
import com.wms.utils.StringUtils;
|
||||
import com.wms.utils.excel.vo.KateDbsExcelVo;
|
||||
import com.wms.utils.excel.vo.StationConfigExcelVo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -21,7 +16,6 @@ import java.time.LocalDateTime;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.wms.utils.StringUtils.convertJsonString;
|
||||
import static com.wms.utils.WmsUtils.generateId;
|
||||
|
||||
/**
|
||||
|
|
@ -47,8 +41,9 @@ public class UploadStationConfigListener implements ReadListener<StationConfigEx
|
|||
|
||||
@Override
|
||||
public void onException(Exception exception, AnalysisContext context) throws Exception {
|
||||
logger.error("处理工站配置数据发生异常:{}", convertJsonString(exception));
|
||||
ReadListener.super.onException(exception, context);
|
||||
int rowCount = context.readRowHolder().getRowIndex() + 1;
|
||||
logger.error("处理工站配置数据发生异常,第{}行发生异常。", rowCount);
|
||||
throw new Exception("第" + rowCount + "行数据异常。");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -95,6 +90,7 @@ public class UploadStationConfigListener implements ReadListener<StationConfigEx
|
|||
.eq(WorkStationConfig::getSmallBox, stationConfigExcelVo.getSmallBox())
|
||||
.last("limit 1"));
|
||||
if (oldConfig != null) {
|
||||
oldConfig.setOrderQuantity(stationConfigExcelVo.getOrderQuantity());
|
||||
oldConfig.setWorkStation(stationConfigExcelVo.getWorkStation());
|
||||
oldConfig.setVehicle(stationConfigExcelVo.getVehicle());
|
||||
oldConfig.setVehicleLocation(stationConfigExcelVo.getVehicleLocation());
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import static com.wms.constants.WmsConstants.MYSQL_JSON_CI;
|
||||
import static com.wms.utils.StringUtils.convertJsonString;
|
||||
import static com.wms.utils.WmsUtils.generateId;
|
||||
|
||||
/**
|
||||
|
|
@ -40,8 +39,9 @@ public class UploadStocksListener implements ReadListener<StockExcelVo> {
|
|||
|
||||
@Override
|
||||
public void onException(Exception exception, AnalysisContext context) throws Exception {
|
||||
logger.error("处理库存数据发生异常:{}", convertJsonString(exception));
|
||||
ReadListener.super.onException(exception, context);
|
||||
int rowCount = context.readRowHolder().getRowIndex() + 1;
|
||||
logger.error("处理库存数据发生异常,第{}行发生异常。", rowCount);
|
||||
throw new Exception("第" + rowCount + "行数据异常。");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import lombok.Data;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -121,7 +120,7 @@ public class KanbanExcelVo {
|
|||
* @param kanbanList 看板列表
|
||||
*/
|
||||
public void setKanban(List<KanbanEntity> kanbanList) {
|
||||
for (Field field : this.getClass().getDeclaredFields()) {
|
||||
for (Field field : this.getClass().getSuperclass().getDeclaredFields()) {
|
||||
if (field.getName().startsWith("KANBAN")) {
|
||||
int sortNum = -1;
|
||||
try {
|
||||
|
|
@ -150,11 +149,11 @@ public class KanbanExcelVo {
|
|||
*/
|
||||
public List<KanbanEntity> convertToKanbanList() {
|
||||
List<KanbanEntity> kanbanList = new ArrayList<>();
|
||||
for (Field field : this.getClass().getDeclaredFields()) {
|
||||
for (Field field : this.getClass().getSuperclass().getDeclaredFields()) {
|
||||
if (field.getName().startsWith("KANBAN")) {
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
if (StringUtils.isNotEmpty(String.valueOf(field.get(this)))) {
|
||||
if (field.get(this) != null && StringUtils.isNotEmpty(String.valueOf(field.get(this)))) {
|
||||
KanbanEntity kanbanEntity = new KanbanEntity();
|
||||
kanbanEntity.setKanbanId(String.valueOf(field.get(this)));
|
||||
kanbanList.add(kanbanEntity);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.wms.utils.excel.vo;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.wms.entity.table.WorkStationConfig;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
@ -33,6 +34,11 @@ public class StationConfigExcelVo {
|
|||
*/
|
||||
@ExcelProperty("机型")
|
||||
private String model;
|
||||
/**
|
||||
* 工单数/大盒子
|
||||
*/
|
||||
@ExcelProperty("orderQuantity")
|
||||
private Integer orderQuantity;
|
||||
/**
|
||||
* 工位
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user