代码更新

This commit is contained in:
梁州 2024-08-04 23:06:47 +08:00
parent 8fd1c50722
commit f567677685
5 changed files with 57 additions and 81 deletions

View File

@ -11,9 +11,7 @@ import com.wms.entity.app.ResponseEntity;
import com.wms.entity.app.dto.PageDto; import com.wms.entity.app.dto.PageDto;
import com.wms.entity.app.request.ConfigQuery; import com.wms.entity.app.request.ConfigQuery;
import com.wms.entity.app.vo.ConfigVo; import com.wms.entity.app.vo.ConfigVo;
import com.wms.entity.app.vo.VehicleVO;
import com.wms.entity.table.Config; import com.wms.entity.table.Config;
import com.wms.entity.table.Vehicle;
import com.wms.service.ConfigService; import com.wms.service.ConfigService;
import com.wms.utils.HttpUtils; import com.wms.utils.HttpUtils;
import com.wms.utils.StringUtils; import com.wms.utils.StringUtils;

View File

@ -10,10 +10,8 @@ import com.wms.constants.enums.ResponseCode;
import com.wms.entity.app.ResponseEntity; import com.wms.entity.app.ResponseEntity;
import com.wms.entity.app.dto.GoodsDto; import com.wms.entity.app.dto.GoodsDto;
import com.wms.entity.app.dto.PageDto; import com.wms.entity.app.dto.PageDto;
import com.wms.entity.app.request.ELocationQuery;
import com.wms.entity.app.request.GoodsQuery; import com.wms.entity.app.request.GoodsQuery;
import com.wms.entity.app.vo.GoodsVo; import com.wms.entity.app.vo.GoodsVo;
import com.wms.entity.table.ETagLocation;
import com.wms.entity.table.Goods; import com.wms.entity.table.Goods;
import com.wms.service.GoodsService; import com.wms.service.GoodsService;
import com.wms.utils.HttpUtils; import com.wms.utils.HttpUtils;
@ -39,6 +37,7 @@ import static com.wms.utils.StringUtils.convertJsonString;
/** /**
* WMS物料控制类 * WMS物料控制类
*
* @author 梁州 * @author 梁州
* @date 2023/3/9 * @date 2023/3/9
*/ */
@ -64,7 +63,7 @@ public class GoodsController {
@PostMapping("/getGoodsInfoByPage") @PostMapping("/getGoodsInfoByPage")
@ResponseBody @ResponseBody
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED) @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
public String getGoodsInfoByPage(@RequestBody GoodsQuery goodsQuery){ public String getGoodsInfoByPage(@RequestBody GoodsQuery goodsQuery) {
logger.info("接收到查询物料数据请求:{}请求ip{}", convertJsonString(goodsQuery), HttpUtils.getIpAddr(servletRequest)); logger.info("接收到查询物料数据请求:{}请求ip{}", convertJsonString(goodsQuery), HttpUtils.getIpAddr(servletRequest));
ResponseEntity response = new ResponseEntity(); ResponseEntity response = new ResponseEntity();
try { try {
@ -134,6 +133,7 @@ public class GoodsController {
/** /**
* 查询物料信息 * 查询物料信息
*
* @param goodsQuery 参数 * @param goodsQuery 参数
* @return 结果 * @return 结果
*/ */
@ -167,6 +167,7 @@ public class GoodsController {
/** /**
* 自动补全物料编码信息---根据物料编号查询物料信息 * 自动补全物料编码信息---根据物料编号查询物料信息
*
* @param goodsQuery 参数 * @param goodsQuery 参数
* @return 结果 * @return 结果
*/ */
@ -261,8 +262,8 @@ public class GoodsController {
try { try {
List<Goods> goodsList = new ArrayList<>(); List<Goods> goodsList = new ArrayList<>();
for (int i = 1; i <= 250; i++) { for (int i = 1; i <= 250; i++) {
Goods goods = new Goods(); Goods goods = new Goods();
goods.setGoodsId("ASRS" + StringUtils.padLeft(String.valueOf(i), 6, "0")); goods.setGoodsId("ASRS" + StringUtils.padLeft(String.valueOf(i), 6, "0"));
goods.setGoodsName("测试物料" + StringUtils.padLeft(String.valueOf(i), 6, "0")); goods.setGoodsName("测试物料" + StringUtils.padLeft(String.valueOf(i), 6, "0"));
goods.setGoodsType("直接物料"); goods.setGoodsType("直接物料");
goods.setGoodsUnit("PC"); goods.setGoodsUnit("PC");
@ -277,7 +278,7 @@ public class GoodsController {
goods.setFeedingType("PULL"); goods.setFeedingType("PULL");
goods.setLastUpdateTime(LocalDateTime.now()); goods.setLastUpdateTime(LocalDateTime.now());
goods.setLastUpdateUser("WMS"); goods.setLastUpdateUser("WMS");
goodsList.add(goods); goodsList.add(goods);
} }
goodsService.saveOrUpdateBatch(goodsList); goodsService.saveOrUpdateBatch(goodsList);

View File

@ -50,7 +50,7 @@ public class JobComponent {
* 每2秒执行一次 * 每2秒执行一次
*/ */
@Async @Async
@Scheduled(fixedDelay = 2000) // @Scheduled(fixedDelay = 2000)
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED) @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
public void executeTasks() { public void executeTasks() {
String sendTask = configMap.get(ConfigMapKeyEnum.SEND_TASK.getConfigKey()); String sendTask = configMap.get(ConfigMapKeyEnum.SEND_TASK.getConfigKey());
@ -85,7 +85,7 @@ public class JobComponent {
* 检测工作 * 检测工作
*/ */
@Async @Async
@Scheduled(fixedDelay = 2000) // @Scheduled(fixedDelay = 2000)
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED) @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
public void detectWork() { public void detectWork() {
String startWork = configMap.get(ConfigMapKeyEnum.START_WORK.getConfigKey()); String startWork = configMap.get(ConfigMapKeyEnum.START_WORK.getConfigKey());

View File

@ -11,6 +11,7 @@ import com.wms.entity.app.request.ELocationQuery;
import com.wms.entity.app.request.LocationQuery; import com.wms.entity.app.request.LocationQuery;
import com.wms.entity.app.request.VehicleQuery; import com.wms.entity.app.request.VehicleQuery;
import com.wms.entity.app.ResponseEntity; import com.wms.entity.app.ResponseEntity;
import com.wms.entity.app.vo.LocationVo;
import com.wms.entity.app.vo.VehicleVO; import com.wms.entity.app.vo.VehicleVO;
import com.wms.entity.table.ETagLocation; import com.wms.entity.table.ETagLocation;
import com.wms.entity.table.Location; import com.wms.entity.table.Location;
@ -66,76 +67,40 @@ public class LocationController {
*/ */
private final HttpServletRequest servletRequest; private final HttpServletRequest servletRequest;
/**
* 查询库位信息
* @param locationQuery 查询参数
* @return 结果
*/
@PostMapping("/getLocationsByPage")
@ResponseBody
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
@MyLog(logTitle = "查询库位信息", logMethod = "getLocationsByPage")
public String getLocationsByPage(@RequestBody LocationQuery locationQuery) {
logger.info("接收到查询库位信息请求:{}请求ip{}", convertJsonString(locationQuery), HttpUtils.getIpAddr(servletRequest));
ResponseEntity response = new ResponseEntity();
try {
Page<Location> page = locationQuery.toMpPage();
Page<Location> locationPage = locationService.page(page, new LambdaQueryWrapper<Location>()
.like(StringUtils.isNotEmpty(locationQuery.getLocationId()), Location::getLocationId, locationQuery.getLocationId())
.like(StringUtils.isNotEmpty(locationQuery.getVehicleId()), Location::getVehicleId, locationQuery.getVehicleId())
.eq(locationQuery.getLocationStatus() != null, Location::getLocationStatus, locationQuery.getLocationStatus())
.eq(locationQuery.getIsLock() != null, Location::getIsLock, locationQuery.getIsLock()));
// /** PageDto<LocationVo> pageDto = PageDto.of(locationPage, location -> BeanUtil.copyProperties(location, LocationVo.class));
// * 查询库位 response.setCode(ResponseCode.OK.getCode());
// * response.setMessage("查询成功");
// * @param locationQuery 查询参数 response.setReturnData(pageDto);
// * @return 结果 return convertJsonString(response);
// */ } catch (Exception e) {
// @PostMapping("/getLocations") // 回滚事务
// @ResponseBody TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
// @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED) logger.error("查询库位信息发生异常");
// @MyLog(logTitle = "删除物料信息", logMethod = "getLocations") response.setCode(ResponseCode.ERROR.getCode());
// public String getLocations(@RequestBody LocationQuery locationQuery) { response.setMessage("查询库位信息发生异常");
// // 创建响应信息 return convertJsonString(response);
// ResponseEntity rsp = new ResponseEntity(); }
// try { }
// // 查询出所有符合条件的库位
// List<LocationDto> locations = locationService.selLocations(location);
// if (locations.size() < 1) {
// logger.error("查询库位发生错误:库位不存在");
// // 返回错误
// rsp.setCode(ResponseCode.ERROR.getCode());
// rsp.setMessage("查询库位发生错误:库位不存在");
// return JSON.toJSONString(rsp);
// }
// List<RowLocation> rowLocations = new LinkedList<>();
// // 查找到最大的排
// locations.sort(Comparator.comparing(LocationDto::getQueue).reversed());
// int maxRow = locations.get(0).getQueue();
// // 按排查找库位
// for (int i = 0; i < maxRow; i++) {
// int finalI = i;
// List<LocationDto> currentRowLocations = new ArrayList<>(locations.stream()
// .filter(l -> l.getQueue().equals(finalI + 1))
// .toList());
// // 先查找每一层的库位
// List<LayerLocation> layerLocations = new LinkedList<>();
// // 找到这一排最大的层
// currentRowLocations.sort(Comparator.comparing(LocationDto::getLayer).reversed());
// int maxLayer = currentRowLocations.get(0).getLayer();
// // 按照每一列查找库位
// for (int j = 0; j < maxLayer; j++) {
// int finalJ = j;
// List<LocationDto> currentLayerLocations = currentRowLocations.stream()
// .filter(l -> l.getLayer().equals(finalJ + 1))
// .toList();
// LayerLocation tempLayerLocation = new LayerLocation();
// tempLayerLocation.setLayer(finalJ + 1);
// tempLayerLocation.setCurrentColLocations(currentLayerLocations);
// layerLocations.add(tempLayerLocation);
// }
// RowLocation tempRowLocation = new RowLocation();
// tempRowLocation.setRow(finalI + 1);
// tempRowLocation.setCurrentLayerLocations(layerLocations);
// rowLocations.add(tempRowLocation);
// }
// logger.info("查询库位数据成功,库区:{}", location.getAreaId());
// // 设置最终数据
// rsp.setReturnData(rowLocations);
// // 返回成功
// rsp.setCode(ResponseCode.OK.getCode());
// rsp.setMessage("查询库位成功");
// return JSON.toJSONString(rsp);
// } catch (Exception e) {
// logger.info("查询库位发生错误:{}", e.getMessage());
// // 返回其他异常
// rsp.setCode(ResponseCode.ERROR.getCode());
// rsp.setMessage(e.getMessage());
// return JSON.toJSONString(rsp);
// }
// }
/** /**
* 更新库位信息 * 更新库位信息
@ -321,8 +286,8 @@ public class LocationController {
Page<Vehicle> page = vehicleQuery.toMpPage(); Page<Vehicle> page = vehicleQuery.toMpPage();
Page<Vehicle> vehiclePage = vehicleService.page(page, new LambdaQueryWrapper<Vehicle>() Page<Vehicle> vehiclePage = vehicleService.page(page, new LambdaQueryWrapper<Vehicle>()
.like(StringUtils.isNotEmpty(vehicleQuery.getVehicleId()), Vehicle::getVehicleId, vehicleQuery.getVehicleId()) .like(StringUtils.isNotEmpty(vehicleQuery.getVehicleId()), Vehicle::getVehicleId, vehicleQuery.getVehicleId())
.eq(vehicleQuery.getVehicleStatus() == null, Vehicle::getVehicleStatus, vehicleQuery.getVehicleStatus()) .eq(vehicleQuery.getVehicleStatus() != null, Vehicle::getVehicleStatus, vehicleQuery.getVehicleStatus())
.eq(vehicleQuery.getIsEmpty() == null, Vehicle::getIsEmpty, vehicleQuery.getIsEmpty())); .eq(vehicleQuery.getIsEmpty() != null, Vehicle::getIsEmpty, vehicleQuery.getIsEmpty()));
PageDto<VehicleVO> pageDto = PageDto.of(vehiclePage, vehicle -> BeanUtil.copyProperties(vehicle, VehicleVO.class)); PageDto<VehicleVO> pageDto = PageDto.of(vehiclePage, vehicle -> BeanUtil.copyProperties(vehicle, VehicleVO.class));
response.setCode(ResponseCode.OK.getCode()); response.setCode(ResponseCode.OK.getCode());

View File

@ -1,5 +1,6 @@
package com.wms.entity.app.vo; package com.wms.entity.app.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data; import lombok.Data;
@Data @Data
@ -7,45 +8,56 @@ public class LocationVo {
/** /**
* 库位编号 * 库位编号
*/ */
@JsonProperty("locationId")
private String locationId; private String locationId;
/** /**
* 库区编号 * 库区编号
*/ */
@JsonProperty("areaId")
private Integer areaId; private Integer areaId;
/** /**
* 设备编号 * 设备编号
*/ */
@JsonProperty("equipmentId")
private Integer equipmentId; private Integer equipmentId;
/** /**
* 库位类型 * 库位类型
*/ */
@JsonProperty("locationType")
private Integer locationType; private Integer locationType;
/** /**
* *
*/ */
@JsonProperty("wRow")
private Integer wRow; private Integer wRow;
/** /**
* *
*/ */
@JsonProperty("wCol")
private Integer wCol; private Integer wCol;
/** /**
* *
*/ */
@JsonProperty("wLayer")
private Integer wLayer; private Integer wLayer;
/** /**
* 深度 * 深度
*/ */
@JsonProperty("wDepth")
private Integer wDepth; private Integer wDepth;
/** /**
* 是否锁定 * 是否锁定
*/ */
@JsonProperty("isLock")
private Integer isLock; private Integer isLock;
/** /**
* 库位状态 * 库位状态
*/ */
@JsonProperty("locationStatus")
private Integer locationStatus; private Integer locationStatus;
/** /**
* 载具号 * 载具号
*/ */
@JsonProperty("vehicleId")
private String vehicleId; private String vehicleId;
} }