add:退料入库

This commit is contained in:
zhaoyf
2026-07-31 17:16:43 +08:00
parent d52b4930cb
commit 52d1f44418
9 changed files with 477 additions and 31 deletions

View File

@@ -2,21 +2,20 @@ package org.nl.wms.pda_manage.ios_manage.purchase.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.base.ResponseData;
import org.nl.common.logging.annotation.Log;
import org.nl.wms.pda_manage.ios_manage.purchase.service.InboundPdaService;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.GroupPlateInboundDto;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.ManualInboundDto;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.PdaGroupPlateDto;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.UsualInboundDto;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.*;
import org.nl.wms.pda_manage.ios_manage.purchase.service.vo.PurchaseMatInfoVo;
import org.nl.wms.pda_manage.util.PdaResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;import org.nl.common.base.ResponseData;
import org.nl.wms.pm_manage.pmreturn.service.IPmReturnService;
import org.nl.wms.pm_manage.pmreturn.service.dao.PmReturn;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@@ -26,6 +25,8 @@ import java.util.List;
public class InboundPdaController {
private final InboundPdaService inboundPdaService;
@Resource
private IPmReturnService pmReturnService;
@GetMapping("/getInfoByCode")
@Log("PDA根据条码查询采购入库单的物料信息")
@@ -41,6 +42,15 @@ public class InboundPdaController {
List<PurchaseMatInfoVo> list = inboundPdaService.getInfoByReceive(code);
return ResponseData.build(list);
}
@GetMapping("/getInfoByReturnBill")
@Log("PDA根据条码查询退料单的物料信息")
@SaIgnore
public ResponseEntity getInfoByReturnBill(@RequestParam String code) {
List<PmReturn> list = pmReturnService.list(new LambdaQueryWrapper<PmReturn>()
.eq(PmReturn::getOrder_code, code));
return ResponseData.build(list);
}
@PostMapping("/groupPlate")
@Log("PDA提交组盘")
@@ -71,6 +81,13 @@ public class InboundPdaController {
inboundPdaService.usualInbound(usualInboundDto);
return ResponseData.build();
}
@PostMapping("/returnInbound")
@Log("退料入库")
@SaIgnore
public ResponseEntity usualInbound(@RequestBody ReturnInboundDto returnInboundDto) {
inboundPdaService.returnInbound(returnInboundDto);
return ResponseData.build();
}
@GetMapping("/unfinishedBills")
@Log("PDA查询未完成采购入库单")

View File

@@ -1,10 +1,7 @@
package org.nl.wms.pda_manage.ios_manage.purchase.service;
import com.alibaba.fastjson.JSONObject;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.GroupPlateInboundDto;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.ManualInboundDto;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.PdaGroupPlateDto;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.UsualInboundDto;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.*;
import org.nl.wms.pda_manage.ios_manage.purchase.service.vo.PurchaseMatInfoVo;
import java.util.List;
@@ -24,4 +21,8 @@ public interface InboundPdaService {
void submitManualInbound(ManualInboundDto dto);
List<PurchaseMatInfoVo> getInfoByReceive(String code);
List<PurchaseMatInfoVo> getInfoByReturnBill(String code);
void returnInbound(ReturnInboundDto returnInboundDto);
}

View File

@@ -0,0 +1,28 @@
package org.nl.wms.pda_manage.ios_manage.purchase.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
@Data
public class ReturnInboundDto {
private String bill_id;
private String vehicle_code;
private String sect_code;
private List<ReturnInboundDto.ReturnInboundDtlDto> detailList;
@Data
public static class ReturnInboundDtlDto implements Serializable {
private static final long serialVersionUID = 1L;
private String order_no;
private String item_no;
private String sku_code;
private String batch_no;
private BigDecimal qty;
}
}

View File

@@ -15,10 +15,7 @@ import org.nl.common.utils.SecurityUtils;
import org.nl.wms.basedata_manage.service.*;
import org.nl.wms.basedata_manage.service.dao.*;
import org.nl.wms.pda_manage.ios_manage.purchase.service.InboundPdaService;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.GroupPlateInboundDto;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.ManualInboundDto;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.PdaGroupPlateDto;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.UsualInboundDto;
import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.*;
import org.nl.wms.pda_manage.ios_manage.purchase.service.vo.PurchaseMatInfoVo;
import org.nl.wms.pm_manage.SourceBillTypeEnum;
import org.nl.wms.pm_manage.listener.PmManageEvent;
@@ -534,6 +531,186 @@ public class InboundPdaServiceImpl implements InboundPdaService {
return purchaseMatInfoVos;
}
@Override
public List<PurchaseMatInfoVo> getInfoByReturnBill(String code) {
return Collections.emptyList();
}
@Override
@Transactional
public void returnInbound(ReturnInboundDto returnInboundDto) {
log.info("PDA提交退料入库 参数:{}", JSON.toJSONString(returnInboundDto));
// 查询库区
Sectattr sectDao = iSectattrService.findByCode(returnInboundDto.getSect_code());
if (sectDao == null){
throw new BadRequestException("仓库不存在");
}
//获取库位
List<Structattr> structList = iStructattrService.lambdaQuery()
.eq(Structattr::getSect_id, sectDao.getSect_id())
.eq(Structattr::getLock_type, LOCK_TYPE.code("未锁定"))
.eq(Structattr::getIs_used, 1)
.isNotNull(Structattr::getStoragevehicle_code)
.orderByAsc(Structattr::getCreate_time).list();
if (structList.isEmpty()){
throw new BadRequestException("入库失败:未找到可用虚拟货位");
}
Structattr struct = structList.get(0);
log.info("平库入库:找到虚拟库位{}",JSON.toJSONString(struct));
String storagevehicleCode = struct.getStoragevehicle_code();//载具编码
boolean flag = false;
List<GroupPlate> gpList = new ArrayList<>();
List<AddInvParam> addInvParams = new ArrayList<>();
for (ReturnInboundDto.ReturnInboundDtlDto item : returnInboundDto.getDetailList()) {
//判断当前物料是否在库内
List<GroupPlate> inStockGps = iMdPbGroupplateService.list(new LambdaQueryWrapper<GroupPlate>()
.eq(GroupPlate::getMaterial_code, item.getSku_code())
.eq(GroupPlate::getStatus, GROUP_PLATE_STATUS.code("入库"))
.likeRight(GroupPlate::getStoragevehicle_code, "VTP"));
if (!inStockGps.isEmpty()){
GroupPlate groupPlate = inStockGps.get(0);
Structattr structattr = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
.eq(Structattr::getStoragevehicle_code, groupPlate.getStoragevehicle_code())
.eq(Structattr::getSect_code, returnInboundDto.getSect_code())
.last("limit 1"));
if (Objects.equals(structattr.getSect_code(), returnInboundDto.getSect_code())){
//已在库,增加库存
flag = true;
AddInvParam addParam = new AddInvParam();
addParam.setPcsn(groupPlate.getPcsn());
addParam.setMaterialCode(groupPlate.getMaterial_code());
addParam.setStoragevehicleCode(groupPlate.getStoragevehicle_code());
addParam.setUnitName(groupPlate.getQty_unit_name());
addParam.setUnitId(groupPlate.getQty_unit_id());
addParam.setExtCode(groupPlate.getExt_code());
addParam.setExtType(groupPlate.getExt_type());
addParam.setSectCode(returnInboundDto.getSect_code());
addParam.setStructCode(structattr.getStruct_code());
addParam.setStorCode(structattr.getStor_code());
addParam.setQty(item.getQty());
addInvParams.add(addParam);
}
}
MdMeMaterialbase materDao = iMdMeMaterialbaseService.getByCode(item.getSku_code());
MdPbMeasureunit unitDao = iMdPbMeasureunitService.getById(materDao.getQty_unit_id());
//组盘
GroupPlate plateDao = GroupPlate.builder()
.group_id(IdUtil.getStringId())
.material_code(item.getSku_code())
.storagevehicle_code(storagevehicleCode)
.pcsn(Optional.ofNullable(item.getBatch_no()).filter(s -> !s.isEmpty()).orElse("1"))
.qty_unit_id(unitDao.getMeasure_unit_id())
.qty_unit_name(unitDao.getUnit_name())
.qty(item.getQty())
.status(GROUP_PLATE_STATUS.code("组盘"))
.ext_code(returnInboundDto.getBill_id())
.ext_type(SourceBillTypeEnum.PM_RETURN.getBillType())
.ext_dtl_code(item.getItem_no())
.create_id(SecurityUtils.getCurrentUserId())
.create_name(SecurityUtils.getCurrentNickName())
.create_time(DateUtil.now())
.build();
if (flag){
gpList.add(plateDao);
}else{
iMdPbGroupplateService.save(plateDao);
}
}
if (flag) iStInventoryService.changeInventory(InventoryChangeType.ADD_INV, addInvParams);
GroupPlateInboundDto groupPlateInboundDto = new GroupPlateInboundDto();
groupPlateInboundDto.setSect_code(sectDao.getSect_code());
groupPlateInboundDto.setVehicle_code(storagevehicleCode);
groupPlateInboundDto.setGroupPlateList(gpList);
// this.submitGroupPlateInbound(groupPlateInboundDto, false);
// 查询组盘明细
List<GroupPlate> plateDaoList;
if (groupPlateInboundDto.getGroupPlateList().isEmpty()){
plateDaoList = iMdPbGroupplateService.list(
new QueryWrapper<GroupPlate>().lambda()
.eq(GroupPlate::getStoragevehicle_code, groupPlateInboundDto.getVehicle_code())
.eq(GroupPlate::getStatus, GROUP_PLATE_STATUS.code("组盘"))
);
}else {
plateDaoList = groupPlateInboundDto.getGroupPlateList();
}
if (ObjectUtil.isEmpty(plateDaoList)) {
throw new BadRequestException("当前没有可入库的物料!");
}
// 总数量
Double total_qty = plateDaoList.stream()
.map(row -> row.getQty().doubleValue())
.reduce(Double::sum).orElse(0.0);
// 查询库区
// Sectattr sectDao = iSectattrService.findByCode(groupPlateInboundDto.getSect_code());
// 组织主表数据
Map<String, Object> jsonMst = new HashMap<>();
jsonMst.put("stor_id", sectDao.getStor_id());
jsonMst.put("bill_status", IOSEnum.BILL_STATUS.code("生成"));
jsonMst.put("total_qty", total_qty);
jsonMst.put("detail_count", 1);
jsonMst.put("bill_type", IOSEnum.BILL_TYPE.code("采购入库"));
jsonMst.put("biz_date", DateUtil.now());
// 组织明细数据
ArrayList<HashMap> tableData = new ArrayList<>();
// GroupPlate plateDao = plateDaoList.get(0);
for (GroupPlate plateDao : plateDaoList) {
HashMap<String, Object> dtl = new HashMap<>();
MdMeMaterialbase materDao = iMdMeMaterialbaseService.getByCode(plateDao.getMaterial_code());
dtl.put("storagevehicle_code", plateDao.getStoragevehicle_code());
dtl.put("material_id", materDao.getMaterial_id());
dtl.put("material_code", materDao.getMaterial_code());
dtl.put("material_name", materDao.getMaterial_name());
dtl.put("pcsn", plateDao.getPcsn());
dtl.put("qty_unit_id", plateDao.getQty_unit_id());
dtl.put("qty_unit_name", plateDao.getQty_unit_name());
dtl.put("qty", plateDao.getQty());
dtl.put("plan_qty", plateDao.getQty());
dtl.put("ext_code", plateDao.getExt_code());
dtl.put("ext_type", plateDao.getExt_type());
dtl.put("source_billdtl_id", plateDao.getExt_dtl_code());
dtl.put("callback_strategy", "dealReturnBillCallback");
// 调用新增
tableData.add(dtl);
}
jsonMst.put("tableData",tableData);
String iostorinv_id = iRawAssistIStorService.insertDtl(jsonMst);
// 查询仓库
BsrealStorattr storeDao = iSrealStorattrService.getById(sectDao.getStor_id());
// 组织主数据
Map<String, Object> jsonMst1 = new HashMap<>();
jsonMst1.put("checked", true);
jsonMst1.put("sect_id", sectDao.getSect_id());
jsonMst1.put("stor_id", sectDao.getStor_id());
jsonMst1.put("sect_code", sectDao.getSect_code());
jsonMst1.put("stor_code", storeDao.getStor_code());
jsonMst1.put("storagevehicle_code", groupPlateInboundDto.getVehicle_code());
// 组织明细数据
List<IOStorInvDtl> ioStorInvDtls = ioStorInvDtlMapper.selectList(
new QueryWrapper<IOStorInvDtl>().lambda()
.eq(IOStorInvDtl::getIostorinv_id, iostorinv_id)
);
IOStorInvDtl dtlDao = ioStorInvDtls.get(0);
// 查找分配明细
Map<String, Object> map = new HashMap<>();
map.put("iostorinvdtl_id", dtlDao.getIostorinvdtl_id());
List<IOStorInvDisDto> disDtl = iRawAssistIStorService.getDisDtl(map);
// 类型转换
disDtl.forEach(item -> {
jsonMst1.put("dis_row", JSONObject.parseObject(JSONObject.toJSONString(item), LinkedHashMap.class));
});
// 调用分配,默认自动分配库位
iRawAssistIStorService.divStruct(new JSONObject(jsonMst1));
List<IOStorInvDis> ioStorInvDis = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<IOStorInvDis>()
.eq(IOStorInvDis::getIostorinv_id, iostorinv_id));
iRawAssistIStorService.disFinish(ioStorInvDis);
}
private Map<String,Object> parseCode(String code){
String[] parts = code.split("#", -1);
log.info("采购单入库条码解析结果:{}", Arrays.toString(parts));

View File

@@ -2,8 +2,6 @@ package org.nl.wms.pm_manage;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.exception.BadRequestException;
/**
* 源单据枚举关联st_ivt_iostorinvdtl表souce_bill_type字段
@@ -14,6 +12,7 @@ public enum SourceBillTypeEnum {
PM_DEMADN("pm_demand","出库需求单"),
PM_PURCHASE("pm_purchase","采购入库单"),
PM_RECEIVING("p_receiving","生产入库"),
PM_RETURN("pm_return","退料入库"),
UNDEFINE("","未定义"),
;
/**

View File

@@ -12,7 +12,9 @@ import org.apache.commons.lang3.StringUtils;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.exception.BadRequestException;
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
import org.nl.wms.basedata_manage.service.IStructattrService;
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
import org.nl.wms.basedata_manage.service.dao.Structattr;
import org.nl.wms.ext_manage.enums.EXTConstant;
import org.nl.wms.ext_manage.service.WmsToZDWmdService;
import org.nl.wms.ext_manage.service.dto.ZDInventory;
@@ -29,8 +31,12 @@ import org.nl.wms.system_manage.service.param.dao.Param;
import org.nl.wms.warehouse_manage.enums.IOSEnum;
import org.nl.wms.warehouse_manage.inAndOut.service.IOutBillService;
import org.nl.wms.warehouse_manage.inventory.IStInventoryService;
import org.nl.wms.warehouse_manage.inventory.core.enums.InventoryChangeType;
import org.nl.wms.warehouse_manage.inventory.core.param.impl.AddInvParam;
import org.nl.wms.warehouse_manage.inventory.core.param.impl.InFinishParam;
import org.nl.wms.warehouse_manage.inventory.dto.StInventoryDto;
import org.nl.wms.warehouse_manage.inventory.dto.StInventoryQuery;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@@ -57,6 +63,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
private IMdMeMaterialbaseService iMdMeMaterialbaseService;
@Autowired
private ISysParamService iSysParamService;
@Autowired
private IStructattrService iStructattrService;
@Override
public Page<PmDemandDto> queryPage(PmDemandQuery query, PageQuery pageQuery) {
@@ -208,15 +216,42 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
List<PmDemandDto> otherDemands = partitioned.get(false);
if (!CollectionUtils.isEmpty(zdDemands)) {
wmsToZDWmdService.syncDemandOrder(zdDemands);
//直接增加对应库存并做库存记录
List<AddInvParam> addInvParams = new ArrayList<>();
List<InFinishParam> inFinishParams = new ArrayList<>();
for (PmDemandDto zdDemand : zdDemands) {
Structattr structattr = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
.eq(Structattr::getSect_code, zdDemand.getTargetHouseCode())
.isNotNull(Structattr::getStoragevehicle_code)
.last("limit 1"));
AddInvParam addInvParam = new AddInvParam();
addInvParam.setMaterialCode(zdDemand.getSkuCode());
addInvParam.setUnitId("1");
addInvParam.setUnitName(zdDemand.getUnit());
addInvParam.setPcsn("1");
addInvParam.setStoragevehicleCode(structattr.getStoragevehicle_code());
addInvParam.setQty(zdDemand.getQty());
addInvParam.setStorCode(structattr.getStor_code());
addInvParam.setSectCode(structattr.getSect_code());
addInvParam.setStructCode(structattr.getStruct_code());
addInvParams.add(addInvParam);
InFinishParam inFinishParam = new InFinishParam();
BeanUtils.copyProperties(addInvParam,inFinishParam);
inFinishParam.setRemark("中鼎需求单变动");
inFinishParams.add(inFinishParam);
}
iStInventoryService.changeInventory(InventoryChangeType.ADD_INV, addInvParams);
iStInventoryService.changeInventory(InventoryChangeType.IN_FINISH, inFinishParams);
}
if (!CollectionUtils.isEmpty(otherDemands)) {
JSONObject billParam = convertDemandsToBillParam(otherDemands);
iOutBillService.saveBill(billParam);
this.update(new LambdaUpdateWrapper<PmDemand>()
.set(PmDemand::getStatus,DemandStatus.SEND.getValue())
.in(PmDemand::getId,pmDemandDtos.stream()
.map(PmDemandDto::getId).collect(Collectors.toList())));
}
this.update(new LambdaUpdateWrapper<PmDemand>()
.set(PmDemand::getStatus,DemandStatus.SEND.getValue())
.in(PmDemand::getId,pmDemandDtos.stream()
.map(PmDemandDto::getId).collect(Collectors.toList())));
}
private JSONObject convertDemandsToBillParam(List<PmDemandDto> demands) {

View File

@@ -217,6 +217,11 @@ public class StInventoryServiceImpl implements IStInventoryService {
final List<InFinishParam> inFinishParams = (List<InFinishParam>) params;
List<StIvtStructivtflow> recordsInFinish = new ArrayList<>();
for (InFinishParam invParam : inFinishParams) {
LambdaQueryWrapper<GroupPlate> query = new QueryWrapper<GroupPlate>().lambda()
.eq(GroupPlate::getStoragevehicle_code, invParam.getStoragevehicleCode())
.eq(GroupPlate::getMaterial_code, invParam.getMaterialCode())
.eq(GroupPlate::getStatus, GROUP_PLATE_STATUS.code("入库"));
GroupPlate groupPlate = iMdPbGroupplateService.getOne(query);
//添加库存变动记录
StIvtStructivtflow record = new StIvtStructivtflow();
record.setId(IdUtil.getStringId());
@@ -224,7 +229,7 @@ public class StInventoryServiceImpl implements IStInventoryService {
record.setVehicle_code(invParam.getStoragevehicleCode());
record.setMaterial_id(invParam.getMaterialCode());
record.setPcsn(invParam.getPcsn());
record.setQty(invParam.getQty());
record.setQty(groupPlate.getQty());
record.setChange_qty(invParam.getQty());
record.setSource_form_id(invParam.getExtCode());
record.setUnit_id(invParam.getUnitId());
@@ -232,6 +237,7 @@ public class StInventoryServiceImpl implements IStInventoryService {
record.setStor_code(invParam.getStorCode());
record.setSect_code(invParam.getSectCode());
record.setGrowth(true);
record.setTask_type(invParam.getRemark());
recordsInFinish.add(record);
}
stIvtStructivtflowService.saveBatch(recordsInFinish);

View File

@@ -0,0 +1,106 @@
package org.nl.wms.warehouse_manage.stockReturn.strategy.core.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang.time.DateFormatUtils;
import org.nl.wms.ext_manage.purchase.service.dto.EasAuditRequestDto;
import org.nl.wms.ext_manage.util.ErpUtil;
import org.nl.wms.pm_manage.pmreturn.service.IPmReturnService;
import org.nl.wms.pm_manage.pmreturn.service.dao.PmReturn;
import org.nl.wms.warehouse_manage.enums.IOSEnum;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInvDtl;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvDtlMapper;
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.warehouse_manage.stockReturn.strategy.core.CallbackStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 生产入库回传
*/
@Service
public class DealReturnBillCallback implements CallbackStrategy {
@Autowired
private IPmStockReturnService iPmStockReturnService;
@Autowired
private IPmReturnService pmReturnService;
@Autowired
private IOStorInvDtlMapper ioStorInvDtlMapper;
@Override
public void buildCallback(IOStorInvDtl param) {
final String orderCode = param.getSource_bill_code();
PmReturn pmReturn = pmReturnService.getOne(new LambdaQueryWrapper<PmReturn>()
.eq(PmReturn::getOrder_code, orderCode));
List<EasAuditRequestDto.EasAuditEntryDto> entryList = new ArrayList<>();
pmReturn.setAssign_qty(pmReturn.getAssign_qty().add(param.getPlan_qty()));
boolean flag = pmReturn.getAssign_qty().compareTo(pmReturn.getQty()) >= 0;
if (flag){
//单据完成
pmReturnService.lambdaUpdate()
.set(PmReturn::getAssign_qty, pmReturn.getAssign_qty())
.set(PmReturn::getUpdate_time, DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"))
.eq(PmReturn::getId, orderCode)
.update();
//保存回传
// 创建最外层的JSONObject
JSONObject root = new JSONObject();
root.put("method", "DealLLDBBill");
root.put("type", "WMS");
// 创建data对象
JSONObject data = new JSONObject();
data.put("billNo", pmReturn.getOrder_code());
data.put("bizTypeNo", "331");
data.put("issueStorageOrgUnitNo", "01.09.14");
data.put("receiptStorageOrgUnitNo", "01.09.14");
// 创建entrys数组
JSONArray entrys = new JSONArray();
JSONObject entry = new JSONObject();
entry.put("qty", pmReturn.getAssign_qty());
entry.put("materialNo", pmReturn.getSku_code());
entry.put("unitNo", "PCS");
entry.put("receiptWarehouseNo", pmReturn.getTarget_house_code());
entry.put("issueWarehouseNo", pmReturn.getSource_house_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(pmReturn.getId());
stockReturn.setRequest_type(IOSEnum.BILL_TYPE.code("库存调拨"));
stockReturn.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中
stockReturn.setCreate_time(DateUtil.now());
stockReturn.setRequest_data(root.toJSONString());
//回传
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);
}else {
//更新分配数量
pmReturnService.lambdaUpdate()
.set(PmReturn::getAssign_qty, pmReturn.getAssign_qty())
.set(PmReturn::getUpdate_time, DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"))
.eq(PmReturn::getId, orderCode)
.update();
}
}
}

View File

@@ -129,6 +129,19 @@
</el-form>
<div slot="footer" class="dialog-footer"><el-button type="primary" @click="viewShow = false">关闭</el-button></div>
</el-dialog>
<el-dialog
:close-on-click-modal="false"
title="打印预览"
:visible.sync="printPreviewVisible"
width="700px"
@close="closePrintPreview"
>
<iframe ref="printIframe" src="about:blank" style="width: 100%; height: 500px; border: 1px solid #ddd;" />
<div slot="footer" class="dialog-footer">
<el-button type="info" @click="printPreviewVisible = false">取消</el-button>
<el-button type="primary" @click="doPrint">打印</el-button>
</div>
</el-dialog>
<el-dialog :visible.sync="inventoryLoading" title="仓库分配" width="820px" :close-on-click-modal="false" @close="closeAllocateDialog">
<div style="margin-bottom:10px;color:#606266;font-size:13px;">
物料编码:<strong>{{ currentReturn.sku_code }}</strong> &nbsp;|&nbsp;
@@ -155,7 +168,8 @@ import rrOperation from '@crud/RR.operation.vue'
import crudOperation from '@crud/CRUD.operation.vue'
import udOperation from '@crud/UD.operation.vue'
import pagination from '@crud/Pagination.vue'
import {allocate, upload} from '@/views/wms/pm_manage/pmReturn/pmReturn'
import QRCode from 'qrcode'
import { allocate, upload } from '@/views/wms/pm_manage/pmReturn/pmReturn'
const createDefaultForm = () => ({
id: '',
@@ -202,10 +216,11 @@ export default {
selectedInventory: '',
allocateSaving: false,
actionDisabled: true,
printPreviewVisible: false,
permission: {
add: ['admin', 'pmReturn:add'],
edit: ['admin', 'pmReturn:edit'],
del: ['admin', 'pmReturn:del']
add: ['pmReturn:add'],
edit: ['pmReturn:edit'],
del: ['pmReturn:del']
},
statusOptions: [
{ value: 0, label: '生成' },
@@ -317,8 +332,8 @@ export default {
}
this.currentReturn.targetHouseCode = this.selectedInventory
allocate(this.currentReturn).then(res => {
if (res.code == 400){
this.$message.warning('分配失败'+res.message)
if (res.code == 400) {
this.$message.warning('分配失败' + res.message)
return
}
this.$message.success('分配成功')
@@ -343,8 +358,8 @@ export default {
type: 'warning'
}).then(() => {
upload(this.multipleSelection[0]).then(res => {
if (res.code == 400){
this.$message.warning('分配失败'+res.message)
if (res.code == 400) {
this.$message.warning('分配失败' + res.message)
return
}
this.$message.success('下推成功')
@@ -366,10 +381,72 @@ export default {
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.crud.notify('当前项目暂未接入打印接口', CRUD.NOTIFICATION_TYPE.INFO)
this.printPreviewVisible = true
this.$nextTick(() => {
this.renderPrintContent(selections)
})
}).catch(() => {})
},
async renderPrintContent(dtlList) {
const iframe = this.$refs.printIframe
if (!iframe) return
const doc = iframe.contentDocument || (iframe.contentWindow && iframe.contentWindow.document)
if (!doc) {
setTimeout(() => this.renderPrintContent(dtlList), 100)
return
}
let html = '<!DOCTYPE html><html><head><meta charset="utf-8"><style>'
html += '*{margin:0;padding:0;box-sizing:border-box}'
html += 'body{font-family:"Microsoft YaHei",Arial,sans-serif;padding:10px}'
html += '.label{page-break-after:always;padding:10px;text-align:center;}'
html += '.label:last-child{page-break-after:auto}'
html += 'h3{text-align:center;font-size:13px;margin-bottom:3px}'
html += 'table{width:463px;border-collapse:collapse;margin:0 auto;height:224px}'
html += 'td{padding:3px 5px;border:2px solid #333;font-size:17px}'
html += '.lbl{width:25%;text-align:right;background:#f9f9f9}'
html += '.val{width:45%;text-align:left}'
html += '.qr{width:30%;text-align:center;vertical-align:middle}'
html += '@media print{@page{size:auto;margin:5mm}}'
html += '</style></head><body>'
for (const dtl of dtlList) {
const orderNo = dtl.orderCode || ''
const itemNo = dtl.serialNo || ''
const skuCode = dtl.skuCode || ''
const skuName = dtl.skuName || ''
const house_code = dtl.targetHouseCode || ''
const qty = dtl.qty || ''
// const qrText = orderNo + '#' + itemNo + '#' + skuCode + '#' + skuName + '##' + qty + '#'
const qrText = dtl.orderCode
const imgSrc = await QRCode.toDataURL(qrText, {
width: 300
})
html += '<div class="label">'
html += '<h3>上海诺力</h3>'
html += '<table>'
html += '<tr><td class="lbl">单据号</td><td class="val">' + orderNo + '</td><td class="qr" rowspan="6"><img src="' + imgSrc + '" width="150" height="150" /></td></tr>'
html += '<tr><td class="lbl">行号</td><td class="val">' + itemNo + '</td></tr>'
html += '<tr><td class="lbl">物料编码</td><td class="val">' + skuCode + '</td></tr>'
html += '<tr><td class="lbl">物料名称</td><td class="val">' + skuName + '</td></tr>'
html += '<tr><td class="lbl">数量</td><td class="val">' + qty + '</td></tr>'
html += '<tr><td class="lbl">仓库</td><td class="val">' + house_code + '</td></tr>'
html += '</table></div>'
}
html += '</body></html>'
doc.open()
doc.write(html)
doc.close()
},
doPrint() {
const iframe = this.$refs.printIframe
if (!iframe) return
iframe.contentWindow.focus()
iframe.contentWindow.print()
},
closePrintPreview() {
this.printPreviewVisible = false
}
}
}
</script>