|
|
@ -1,5 +1,6 @@ |
|
|
|
package org.nl.wms.pda.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.lang.Assert; |
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.nl.common.exception.BadRequestException; |
|
|
|
import org.nl.common.utils.CodeUtil; |
|
|
|
import org.nl.common.utils.CopyUtil; |
|
|
|
import org.nl.common.utils.SecurityUtils; |
|
|
|
import org.nl.wms.database.material.service.IMdBaseMaterialService; |
|
|
|
import org.nl.wms.database.material.service.dao.MdBaseMaterial; |
|
|
@ -102,6 +104,7 @@ public class PdaServiceImpl implements PdaService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public PdaResponseVo manualCreateByPda(ManualGroupDto entity) { |
|
|
|
Assert.notNull(entity, "参数不能为空!"); |
|
|
|
SchBaseVehiclematerialgroup groupInfo = vehiclematerialgroupService.getGroupInfo(entity.getVehicle_code(), |
|
|
@ -124,14 +127,21 @@ public class PdaServiceImpl implements PdaService { |
|
|
|
group.setInstorage_time(DateUtil.now()); |
|
|
|
group.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); |
|
|
|
//判断是否需要配盘
|
|
|
|
group.setLink_status(!entity.is_link() ? LinkStatusEnum.LINK_FINISH.getType() : LinkStatusEnum.LINK_READY.getType()); |
|
|
|
group.setPcsn(!entity.is_link() ? CodeUtil.getNewCode("PCSN_CODE") : null); |
|
|
|
group.setLink_status(!entity.getIs_link() ? LinkStatusEnum.LINK_FINISH.getType() : LinkStatusEnum.LINK_READY.getType()); |
|
|
|
group.setPcsn(!entity.getIs_link() ? CodeUtil.getNewCode("PCSN_CODE") : null); |
|
|
|
group.setMove_way(basePoint.getPoint_code()); |
|
|
|
group.setBuss_move_id(IdUtil.getSnowflake(1, 1).nextIdStr()); |
|
|
|
group.setCreate_id(SecurityUtils.getCurrentUserId()); |
|
|
|
group.setCreate_name(SecurityUtils.getCurrentNickName()); |
|
|
|
group.setCreate_time(DateUtil.now()); |
|
|
|
vehiclematerialgroupService.save(group); |
|
|
|
|
|
|
|
//同时更新组盘点位的载具信息
|
|
|
|
basePoint.setVehicle_code(entity.getVehicle_code()); |
|
|
|
basePoint.setVehicle_type(entity.getVehicle_type()); |
|
|
|
basePoint.setVehicle_qty(1); |
|
|
|
basePoint.setPoint_status(PointStatusEnum.FULL_POINT.getCode()); |
|
|
|
pointService.updateById(basePoint); |
|
|
|
return PdaResponseVo.pdaResultOk("组盘成功"); |
|
|
|
} |
|
|
|
|
|
|
@ -159,15 +169,16 @@ public class PdaServiceImpl implements PdaService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PrintTagVo printf(CommonPointQueryDto requestParam) { |
|
|
|
public PrintTagVo printf(CommonVehicleInfoDto requestParam) { |
|
|
|
Assert.notNull(requestParam, "参数不能为空!"); |
|
|
|
String point_code = requestParam.getPoint_code(); |
|
|
|
String vehicle_code = requestParam.getVehicle_code(); |
|
|
|
LambdaQueryWrapper<SchBaseVehiclematerialgroup> lqw = new LambdaQueryWrapper<>(); |
|
|
|
lqw.eq(SchBaseVehiclematerialgroup::getPoint_code, point_code) |
|
|
|
lqw.eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicle_code) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getLink_status, LinkStatusEnum.LINK_FINISH.getType()) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getGroup_bind_material_status, GroupBindMaterialStatusEnum.BOUND.getValue()) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getGroup_status, GroupStatusEnum.IN_STORAGE.getType()); |
|
|
|
SchBaseVehiclematerialgroup vehiclematerialgroup = vehiclematerialgroupService.getOne(lqw); |
|
|
|
Assert.notNull(vehiclematerialgroup, "点位:" + point_code + ",未找到对应的组盘信息,组盘或配盘未完成!"); |
|
|
|
Assert.notNull(vehiclematerialgroup, "载具:" + vehicle_code + ",未进行配盘!"); |
|
|
|
PrintTagVo printTagVo = new PrintTagVo(); |
|
|
|
printTagVo.setVehicle_code(vehiclematerialgroup.getVehicle_code()); |
|
|
|
printTagVo.setMaterial_code(vehiclematerialgroup.getMaterial_code()); |
|
|
@ -193,8 +204,17 @@ public class PdaServiceImpl implements PdaService { |
|
|
|
@Override |
|
|
|
public PdaResponseVo fullVehicleIn(CommonPointQueryDto requestParam) { |
|
|
|
Assert.notNull(requestParam, "参数不能为空!"); |
|
|
|
String point_code = requestParam.getPoint_code(); |
|
|
|
LambdaQueryWrapper<SchBasePoint> lqw = new LambdaQueryWrapper<>(); |
|
|
|
lqw.eq(SchBasePoint::getPoint_code, point_code) |
|
|
|
.eq(SchBasePoint::getPoint_status, PointStatusEnum.FULL_POINT.getCode()) |
|
|
|
.eq(SchBasePoint::getIs_used, true); |
|
|
|
SchBasePoint point = pointService.getOne(lqw); |
|
|
|
if (ObjectUtil.isEmpty(point)) { |
|
|
|
throw new BadRequestException("点位:" + point_code + ",状态不是有料状态!"); |
|
|
|
} |
|
|
|
JSONObject param = new JSONObject(); |
|
|
|
param.put("device_code", requestParam.getPoint_code()); |
|
|
|
param.put("device_code", point_code); |
|
|
|
param.put("config_code", "ZPRKTask"); |
|
|
|
param.put("requestNo", IdUtil.simpleUUID()); |
|
|
|
param.put("user_id", "1"); |
|
|
@ -226,10 +246,12 @@ public class PdaServiceImpl implements PdaService { |
|
|
|
new LambdaQueryWrapper<>(); |
|
|
|
lqw.eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicle_code) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getGroup_status, GroupStatusEnum.IN_STORAGE.getType()) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getLink_status, LinkStatusEnum.LINK_FINISH); |
|
|
|
.eq(SchBaseVehiclematerialgroup::getGroup_bind_material_status, GroupBindMaterialStatusEnum.BOUND.getValue()) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getLink_status, LinkStatusEnum.LINK_FINISH.getType()); |
|
|
|
SchBaseVehiclematerialgroup groupOne = vehiclematerialgroupService.getOne(lqw); |
|
|
|
Assert.notNull(groupOne, "载具号:'" + vehicle_code + "',对应的组盘信息不存在!"); |
|
|
|
this.checkQty(groupOne, residue_num); |
|
|
|
if (ObjectUtil.isNotEmpty(groupOne)) { |
|
|
|
this.checkQty(groupOne, residue_num); |
|
|
|
} |
|
|
|
JSONObject param = new JSONObject(); |
|
|
|
param.put("device_code", requestParam.getPoint_code()); |
|
|
|
param.put("config_code", "JLHCHKTask"); |
|
|
@ -252,30 +274,40 @@ public class PdaServiceImpl implements PdaService { |
|
|
|
new LambdaQueryWrapper<>(); |
|
|
|
lqw.eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicle_code) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getGroup_status, GroupStatusEnum.IN_STORAGE.getType()) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getLink_status, LinkStatusEnum.LINK_FINISH); |
|
|
|
.eq(SchBaseVehiclematerialgroup::getGroup_bind_material_status, GroupBindMaterialStatusEnum.BOUND.getValue()) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getLink_status, LinkStatusEnum.LINK_FINISH.getType()); |
|
|
|
SchBaseVehiclematerialgroup groupOne = vehiclematerialgroupService.getOne(lqw); |
|
|
|
Assert.notNull(groupOne, "载具号:'" + vehicle_code + "',对应的组盘信息不存在!"); |
|
|
|
this.checkQty(groupOne, residue_num); |
|
|
|
//如果余料数量为0
|
|
|
|
if (residue_num.matches("^0*(\\.\\d+)?$")) { |
|
|
|
groupOne.setLink_status(LinkStatusEnum.LINK_READY.getType()); |
|
|
|
groupOne.setPcsn(""); |
|
|
|
groupOne.setMaterial_code(""); |
|
|
|
groupOne.setMaterial_id(""); |
|
|
|
groupOne.setMaterial_name(""); |
|
|
|
groupOne.setInstorage_time(DateUtil.now()); |
|
|
|
groupOne.setUpdate_id(SecurityUtils.getCurrentUserId()); |
|
|
|
groupOne.setUpdate_name(SecurityUtils.getCurrentNickName()); |
|
|
|
groupOne.setUpdate_time(DateUtil.now()); |
|
|
|
groupOne.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue()); |
|
|
|
vehiclematerialgroupService.update(groupOne); |
|
|
|
|
|
|
|
SchBasePoint point = pointService.getById(point_code); |
|
|
|
point.setPoint_status(PointStatusEnum.EMPTY_VEHICLE.getCode()); |
|
|
|
pointService.update(point); |
|
|
|
} else { |
|
|
|
//如果余料数量不为0
|
|
|
|
groupOne.setMaterial_qty(residue_num); |
|
|
|
SchBaseVehiclematerialgroup copyGroup = BeanUtil.copyProperties(groupOne, SchBaseVehiclematerialgroup.class); |
|
|
|
double originalNum = Double.parseDouble(groupOne.getMaterial_qty()); |
|
|
|
double residueNum = Double.parseDouble(residue_num); |
|
|
|
double outNum = originalNum - residueNum; |
|
|
|
//解绑原有的组盘信息
|
|
|
|
groupOne.setMaterial_qty(String.valueOf(outNum)); |
|
|
|
groupOne.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue()); |
|
|
|
groupOne.setUpdate_id(SecurityUtils.getCurrentUserId()); |
|
|
|
groupOne.setUpdate_name(SecurityUtils.getCurrentNickName()); |
|
|
|
groupOne.setUpdate_time(DateUtil.now()); |
|
|
|
vehiclematerialgroupService.update(groupOne); |
|
|
|
//新增一条新的组盘信息
|
|
|
|
copyGroup.setGroup_id(IdUtil.simpleUUID()); |
|
|
|
copyGroup.setMaterial_qty(residue_num); |
|
|
|
vehiclematerialgroupService.create(copyGroup); |
|
|
|
} |
|
|
|
return PdaResponseVo.pdaResultOk("满托出库确认请求成功"); |
|
|
|
} |
|
|
@ -292,14 +324,23 @@ public class PdaServiceImpl implements PdaService { |
|
|
|
List<SchBaseVehiclematerialgroup> list = vehiclematerialgroupService.list(lqw); |
|
|
|
List<VehicleLinkVo> vehicleLinkVoList = new ArrayList<>(); |
|
|
|
for (SchBaseVehiclematerialgroup group : list) { |
|
|
|
SchBasePoint point = pointService.getById(group.getPoint_code()); |
|
|
|
if (!point.getRegion_code().equals("YCL")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
MdBaseMaterial material = materialService.getById(group.getMaterial_id()); |
|
|
|
Assert.notNull(material, "物料信息有误!未查询出对应的物料信息,物料id:" + group.getMaterial_id()); |
|
|
|
VehicleLinkVo vehicleLinkVo = new VehicleLinkVo(); |
|
|
|
vehicleLinkVo.setMaterial_id(group.getMaterial_id()); |
|
|
|
vehicleLinkVo.setGroup_id(group.getGroup_id()); |
|
|
|
vehicleLinkVo.setVehicle_code(group.getVehicle_code()); |
|
|
|
vehicleLinkVo.setMaterial_name(group.getMaterial_name()); |
|
|
|
vehicleLinkVo.setMaterial_name(material.getMaterial_name()); |
|
|
|
vehicleLinkVo.setPoint_code(group.getPoint_code()); |
|
|
|
vehicleLinkVo.setPoint_name(group.getPoint_name()); |
|
|
|
vehicleLinkVo.setPcsn(group.getPcsn()); |
|
|
|
vehicleLinkVo.setVehicle_type(group.getVehicle_type()); |
|
|
|
vehicleLinkVo.setMaterial_code(group.getMaterial_code()); |
|
|
|
vehicleLinkVo.setMaterial_code(material.getMaterial_code()); |
|
|
|
vehicleLinkVo.setMaterial_qty(group.getMaterial_qty()); |
|
|
|
vehicleLinkVoList.add(vehicleLinkVo); |
|
|
|
} |
|
|
|
return vehicleLinkVoList; |
|
|
@ -311,19 +352,23 @@ public class PdaServiceImpl implements PdaService { |
|
|
|
//除这些区域外 其它区域都存在定点流转任务
|
|
|
|
//叫料缓存区、组盘区、空托盘缓存区1、空托盘缓存区2、原材料
|
|
|
|
lqw.notIn(SchBasePoint::getRegion_code, "JLHC", "ZP", "KTPHC1", "KTPHC2", "YCL") |
|
|
|
.and(la -> la.isNotNull(SchBasePoint::getNext_point_code)) |
|
|
|
.eq(SchBasePoint::getIs_used, true); |
|
|
|
List<PointVo> list = this.copyPointVoList(pointService.list(lqw)); |
|
|
|
for (PointVo pointVo : list) { |
|
|
|
List<PointVo> end_points = pointVo.getEnd_points(); |
|
|
|
SchBasePoint point = pointService.getOne(new LambdaQueryWrapper<SchBasePoint>().eq(SchBasePoint::getPoint_code, pointVo.getPoint_code()).eq(SchBasePoint::getIs_used, true)); |
|
|
|
String[] nextPointCodes = point.getNext_point_code().split(","); |
|
|
|
for (int i = 0; i < nextPointCodes.length; i++) { |
|
|
|
String nextPointCode = nextPointCodes[i]; |
|
|
|
SchBasePoint one = pointService.getOne(new LambdaQueryWrapper<SchBasePoint>().eq(SchBasePoint::getPoint_code, nextPointCode).eq(SchBasePoint::getIs_used, true)); |
|
|
|
PointVo pv = new PointVo(); |
|
|
|
pv.setPoint_code(one.getPoint_code()); |
|
|
|
pv.setPoint_name(one.getPoint_name()); |
|
|
|
end_points.add(pv); |
|
|
|
if (StrUtil.isNotEmpty(point.getNext_point_code())) { |
|
|
|
String[] nextPointCodes = point.getNext_point_code().split(","); |
|
|
|
for (int i = 0; i < nextPointCodes.length; i++) { |
|
|
|
String nextPointCode = nextPointCodes[i]; |
|
|
|
SchBasePoint one = pointService.getOne(new LambdaQueryWrapper<SchBasePoint>().eq(SchBasePoint::getPoint_code, nextPointCode).eq(SchBasePoint::getIs_used, true)); |
|
|
|
PointVo pv = new PointVo(); |
|
|
|
pv.setPoint_id(IdUtil.simpleUUID()); |
|
|
|
pv.setPoint_code(one.getPoint_code()); |
|
|
|
pv.setPoint_name(one.getPoint_name()); |
|
|
|
end_points.add(pv); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return list; |
|
|
@ -348,6 +393,7 @@ public class PdaServiceImpl implements PdaService { |
|
|
|
List<PointVo> pointVoList = new ArrayList<>(); |
|
|
|
for (SchBasePoint point : list) { |
|
|
|
PointVo pointVo = new PointVo(); |
|
|
|
pointVo.setPoint_id(IdUtil.simpleUUID()); |
|
|
|
pointVo.setPoint_code(point.getPoint_code()); |
|
|
|
pointVo.setPoint_name(point.getPoint_name()); |
|
|
|
pointVoList.add(pointVo); |
|
|
@ -381,7 +427,8 @@ public class PdaServiceImpl implements PdaService { |
|
|
|
*/ |
|
|
|
private void checkQty(SchBaseVehiclematerialgroup groupOne, String residue_num) { |
|
|
|
String regex = "^\\d+(\\.\\d+)?0*$"; |
|
|
|
Assert.isFalse(Pattern.matches(regex, residue_num), "余料数量有误,不是0.5的整数倍"); |
|
|
|
//String regex = "^(0|([1-9]\\d*))(\\.5)?0*$";
|
|
|
|
Assert.isTrue(Pattern.matches(regex, residue_num), "余料数量有误,不是0.5的整数倍"); |
|
|
|
try { |
|
|
|
double residueNum = Double.parseDouble(residue_num); |
|
|
|
double material_qty = Double.parseDouble(groupOne.getMaterial_qty()); |
|
|
@ -389,7 +436,7 @@ public class PdaServiceImpl implements PdaService { |
|
|
|
throw new BadRequestException("回库余料数量不符合要求,大于原有数量或者小于0!"); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
throw new IllegalArgumentException("输入数据有误: " + residue_num, e); |
|
|
|
throw new BadRequestException("输入数据有误:{},{} " + residue_num + "," + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|