opt:优化代码
This commit is contained in:
@@ -56,12 +56,6 @@ public class BstIvtStockingivtController {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("操作管芯托盘库存")
|
||||
@PostMapping("operateIvt")
|
||||
public ResponseEntity<Object> operateIvt(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(bstIvtStockingivtService.operateIvt(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("查询管芯托盘库存明细")
|
||||
@PostMapping("/showDetail")
|
||||
public ResponseEntity<Object> showDetail(@RequestBody JSONObject param) {
|
||||
|
||||
@@ -81,8 +81,6 @@ public interface IBstIvtStockingivtService extends IService<BstIvtStockingivt> {
|
||||
*/
|
||||
BstIvtStockingivt getCanMovePointOne(String location, String pointType);
|
||||
|
||||
JSONObject operateIvt(JSONObject jsonObject) ;
|
||||
|
||||
/**
|
||||
* 分组聚合获取需要管芯的托盘位置
|
||||
* @param pointType
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.b_lms.bst.ivt.paper.service.dao.MdPbPaper;
|
||||
import org.nl.b_lms.bst.ivt.paper.service.dao.mapper.MdPbPaperMapper;
|
||||
import org.nl.b_lms.bst.ivt.papervehicle.service.IMdPbPapervehicleService;
|
||||
import org.nl.b_lms.bst.ivt.papervehicle.service.dao.MdPbPapervehicle;
|
||||
import org.nl.b_lms.bst.ivt.stockingivt.service.IBstIvtStockingivtService;
|
||||
@@ -32,6 +34,7 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -133,178 +136,6 @@ public class BstIvtStockingivtServiceImpl extends ServiceImpl<BstIvtStockingivtM
|
||||
return bstIvtStockingivtMapper.getCanMovePointOne(location, pointType);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// List<String> lines = new ArrayList<>();
|
||||
// lines.add("纸制简管|纸管|6英寸|1300");
|
||||
// lines.add("纸制简管|纸管|3英寸|12|650");
|
||||
// lines.add("玻璃纤维及其制品|FRP管|6英寸|15-20|1700|阶梯");
|
||||
// lines.add("玻璃纤维及其制品|FRP管|6英寸|15|1700|高强");
|
||||
// // 定义正则表达式,去除最后的中文部分
|
||||
// String regex = "\\|[\\u4e00-\\u9fa5]+$";
|
||||
//
|
||||
// // 处理每一行数据
|
||||
// List<String> cleanedLines = new ArrayList<>();
|
||||
// for (String line : lines) {
|
||||
// cleanedLines.add(line.replaceAll(regex, ""));
|
||||
// }
|
||||
//
|
||||
// // 打印结果
|
||||
// for (String cleanedLine : cleanedLines) {
|
||||
// System.out.println(cleanedLine);
|
||||
// }
|
||||
String material_name = "玻璃纤维及其制品|FRP管|6英寸|15-20|1100|阶梯";
|
||||
String[] tubeArray = material_name.replaceAll("\\|[\\u4e00-\\u9fa5]+$", "").split("\\|");
|
||||
System.out.println(tubeArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject operateIvt(JSONObject jsonObject) {
|
||||
log.info("手持操作管芯托盘 - {}", jsonObject);
|
||||
//载具托盘号
|
||||
String vehicle_code = jsonObject.getString("vehicle_code");
|
||||
//排
|
||||
String row_num = jsonObject.getString("row_num");
|
||||
//列
|
||||
String col_num = jsonObject.getString("col_num");
|
||||
//物料
|
||||
String material_code = jsonObject.getString("material_code");
|
||||
//管芯/纸管编码
|
||||
String paper_code = jsonObject.getString("paper_code");
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
if (ObjectUtil.isEmpty(row_num)) {
|
||||
throw new BadRequestException("排数不能为空!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(col_num)) {
|
||||
throw new BadRequestException("列数不能为空!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(vehicle_code)) {
|
||||
throw new BadRequestException("托盘信息不能为空!");
|
||||
}
|
||||
if(!vehicle_code.contains("GX")){
|
||||
throw new BadRequestException("请扫描或输入正确的托盘码!");
|
||||
}
|
||||
//1-绑定;2-清除
|
||||
String type = jsonObject.getString("type");
|
||||
if (type.equals("1")) {
|
||||
if (ObjectUtil.isEmpty(material_code)) {
|
||||
throw new BadRequestException("物料编码不能为空!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(paper_code)) {
|
||||
throw new BadRequestException("管芯/纸管编码不能为空!");
|
||||
}
|
||||
MaterialbaseDto mater = materialbaseService.findByCode(material_code);
|
||||
String material_name = mater.getMaterial_name();
|
||||
//查询当前载具和排列是否存在库存
|
||||
MdPbPapervehicle papervehicle = papervehicleService.getOne(new LambdaQueryWrapper<MdPbPapervehicle>()
|
||||
.eq(MdPbPapervehicle::getVehicle_code, vehicle_code)
|
||||
.eq(MdPbPapervehicle::getRow_num, row_num)
|
||||
.eq(MdPbPapervehicle::getCol_num, col_num));
|
||||
if (ObjectUtil.isNotEmpty(papervehicle) && !papervehicle.getMaterial_code().equals(material_code)) {
|
||||
throw new BadRequestException("当前排-列已有物料为【" + papervehicle.getMaterial_code() + "】,如需要修改请先清除库存,再进行绑定!");
|
||||
}
|
||||
//查询当前管芯编码是否在托盘中
|
||||
MdPbPapervehicle papervehicle_flag = papervehicleService.getOne(new LambdaQueryWrapper<MdPbPapervehicle>()
|
||||
.eq(MdPbPapervehicle::getPaper_code, paper_code));
|
||||
if (ObjectUtil.isNotEmpty(papervehicle_flag)) {
|
||||
throw new BadRequestException("当前管芯编码已存在托盘上:" + papervehicle_flag.getVehicle_code() + "所在位置排列:"+papervehicle_flag.getRow_num()+"-"+papervehicle_flag.getCol_num());
|
||||
}
|
||||
//获取当前纸管的高度
|
||||
// 解析描述数组
|
||||
String[] tubeArray = material_name.replaceAll("\\|[\\u4e00-\\u9fa5]+$", "").split("\\|");
|
||||
|
||||
int currLength = Integer.parseInt(tubeArray[tubeArray.length - 1]);
|
||||
|
||||
//校验高度差要大于50MM,否则不允许进行绑定
|
||||
int num = Integer.parseInt(row_num);
|
||||
if (num == 1) {
|
||||
//只判断第二排的纸管长度
|
||||
int nextNum = num + 1;
|
||||
MdPbPapervehicle nextPaper = papervehicleService.getOne(new LambdaQueryWrapper<MdPbPapervehicle>().eq(MdPbPapervehicle::getVehicle_code, vehicle_code)
|
||||
.eq(MdPbPapervehicle::getRow_num, nextNum));
|
||||
if (ObjectUtil.isNotEmpty(nextPaper)) {
|
||||
//获取第二排的纸管高度和纸管类型
|
||||
String nextMaterialName = nextPaper.getMaterial_name();
|
||||
String[] nextArray = nextMaterialName.replaceAll("\\|[\\u4e00-\\u9fa5]+$", "").split("\\|");
|
||||
int nextLength = Integer.parseInt(nextArray[nextArray.length - 1]);
|
||||
if (Math.abs(nextLength - currLength) <= 50 && !material_code.equals(nextPaper.getMaterial_code())) {
|
||||
throw new BadRequestException("相邻排的纸管高度差要大于等于50MM!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//判断后一排的纸管高度
|
||||
int nextNum = num + 1;
|
||||
MdPbPapervehicle nextPaper = papervehicleService.getOne(new LambdaQueryWrapper<MdPbPapervehicle>().eq(MdPbPapervehicle::getVehicle_code, vehicle_code)
|
||||
.eq(MdPbPapervehicle::getRow_num, nextNum));
|
||||
if (ObjectUtil.isNotEmpty(nextPaper)) {
|
||||
//获取后一排的纸管高度和纸管类型
|
||||
String nextMaterialName = nextPaper.getMaterial_name();
|
||||
String[] nextArray = nextMaterialName.replaceAll("\\|[\\u4e00-\\u9fa5]+$", "").split("\\|");
|
||||
int nextLength = Integer.parseInt(nextArray[nextArray.length - 1]);
|
||||
if (Math.abs(nextLength - currLength) <= 50 && !material_code.equals(nextPaper.getMaterial_code())) {
|
||||
throw new BadRequestException("相邻排的纸管高度差要大于等于50MM!");
|
||||
}
|
||||
}
|
||||
//判断前一排的纸管高度
|
||||
int preNum = num - 1;
|
||||
MdPbPapervehicle prePaper = papervehicleService.getOne(new LambdaQueryWrapper<MdPbPapervehicle>().eq(MdPbPapervehicle::getVehicle_code, vehicle_code)
|
||||
.eq(MdPbPapervehicle::getRow_num, preNum));
|
||||
if (ObjectUtil.isNotEmpty(prePaper)) {
|
||||
//获取后一排的纸管高度和纸管类型
|
||||
String preMaterialName = prePaper.getMaterial_name();
|
||||
String[] preArray = preMaterialName.replaceAll("\\|[\\u4e00-\\u9fa5]+$", "").split("\\|");
|
||||
int preLength = Integer.parseInt(preArray[preArray.length - 1]);
|
||||
if (Math.abs(preLength - currLength) <= 50 && !material_code.equals(prePaper.getMaterial_code())) {
|
||||
throw new BadRequestException("相邻排的纸管高度差要大于等于50MM!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(papervehicle)) {
|
||||
papervehicle.setQty(1);
|
||||
papervehicle.setUpdate_optid(currentUserId);
|
||||
papervehicle.setUpdate_optname(nickName);
|
||||
papervehicle.setUpdate_time(now);
|
||||
papervehicleService.updateById(papervehicle);
|
||||
} else {
|
||||
papervehicle = new MdPbPapervehicle();
|
||||
papervehicle.setIvt_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
papervehicle.setVehicle_code(vehicle_code);
|
||||
papervehicle.setRow_num(row_num);
|
||||
papervehicle.setMaterial_code(material_code);
|
||||
papervehicle.setMaterial_name(material_name);
|
||||
papervehicle.setQty(1);
|
||||
papervehicle.setUpdate_optid(currentUserId);
|
||||
papervehicle.setUpdate_optname(nickName);
|
||||
papervehicle.setUpdate_time(now);
|
||||
papervehicleService.save(papervehicle);
|
||||
}
|
||||
}else if (type.equals("2")) {
|
||||
//清除管芯托盘库存
|
||||
papervehicleService.remove(new LambdaQueryWrapper<MdPbPapervehicle>().eq(MdPbPapervehicle::getVehicle_code, vehicle_code)
|
||||
.eq(MdPbPapervehicle::getRow_num, row_num)
|
||||
.eq(MdPbPapervehicle::getCol_num, col_num));
|
||||
}
|
||||
|
||||
//判断绑定的纸管是否在机械手范围内,如果存在的话把最新库存推送给电气
|
||||
BstIvtStockingivt bstIvtStockingivt = bstIvtStockingivtMapper.selectOne(new LambdaQueryWrapper<BstIvtStockingivt>().eq(BstIvtStockingivt::getVehicle_code, vehicle_code));
|
||||
if (bstIvtStockingivt != null && bstIvtStockingivt.getPoint_type().equals("1")) {
|
||||
List<MdPbPapervehicle> list = papervehicleService.list(new LambdaQueryWrapper<MdPbPapervehicle>().eq(MdPbPapervehicle::getVehicle_code, vehicle_code));
|
||||
JSONObject jo = new JSONObject();
|
||||
SlitterTaskUtil.doSavePaperInfos(list, jo);
|
||||
jo.put("product_area", bstIvtStockingivt.getProduct_area());
|
||||
jo.put("device_code", bstIvtStockingivt.getPoint_code());
|
||||
wmsToAcsService.getTubeMsg(jo);
|
||||
}
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "操作成功!");
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BhTubePointDto> getNeedPaperTubePoint(String pointType, String tube, String location) {
|
||||
return bstIvtStockingivtMapper.getNeedPaperTubePoint(pointType, tube, location);
|
||||
|
||||
@@ -71,10 +71,10 @@ public class StockingIvtController {
|
||||
}
|
||||
|
||||
@Log("操作管芯托盘库存")
|
||||
@PostMapping("operateIvt")
|
||||
@PostMapping("/operateIvt")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> operateIvt(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(bstIvtStockingivtService.operateIvt(param), HttpStatus.OK);
|
||||
return new ResponseEntity<>(stockingIvtService.operateIvt(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.b_lms.bst.ivt.paper.service.dao.MdPbPaper;
|
||||
import org.nl.b_lms.bst.ivt.paper.service.dao.mapper.MdPbPaperMapper;
|
||||
import org.nl.b_lms.bst.ivt.papervehicle.service.IMdPbPapervehicleService;
|
||||
import org.nl.b_lms.bst.ivt.papervehicle.service.dao.MdPbPapervehicle;
|
||||
import org.nl.b_lms.bst.ivt.stockingivt.service.IBstIvtStockingivtService;
|
||||
@@ -19,7 +21,6 @@ import org.nl.b_lms.sch.tasks.slitter.InstorStockAgvTask;
|
||||
import org.nl.b_lms.sch.tasks.slitter.constant.SlitterConstant;
|
||||
import org.nl.b_lms.sch.tasks.slitter.constant.SlitterEnum;
|
||||
import org.nl.b_lms.sch.tasks.slitter.util.SlitterTaskUtil;
|
||||
import org.nl.b_lms.storage_manage.md.service.MaterialbaseService;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.common.utils.TaskUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
@@ -32,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -42,20 +44,20 @@ import java.util.List;
|
||||
@Slf4j
|
||||
@Service
|
||||
public class StockingIvtServiceImpl implements StockingIvtService {
|
||||
@Autowired
|
||||
@Resource
|
||||
private BstIvtStockingivtMapper bstIvtStockingivtMapper;
|
||||
@Autowired
|
||||
private IBstIvtStockingivtService stockingivtService;
|
||||
@Autowired
|
||||
private InstorStockAgvTask instorStockAgvTask;
|
||||
@Autowired
|
||||
@Resource
|
||||
private SysDictMapper sysDictMapper;
|
||||
@Autowired
|
||||
private WmsToAcsService wmsToAcsService;
|
||||
@Autowired
|
||||
private IMdPbPapervehicleService papervehicleService;
|
||||
@Autowired
|
||||
private MaterialbaseService materialbaseService;
|
||||
@Resource
|
||||
private MdPbPaperMapper mdPbPaperMapper;
|
||||
|
||||
@Override
|
||||
public JSONObject doStockAreaBinding(JSONObject param) {
|
||||
@@ -264,35 +266,45 @@ public class StockingIvtServiceImpl implements StockingIvtService {
|
||||
String row_num = jsonObject.getString("row_num");
|
||||
//列
|
||||
String col_num = jsonObject.getString("col_num");
|
||||
//物料
|
||||
String material_code = jsonObject.getString("material_code");
|
||||
//管芯/纸管编码
|
||||
String paper_code = jsonObject.getString("paper_code");
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
if (ObjectUtil.isEmpty(row_num)) {
|
||||
throw new BadRequestException("排数不能为空!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(col_num)) {
|
||||
throw new BadRequestException("列数不能为空!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(vehicle_code)) {
|
||||
throw new BadRequestException("托盘信息不能为空!");
|
||||
}
|
||||
if(!vehicle_code.contains("GX")){
|
||||
throw new BadRequestException("请扫描或输入正确的托盘码!");
|
||||
}
|
||||
//1-绑定;2-清除
|
||||
String type = jsonObject.getString("type");
|
||||
if (type.equals("1")) {
|
||||
if (ObjectUtil.isEmpty(vehicle_code)) {
|
||||
throw new BadRequestException("托盘信息不能为空!");
|
||||
}
|
||||
if(!vehicle_code.contains("GX")){
|
||||
throw new BadRequestException("请扫描或输入正确的托盘码!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(material_code)) {
|
||||
throw new BadRequestException("物料不能为空!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(paper_code)) {
|
||||
throw new BadRequestException("管芯/纸管编码不能为空!");
|
||||
}
|
||||
MaterialbaseDto mater = materialbaseService.findByCode(material_code);
|
||||
String material_name = mater.getMaterial_name();
|
||||
//查询当前载具和排是否存在库存
|
||||
MdPbPapervehicle papervehicle = papervehicleService.getOne(new LambdaQueryWrapper<MdPbPapervehicle>().eq(MdPbPapervehicle::getVehicle_code, vehicle_code)
|
||||
.eq(MdPbPapervehicle::getRow_num, row_num).eq(MdPbPapervehicle::getCol_num, col_num));
|
||||
//查询管芯记录
|
||||
LambdaQueryWrapper<MdPbPaper> lam = new LambdaQueryWrapper<>();
|
||||
lam.eq( ObjectUtil.isNotEmpty(paper_code),MdPbPaper::getPaper_code,paper_code);
|
||||
MdPbPaper paper = mdPbPaperMapper.selectOne(lam);
|
||||
if(ObjectUtil.isEmpty(paper)){
|
||||
throw new BadRequestException("管芯/纸管记录不存在!");
|
||||
}
|
||||
//物料
|
||||
String material_code = paper.getMaterial_code();
|
||||
String material_name = paper.getMaterial_name();
|
||||
//查询当前载具和排列是否存在库存
|
||||
MdPbPapervehicle papervehicle = papervehicleService.getOne(new LambdaQueryWrapper<MdPbPapervehicle>()
|
||||
.eq(MdPbPapervehicle::getVehicle_code, vehicle_code)
|
||||
.eq(MdPbPapervehicle::getRow_num, row_num)
|
||||
.eq(MdPbPapervehicle::getCol_num, col_num));
|
||||
if (ObjectUtil.isNotEmpty(papervehicle) && !papervehicle.getMaterial_code().equals(material_code)) {
|
||||
throw new BadRequestException("当前排-列已有物料为【" + papervehicle.getMaterial_code() + "】,如需要修改请先清除库存,再进行绑定!");
|
||||
}
|
||||
@@ -352,17 +364,13 @@ public class StockingIvtServiceImpl implements StockingIvtService {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(papervehicle)) {
|
||||
papervehicle.setQty(1);
|
||||
papervehicle.setUpdate_optid(currentUserId);
|
||||
papervehicle.setUpdate_optname(nickName);
|
||||
papervehicle.setUpdate_time(now);
|
||||
papervehicleService.updateById(papervehicle);
|
||||
} else {
|
||||
if (ObjectUtil.isEmpty(papervehicle)) {
|
||||
papervehicle = new MdPbPapervehicle();
|
||||
papervehicle.setIvt_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
papervehicle.setVehicle_code(vehicle_code);
|
||||
papervehicle.setRow_num(row_num);
|
||||
papervehicle.setCol_num(col_num);
|
||||
papervehicle.setPaper_code(paper_code);
|
||||
papervehicle.setMaterial_code(material_code);
|
||||
papervehicle.setMaterial_name(material_name);
|
||||
papervehicle.setQty(1);
|
||||
|
||||
Reference in New Issue
Block a user