add:验箱流程

This commit is contained in:
zhangzq
2025-01-08 10:45:16 +08:00
parent f184e184f5
commit 7340eeb746
9 changed files with 184 additions and 25 deletions

View File

@@ -157,6 +157,31 @@ public class PdmBiSubpackagerelationController {
}
@PostMapping("/zjInBound")
@SaIgnore
@Log("子卷装箱入库")
//@SaCheckPermission("@el.check(updateEntityList)")
public ResponseEntity<Object> zjInBound(@RequestBody JSONObject whereJson) {
RLock lock = redissonClient.getLock("updateEntityList");
boolean tryLock = false;
try {
tryLock = lock.tryLock(0, TimeUnit.SECONDS);
if (tryLock) {
pdmBiSubpackagerelationService.updateEntityList(whereJson);
} else {
log.info("子卷装箱操作正在执行被锁住。");
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
if (tryLock) {
lock.unlock();
}
}
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping("/transferBoxPackageToMes")
@Log("传输子卷包装关系至LMS")
//@SaCheckPermission("@el.check(updateEntityList)")

View File

@@ -63,11 +63,14 @@ public interface IpdmBiSubpackagerelationService extends IService<PdmBiSubpackag
/**
* 子卷分配木箱规格
*
* @param whereJson 分配信息
* 绑定组卷包装关系:验箱准备
*/
void updateEntityList(JSONObject whereJson);
/**
* 验箱入库
*/
void zjInBoundConfirm(JSONObject whereJson);
/**
* 传输子卷包装关系至LMS

View File

@@ -295,6 +295,93 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
outBox(workIdList, containerNameList, deviceCode, maxBoxGroup, whereJson, totalWeight);
}
@Override
public void zjInBoundConfirm(JSONObject param) {
// String containerName = param.getString("container_name");
// if (StringUtils.isEmpty(containerName)){
// throw new BadRequestException("子卷编码不能为空");
// }
// String[] split = containerName.split(",");
// //理论毛重
// List<PdmBiSubpackagerelation> subList = this.list(new QueryWrapper<PdmBiSubpackagerelation>()
// .eq("status", "0")
// .in("container_name", split));
// if (subList.size() != containerName.length()){
// throw new BadRequestException("子卷包装信息与子卷不相符合");
// }
// Set<String> collect = subList.stream().map(PdmBiSubpackagerelation::getPackage_box_sn).collect(Collectors.toSet());
// if (collect.size()>1){
// throw new BadRequestException("当前子卷不属于同一组"+ collect);
// }
// if (subList.get(0).getQuanlity_in_box().intValue()!= split.length){
// throw new BadRequestException("当前木箱"+subList.get(0).getQuanlity_in_box()+"要装箱的子卷"+split.length+"未装完");
// }
// String boxSn = subList.get(0).getPackage_box_sn();
// updateWrapper.set("box_weight", NumberUtil.round(totalWeight, 2).toString());
// updateWrapper.set("package_box_sn", boxDao.getBox_no());
// updateWrapper.set("quanlity_in_box", workIdList.size());
// updateWrapper.set("box_type", boxDao.getMaterial_code());
// updateWrapper.set("box_length", boxDao.getBox_length());
// updateWrapper.set("box_width", boxDao.getBox_width());
// updateWrapper.set("box_high", boxDao.getBox_high());
// updateWrapper.set("box_group", maxBoxGroup);
// updateWrapper.set("status", "0");
// updateWrapper.in("workorder_id", workIdList);
// pdmBiSubpackagerelationMapper.update(null, updateWrapper);
// List<PdmBiSubpackagerelation> packagerelationList = JSONObject.parseArray(whereJson.getJSONArray("tableMater").toJSONString(), PdmBiSubpackagerelation.class);
// //子卷信息校验
// checkEntityList(whereJson, packagerelationList);
// //均衡获取木箱出库装箱区对接位
// //= getPointCode(packagerelationList.size());
// String deviceCode = "ZXQ_1_1";
// int count = taskService.count(new QueryWrapper<SchBaseTask>()
// .eq("task_type", "010908")
// .eq("is_delete", "0")
// .lt("task_status", TaskStatusEnum.FINISHED.getCode()));
// int count2 = packageinfoivtService.count(new QueryWrapper<BstIvtPackageinfoivt>()
// .eq("point_status",PackageInfoIvtEnum.POINT_STATUS.code("装箱区"))
// .eq("ivt_status",PackageInfoIvtEnum.IVT_STATUS.code("合格品")));
// if (count+count2>8){
// throw new BadRequestException("当前装箱区木箱任务已满,稍后再试");
// }
// List<String> workIdList = JSONObject.parseArray(whereJson.getJSONArray("tableMater").toJSONString(), PdmBiSubpackagerelation.class).stream()
// .map(PdmBiSubpackagerelation::getWorkorder_id)
// .map(String::valueOf)
// .collect(Collectors.toList());
// //根据分切计划获取子卷重量计算理论毛重
// Set<String> containerNameList = packagerelationList.stream()
// .map(PdmBiSubpackagerelation::getContainer_name)
// .collect(Collectors.toSet());
// List<PdmBiSlittingproductionplan> planList = iPdmBiSlittingproductionplanService.list(new LambdaQueryWrapper<PdmBiSlittingproductionplan>()
// .in(PdmBiSlittingproductionplan::getContainer_name, containerNameList)
// .eq(PdmBiSlittingproductionplan::getIs_delete,IOSEnum.IS_NOTANDYES.code("否"))
// );
//
// if (ObjectUtils.isEmpty(planList)) {
// throw new BadRequestException("子卷查询不到分切计划,请检查!");
// }
// BigDecimal totalWeight;
// totalWeight = planList.stream()
// .map(PdmBiSlittingproductionplan::getWeight)
// .filter(p -> p != null && !p.trim().isEmpty())
// .filter(r -> !r.isEmpty())
// .map(BigDecimal::new)
// .reduce(BigDecimal.ZERO, BigDecimal::add);
// if (totalWeight.compareTo(new BigDecimal(0)) == 0) {
// throw new BadRequestException("分切计划的子卷重量不能为0");
// }
// //获取子卷组号
// List<PdmBiSubpackagerelation> pdmBiSubpackagerelationList = pdmBiSubpackagerelationMapper
// .selectList(new LambdaQueryWrapper<PdmBiSubpackagerelation>().eq(PdmBiSubpackagerelation::getSale_order_name, packagerelationList.get(0).getSale_order_name()));
// Integer maxBoxGroup = pdmBiSubpackagerelationList.stream()
// .map(PdmBiSubpackagerelation::getBox_group)
// .filter(r -> r != null && !r.trim().isEmpty())
// .map(Integer::parseInt)
// .max(Integer::compareTo)
// .orElse(0) + 1;
// outBox(workIdList, containerNameList, deviceCode, maxBoxGroup, whereJson, totalWeight);
}
private void checkEntityList(JSONObject whereJson, List<PdmBiSubpackagerelation> packagerelationList) {
JSONArray jsonArray = whereJson.getJSONArray("tableMater");
if (jsonArray == null || jsonArray.size() == 0) {
@@ -330,7 +417,7 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
/**
* 空木箱出库
* 空木箱绑定
*/
public void outBox(List<String> workIdList, Set<String> containerNameList, String deviceCode, Integer maxBoxGroup, JSONObject whereJson, BigDecimal totalWeight) {
JSONObject boxInfo = new JSONObject();
@@ -338,7 +425,7 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
boxInfo.put("device_code", deviceCode);
boxInfo.put("material_code", whereJson.getString("checked"));
boxInfo.put("num", workIdList.size());
String boxSn = outBoxManageService.outBox(boxInfo);
String boxSn = outBoxManageService.outBoxNoTask(boxInfo);
BstIvtBoxinfo boxDao = iBstIvtBoxinfoService.getOne(
new QueryWrapper<BstIvtBoxinfo>().lambda()
.eq(BstIvtBoxinfo::getBox_no, boxSn)
@@ -348,8 +435,20 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
totalWeight = totalWeight.add(boxWeight);
//更新及子卷包装状态已分配规格及木箱规格组
String weightTotal = totalWeight.toString();
updateBoxGroup(maxBoxGroup, workIdList, boxDao, weightTotal);
agvTransfer(containerNameList, deviceCode, boxSn);
UpdateWrapper<PdmBiSubpackagerelation> updateWrapper = new UpdateWrapper<>();
//理论毛重
updateWrapper.set("box_weight", NumberUtil.round(totalWeight, 2).toString());
updateWrapper.set("package_box_sn", boxDao.getBox_no());
updateWrapper.set("quanlity_in_box", workIdList.size());
updateWrapper.set("box_type", boxDao.getMaterial_code());
updateWrapper.set("box_length", boxDao.getBox_length());
updateWrapper.set("box_width", boxDao.getBox_width());
updateWrapper.set("box_high", boxDao.getBox_high());
updateWrapper.set("box_group", maxBoxGroup);
updateWrapper.set("status", "0");
updateWrapper.in("workorder_id", workIdList);
pdmBiSubpackagerelationMapper.update(null, updateWrapper);
// agvTransfer(containerNameList, deviceCode, boxSn);
//给MES传输子卷包装关系
CompletableFuture.runAsync(() -> {
try {
@@ -364,22 +463,6 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
}
private void updateBoxGroup(Integer maxBoxGroup, List<String> entityList, BstIvtBoxinfo boxDao, String totalWeight) {
UpdateWrapper<PdmBiSubpackagerelation> updateWrapper = new UpdateWrapper<>();
//理论毛重
updateWrapper.set("box_weight", NumberUtil.round(totalWeight, 2).toString());
updateWrapper.set("package_box_sn", boxDao.getBox_no());
updateWrapper.set("quanlity_in_box", entityList.size());
updateWrapper.set("box_type", boxDao.getMaterial_code());
updateWrapper.set("box_length", boxDao.getBox_length());
updateWrapper.set("box_width", boxDao.getBox_width());
updateWrapper.set("box_high", boxDao.getBox_high());
updateWrapper.set("box_group", maxBoxGroup);
updateWrapper.set("status", "0");
updateWrapper.in("workorder_id", entityList);
pdmBiSubpackagerelationMapper.update(null, updateWrapper);
}
/**
* 传输子卷包装关系至LMS

View File

@@ -59,6 +59,7 @@ public class BstIvtPackageinfoivtController {
* @return JSONObject 返回信息
*/
@PostMapping("/secondaryAllocationPoint")
@Log("二次分配")
@SaIgnore
ResponseEntity<Object> secondaryAllocationPoint(@RequestBody JSONObject whereJson) {
log.info("一楼装箱区二次分配接口请求参数:---------------------------------------------" + whereJson.toString());

View File

@@ -63,7 +63,7 @@ public enum IOSEnum {
"空托盘出库锁", "4", "空托盘入库锁", "5",
"移出锁", "6", "移入锁", "7","木箱入库锁","8",
"木箱出库锁","9","出库异常锁","10",
"货位异常锁", "11","货位异常出库锁", "12","其它", "99"
"货位异常锁", "11","货位异常出库锁", "12","验箱出库锁", "13","其它", "99"
)),
//仓库id

View File

@@ -122,6 +122,39 @@ public class OutBoxManageServiceImpl implements OutBoxManageService {
taskBean.createTask(jsonTaskParam);
taskBean.immediateNotifyAcs(null);
// 锁定起点
jsonAttr.put("lock_type", IOSEnum.LOCK_TYPE.code("验箱出库锁"));
attrTab.update(jsonAttr);
// 清空缓存
notOutRowList.clear();
notOutBlockList.clear();
return jsonAttr.getString("storagevehicle_code");
}
@Override
public String outBoxNoTask(JSONObject whereJson) {
// 仓位表
WQLObject attrTab = WQLObject.getWQLObject("st_ivt_structattr");
// 载具扩展属性表
WQLObject veExtTab = WQLObject.getWQLObject("md_pb_storagevehicleext");
whereJson.put("stor_id", IOSEnum.STOR_ID.code("二期"));
whereJson.put("sect_id", RegionTypeEnum.TWO_BZC01.getId());
JSONObject jsonAttr = getStruct(whereJson);
if (ObjectUtil.isEmpty(jsonAttr)) {
notOutRowList.clear();
notOutBlockList.clear();
throw new BadRequestException("没有符合规格的木箱!");
}
// 查询木箱对应的托盘号
JSONObject jsonVeExt = veExtTab.query("pcsn = '" + jsonAttr.getString("storagevehicle_code") + "'")
.uniqueResult(0);
if (ObjectUtil.isEmpty(jsonVeExt)) {
throw new BadRequestException("此木箱没有绑定托盘号!"+jsonAttr.getString("storagevehicle_code"));
}
// 锁定起点
jsonAttr.put("lock_type", IOSEnum.LOCK_TYPE.code("木箱出库锁"));
attrTab.update(jsonAttr);
// 清空缓存

View File

@@ -25,6 +25,8 @@ public interface OutBoxManageService {
*/
String outBox(JSONObject whereJson);
String outBoxNoTask(JSONObject whereJson);
/**
* 任务异常处理(1.空出 )

View File

@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
import java.util.List;
@Component
//@Component
@RequiredArgsConstructor
@Order(100)
public class JobRunner implements ApplicationRunner {

View File

@@ -1,11 +1,14 @@
package org.nl.wms.pdm.bi.rest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.logging.annotation.Log;
import org.nl.wms.pdm.bi.service.SubpackagerelationService;
import org.nl.wms.pdm.bi.service.dto.SubpackagerelationDto;
import org.nl.wms.util.TranUtil;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -70,4 +73,13 @@ public class SubpackagerelationController {
public void download(@RequestParam Map map, HttpServletResponse response) throws IOException {
subpackagerelationService.download(map, response);
}
@Log("导出数据")
@GetMapping(value = "/tranTest")
public void tranTest(@RequestBody JSONObject param) throws IOException {
TranUtil.openTransaction((req,callback)->{
return null;
},new JSONArray());
}
}