冲孔回立库增加任务明细数据

重入库二次判断是否有占用
main
Comair 1 year ago
parent 45ec292663
commit e40fbd2baf
  1. 5
      shkj-admin/src/main/resources/application-test.yml
  2. 219
      shkj-admin/src/test/java/com/shkj/testB.java
  3. 2
      shkj-wms/src/main/java/com/shkj/wms/enums/TaskTypeEnum.java
  4. 14
      shkj-wms/src/main/java/com/shkj/wms/plc/PlcEventTask.java
  5. 33
      shkj-wms/src/main/java/com/shkj/wms/scheduled/ScheduledTasks.java
  6. 2
      shkj-wms/src/main/java/com/shkj/wms/service/IBaseLocationService.java
  7. 9
      shkj-wms/src/main/java/com/shkj/wms/service/impl/BaseLocationServiceImpl.java
  8. 52
      shkj-wms/src/main/java/com/shkj/wms/service/impl/StackServiceImpl.java
  9. 5
      shkj-wms/src/main/java/com/shkj/wms/service/impl/SysStockDetailServiceImpl.java
  10. 2
      shkj-wms/src/main/java/com/shkj/wms/service/impl/SysStockServiceImpl.java

@ -13,13 +13,12 @@ spring:
# 主库数据源
master:
url: jdbc:mysql://127.0.0.1:3306/po1_wms_wcs?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# url: jdbc:mysql://127.0.0.1:3306/po1testsh?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
password: root
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
enabled: falsegetGoodsInfoByDerive
url:
username:
password:

