add:配盘出库,工单下发根据产线修改bom仓库,点对点任务优化
This commit is contained in:
@@ -14,11 +14,9 @@ import org.nl.wms.ext_manage.mes.mq.producer.WorkReportProducer;
|
||||
import org.nl.wms.ext_manage.mes.service.dto.WorkReportParam;
|
||||
import org.nl.wms.ext_manage.service.MesToWmsService;
|
||||
import org.nl.wms.ext_manage.service.WmsToZDWmdService;
|
||||
import org.nl.wms.ext_manage.service.dto.FeedingRecordPushDto;
|
||||
import org.nl.wms.ext_manage.service.dto.MesTaskParams;
|
||||
import org.nl.wms.ext_manage.service.dto.ZDInventory;
|
||||
import org.nl.wms.pm_manage.demand.service.IPmDemandPlatingService;
|
||||
import org.nl.wms.ext_manage.service.dto.*;
|
||||
import org.nl.wms.pm_manage.demand.service.IPlatingDemandService;
|
||||
import org.nl.wms.pm_manage.demand.service.IPmDemandPlatingService;
|
||||
import org.nl.wms.pm_manage.demand.service.IPmDemandService;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandParam;
|
||||
import org.nl.wms.pm_manage.pmreturn.service.IPmReturnService;
|
||||
@@ -32,6 +30,7 @@ import org.nl.wms.welding_manage.service.work_order.IWorkOrderService;
|
||||
import org.nl.wms.welding_manage.service.work_order.dto.WorkOrderDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -61,6 +60,8 @@ public class MesToWmsController {
|
||||
private IPmDemandService iPmDemandService;
|
||||
@Autowired
|
||||
private IPmDemandPlatingService iPmDemandPlatingService;
|
||||
@Autowired
|
||||
private IPlatingDemandService platingDemandService;
|
||||
|
||||
@Autowired
|
||||
private IStInventoryService iStInventoryService;
|
||||
@@ -91,13 +92,27 @@ public class MesToWmsController {
|
||||
@PostMapping("api/mes/subWorkOrder")
|
||||
@SaIgnore
|
||||
@Log("工单同步")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity subWorkOrder(@RequestBody List<WorkOrderDto.WorkOrderDataDto> dtos){
|
||||
String[] filter = {};//过滤产线
|
||||
String[] filterOnDemand = {"E317"};//下发需求产线过滤
|
||||
List<String> orderCodes = new ArrayList<>();
|
||||
for (WorkOrderDto.WorkOrderDataDto dto : dtos) {
|
||||
if (!ArrayUtils.contains(filter, dto.getWorkArea())){
|
||||
if (ArrayUtils.contains(filterOnDemand, dto.getWorkArea())){
|
||||
orderCodes.add(dto.getOrderCode());
|
||||
dto.getWorkOrderBomList().forEach(bom -> {
|
||||
bom.setWarehouseCode("6.011.03");
|
||||
bom.setWarehouseName("五期智能结构件仓库");
|
||||
});
|
||||
}
|
||||
iWorkOrderService.insert(dto);
|
||||
|
||||
}
|
||||
}
|
||||
if (!orderCodes.isEmpty()) {
|
||||
platingDemandService.issueFromMes(orderCodes);
|
||||
}
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@@ -251,4 +266,4 @@ public class MesToWmsController {
|
||||
feedingRecordService.pushFeedingBill(param);
|
||||
return ResponseData.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class MesToWmsServiceImpl implements MesToWmsService {
|
||||
.eq(SchBasePoint::getPoint_type, "1"));
|
||||
|
||||
if (matPoints.isEmpty()) {
|
||||
throw new BadRequestException("叫满任务失败,库存没有当前下料口的组盘物料");
|
||||
throw new BadRequestException("叫满任务失败,缺少当前上料口配盘物料");
|
||||
}
|
||||
SchBasePoint start_point = matPoints.get(0);
|
||||
String veh = start_point.getVehicle_code();
|
||||
|
||||
@@ -17,8 +17,8 @@ public class PlatingDemandController {
|
||||
@Resource private IPlatingDemandService platingDemandService;
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<Object> page(PageQuery page, String workOrderCode, Integer status) {
|
||||
return ResponseData.build(platingDemandService.page(page.getPage() + 1L, page.getSize(), workOrderCode, status), HttpStatus.OK);
|
||||
public ResponseEntity<Object> page(PageQuery page, String workOrderCode, String workArea, String loadPort, Integer status) {
|
||||
return ResponseData.build(platingDemandService.page(page.getPage() + 1L, page.getSize(), workOrderCode, workArea, loadPort, status), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/preview")
|
||||
|
||||
@@ -9,7 +9,8 @@ import java.util.List;
|
||||
public interface IPlatingDemandService {
|
||||
List<PlatingDemandDto> preview(List<String> workOrderCodes);
|
||||
void issue(List<String> workOrderCodes);
|
||||
Page<PlatingDemandDto> page(long current, long size, String workOrderCode, Integer status);
|
||||
void issueFromMes(List<String> workOrderCodes);
|
||||
Page<PlatingDemandDto> page(long current, long size, String workOrderCode, String workArea, String loadPort, Integer status);
|
||||
List<PlatingDemandDto> unfinished();
|
||||
PlatingDemandDto detail(String id);
|
||||
void complete(String id, PlatingDemandCompleteParam param);
|
||||
|
||||
@@ -21,4 +21,6 @@ public class PmPlatingDemandItem {
|
||||
private String warehouse_code;
|
||||
private String warehouse_name;
|
||||
private BigDecimal demand_qty;
|
||||
private BigDecimal allocated_qty;
|
||||
private Integer is_ignored;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,21 @@ package org.nl.wms.pm_manage.demand.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PlatingDemandCompleteParam {
|
||||
private String palletCode;
|
||||
private String storeCode;
|
||||
private String pointCode;
|
||||
private List<Item> items;
|
||||
|
||||
@Data
|
||||
public static class Item {
|
||||
private String itemId;
|
||||
private String materialCode;
|
||||
private BigDecimal qty;
|
||||
private Boolean ignored;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,5 +27,7 @@ public class PlatingDemandDto {
|
||||
private String warehouseCode;
|
||||
private String warehouseName;
|
||||
private BigDecimal demandQty;
|
||||
private BigDecimal allocatedQty;
|
||||
private Integer ignored;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.nl.wms.warehouse_manage.enums.IOSEnum.GROUP_PLATE_STATUS;
|
||||
|
||||
@Service
|
||||
public class PlatingDemandServiceImpl implements IPlatingDemandService {
|
||||
@Resource
|
||||
@@ -79,9 +81,9 @@ public class PlatingDemandServiceImpl implements IPlatingDemandService {
|
||||
@Resource
|
||||
private IPmStockReturnService stockReturnService;
|
||||
@Resource
|
||||
private ISchBasePointService schBasePointService;
|
||||
@Resource
|
||||
private IMdPbStoragevehicleinfoService storagevehicleinfoService;
|
||||
@Resource
|
||||
private ISchBasePointService pointService;
|
||||
|
||||
@Override
|
||||
public List<PlatingDemandDto> preview(List<String> workOrderCodes) {
|
||||
@@ -116,37 +118,58 @@ public class PlatingDemandServiceImpl implements IPlatingDemandService {
|
||||
.eq(PmPlatingDemand::getLoad_port, preview.getLoadPort())) > 0) {
|
||||
throw new BadRequestException("工单" + preview.getWorkOrderCode() + "上料口" + preview.getLoadPort() + "已下发需求单");
|
||||
}
|
||||
PmPlatingDemand demand = new PmPlatingDemand();
|
||||
demand.setId(IdUtil.getStringId());
|
||||
demand.setDemand_code("PD" + DateUtil.format(new Date(), "yyyyMMddHHmmss") + UUID.randomUUID().toString().replace("-", "").substring(0, 6).toUpperCase());
|
||||
demand.setWork_order_code(preview.getWorkOrderCode());
|
||||
demand.setLoad_port(preview.getLoadPort());
|
||||
demand.setWork_area(preview.getWorkArea());
|
||||
demand.setStatus(0);
|
||||
demand.setCreate_by(SecurityUtils.getCurrentNickName());
|
||||
demand.setCreate_time(DateUtil.now());
|
||||
demandMapper.insert(demand);
|
||||
for (PlatingDemandDto.Item item : preview.getItems()) {
|
||||
PmPlatingDemandItem entity = new PmPlatingDemandItem();
|
||||
entity.setId(IdUtil.getStringId());
|
||||
entity.setDemand_id(demand.getId());
|
||||
entity.setBom_item_id(item.getId());
|
||||
entity.setMaterial_code(item.getMaterialCode());
|
||||
entity.setMaterial_name(item.getMaterialName());
|
||||
entity.setSpec(item.getSpec());
|
||||
entity.setUnit(item.getUnit());
|
||||
entity.setWarehouse_code(item.getWarehouseCode());
|
||||
entity.setWarehouse_name(item.getWarehouseName());
|
||||
entity.setDemand_qty(item.getDemandQty());
|
||||
itemMapper.insert(entity);
|
||||
}
|
||||
saveDemand(preview);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PlatingDemandDto> page(long current, long size, String workOrderCode, Integer status) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void issueFromMes(List<String> workOrderCodes) {
|
||||
for (PlatingDemandDto preview : preview(workOrderCodes)) {
|
||||
if (demandMapper.selectCount(new LambdaQueryWrapper<PmPlatingDemand>()
|
||||
.eq(PmPlatingDemand::getWork_order_code, preview.getWorkOrderCode())
|
||||
.eq(PmPlatingDemand::getLoad_port, preview.getLoadPort())) > 0) {
|
||||
continue;
|
||||
}
|
||||
saveDemand(preview);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveDemand(PlatingDemandDto preview) {
|
||||
PmPlatingDemand demand = new PmPlatingDemand();
|
||||
demand.setId(IdUtil.getStringId());
|
||||
demand.setDemand_code("PD" + DateUtil.format(new Date(), "yyyyMMddHHmmss") + UUID.randomUUID().toString().replace("-", "").substring(0, 6).toUpperCase());
|
||||
demand.setWork_order_code(preview.getWorkOrderCode());
|
||||
demand.setLoad_port(preview.getLoadPort());
|
||||
demand.setWork_area(preview.getWorkArea());
|
||||
demand.setStatus(0);
|
||||
demand.setCreate_by(SecurityUtils.getCurrentNickName());
|
||||
demand.setCreate_time(DateUtil.now());
|
||||
demandMapper.insert(demand);
|
||||
for (PlatingDemandDto.Item item : preview.getItems()) {
|
||||
PmPlatingDemandItem entity = new PmPlatingDemandItem();
|
||||
entity.setId(IdUtil.getStringId());
|
||||
entity.setDemand_id(demand.getId());
|
||||
entity.setBom_item_id(item.getId());
|
||||
entity.setMaterial_code(item.getMaterialCode());
|
||||
entity.setMaterial_name(item.getMaterialName());
|
||||
entity.setSpec(item.getSpec());
|
||||
entity.setUnit(item.getUnit());
|
||||
entity.setWarehouse_code(item.getWarehouseCode());
|
||||
entity.setWarehouse_name(item.getWarehouseName());
|
||||
entity.setDemand_qty(item.getDemandQty());
|
||||
entity.setAllocated_qty(BigDecimal.ZERO);
|
||||
entity.setIs_ignored(0);
|
||||
itemMapper.insert(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PlatingDemandDto> page(long current, long size, String workOrderCode, String workArea, String loadPort, Integer status) {
|
||||
Page<PmPlatingDemand> page = demandMapper.selectPage(new Page<PmPlatingDemand>(current, size), new LambdaQueryWrapper<PmPlatingDemand>()
|
||||
.eq(workOrderCode != null && !workOrderCode.trim().isEmpty(), PmPlatingDemand::getWork_order_code, workOrderCode)
|
||||
.eq(workArea != null && !workArea.trim().isEmpty(), PmPlatingDemand::getWork_area, workArea)
|
||||
.like(loadPort != null && !loadPort.trim().isEmpty(), PmPlatingDemand::getLoad_port, loadPort)
|
||||
.eq(status != null, PmPlatingDemand::getStatus, status).orderByDesc(PmPlatingDemand::getCreate_time));
|
||||
Page<PlatingDemandDto> result = new Page<>(page.getCurrent(), page.getSize(), page.getTotal());
|
||||
result.setRecords(page.getRecords().stream().map(this::toDto).collect(Collectors.toList()));
|
||||
@@ -156,6 +179,7 @@ public class PlatingDemandServiceImpl implements IPlatingDemandService {
|
||||
@Override
|
||||
public List<PlatingDemandDto> unfinished() {
|
||||
return demandMapper.selectList(new LambdaQueryWrapper<PmPlatingDemand>().lt(PmPlatingDemand::getStatus, 2)
|
||||
.orderByAsc(PmPlatingDemand::getLoad_port)
|
||||
.orderByAsc(PmPlatingDemand::getCreate_time)).stream().map(this::toDto).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -174,26 +198,102 @@ public class PlatingDemandServiceImpl implements IPlatingDemandService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void complete(String id, PlatingDemandCompleteParam param) {
|
||||
SchBasePoint point = schBasePointService.selectByCode(param.getPointCode());
|
||||
if (point == null) throw new BadRequestException("点位不存在:" + param.getPointCode());
|
||||
PmPlatingDemand demand = demandMapper.selectById(id);
|
||||
if (demand == null || demand.getStatus() == 2) throw new BadRequestException("需求单不存在或已完成");
|
||||
if (param == null || param.getPalletCode() == null || param.getPalletCode().trim().isEmpty())
|
||||
throw new BadRequestException("请输入托盘编码");
|
||||
storagevehicleinfoService.chackAndInsert(param.getPalletCode());
|
||||
if (param == null || CollectionUtils.isEmpty(param.getItems()))
|
||||
throw new BadRequestException("请填写本次配盘物料");
|
||||
List<PmPlatingDemandItem> items = items(id);
|
||||
List<GroupPlate> plates = groupplateService.list(new LambdaQueryWrapper<GroupPlate>().eq(GroupPlate::getStoragevehicle_code, param.getPalletCode()).ne(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("出库")));
|
||||
Map<String, BigDecimal> palletQty = plates.stream().collect(Collectors.groupingBy(GroupPlate::getMaterial_code, Collectors.mapping(GroupPlate::getQty, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
|
||||
for (PmPlatingDemandItem item : items)
|
||||
if (palletQty.getOrDefault(item.getMaterial_code(), BigDecimal.ZERO).compareTo(item.getDemand_qty()) < 0)
|
||||
throw new BadRequestException("托盘物料不足:" + item.getMaterial_code());
|
||||
Structattr struct = structattrService.getOne(new LambdaQueryWrapper<Structattr>().eq(Structattr::getSect_code, param.getStoreCode()).last("limit 1"));
|
||||
if (struct == null) throw new BadRequestException("托盘未绑定库位:" + param.getPalletCode());
|
||||
saveOutbound(demand, items, struct, param.getPalletCode());
|
||||
demandMapper.update(null, new LambdaUpdateWrapper<PmPlatingDemand>().eq(PmPlatingDemand::getId, id).set(PmPlatingDemand::getStatus, 2).set(PmPlatingDemand::getPallet_code, param.getPalletCode()).set(PmPlatingDemand::getFinish_time, DateUtil.now()));
|
||||
Map<String, PmPlatingDemandItem> itemMap = items.stream().collect(Collectors.toMap(PmPlatingDemandItem::getId, Function.identity()));
|
||||
Map<PmPlatingDemandItem, BigDecimal> allocations = new LinkedHashMap<>();
|
||||
boolean changed = false;
|
||||
for (PlatingDemandCompleteParam.Item input : param.getItems()) {
|
||||
PmPlatingDemandItem item = itemMap.get(input.getItemId());
|
||||
if (item == null) throw new BadRequestException("需求单物料明细不存在:" + input.getItemId());
|
||||
BigDecimal allocated = item.getAllocated_qty() == null ? BigDecimal.ZERO : item.getAllocated_qty();
|
||||
BigDecimal qty = input.getQty() == null ? BigDecimal.ZERO : input.getQty();
|
||||
if (qty.compareTo(BigDecimal.ZERO) < 0) throw new BadRequestException("配盘数量不能小于0");
|
||||
if (Boolean.TRUE.equals(input.getIgnored())) {
|
||||
if (qty.compareTo(BigDecimal.ZERO) > 0) throw new BadRequestException("忽略物料的本次配盘数量必须为0");
|
||||
if (!Objects.equals(item.getIs_ignored(), 1)) changed = true;
|
||||
itemMapper.update(null, new LambdaUpdateWrapper<PmPlatingDemandItem>()
|
||||
.eq(PmPlatingDemandItem::getId, item.getId()).set(PmPlatingDemandItem::getIs_ignored, 1));
|
||||
continue;
|
||||
}
|
||||
if (Objects.equals(item.getIs_ignored(), 1)) throw new BadRequestException("已忽略的物料不能继续配盘");
|
||||
if (allocated.add(qty).compareTo(item.getDemand_qty()) > 0)
|
||||
throw new BadRequestException("物料配盘数量超过剩余需求:" + item.getMaterial_code());
|
||||
if (qty.compareTo(BigDecimal.ZERO) > 0) {
|
||||
allocations.put(item, qty);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (!changed) throw new BadRequestException("请填写配盘数量或选择需要忽略的物料");
|
||||
if (!allocations.isEmpty()) {
|
||||
if (param.getPalletCode() == null || param.getPalletCode().trim().isEmpty())
|
||||
throw new BadRequestException("请输入托盘编码");
|
||||
storagevehicleinfoService.chackAndInsert(param.getPalletCode());
|
||||
// List<GroupPlate> plates = groupplateService.list(new LambdaQueryWrapper<GroupPlate>()
|
||||
// .eq(GroupPlate::getStoragevehicle_code, param.getPalletCode())
|
||||
// .ne(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("出库")));
|
||||
// Map<String, BigDecimal> palletQty = plates.stream().collect(Collectors.groupingBy(GroupPlate::getMaterial_code,
|
||||
// Collectors.mapping(GroupPlate::getQty, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
|
||||
// Map<String, BigDecimal> requested = allocations.entrySet().stream().collect(Collectors.groupingBy(
|
||||
// entry -> entry.getKey().getMaterial_code(), Collectors.mapping(Map.Entry::getValue, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
|
||||
// for (Map.Entry<String, BigDecimal> entry : requested.entrySet()) {
|
||||
// if (palletQty.getOrDefault(entry.getKey(), BigDecimal.ZERO).compareTo(entry.getValue()) < 0)
|
||||
// throw new BadRequestException("托盘物料不足:" + entry.getKey());
|
||||
// }
|
||||
Structattr struct = structattrService.getOne(new LambdaQueryWrapper<Structattr>()
|
||||
.eq(Structattr::getSect_code, param.getStoreCode()).last("limit 1"));
|
||||
if (struct == null) {
|
||||
throw new BadRequestException("仓库未创建库位:" + param.getStoreCode());
|
||||
}
|
||||
saveOutbound(demand, allocations, struct, struct.getStoragevehicle_code());
|
||||
for (PlatingDemandCompleteParam.Item item : param.getItems()) {
|
||||
MdMeMaterialbase materialbase = materialService.getByCode(item.getMaterialCode());
|
||||
//组盘
|
||||
GroupPlate plateDao = GroupPlate.builder()
|
||||
.group_id(IdUtil.getStringId())
|
||||
.material_code(materialbase.getMaterial_code())
|
||||
.storagevehicle_code(param.getPalletCode())
|
||||
.pcsn("1")
|
||||
.qty_unit_id(materialbase.getQty_unit_id())
|
||||
.qty_unit_name(materialbase.getQty_unit_name())
|
||||
.qty(item.getQty())
|
||||
.status(GROUP_PLATE_STATUS.code("出库"))
|
||||
.load_port(demand.getLoad_port())
|
||||
.ext_code("")
|
||||
.ext_type("")
|
||||
.ext_dtl_code("")
|
||||
.create_id(SecurityUtils.getCurrentUserId())
|
||||
.create_name(SecurityUtils.getCurrentNickName())
|
||||
.create_time(DateUtil.now())
|
||||
.build();
|
||||
groupplateService.save(plateDao);
|
||||
}
|
||||
pointService.update(new LambdaUpdateWrapper<SchBasePoint>()
|
||||
.set(SchBasePoint::getVehicle_code, param.getPalletCode())
|
||||
.eq(SchBasePoint::getPoint_code, param.getPointCode()));//绑定点位
|
||||
for (Map.Entry<PmPlatingDemandItem, BigDecimal> entry : allocations.entrySet()) {
|
||||
BigDecimal allocated = entry.getKey().getAllocated_qty() == null ? BigDecimal.ZERO : entry.getKey().getAllocated_qty();
|
||||
itemMapper.update(null, new LambdaUpdateWrapper<PmPlatingDemandItem>()
|
||||
.eq(PmPlatingDemandItem::getId, entry.getKey().getId())
|
||||
.set(PmPlatingDemandItem::getAllocated_qty, allocated.add(entry.getValue())));
|
||||
}
|
||||
}
|
||||
List<PmPlatingDemandItem> currentItems = items(id);
|
||||
boolean finished = currentItems.stream().allMatch(item -> Objects.equals(item.getIs_ignored(), 1)
|
||||
|| (item.getAllocated_qty() != null && item.getAllocated_qty().compareTo(item.getDemand_qty()) >= 0));
|
||||
LambdaUpdateWrapper<PmPlatingDemand> update = new LambdaUpdateWrapper<PmPlatingDemand>()
|
||||
.eq(PmPlatingDemand::getId, id).set(PmPlatingDemand::getStatus, finished ? 2 : 1);
|
||||
if (param.getPalletCode() != null && !param.getPalletCode().trim().isEmpty())
|
||||
update.set(PmPlatingDemand::getPallet_code, param.getPalletCode());
|
||||
if (finished) update.set(PmPlatingDemand::getFinish_time, DateUtil.now());
|
||||
demandMapper.update(null, update);
|
||||
}
|
||||
|
||||
private void saveOutbound(PmPlatingDemand demand, List<PmPlatingDemandItem> items, Structattr struct, String palletCode) {
|
||||
private void saveOutbound(PmPlatingDemand demand, Map<PmPlatingDemandItem, BigDecimal> allocations, Structattr struct, String palletCode) {
|
||||
List<PmPlatingDemandItem> items = new ArrayList<>(allocations.keySet());
|
||||
Map<String, MdMeMaterialbase> materials = materialService.list(new LambdaQueryWrapper<MdMeMaterialbase>().in(MdMeMaterialbase::getMaterial_code, items.stream().map(PmPlatingDemandItem::getMaterial_code).collect(Collectors.toList()))).stream().collect(Collectors.toMap(MdMeMaterialbase::getMaterial_code, Function.identity()));
|
||||
WorkOrderDao order = workOrderService.getWorkOrder(demand.getWork_order_code());
|
||||
IOStorInv bill = new IOStorInv();
|
||||
@@ -220,6 +320,7 @@ public class PlatingDemandServiceImpl implements IPlatingDemandService {
|
||||
int seq = 1;
|
||||
Map<String, WorkOrderBomDao> boms = workOrderService.getOrderBomItem(demand.getWork_order_code()).stream().collect(Collectors.toMap(WorkOrderBomDao::getId, Function.identity()));
|
||||
for (PmPlatingDemandItem item : items) {
|
||||
BigDecimal qty = allocations.get(item);
|
||||
MdMeMaterialbase material = materials.get(item.getMaterial_code());
|
||||
if (material == null) throw new BadRequestException("物料不存在:" + item.getMaterial_code());
|
||||
IOStorInvDtl detail = new IOStorInvDtl();
|
||||
@@ -232,8 +333,8 @@ public class PlatingDemandServiceImpl implements IPlatingDemandService {
|
||||
detail.setQty_unit_name(material.getQty_unit_name());
|
||||
detail.setPcsn("1");
|
||||
detail.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
|
||||
detail.setPlan_qty(item.getDemand_qty());
|
||||
detail.setAssign_qty(item.getDemand_qty());
|
||||
detail.setPlan_qty(qty);
|
||||
detail.setAssign_qty(qty);
|
||||
detail.setUnassign_qty(BigDecimal.ZERO);
|
||||
detail.setSource_bill_code(demand.getWork_order_code());
|
||||
detail.setSource_bill_type("work_order");
|
||||
@@ -253,16 +354,16 @@ public class PlatingDemandServiceImpl implements IPlatingDemandService {
|
||||
dis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("是"));
|
||||
dis.setQty_unit_id(material.getQty_unit_id());
|
||||
dis.setQty_unit_name(material.getQty_unit_name());
|
||||
dis.setPlan_qty(item.getDemand_qty());
|
||||
dis.setReal_qty(item.getDemand_qty());
|
||||
dis.setPlan_qty(qty);
|
||||
dis.setReal_qty(qty);
|
||||
distributions.add(dis);
|
||||
changes.add(OutFinishParam.builder().storagevehicleCode(palletCode).sectCode(struct.getSect_code()).structCode(struct.getStruct_code()).materialCode(item.getMaterial_code()).changeQty(item.getDemand_qty()).build());
|
||||
changes.add(OutFinishParam.builder().storagevehicleCode(palletCode).sectCode(struct.getSect_code()).structCode(struct.getStruct_code()).materialCode(item.getMaterial_code()).changeQty(qty).build());
|
||||
WorkOrderBomDao bom = boms.get(item.getBom_item_id());
|
||||
JSONObject entry = new JSONObject();
|
||||
entry.put("srcbillno", demand.getWork_order_code());
|
||||
entry.put("srcbillid", order.getOrder_id());
|
||||
entry.put("srcbillentryid", bom == null ? null : bom.getItem_id());
|
||||
entry.put("qty", item.getDemand_qty());
|
||||
entry.put("qty", qty);
|
||||
entries.add(entry);
|
||||
}
|
||||
ioStorInvMapper.insert(bill);
|
||||
@@ -324,7 +425,7 @@ public class PlatingDemandServiceImpl implements IPlatingDemandService {
|
||||
|
||||
private PlatingDemandDto.Item toItem(PmPlatingDemandItem item) {
|
||||
PlatingDemandDto.Item dto = new PlatingDemandDto.Item();
|
||||
dto.setId(item.getBom_item_id());
|
||||
dto.setId(item.getId());
|
||||
dto.setMaterialCode(item.getMaterial_code());
|
||||
dto.setMaterialName(item.getMaterial_name());
|
||||
dto.setSpec(item.getSpec());
|
||||
@@ -332,6 +433,8 @@ public class PlatingDemandServiceImpl implements IPlatingDemandService {
|
||||
dto.setWarehouseCode(item.getWarehouse_code());
|
||||
dto.setWarehouseName(item.getWarehouse_name());
|
||||
dto.setDemandQty(item.getDemand_qty());
|
||||
dto.setAllocatedQty(item.getAllocated_qty() == null ? BigDecimal.ZERO : item.getAllocated_qty());
|
||||
dto.setIgnored(item.getIs_ignored() == null ? 0 : item.getIs_ignored());
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,13 @@ package org.nl.wms.sch_manage.service.core.tasks;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.basedata_manage.service.IStructattrService;
|
||||
import org.nl.wms.ext_manage.util.ErpUtil;
|
||||
import org.nl.wms.sch_manage.enums.TaskStatus;
|
||||
import org.nl.wms.sch_manage.service.ISchBasePointService;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseTaskService;
|
||||
@@ -22,19 +19,12 @@ import org.nl.wms.sch_manage.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
|
||||
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_manage.service.IMdPbGroupplateService;
|
||||
import org.nl.wms.warehouse_manage.service.dao.GroupPlate;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.dao.PmStockReturn;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
|
||||
import org.nl.wms.welding_manage.service.work_order.IWorkOrderService;
|
||||
import org.nl.wms.welding_manage.service.work_order.dao.WorkOrderBomDao;
|
||||
import org.nl.wms.welding_manage.service.work_order.dao.WorkOrderDao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 点对点搬运任务
|
||||
*/
|
||||
@@ -172,64 +162,6 @@ public class Point2PointTask extends AbstractTask {
|
||||
taskObj.setRemark("已完成");
|
||||
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
||||
taskService.updateById(taskObj);
|
||||
//获取组盘信息
|
||||
String workOrderCode = taskObj.getExt_group_data();
|
||||
String vehicleCode = taskObj.getVehicle_code();
|
||||
List<GroupPlate> groupList = iMdPbGroupplateService.list(new LambdaQueryWrapper<GroupPlate>()
|
||||
.eq(GroupPlate::getStoragevehicle_code, vehicleCode)
|
||||
.eq(GroupPlate::getExt_code, workOrderCode)
|
||||
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("组盘")));
|
||||
//获取工单信息
|
||||
WorkOrderDao workOrder = iWorkOrderService.getWorkOrder(workOrderCode);
|
||||
List<WorkOrderBomDao> orderBomItems = iWorkOrderService.getOrderBomItem(workOrderCode);
|
||||
|
||||
// 创建最外层的JSONObject
|
||||
JSONObject root = new JSONObject();
|
||||
root.put("method", "DealLLDBBill");
|
||||
root.put("type", "WMS");
|
||||
// 创建data对象
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("billNo", taskObj.getTask_id());
|
||||
data.put("bizTypeNo", "331");
|
||||
data.put("issueStorageOrgUnitNo", workOrder.getOrg_code());
|
||||
data.put("receiptStorageOrgUnitNo", workOrder.getOrg_code());
|
||||
// 创建entrys数组
|
||||
JSONArray entrys = new JSONArray();
|
||||
for (GroupPlate plate : groupList) {
|
||||
for (WorkOrderBomDao orderBomItem : orderBomItems) {
|
||||
if (plate.getMaterial_code().equals(orderBomItem.getMaterial_code())){
|
||||
JSONObject entry = new JSONObject();
|
||||
entry.put("qty", plate.getQty());
|
||||
entry.put("materialNo", orderBomItem.getMaterial_code());
|
||||
entry.put("unitNo", "PCS");
|
||||
entry.put("receiptWarehouseNo", workOrder.getDefault_warehouse_code());
|
||||
entry.put("issueWarehouseNo", orderBomItem.getWarehouse_code());
|
||||
// 将entry添加到数组中
|
||||
entrys.add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 将entrys数组设置到data中
|
||||
data.put("entrys", entrys);
|
||||
// 将data设置到根对象中
|
||||
root.put("data", data);
|
||||
// ErpUtil.create().login().audit(root.toJSONString());
|
||||
//保存回传单
|
||||
PmStockReturn stockReturn = new PmStockReturn();
|
||||
stockReturn.setRequest_Id(workOrder.getOrder_id());
|
||||
stockReturn.setRequest_type(IOSEnum.BILL_TYPE.code("库存调拨"));
|
||||
stockReturn.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中
|
||||
stockReturn.setCreate_time(DateUtil.now());
|
||||
stockReturn.setRequest_data(root.toJSONString());
|
||||
//调erp业务接口
|
||||
try {
|
||||
ErpUtil.create().login().audit(root.toJSONString());
|
||||
stockReturn.setStatus(StockReturnStatusEnum.SUCESS.getCode());
|
||||
} catch (Exception e) {
|
||||
stockReturn.setError_msg(e.getMessage());
|
||||
stockReturn.setStatus(StockReturnStatusEnum.FAIL.getCode());
|
||||
}
|
||||
iPmStockReturnService.save(stockReturn);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
<div class="app-container">
|
||||
<div class="head-container">
|
||||
<el-form :inline="true" size="mini">
|
||||
<el-form-item label="工单编号"><el-input v-model="query.workOrderCode" clearable @keyup.enter.native="loadData" /></el-form-item>
|
||||
<el-form-item label="工单编号"><el-input v-model="query.workOrderCode" clearable @keyup.enter.native="crud.toQuery" /></el-form-item>
|
||||
<el-form-item label="产线"><el-input v-model="query.workArea" clearable placeholder="请输入产线" @keyup.enter.native="crud.toQuery" /></el-form-item>
|
||||
<el-form-item label="上料口"><el-input v-model="query.loadPort" clearable placeholder="请输入上料口" @keyup.enter.native="crud.toQuery" /></el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="query.status" clearable @change="loadData"><el-option v-for="item in statuses" :key="item.value" :label="item.label" :value="item.value" /></el-select>
|
||||
<el-select v-model="query.status" clearable @change="crud.toQuery"><el-option v-for="item in statuses" :key="item.value" :label="item.label" :value="item.value" /></el-select>
|
||||
</el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" @click="loadData">查询</el-button>
|
||||
<el-button type="primary" icon="el-icon-search" @click="crud.toQuery">查询</el-button>
|
||||
</el-form>
|
||||
<el-table v-loading="loading" :data="data" border size="small">
|
||||
<el-table v-loading="crud.loading" :data="crud.data" border size="small">
|
||||
<el-table-column prop="demandCode" label="需求单编号" min-width="160" />
|
||||
<el-table-column prop="workOrderCode" label="工单编号" min-width="150" />
|
||||
<el-table-column prop="loadPort" label="上料口" min-width="150" />
|
||||
@@ -18,33 +20,38 @@
|
||||
<el-table-column prop="createTime" label="创建时间" min-width="160" />
|
||||
<el-table-column label="物料明细" width="100" align="center"><template slot-scope="scope"><el-button type="text" size="mini" @click="showItems(scope.row)">查看</el-button></template></el-table-column>
|
||||
</el-table>
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="query.page" :limit.sync="query.size" @pagination="loadData" />
|
||||
<pagination />
|
||||
</div>
|
||||
<el-dialog :visible.sync="detailVisible" title="需求物料" width="960px"><el-table :data="current.items" size="small" border><el-table-column prop="materialCode" label="物料编码" min-width="150" /><el-table-column prop="materialName" label="物料名称" min-width="160" /><el-table-column prop="spec" label="规格" min-width="120" /><el-table-column prop="warehouseCode" label="仓库编码" min-width="120" /><el-table-column prop="warehouseName" label="仓库名称" min-width="150" /><el-table-column prop="demandQty" label="需求数量" width="110" /><el-table-column prop="unit" label="单位" width="80" /></el-table></el-dialog>
|
||||
<el-dialog :visible.sync="detailVisible" title="需求物料" width="1100px"><el-table :data="current.items" size="small" border><el-table-column prop="materialCode" label="物料编码" min-width="150" /><el-table-column prop="materialName" label="物料名称" min-width="160" /><el-table-column prop="spec" label="规格" min-width="120" /><el-table-column prop="warehouseCode" label="仓库编码" min-width="120" /><el-table-column prop="warehouseName" label="仓库名称" min-width="150" /><el-table-column prop="demandQty" label="需求数量" width="110" /><el-table-column prop="allocatedQty" label="已配数量" width="110" /><el-table-column label="状态" width="90"><template slot-scope="scope">{{ scope.row.ignored === 1 ? '已忽略' : '正常' }}</template></el-table-column><el-table-column prop="unit" label="单位" width="80" /></el-table></el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CRUD, { crud, header, presenter } from '@crud/crud'
|
||||
import pagination from '@crud/Pagination.vue'
|
||||
import api from './demand'
|
||||
|
||||
export default {
|
||||
name: 'PlatingDemand',
|
||||
components: { pagination },
|
||||
mixins: [presenter(), header(), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
title: '托盘配料需求单',
|
||||
url: 'api/platingDemand',
|
||||
idField: 'id',
|
||||
sort: 'create_time,desc',
|
||||
query: { workOrderCode: '', workArea: '', loadPort: '', status: undefined },
|
||||
optShow: { add: false, edit: false, del: false, reset: true }
|
||||
})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
data: [],
|
||||
total: 0,
|
||||
query: { page: 0, size: 20, workOrderCode: '', status: undefined },
|
||||
statuses: [{ value: 0, label: '创建' }, { value: 1, label: '配盘中' }, { value: 2, label: '完成' }],
|
||||
detailVisible: false,
|
||||
current: { items: [] }
|
||||
}
|
||||
},
|
||||
created() { this.loadData() },
|
||||
methods: {
|
||||
loadData() { this.loading = true; api.getList(this.query).then(result => { this.data = result.data || []; this.total = result.totalElements || 0 }).finally(() => { this.loading = false }) },
|
||||
showItems(row) { this.current = row; this.detailVisible = true },
|
||||
statusLabel(status) { const item = this.statuses.find(value => value.value === status); return item ? item.label : '-' },
|
||||
statusType(status) { return ['info', 'warning', 'success'][status] || 'info' }
|
||||
|
||||
@@ -17,9 +17,16 @@
|
||||
<template v-if="current">
|
||||
<van-divider>需求物料</van-divider>
|
||||
<van-cell-group inset>
|
||||
<van-cell v-for="item in current.items" :key="item.id" :title="item.materialCode"
|
||||
:label="item.materialName + (item.spec ? ' ' + item.spec : '') + (item.warehouseName ? ' | ' + item.warehouseName : '')"
|
||||
:value="item.demandQty + ' ' + item.unit"/>
|
||||
<div v-for="item in current.items" :key="item.id" class="material-card">
|
||||
<van-cell :title="item.materialCode"
|
||||
:label="item.materialName + (item.spec ? ' ' + item.spec : '') + (item.warehouseName ? ' | ' + item.warehouseName : '')"
|
||||
:value="'剩余 ' + remainingQty(item) + ' ' + item.unit"/>
|
||||
<van-field v-model="item.inputQty" type="number" label="本次数量" :disabled="item.ignore || item.ignored === 1" placeholder="请输入本托盘数量"/>
|
||||
<van-cell title="现场无料,忽略该物料">
|
||||
<template #right-icon><van-switch v-model="item.ignore" :disabled="item.ignored === 1" size="22"/></template>
|
||||
</van-cell>
|
||||
<div class="progress-text">需求 {{ item.demandQty }},已配 {{ item.allocatedQty || 0 }}</div>
|
||||
</div>
|
||||
</van-cell-group>
|
||||
<van-field v-model="palletCode" label="托盘编码" placeholder="请扫描或输入托盘编码" clearable/>
|
||||
<BottomButton text="完成配盘并出库" :loading="submitting" @click="complete"/>
|
||||
@@ -60,27 +67,52 @@ async function loadDemands() {
|
||||
|
||||
async function selectDemand(id) {
|
||||
const res = await request.get(`/api/pda/platingDemand/${id}`);
|
||||
current.value = res.data;
|
||||
current.value = {
|
||||
...res.data,
|
||||
items: (res.data.items || []).map(item => ({
|
||||
...item,
|
||||
inputQty: item.ignored === 1 ? '0' : String(remainingQty(item)),
|
||||
ignore: item.ignored === 1,
|
||||
})),
|
||||
};
|
||||
palletCode.value = ''
|
||||
}
|
||||
|
||||
function remainingQty(item) {
|
||||
return Math.max(0, Number(item.demandQty || 0) - Number(item.allocatedQty || 0))
|
||||
}
|
||||
|
||||
async function complete() {
|
||||
if (!palletCode.value) {
|
||||
const items = current.value.items
|
||||
.filter(item => item.ignored !== 1 && remainingQty(item) > 0)
|
||||
.map(item => ({
|
||||
itemId: item.id,
|
||||
qty: item.ignore ? 0 : Number(item.inputQty || 0),
|
||||
ignored: item.ignore,
|
||||
}))
|
||||
if (!items.some(item => item.ignored || item.qty > 0)) {
|
||||
showToast({message: '请填写本次配盘数量或选择忽略物料', type: 'fail'});
|
||||
return
|
||||
}
|
||||
if (items.some(item => item.qty > 0) && !palletCode.value) {
|
||||
showToast({message: '请输入托盘编码', type: 'fail'});
|
||||
return
|
||||
}
|
||||
try {
|
||||
await showConfirmDialog({title: '确认完成', message: '将按需求数量生产出库并创建回传单,确认继续?'})
|
||||
await showConfirmDialog({title: '确认提交', message: '将按本次填写数量执行当前托盘出库,确认继续?'})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
try {
|
||||
await request.post(`/api/pda/platingDemand/${current.value.id}/complete`, {palletCode: palletCode.value});
|
||||
showToast({message: '配盘完成', type: 'success'});
|
||||
current.value = null;
|
||||
const demandId = current.value.id
|
||||
await request.post(`/api/pda/platingDemand/${demandId}/complete`, {palletCode: palletCode.value, items});
|
||||
showToast({message: '本托盘配盘成功', type: 'success'});
|
||||
palletCode.value = '';
|
||||
await loadDemands()
|
||||
const unfinished = demands.value.some(item => item.id === demandId)
|
||||
if (unfinished) await selectDemand(demandId)
|
||||
else current.value = null
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
@@ -95,4 +127,15 @@ onMounted(loadDemands)
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.material-card {
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.progress-text {
|
||||
padding: 0 16px 8px;
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -28,7 +28,16 @@ CREATE TABLE `pm_plating_demand_item` (
|
||||
`warehouse_code` varchar(100) DEFAULT NULL COMMENT '领料仓库编码',
|
||||
`warehouse_name` varchar(255) DEFAULT NULL COMMENT '领料仓库名称',
|
||||
`demand_qty` decimal(20,8) NOT NULL COMMENT '需求数量',
|
||||
`allocated_qty` decimal(20,8) NOT NULL DEFAULT 0 COMMENT '累计已配盘数量',
|
||||
`is_ignored` tinyint NOT NULL DEFAULT 0 COMMENT '是否忽略:0-否,1-是',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_demand_id` (`demand_id`),
|
||||
KEY `idx_material_code` (`material_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='托盘配料需求单明细表';
|
||||
|
||||
-- 已执行旧版建表脚本的数据库使用以下增量语句:
|
||||
-- ALTER TABLE `pm_plating_demand_item`
|
||||
-- ADD COLUMN `warehouse_code` varchar(100) DEFAULT NULL COMMENT '领料仓库编码' AFTER `unit`,
|
||||
-- ADD COLUMN `warehouse_name` varchar(255) DEFAULT NULL COMMENT '领料仓库名称' AFTER `warehouse_code`,
|
||||
-- ADD COLUMN `allocated_qty` decimal(20,8) NOT NULL DEFAULT 0 COMMENT '累计已配盘数量' AFTER `demand_qty`,
|
||||
-- ADD COLUMN `is_ignored` tinyint NOT NULL DEFAULT 0 COMMENT '是否忽略:0-否,1-是' AFTER `allocated_qty`;
|
||||
|
||||
Reference in New Issue
Block a user