代码更新
This commit is contained in:
parent
cb54c0fdea
commit
1f298e89d6
|
|
@ -6,7 +6,9 @@ public enum ConfigMapKeyEnum {
|
|||
URL_NEW_DESTINATION("URL_NEW_DESTINATION"),
|
||||
URL_WCS_PICK_TASK("URL_WCS_PICK_TASK"),
|
||||
URL_WCS_E_TASK("URL_WCS_E_TASK"),
|
||||
URL_WCS_DISPOSE_VEHICLE("URL_WCS_DISPOSE_VEHICLE");
|
||||
URL_WCS_DISPOSE_VEHICLE("URL_WCS_DISPOSE_VEHICLE"),
|
||||
START_WORK("START_WORK"),
|
||||
SEND_TASK("SEND_TASK");
|
||||
private final String configKey;
|
||||
ConfigMapKeyEnum(String configKey) {
|
||||
this.configKey = configKey;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@ import com.wms.constants.enums.ResponseCode;
|
|||
import com.wms.entity.app.ResponseEntity;
|
||||
import com.wms.entity.app.dto.GoodsDto;
|
||||
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.vo.GoodsVo;
|
||||
import com.wms.entity.table.ETagLocation;
|
||||
import com.wms.entity.table.Goods;
|
||||
import com.wms.service.GoodsService;
|
||||
import com.wms.utils.HttpUtils;
|
||||
|
|
@ -28,6 +30,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.wms.utils.StringUtils.convertJsonString;
|
||||
|
|
@ -237,4 +242,57 @@ public class GoodsController {
|
|||
return convertJsonString(rsp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成测试物料数据
|
||||
*
|
||||
* @param goodsQuery 物料
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/genGoods")
|
||||
@ResponseBody
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
@MyLog(logTitle = "生成物料表", logMethod = "genGoods")
|
||||
public String genGoods(@RequestBody GoodsQuery goodsQuery) {
|
||||
// 9*64*22
|
||||
logger.info("生成测试物料:{},请求ip地址:{}", convertJsonString(goodsQuery), HttpUtils.getIpAddr(servletRequest));
|
||||
// 创建响应信息
|
||||
ResponseEntity rsp = new ResponseEntity();
|
||||
try {
|
||||
List<Goods> goodsList = new ArrayList<>();
|
||||
for (int i = 1; i <= 250; i++) {
|
||||
Goods goods = new Goods();
|
||||
goods.setGoodsId("ASRS" + StringUtils.padLeft(String.valueOf(i), 6, "0"));
|
||||
goods.setGoodsName("测试物料" + StringUtils.padLeft(String.valueOf(i), 6, "0"));
|
||||
goods.setGoodsType("直接物料");
|
||||
goods.setGoodsUnit("PC");
|
||||
goods.setProviderType("CLC");
|
||||
goods.setWeight(BigDecimal.ONE);
|
||||
goods.setWeightUnit("KG");
|
||||
goods.setQuantityPerBox(BigDecimal.valueOf(20));
|
||||
goods.setUnpackingType("套袋子");
|
||||
goods.setVehicleType("FC01");
|
||||
goods.setVehicleTypeDescription("822整体1个");
|
||||
goods.setGoodsInVehicleType("CLC一箱一料");
|
||||
goods.setFeedingType("PULL");
|
||||
goods.setLastUpdateTime(LocalDateTime.now());
|
||||
goods.setLastUpdateUser("WMS");
|
||||
goodsList.add(goods);
|
||||
}
|
||||
goodsService.saveOrUpdateBatch(goodsList);
|
||||
|
||||
logger.info("生成测试物料成功。");
|
||||
rsp.setCode(ResponseCode.OK.getCode());
|
||||
rsp.setMessage("生成测试物料成功。");
|
||||
return convertJsonString(rsp);
|
||||
} catch (Exception e) {
|
||||
// 回滚事务
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
logger.info("生成测试物料异常:{}", convertJsonString(e));
|
||||
// 返回其他异常
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage("生成测试物料异常");
|
||||
return convertJsonString(rsp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
package com.wms.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.wms.constants.enums.ConfigMapKeyEnum;
|
||||
import com.wms.entity.table.Stand;
|
||||
import com.wms.service.*;
|
||||
import com.wms.service.business.IWmsJobService;
|
||||
import com.wms.service.business.IWorkService;
|
||||
import com.wms.utils.StringUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -17,6 +19,7 @@ import org.springframework.transaction.annotation.Propagation;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import static com.wms.config.InitLocalConfig.configMap;
|
||||
import static com.wms.utils.StringUtils.convertJsonString;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -50,6 +53,11 @@ public class JobComponent {
|
|||
@Scheduled(fixedDelay = 2000)
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
public void executeTasks() {
|
||||
String sendTask = configMap.get(ConfigMapKeyEnum.SEND_TASK.getConfigKey());
|
||||
if (StringUtils.isEmpty(sendTask) || !sendTask.equals("1")) {
|
||||
logger.info("暂停发送任务,跳过...");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// 发送正常任务
|
||||
wmsJobService.sendCommonTasks();
|
||||
|
|
@ -80,6 +88,11 @@ public class JobComponent {
|
|||
@Scheduled(fixedDelay = 2000)
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
public void detectWork() {
|
||||
String startWork = configMap.get(ConfigMapKeyEnum.START_WORK.getConfigKey());
|
||||
if (StringUtils.isEmpty(startWork) || !startWork.equals("1")) {
|
||||
logger.info("未开始工作,跳过...");
|
||||
return;
|
||||
}
|
||||
// 轮询工作站台,判断是否需要下发任务
|
||||
List<Stand> stands = standService.list(new LambdaQueryWrapper<Stand>()
|
||||
.eq(Stand::getIsLock, 0).eq(Stand::getStandStatus, 0)
|
||||
|
|
|
|||
|
|
@ -7,12 +7,15 @@ 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.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.VehicleVO;
|
||||
import com.wms.entity.table.ETagLocation;
|
||||
import com.wms.entity.table.Location;
|
||||
import com.wms.entity.table.Vehicle;
|
||||
import com.wms.service.ETagLocationService;
|
||||
import com.wms.service.LocationService;
|
||||
import com.wms.service.VehicleService;
|
||||
import com.wms.utils.HttpUtils;
|
||||
|
|
@ -54,6 +57,10 @@ public class LocationController {
|
|||
* 料箱服务
|
||||
*/
|
||||
private final VehicleService vehicleService;
|
||||
/**
|
||||
* 电子标签库位服务
|
||||
*/
|
||||
private final ETagLocationService etagLocationService;
|
||||
/**
|
||||
* 请求头部信息
|
||||
*/
|
||||
|
|
@ -184,7 +191,7 @@ public class LocationController {
|
|||
@PostMapping("/genLocations")
|
||||
@ResponseBody
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
@MyLog(logTitle = "更新库位信息", logMethod = "genLocations")
|
||||
@MyLog(logTitle = "生成库位表", logMethod = "genLocations")
|
||||
public String genLocations(@RequestBody LocationQuery locationQuery) {
|
||||
// 9*64*22
|
||||
logger.info("接收到生成库位表数据请求:{},请求ip地址:{}", convertJsonString(locationQuery), HttpUtils.getIpAddr(servletRequest));
|
||||
|
|
@ -251,6 +258,53 @@ public class LocationController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成电子标签库位表数据
|
||||
*
|
||||
* @param eLocationQuery 库位
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/genELocations")
|
||||
@ResponseBody
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
@MyLog(logTitle = "生成电子标签库位表", logMethod = "genELocations")
|
||||
public String genELocations(@RequestBody ELocationQuery eLocationQuery) {
|
||||
// 9*64*22
|
||||
logger.info("接收到生成电子标签库位表数据请求:{},请求ip地址:{}", convertJsonString(eLocationQuery), HttpUtils.getIpAddr(servletRequest));
|
||||
// 创建响应信息
|
||||
ResponseEntity rsp = new ResponseEntity();
|
||||
try {
|
||||
List<ETagLocation> eLocations = new ArrayList<>();
|
||||
for (int i = 1; i <= 9; i++) {
|
||||
for (int j = 1; j <= 48; j++) {
|
||||
ETagLocation eTagLocation = new ETagLocation();
|
||||
eTagLocation.setELocationId(i + "-" + StringUtils.padLeft(String.valueOf(j), 2, "0"));
|
||||
eTagLocation.setAreaId(String.valueOf(i));
|
||||
eTagLocation.setSequenceId(j);
|
||||
eTagLocation.setELocationStatus(0);
|
||||
eTagLocation.setWorkStation("ASRS-#" + i);
|
||||
eTagLocation.setPickStatus(0);
|
||||
eLocations.add(eTagLocation);
|
||||
}
|
||||
}
|
||||
etagLocationService.remove(new LambdaQueryWrapper<>());
|
||||
etagLocationService.saveBatch(eLocations);
|
||||
|
||||
logger.info("生成电子标签库位成功。");
|
||||
rsp.setCode(ResponseCode.OK.getCode());
|
||||
rsp.setMessage("生成电子标签库位成功。");
|
||||
return convertJsonString(rsp);
|
||||
} catch (Exception e) {
|
||||
// 回滚事务
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
logger.info("生成电子标签库位异常:{}", convertJsonString(e));
|
||||
// 返回其他异常
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage("生成电子标签库位异常");
|
||||
return convertJsonString(rsp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询料箱信息
|
||||
* @param vehicleQuery 查询参数
|
||||
|
|
|
|||
|
|
@ -1038,6 +1038,16 @@ public class TaskController {
|
|||
}
|
||||
// 更新workFlow
|
||||
workFlowService.updateById(workFlow);
|
||||
// 更新库存数量
|
||||
Stock existStock = stockService.getOne(new LambdaQueryWrapper<Stock>()
|
||||
.apply("goods_related -> '$.goodsId' = {0}", workFlow.getGoodsId())
|
||||
.eq(Stock::getVehicleId, eTaskFeedbackRequest.getVehicleNo()));
|
||||
if (existStock != null && existStock.getGoodsRelated() != null) {
|
||||
StockDetailInfo goodsDetail = existStock.getGoodsRelated();
|
||||
goodsDetail.setRemainNum(goodsDetail.getRemainNum().subtract(BigDecimal.valueOf(eTaskFeedbackRequest.getConfirmNum())));
|
||||
existStock.setGoodsRelated(goodsDetail);
|
||||
stockService.updateById(existStock);
|
||||
}
|
||||
// 更新亮灯信息
|
||||
etagLocationService.update(new LambdaUpdateWrapper<ETagLocation>()
|
||||
.set(ETagLocation::getPickStatus, 0)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
|
@ -42,7 +43,7 @@ public class GoodsDto {
|
|||
/**
|
||||
* 最后更新日期
|
||||
*/
|
||||
private Date lastUpdateTime;
|
||||
private LocalDateTime lastUpdateTime;
|
||||
/**
|
||||
* 最后更新用户
|
||||
*/
|
||||
|
|
|
|||
75
src/main/java/com/wms/entity/app/request/ELocationQuery.java
Normal file
75
src/main/java/com/wms/entity/app/request/ELocationQuery.java
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
package com.wms.entity.app.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 电子标签库位查询请求
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ELocationQuery extends PageQuery {
|
||||
/**
|
||||
* 库位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;
|
||||
}
|
||||
|
|
@ -5,8 +5,6 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 电子标签库位信息
|
||||
*/
|
||||
|
|
@ -41,20 +39,30 @@ public class ETagLocation {
|
|||
@TableField("work_station")
|
||||
private String workStation;
|
||||
/**
|
||||
* 工单工位盒子号
|
||||
* 任务号
|
||||
*/
|
||||
@TableField("order_box_no")
|
||||
private String orderBoxNo;
|
||||
@TableField("task_id")
|
||||
private String taskId;
|
||||
/**
|
||||
* 物料编号
|
||||
* 箱号
|
||||
*/
|
||||
@TableField("goods_id")
|
||||
private String goodsId;
|
||||
@TableField("vehicle_no")
|
||||
private String vehicleNo;
|
||||
/**
|
||||
* 数量
|
||||
* 需求数量
|
||||
*/
|
||||
@TableField("quantity")
|
||||
private BigDecimal quantity;
|
||||
@TableField("need_num")
|
||||
private Integer needNum;
|
||||
/**
|
||||
* 确认数量
|
||||
*/
|
||||
@TableField("confirm_num")
|
||||
private Integer confirmNum;
|
||||
/**
|
||||
* 任务类型
|
||||
*/
|
||||
@TableField("task_type")
|
||||
private Integer taskType;
|
||||
/**
|
||||
* 拣货状态
|
||||
* 0:未亮灯
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.wms.entity.app.dto.extend.KanbanEntity;
|
|||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -128,7 +129,7 @@ public class Goods {
|
|||
* 最后更新日期
|
||||
*/
|
||||
@TableField("last_update_time")
|
||||
private Date lastUpdateTime;
|
||||
private LocalDateTime lastUpdateTime;
|
||||
/**
|
||||
* 最后更新用户
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.wms.service.serviceImplements;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.wms.constants.enums.StockStatus;
|
||||
import com.wms.entity.table.Location;
|
||||
|
|
@ -17,6 +18,7 @@ import lombok.RequiredArgsConstructor;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
|
|
@ -41,6 +43,7 @@ public class LocationServiceImplements extends ServiceImpl<LocationMapper, Locat
|
|||
|
||||
/**
|
||||
* 查找一个可用库位
|
||||
*
|
||||
* @param inPoint 入库站点
|
||||
* @param goodsId 物料编号--可选
|
||||
* @return 结果
|
||||
|
|
@ -90,6 +93,9 @@ public class LocationServiceImplements extends ServiceImpl<LocationMapper, Locat
|
|||
for (Stand lruStand : LRUStands) {
|
||||
getOneLocationByEquipmentId(resultMap, locationQueryWrapper, lruStand.getEquipmentId());
|
||||
if (!resultMap.isEmpty()) {
|
||||
// 更新最近使用时间
|
||||
lruStand.setLastUseTime(LocalDateTime.now());
|
||||
standMapper.updateById(lruStand);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -101,6 +107,7 @@ public class LocationServiceImplements extends ServiceImpl<LocationMapper, Locat
|
|||
|
||||
/**
|
||||
* 根据设备号查找库位
|
||||
*
|
||||
* @param resultMap 结果集
|
||||
* @param locationQueryWrapper 查询条件
|
||||
* @param equipmentId 设备号
|
||||
|
|
@ -114,6 +121,10 @@ public class LocationServiceImplements extends ServiceImpl<LocationMapper, Locat
|
|||
List<Location> availableLocations = locationMapper.selectList(locationQueryWrapper);
|
||||
for (Location oneAvailableLocation : availableLocations) {
|
||||
resultMap.put("nextLocationId", oneAvailableLocation.getLocationId());
|
||||
standMapper.update(new LambdaUpdateWrapper<Stand>()
|
||||
.set(Stand::getLastUseTime, LocalDateTime.now())
|
||||
.eq(Stand::getEquipmentId, equipmentId)
|
||||
.eq(Stand::getStandType, 3));
|
||||
break;
|
||||
}
|
||||
return resultMap;
|
||||
|
|
@ -121,6 +132,7 @@ public class LocationServiceImplements extends ServiceImpl<LocationMapper, Locat
|
|||
|
||||
/**
|
||||
* 根据最近最久未使用加物料来判断应该使用哪个设备
|
||||
*
|
||||
* @param LRUStands 符合的设备
|
||||
* @param goodsId 物料编号
|
||||
* @return 设备号
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user