@ -1,104 +1,115 @@
//package com.shkj;
//
//
//import io.swagger.models.auth.In;
//import org.apache.commons.lang3.tuple.ImmutablePair;
//import org.apache.commons.lang3.tuple.Pair;
//import org.apache.poi.ss.formula.functions.T;
//import org.junit.Test;
//
//import java.util.*;
//import java.util.stream.Collectors;
//
//public class testB {
//
//
//
//
// public class WeightRandomStrategy<k, V extends Number> {
// private TreeMap<Double, k> weightMap = new TreeMap<>();
// private Map<String, Integer> map =new HashMap();
// private Map nmap =new HashMap();
// private TreeMap<Double,k> Map = new TreeMap<>();
//
// public WeightRandomStrategy(List<Pair<k, V>> list) {
// for (Pair<k, V> pair : list) {
// nmap.put(pair.getKey(),pair.getValue());
// map.put(String.valueOf(pair.getKey()),0);
// double lastWeight = this.weightMap.size() == 0 ? 0 : this.weightMap.lastKey();
// this.weightMap.put(pair.getValue().doubleValue() + lastWeight, pair.getKey());
// }
// }
//
// public java.lang.String randome(){
// Map.putAll(weightMap);
// String k = random();
// return k;
// }
//
// public String random() {
//
// Double aDouble = this.Map.lastKey();
// double random = Math.random();
// double randomWeight = aDouble* random;
// SortedMap<Double, k> tailMap = this.Map.tailMap(randomWeight, false);
// String k = String.valueOf(this.Map.get(tailMap.firstKey()));
// int o = (Integer) this.nmap.get(k);
// int o2 = (Integer)map.get(k);
// if (o2==o){
// System.out.println("========"+k);
// Map.remove(tailMap.firstKey());
//
// if (Map.size()==0){
// List collect = map.entrySet().stream().map(java.util.Map.Entry::getKey).collect(Collectors.toList());
// collect.stream().forEach(e->{
// map.put(String.valueOf(e),0);
// });
// Map.putAll(weightMap);
// }
// k=random();
// return k;
// }
// Integer o1 = (Integer) map.get(k);
// map.put(k,o1+1);
// return k;
// }
// }
// @Test
// public void testb(){
// List<Pair<String, Integer>> list = new ArrayList<>();
// list.add(new ImmutablePair<>("RKu", 2));
// list.add(new ImmutablePair<>("Cku", 2));
// list.add(new ImmutablePair<>("CKong", 1));
// list.add(new ImmutablePair<>("YChang", 1));
// list.add(new ImmutablePair<>("HLiu", 1));
// list.add(new ImmutablePair<>("JinCK", 1));
// list.add(new ImmutablePair<>("TE",3));
// WeightRandomStrategy<String, Integer> strategy = new WeightRandomStrategy<>(list);
// int a = 0, b = 0,c = 0,d = 0,e = 0,f =0,g = 0;
// for (int i = 0; i < 10014; i++) {
// String randome = strategy.randome();
// System.out.println(randome);
// switch (randome){
// case "RKu": a++;break;
// case "Cku":b++;break;
// case "CKong":c++;break;
// case "YChang":d++;break;
// case "HLiu":e++;break;
// case "JinCK":f++;break;
// case "TE":g++;break;
// }
// }
// System.out.println("a=" + a + ", b=" + b+", c=" + c+", d=" + d+", e=" + e+", f=" + f+", g=" + g);
// System.out.println("a+b=" + (a + b+c+d+e+f+g));
//
// }
//
// @Test
// public void test01(){
// List list = new ArrayList();
// System.out.println(list.size());
// }
//
//
//}
package com.shkj;
import com.shkj.wms.service.ISysAppVersionService;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.poi.ss.formula.functions.T;
import org.junit.Test;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
public class testB {
public class WeightRandomStrategy<k, V extends Number> {
private TreeMap<Double, k> weightMap = new TreeMap<>();
private Map<String, Integer> map =new HashMap();
private Map nmap =new HashMap();
private TreeMap<Double,k> Map = new TreeMap<>();
public WeightRandomStrategy(List<Pair<k, V>> list) {
for (Pair<k, V> pair : list) {
nmap.put(pair.getKey(),pair.getValue());
map.put(String.valueOf(pair.getKey()),0);
double lastWeight = this.weightMap.size() == 0 ? 0 : this.weightMap.lastKey();
this.weightMap.put(pair.getValue().doubleValue() + lastWeight, pair.getKey());
}
}
public java.lang.String randome(){
Map.putAll(weightMap);
String k = random();
return k;
}
public String random() {
Double aDouble = this.Map.lastKey();
double random = Math.random();
double randomWeight = aDouble* random;
SortedMap<Double, k> tailMap = this.Map.tailMap(randomWeight, false);
String k = String.valueOf(this.Map.get(tailMap.firstKey()));
int o = (Integer) this.nmap.get(k);
int o2 = (Integer)map.get(k);
if (o2==o){
System.out.println("========"+k);
Map.remove(tailMap.firstKey());
if (Map.size()==0){
List collect = map.entrySet().stream().map(java.util.Map.Entry::getKey).collect(Collectors.toList());
collect.stream().forEach(e->{
map.put(String.valueOf(e),0);
});
Map.putAll(weightMap);
}
k=random();
return k;
}
Integer o1 = (Integer) map.get(k);
map.put(k,o1+1);
return k;
}
}
@Test
public void testb(){
List<Pair<String, Integer>> list = new ArrayList<>();
list.add(new ImmutablePair<>("RKu", 2));
list.add(new ImmutablePair<>("Cku", 2));
list.add(new ImmutablePair<>("CKong", 1));
list.add(new ImmutablePair<>("YChang", 1));
list.add(new ImmutablePair<>("HLiu", 1));
list.add(new ImmutablePair<>("JinCK", 1));
list.add(new ImmutablePair<>("TE",3));
WeightRandomStrategy<String, Integer> strategy = new WeightRandomStrategy<>(list);
int a = 0, b = 0,c = 0,d = 0,e = 0,f =0,g = 0;
for (int i = 0; i < 10014; i++) {
String randome = strategy.randome();
System.out.println(randome);
switch (randome){
case "RKu": a++;break;
case "Cku":b++;break;
case "CKong":c++;break;
case "YChang":d++;break;
case "HLiu":e++;break;
case "JinCK":f++;break;
case "TE":g++;break;
}
}
System.out.println("a=" + a + ", b=" + b+", c=" + c+", d=" + d+", e=" + e+", f=" + f+", g=" + g);
System.out.println("a+b=" + (a + b+c+d+e+f+g));
}
@Test
public void test01(){
List list = new ArrayList();
System.out.println(list.size());
}
@Test
public void tees02(){
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.DATE, 98);
System.out.println("获取的新的时间:"+c.getTime());
}
}

@ -114,7 +114,7 @@ public enum TaskTypeEnum {
/**
* 指定货位出库
*/
named_loc("22","指定货位出库"),
named_loc("25","指定货位出库"),
/**
* 23 跨巷道移库出库

@ -136,7 +136,7 @@ public class PlcEventTask {
private ScheduledExecutorService executorService = Executors.newScheduledThreadPool(8);
@Scheduled(fixedRate = 200)
// @Scheduled(fixedRate = 200)
public void init() {
//查询需要连接的PLC,初始化连接对象
List<WcsPlcConnectVo> plcList = iWcsPlcConnectService.selectWcsPlcConnectList(new WcsPlcConnect().setIsActive("1"));
@ -219,7 +219,7 @@ public class PlcEventTask {
}
}
@Scheduled(fixedRate = 200)
// @Scheduled(fixedRate = 200)
public void init1() {
//查询需要连接的PLC,初始化连接对象
List<WcsPlcConnectVo> plcList = iWcsPlcConnectService.selectWcsPlcConnectList(new WcsPlcConnect().setIsActive("1"));
@ -237,7 +237,7 @@ public class PlcEventTask {
}
}
@Scheduled(fixedRate = 200)
// @Scheduled(fixedRate = 200)
public void init2() {
//查询需要连接的PLC,初始化连接对象
List<WcsPlcConnectVo> plcList = iWcsPlcConnectService.selectWcsPlcConnectList(new WcsPlcConnect().setIsActive("1"));
@ -255,7 +255,7 @@ public class PlcEventTask {
}
}
@Scheduled(fixedDelay = 6000)
// @Scheduled(fixedDelay = 6000)
public void writePlcheartbeat() {
//根据连接的plcId获取属性
PlcOperate plcOperate = plcInit.getPlcOperate_41();
@ -930,10 +930,14 @@ public class PlcEventTask {
//重新验证货位状态是否有货,如果有则重新分配货位,只获取当前货位中可用货位
Long locationId = businDataTask.getLocationId();
BaseLocation baseLocation = iBaseLocationService.getById(locationId);
log.info("给堆垛机下发任务时,原货位:"+JsonUtil.toJSONString(baseLocation));
if (baseLocation == null){
baseLocation= iBaseLocationService.queryBaseLocationByrcl(businDataTask.getToRow(), businDataTask.getToColumn(),businDataTask.getToLayer(),businDataTask.getTunnel());
}
String locationStatus = baseLocation.getLocationStatus();
if ("1".equals(locationStatus) || "2".equals(locationStatus) || "5".equals(locationStatus) ){
log.info("给堆垛机下发任务:"+taskId+" 原货位:"+JsonUtil.toJSONString(baseLocation));
BaseLocationVo baseLocationVo = iBaseLocationService.queryLocationByTunnel(baseLocation.getTunnel());
BaseLocation newLocation = BeanUtil.toBean(baseLocationVo, BaseLocation.class);
newLocation.setLocationStatus("4");

@ -177,8 +177,7 @@ public class ScheduledTasks {
return booleanResult;
}
// @PostConstruct
// @Scheduled(cron = "0/3 * * * * ? ")
@Scheduled(fixedRate = 200)
public void task() {
// log.info("开始获取需要执行的任务");
@ -236,10 +235,11 @@ public class ScheduledTasks {
taskQueryBo.setTaskType("21");
List<BusinDataTaskVo> businDataTaskVo21 = iBusinDataTaskService.selectBusinDataTask1(taskQueryBo);
businDataTaskVos.addAll(businDataTaskVo21);
taskQueryBo.setTaskType("22");
List<BusinDataTaskVo> businDataTaskVo22 = iBusinDataTaskService.selectBusinDataTask1(taskQueryBo);
businDataTaskVos.addAll(businDataTaskVo22);
log.info("要执行的任务信息:"+JsonUtil.toJSONString(businDataTaskVos));
//指定货位出库
taskQueryBo.setTaskType("25");
List<BusinDataTaskVo> businDataTaskVo25 = iBusinDataTaskService.selectBusinDataTask1(taskQueryBo);
businDataTaskVos.addAll(businDataTaskVo25);
// log.info("要执行的任务信息:"+JsonUtil.toJSONString(businDataTaskVos));
for (BusinDataTaskVo businDataTaskVo : businDataTaskVos) {
doTask(businDataTaskVo);
}
@ -347,10 +347,6 @@ public class ScheduledTasks {
Long stkPlcId = null;
String agvno = null;
//获取派生
// TODO 由于逻辑区域换成与车型相匹配,不是与派生匹配,所以注释掉
// Long dervieId = getLocationByDervie(vehicheModel, color);
String randome = "P01";
if (businDataTaskVo.getWarehouseType().equals("1")) {
@ -1601,6 +1597,23 @@ public class ScheduledTasks {
}else if (taskType.equals(TaskTypeEnum.relocation_out.getValue())){
BusinDataTask businDataTask = iBusinDataTaskService.getById(businDataTaskVo.getId());
Result<Boolean> taskResult = outTask(businDataTask);
if (Result.isOk(taskResult)) {
businDataTaskVo.setTaskStatus(TaskStatusEnum.wait_callback.getValue());
} else {
businDataTaskVo.setExceptionMsg("下发堆垛机失败");
businDataTask.setTaskStatus(TaskStatusEnum.err.getValue());
}
}
else if("25".equals(taskType)){
BusinDataTask businDataTask = iBusinDataTaskService.getById(businDataTaskVo.getId());
Result<Boolean> taskResult = outTask(businDataTask);
businDataTaskVo.setUpdateTime(DateUtils.getNowDate());
if (Result.isOk(taskResult)) {
businDataTaskVo.setTaskStatus(TaskStatusEnum.wait_callback.getValue());
} else {
businDataTaskVo.setExceptionMsg("下发堆垛机失败");
businDataTask.setTaskStatus(TaskStatusEnum.err.getValue());
}
}
log.info("任务号" + businDataTaskVo.getId() + "任务状态" + businDataTaskVo.getTaskStatus() + "点位信息" + businDataTaskVo.getPoints());
//统一提交任务数据

@ -96,6 +96,8 @@ public interface IBaseLocationService extends IService<BaseLocation> {
*/
List<BaseLocationVo> queryBaseLocationList(BaseLocationQueryPageBo bo);
BaseLocation queryBaseLocationByrcl(String locationRow,String locationCol,String layer,String tunnel);
/**
* 查询满足条件下的货位数据对应的巷道号

@ -214,6 +214,15 @@ public class BaseLocationServiceImpl extends ServiceImpl<BaseLocationMapper, Bas
return list;
}
@Override
public BaseLocation queryBaseLocationByrcl(String locationRow, String locationCol, String layer,String tunnel) {
LambdaQueryWrapper<BaseLocation> wrapper = new LambdaQueryWrapper<BaseLocation>().eq(BaseLocation::getLocationRow, locationRow)
.eq(BaseLocation::getLocationColumn, locationCol).eq(BaseLocation::getLayer, layer).eq(BaseLocation::getTunnel, tunnel).last("limit 1");
BaseLocation baseLocation = this.getOne(wrapper);
return baseLocation;
}
@Override
@DataScopeConsignor(branchAlias = "bl")
public List<String> queryBaseLocationTunnelList(BaseLocationQueryListBo bo) {

@ -279,36 +279,29 @@ public class StackServiceImpl implements IStackService {
case 2:
//获取当前在冲孔放货口的任务相关信息
if(ObjectUtils.isEmpty(redisTemplate.opsForValue().get(RedisConstant.endPunchingTaskId))){
break;
return AjaxResult.error("未货位到冲孔信息");
}
// 将redis 中的值转成字符串
String endPunchingTaskId = redisTemplate.opsForValue().get(RedisConstant.endPunchingTaskId).toString();
log.info("冲孔去立库,获取redis中的数据:"+endPunchingTaskId);
String[] endIdArr = endPunchingTaskId.split("_");
BasePointDeviceVo basePointDeviceVo = new BasePointDeviceVo();
//立库输送线接驳点-入
String toLocation = "";
BusinTaskExeBo exeBo = new BusinTaskExeBo();
Long plcId = null;
Long stkPlcId=null;
List<BusinDataTaskGoodsVo> businDataTaskGoodsVos = iBusinDataTaskGoodsService.selectBusinTaskGoodsByTaskCode(Long.valueOf(endIdArr[0]));
if(ObjectUtils.isEmpty(businDataTaskGoodsVos)){
break;
log.info("冲孔入立库,无保险杠信息不可入:"+endIdArr);
return AjaxResult.error("无保险杠明细信息,不可入立库");
}
BusinDataTaskGoodsVo goodsVo = businDataTaskGoodsVos.get(0);
String vehicheModel = goodsVo.getVehicheModel();
String color =goodsVo.getColor();
String goodsNo = goodsVo.getGoodsNo();
String startPoint = toPointNoTwo;
//根据派生分配库位
// TODO: 2024/6/28 zjx
// Result<BaseLocationVo> locationVoResult = iBaseLocationService.assignEmptyLocation(vehicheModel,color, DateUtils.getDate(),businDataTaskGoodsVos);
// Result<BaseLocationVo> locationVoResult = iBaseLocationService.assignEmptyLocationByStock( goodsNo, vehicheModel,DateUtils.getDate(),businDataTaskGoodsVos);
// 2024/07/18 zjx 分配货位统一方法
AssingEmptyLocBo emptyLocBo = new AssingEmptyLocBo();
emptyLocBo.setBatch(DateUtils.getDate());
@ -317,30 +310,26 @@ public class StackServiceImpl implements IStackService {
emptyLocBo.setBusinDataTaskGoodsVos(businDataTaskGoodsVos);
Result<BaseLocationVo> locationVoResult=iBaseLocationService.assignEmptyLocationAll(emptyLocBo);
String agvno=null;
BaseLocationVo locationVo = locationVoResult.getData();
String tunnel = locationVo.getTunnel();
Long locationId = locationVo.getId();
for (BusinDataTaskGoodsVo businDataTaskGoodsVo : businDataTaskGoodsVos) {
businDataTaskGoodsVo.setLocationId(locationId);
}
int agvTaskType1 = RCSTaskTypeEnum.TO_B_AND_PUT.getValue();
//获取下料点点位
String taskCode = "T_" + DateUtils.dateTimeNow();
String transId = com.shkj.common.utils.uuid.UUID.randomUUID().toString();
//String transId = com.shkj.common.utils.uuid.UUID.randomUUID().toString();
BusinDataTask businDataTask =new BusinDataTask();
businDataTask.setTaskCode(taskCode);
businDataTask.setTaskStatus(TaskStatusEnum.wait_put.getValue());
businDataTask.setCreateTime(DateUtils.getNowDate());
businDataTask.setBatch(DateUtils.getDate());
businDataTask.setTransId(transId);
// businDataTask.setTransId(transId);
businDataTask.setAgvNo(endIdArr[1]);
businDataTask.setContainerId(Long.valueOf(endIdArr[2]));
businDataTask.setTaskType("18");
businDataTask.setIsDown(agvTaskType1+"");
businDataTask.setLocationId(locationId);
//回填任务的入行高列
businDataTask.setToColumn(locationVo.getLocationColumn());
@ -363,19 +352,23 @@ public class StackServiceImpl implements IStackService {
iBusinDataTaskService.insertBusinDataTask(businDataTask);
Long taskId =businDataTask.getId();
List<BusinDataTaskGoods> goodsList = new ArrayList<>();
for (BusinDataTaskGoodsVo taskGoodsVo : businDataTaskGoodsVos) {
BusinDataTaskGoods businDataTaskGoods = BeanUtil.toBean(taskGoodsVo, BusinDataTaskGoods.class);
businDataTaskGoods.setTaskCode(taskId);
businDataTaskGoods.setCreateTime(DateUtils.getNowDate());
goodsList.add(businDataTaskGoods);
}
boolean b = iBusinDataTaskGoodsService.saveOrUpdateBatch(goodsList);
if (!b){
log.info("冲孔去立库添加保险杠明细失败");
}
//获取巷道对应的堆垛机信息
pointQueryBo.setDevType("1");
BaseDevicePlcVo baseDevicePlcVo = baseLocationPlcMapper.selectBaseDevicePlc(pointQueryBo);
stkPlcId = baseDevicePlcVo.getPlcId();
exeBo.setTaskCode(taskId);
exeBo.setBusinDataTaskGoodsVo(businDataTaskGoodsVos);
exeBo.setContainerId(Long.valueOf(endIdArr[2]));
exeBo.setBaseLocationVo(locationVo);
exeBo.setTransNo("1");
exeBo.setTransQual("1");
List<String> points = new ArrayList<>();
points.add(startPoint);
@ -416,15 +409,6 @@ public class StackServiceImpl implements IStackService {
if (booleanResult1.getCode()== HttpStatus.SUCCESS.getCode()) {
businDataTaskVo.setTaskPath(toLocation);
businDataTaskVo.setTaskStatus(TaskStatusEnum.wait_callback.getValue());
//生成入库单
// Result<String> stringResult = iPutInOutStorageService.exeTaskPutinStorage(exeBo);
//生成入库单成功
// if (stringResult.getCode() == HttpStatus.SUCCESS.getCode()) {
// businDataTaskVo.setTransId(stringResult.getData());
// } else {
// businDataTaskVo.setTaskStatus(TaskStatusEnum.err.getValue());
// businDataTaskVo.setExceptionMsg("生成入库单失败");
//}
//修改冲孔完成
BasePunchRecord basePunchRecord = iBasePunchRecordService.getOne(new LambdaQueryWrapper<BasePunchRecord>()
.eq(BasePunchRecord::getTaskCode,Long.valueOf(endIdArr[0]))

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.shkj.common.core.domain.Result;
import com.shkj.common.utils.DateUtils;
import com.shkj.common.utils.SecurityUtils;
import com.shkj.wms.bo.*;
import com.shkj.wms.domain.*;
@ -54,7 +55,7 @@ public class SysStockDetailServiceImpl extends ServiceImpl<SysStockDetailMapper,
private IBaseDeriveService iBaseDeriveService;
@Autowired
private IBaseLogicareaVmService iBaseLogicareaVmService;
@Autowired
@Resource
private SysStockDetailMapper sysStockDetailMapper;
@Override
@ -182,6 +183,8 @@ public class SysStockDetailServiceImpl extends ServiceImpl<SysStockDetailMapper,
sysStockDetail.setLocationId(locationId);
sysStockDetail.setBatch(batch);
sysStockDetail.setIsPuch(isPuch);
sysStockDetail.setCreateTime(DateUtils.getNowDate());
sysStockDetail.setInTime(DateUtils.getNowDate());
if (StrUtil.isNotBlank(good.get("goodsNo"))) {
sysStockDetail.setGoodsNo(good.get("goodsNo"));
}

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.shkj.common.constant.HttpStatus;
import com.shkj.common.core.domain.Result;
import com.shkj.common.utils.DateUtils;
import com.shkj.common.utils.SecurityUtils;
import com.shkj.wms.bo.*;
import com.shkj.wms.domain.SysStock;
@ -150,6 +151,7 @@ public class SysStockServiceImpl extends ServiceImpl<SysStockMapper, SysStock> i
sysStock = this.getById(sysStockVos.get(0).getId());
sysStock.setStorageId(storageCode);
sysStock.setGoodsNo(good.get("goodsNo"));
sysStock.setCreateTime(DateUtils.getNowDate());
BigDecimal oldQty = sysStock.getQty() != null ? sysStock.getQty() : BigDecimal.valueOf(0);
sysStock.setQty(oldQty.add(BigDecimal.valueOf(goods.size())));
this.updateById(sysStock);

Loading…
Cancel
Save