opt:优化倒扣逻辑改成同步EAS一起过账,EAS非库存的失败标记过账失败
This commit is contained in:
@@ -82,7 +82,7 @@ public class MesReportServiceImpl implements MesReportService {
|
||||
sideDto.setReportParam(JSON.toJSONString(workReportParam));
|
||||
sideDto.setTrackNo(workReportParam.getTrackNo());
|
||||
sideDto.setWorkArea(workReportParam.getWorkArea());
|
||||
pdaIosOutService.directConfirm(sideDto);
|
||||
pdaIosOutService.directConfirmByAfter(sideDto);
|
||||
}catch (Exception ex){
|
||||
log.error("报工回传异常:{}",ex);
|
||||
ReceiveOutReturn entity = new ReceiveOutReturn();
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ErpUtil {
|
||||
* 审核接口请求
|
||||
*/
|
||||
public JSONObject audit(String json){
|
||||
log.warn("----"+json);
|
||||
log.warn("--easaudit--"+json);
|
||||
try {
|
||||
call.clearOperation();
|
||||
call.setOperationName("dealTask");
|
||||
@@ -90,8 +90,7 @@ public class ErpUtil {
|
||||
if (resultJson.getBoolean("status") == false){
|
||||
throw new BadRequestException("EAS接口请求失败失败:" + resultJson.getString("message"));
|
||||
}
|
||||
log.error("Eas接口请求成功!");
|
||||
log.error("Eas接口invoke调用结果:" + result);
|
||||
log.info("--easaudit-sucess-");
|
||||
return resultJson;
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("erp审核接口请求失败:" + e.getMessage());
|
||||
|
||||
@@ -58,6 +58,13 @@ public interface PdaIosOutService {
|
||||
*/
|
||||
PdaResponse directConfirm(LineSideDto whereJson);
|
||||
|
||||
/**
|
||||
* WMS过账后置跟EAS一起
|
||||
* @param whereJson
|
||||
* @return
|
||||
*/
|
||||
PdaResponse directConfirmByAfter(LineSideDto whereJson);
|
||||
|
||||
/**
|
||||
* 货架与站点绑定或解绑
|
||||
*
|
||||
|
||||
@@ -279,6 +279,9 @@ public class PdaIosOutServiceImpl implements PdaIosOutService {
|
||||
for (WorkOrderBomItem bomItem : workOrderBomItems) {
|
||||
final String materialCode = bomItem.getMaterialCode();
|
||||
final BigDecimal bomQty = bomItem.getBomQty();
|
||||
if (bomQty == null || bomQty.intValue() == 0){
|
||||
continue;
|
||||
}
|
||||
final BigDecimal qty = bomQty.multiply(param.getReportedQty()).setScale(0, RoundingMode.HALF_UP);
|
||||
final BigDecimal actualQty = groupInventoryMap.get(materialCode) == null?BigDecimal.ZERO:groupInventoryMap.get(materialCode).setScale(0, RoundingMode.HALF_UP);
|
||||
ReceiveOutRequest.Entrys entry = new ReceiveOutRequest.Entrys();
|
||||
@@ -301,7 +304,8 @@ public class PdaIosOutServiceImpl implements PdaIosOutService {
|
||||
entry.setRemark("WMS库存不足:当前" + actualQty + "需求" + qty.intValue());
|
||||
}
|
||||
entrys.add(entry);
|
||||
}else {
|
||||
}
|
||||
else {
|
||||
final BigDecimal subtract = groupInventoryMap.get(materialCode).subtract(qty);
|
||||
groupInventoryMap.put(materialCode,subtract.setScale(0, RoundingMode.HALF_UP));
|
||||
final IOStorInvDtl ioStorInvDtl = new IOStorInvDtl();
|
||||
@@ -381,7 +385,62 @@ public class PdaIosOutServiceImpl implements PdaIosOutService {
|
||||
receiveOutRequest, status, null,CollectionUtils.isEmpty(ioStorInvDtls)?null:ioStorInv.getBill_code(),param.getReportParam());
|
||||
return PdaResponse.requestOk();
|
||||
}
|
||||
@Override
|
||||
@Transactional
|
||||
public PdaResponse directConfirmByAfter(LineSideDto param) {
|
||||
//创建出库单/明细/分配
|
||||
List<WorkOrderBomItem> workOrderBomItems = mesApi.workOrderMaterialList(param.getSrcBillNo());
|
||||
final Structattr struct = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
|
||||
.eq(Structattr::getStoragevehicle_code, param.getStorageVehicleCode()));
|
||||
if (struct ==null ||StringUtils.isEmpty(param.getStorageVehicleCode())){
|
||||
throw new BadRequestException("当前虚拟仓库未绑定"+param.getStorageVehicleCode());
|
||||
}
|
||||
//创建出库单据
|
||||
String status = StockReturnStatusEnum.TODO.getCode();
|
||||
final List<ReceiveOutRequest.Entrys> entrys = new ArrayList<>();
|
||||
|
||||
for (WorkOrderBomItem bomItem : workOrderBomItems) {
|
||||
final String materialCode = bomItem.getMaterialCode();
|
||||
final BigDecimal bomQty = bomItem.getBomQty();
|
||||
if (bomQty == null || bomQty.intValue() == 0){
|
||||
continue;
|
||||
}
|
||||
final BigDecimal qty = bomQty.multiply(param.getReportedQty()).setScale(0, RoundingMode.HALF_UP);
|
||||
ReceiveOutRequest.Entrys entry = new ReceiveOutRequest.Entrys();
|
||||
entry.setSeq(Integer.valueOf(bomItem.getItemNo()));
|
||||
entry.setMaterialno(materialCode);
|
||||
entry.setUnitno(bomItem.getUnit());
|
||||
entry.setQty(qty);
|
||||
entry.setBaseqty(bomItem.getBomQty());
|
||||
entry.setWarehouseno(param.getSectCode());
|
||||
entry.setSrcbillno(param.getSrcBillNo());
|
||||
entry.setSrcbillid(param.getSrcBillId());
|
||||
entry.setSrcbillentryid(bomItem.getItemId());
|
||||
entry.setStatus(StockReturnStatusEnum.TODO.getCode());
|
||||
entrys.add(entry);
|
||||
|
||||
}
|
||||
ReceiveOutRequest receiveOutRequest = new ReceiveOutRequest();
|
||||
receiveOutRequest.setOrgno(param.getOrgNo());
|
||||
receiveOutRequest.setSn(param.getSn());
|
||||
//这个单号存工单
|
||||
receiveOutRequest.setBillno(param.getWorkOrder());
|
||||
receiveOutRequest.setBiztype("340");
|
||||
receiveOutRequest.setInvscheme("002");
|
||||
receiveOutRequest.setBiztime(LocalDate.now().toString());
|
||||
receiveOutRequest.setCztype("02");
|
||||
receiveOutRequest.setTranstype("020");
|
||||
receiveOutRequest.setRequserno("WMS");
|
||||
receiveOutRequest.setRequsername("WMS");
|
||||
receiveOutRequest.setDeptno("01.09.14.02");
|
||||
receiveOutRequest.setDeptno("01.09.14.02");
|
||||
receiveOutRequest.setTrackNo(param.getTrackNo());
|
||||
receiveOutRequest.setWorkArea(param.getWorkArea());
|
||||
receiveOutRequest.setEntrys(entrys);
|
||||
ReceiveOutReturn entity = receiveOutReturnService.saveFromRequest(
|
||||
receiveOutRequest, status, null,null,param.getReportParam());
|
||||
return PdaResponse.requestOk();
|
||||
}
|
||||
|
||||
/**
|
||||
* 空载具出库
|
||||
|
||||
@@ -7,10 +7,12 @@ import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dao.ReceiveOutReturn;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.service.IReceiveOutReturnService;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 倒冲领料定时回传,每次回传五条
|
||||
@@ -27,18 +29,18 @@ public class ReceiveReturnAutoTask {
|
||||
public void run() {
|
||||
log.info("========>倒冲领料定时回传任务");
|
||||
List<ReceiveOutReturn> list = receiveOutReturnService.list(new LambdaQueryWrapper<ReceiveOutReturn>()
|
||||
.eq(ReceiveOutReturn::getStatus, 0)
|
||||
.eq(ReceiveOutReturn::getStatus, StockReturnStatusEnum.TODO.getCode())
|
||||
.or()
|
||||
.eq(ReceiveOutReturn::getStatus, 2)
|
||||
.eq(ReceiveOutReturn::getStatus, StockReturnStatusEnum.FAIL.getCode())
|
||||
.last("limit 5"));
|
||||
log.info("========>倒冲领料定时回传列表:{}", JSON.toJSONString(list));
|
||||
log.info("========>倒冲领料定时回传列表:{}", list.stream().map(ReceiveOutReturn::getBillno).collect(Collectors.joining(",")));
|
||||
for (ReceiveOutReturn item : list) {
|
||||
try {
|
||||
receiveOutReturnService.uploadErp(item);
|
||||
} catch (Exception e) {
|
||||
log.error("========>倒冲领料定时回传错误:{}", e.getMessage());
|
||||
}
|
||||
Thread.sleep(1000 * 5);
|
||||
Thread.sleep(1000 * 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class ReceiveOutReturnController {
|
||||
|
||||
|
||||
@PostMapping("/upload")
|
||||
@Log("ERP回传")
|
||||
@Log("EAS过账")
|
||||
public ResponseEntity<Object> upload(@RequestBody ReceiveOutReturn receive) {
|
||||
receiveOutReturnService.uploadErp(receive);
|
||||
return ResponseData.build();
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class ReceiveOutReturnDetailDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField("return_id")
|
||||
private Long returnId;
|
||||
|
||||
private Integer seq;
|
||||
private String materialno;
|
||||
private String materialname;
|
||||
private String unitno;
|
||||
private BigDecimal qty;
|
||||
private BigDecimal baseqty;
|
||||
private String warehouseno;
|
||||
private String srcbillno;
|
||||
private String srcbillid;
|
||||
private String srcbillentryid;
|
||||
private String entrycomment;
|
||||
private String auxptyno;
|
||||
private String tracknumber;
|
||||
private String lotnumber;
|
||||
private String stockerno;
|
||||
private String stockername;
|
||||
private String iobillcode;
|
||||
@TableField("update_time")
|
||||
private String updateTime;
|
||||
private String status;
|
||||
private String remark;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class ReceiveOutReturnDto {
|
||||
private String status;
|
||||
private String requestId;
|
||||
private String createdBy;
|
||||
private String updatedTime;
|
||||
private String updateTime;
|
||||
private String reportParam;
|
||||
private List<ReceiveOutReturnDetail> details;
|
||||
}
|
||||
|
||||
@@ -32,12 +32,12 @@ public interface IReceiveOutReturnService extends IService<ReceiveOutReturn> {
|
||||
|
||||
void updateDetailUploadResult(Long detailId, String status,String remark);
|
||||
|
||||
void refreshUploadResult(Long id, Boolean sucess);
|
||||
void refreshUploadResult(Long id);
|
||||
|
||||
void uploadErp(ReceiveOutReturn mst);
|
||||
|
||||
/**
|
||||
* 抽出事物方法
|
||||
*/
|
||||
Boolean callEasByAllBill(ReceiveOutReturn entity, Long id, List<ReceiveOutReturnDetail> details, String now, ErpUtil login);
|
||||
Boolean callEasByAllBill(ReceiveOutReturn entity, List<ReceiveOutReturnDetail> details, String now, ErpUtil login);
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
||||
dto.setStatus(entity.getStatus());
|
||||
dto.setRequestId(entity.getRequestId());
|
||||
dto.setCreatedBy(entity.getCreatedBy());
|
||||
dto.setUpdatedTime(entity.getUpdateTime());
|
||||
dto.setUpdateTime(entity.getUpdateTime());
|
||||
dto.setReportParam(entity.getReportParam());
|
||||
return dto;
|
||||
}
|
||||
@@ -317,21 +317,25 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
||||
if (mst == null || mst.getId() == null) {throw new BadRequestException("请选择需要回传的数据");}
|
||||
ReceiveOutReturn entity = this.getById(mst.getId());
|
||||
if (entity == null) {throw new BadRequestException("回传记录不存在");}
|
||||
Boolean sucess = Boolean.TRUE;
|
||||
final Long id = entity.getId();
|
||||
|
||||
final List<String> statusSet = new ArrayList<>();
|
||||
statusSet.add(StockReturnStatusEnum.TODO.getCode());
|
||||
statusSet.add(StockReturnStatusEnum.FAIL.getCode());
|
||||
statusSet.add(StockReturnStatusEnum.ERROR.getCode());
|
||||
List<ReceiveOutReturnDetail> details = receiveOutReturnDetailMapper.selectList(new LambdaQueryWrapper<ReceiveOutReturnDetail>()
|
||||
.eq(ReceiveOutReturnDetail::getReturnId, id)
|
||||
.eq(ReceiveOutReturnDetail::getReturnId, entity.getId())
|
||||
.in(ReceiveOutReturnDetail::getStatus, statusSet)
|
||||
.orderByAsc(ReceiveOutReturnDetail::getSeq)
|
||||
.orderByAsc(ReceiveOutReturnDetail::getId));
|
||||
if (details.isEmpty()) {
|
||||
this.refreshUploadResult(id,sucess);
|
||||
ReceiveOutReturn update = new ReceiveOutReturn();
|
||||
update.setId(entity.getId());
|
||||
update.setUpdateTime(DateUtil.now());
|
||||
update.setStatus(StockReturnStatusEnum.SUCESS.getCode());
|
||||
update.setRemark("回传成功");
|
||||
this.updateById(entity);
|
||||
}else {
|
||||
final ReceiveOutReturnDetail detail1 = details.get(0);
|
||||
final Sectattr sectattr = iSectattrService.findByCode(detail1.getWarehouseno());
|
||||
final Sectattr sectattr = iSectattrService.findByCode(details.get(0).getWarehouseno());
|
||||
final BsrealStorattr storattr = iBsrealStorattrService.findById(sectattr.getStor_id());
|
||||
final Set<String> materials = details.stream().map(ReceiveOutReturnDetail::getMaterialno).collect(Collectors.toSet());
|
||||
Map<String, MdMeMaterialbase> materialMap = iMdMeMaterialbaseService
|
||||
@@ -340,69 +344,65 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
||||
.stream()
|
||||
.collect(Collectors.toMap(MdMeMaterialbase::getMaterial_code, Function.identity()
|
||||
));
|
||||
//线边6。007对应VTP0008后期修改
|
||||
final List<GroupPlate> groupInventory = iMdPbGroupplateService.list(new LambdaQueryWrapper<GroupPlate>()
|
||||
//线边6。007对应VTP0008后期修改,没库存的话WMS不扣,EAS扣
|
||||
Map<String, BigDecimal> groupInventoryMap = iMdPbGroupplateService.list(new LambdaQueryWrapper<GroupPlate>()
|
||||
.eq(GroupPlate::getStoragevehicle_code, "VTP0008")
|
||||
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库"))
|
||||
.in(GroupPlate::getMaterial_code, materials));
|
||||
//没库存的话WMS不扣,EAS扣
|
||||
Map<String, BigDecimal> groupInventoryMap = groupInventory.stream()
|
||||
.in(GroupPlate::getMaterial_code, materials)).stream()
|
||||
.collect(Collectors.toMap(
|
||||
GroupPlate::getMaterial_code,
|
||||
GroupPlate::getQty,
|
||||
BigDecimal::add
|
||||
));
|
||||
//创建出库单据
|
||||
String now = DateUtil.now();
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
final QueryEasStockRequest easStockRequest = new QueryEasStockRequest();
|
||||
easStockRequest.setOrgno("01.09.14");
|
||||
easStockRequest.setWarehouseno(details.get(0).getWarehouseno());
|
||||
final List<QueryEasStockResponse> easStockResponses = easApi.queryStock(easStockRequest);
|
||||
// 将库存列表转换为 Map,key 为 materialno,value 为 qty(转为 BigDecimal)
|
||||
Map<String, BigDecimal> stockMap = easStockResponses.stream()
|
||||
.collect(Collectors.toMap(
|
||||
QueryEasStockResponse::getMaterialno,
|
||||
response -> new BigDecimal(response.getQty()),
|
||||
(existing, replacement) -> existing // 如果有重复物料号,保留第一个
|
||||
));
|
||||
final List<ReceiveOutReturnDetail> failDetailWMS = new ArrayList<>();
|
||||
final List<ReceiveOutReturnDetail> failDetailEAS = new ArrayList<>();
|
||||
final List<ReceiveOutReturnDetail> needDetail = new ArrayList<>();
|
||||
|
||||
//出入库过账数据
|
||||
final String invId = IdUtil.getStringId();
|
||||
int seq = 1;
|
||||
BigDecimal totalQty = BigDecimal.ZERO;
|
||||
IOStorInv ioStorInv = new IOStorInv();
|
||||
ioStorInv.setIostorinv_id(IdUtil.getStringId());
|
||||
ioStorInv.setBill_code(CodeUtil.getNewCode("OUT_STORE_CODE"));
|
||||
ioStorInv.setIo_type(IOSEnum.IO_TYPE.code("出库"));
|
||||
ioStorInv.setBill_type(IOSEnum.BILL_TYPE.code("生产出库"));
|
||||
ioStorInv.setBiz_date(DateUtil.today());
|
||||
ioStorInv.setStor_code(storattr.getStor_code());
|
||||
ioStorInv.setStor_name(storattr.getStor_name());
|
||||
ioStorInv.setStor_id(storattr.getStor_id());
|
||||
ioStorInv.setDetail_count(materials.size());
|
||||
ioStorInv.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
|
||||
ioStorInv.setCreate_mode(IOSEnum.CREATE_MODE.code("终端产生"));
|
||||
ioStorInv.setInput_optid(currentUserId);
|
||||
ioStorInv.setInput_optname(nickName);
|
||||
ioStorInv.setInput_time(now);
|
||||
ioStorInv.setIs_delete(BaseDataEnum.IS_YES_NOT.code("否"));
|
||||
ioStorInv.setIs_upload(BaseDataEnum.IS_YES_NOT.code("是"));
|
||||
final String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
final String currentNickName = SecurityUtils.getCurrentNickName();
|
||||
final String now = DateUtil.now();
|
||||
final List<IOStorInvDtl> ioStorInvDtls = new ArrayList<>();
|
||||
final List<IOStorInvDis> iOStorInvDiss = new ArrayList<>();
|
||||
final List<ReceiveOutReturnDetail> entrys = new ArrayList<>();
|
||||
List<OutFinishParam> outFinsParams = new ArrayList<>();
|
||||
|
||||
for (ReceiveOutReturnDetail detail : details) {
|
||||
//已经生成单子但是回传EAS报错了
|
||||
if (detail.getStatus().equals(StockReturnStatusEnum.ERROR.getCode())){
|
||||
needDetail.add(detail);
|
||||
continue;
|
||||
}
|
||||
final String materialCode = detail.getMaterialno();
|
||||
final BigDecimal qty = detail.getQty();
|
||||
final BigDecimal actualQty = groupInventoryMap.get(materialCode) == null?BigDecimal.ZERO:groupInventoryMap.get(materialCode);
|
||||
if (qty.compareTo(actualQty) > 0 && detail.getStatus().equals(StockReturnStatusEnum.FAIL.getCode())) {
|
||||
//跳过
|
||||
sucess = Boolean.FALSE;
|
||||
final BigDecimal easQty = stockMap.get(materialCode) == null?BigDecimal.ZERO:stockMap.get(materialCode);
|
||||
if (qty.compareTo(actualQty) > 0) {
|
||||
failDetailWMS.add(detail);
|
||||
continue;
|
||||
} else if (qty.compareTo(actualQty) > 0 && detail.getStatus().equals(StockReturnStatusEnum.TODO.getCode())) {
|
||||
sucess = Boolean.FALSE;
|
||||
continue;//库存不足但是同步时生成过出入库单
|
||||
} else{
|
||||
detail.setStatus(StockReturnStatusEnum.TODO.getCode());
|
||||
detail.setIobillcode(ioStorInv.getBill_code());
|
||||
}
|
||||
entrys.add(detail);
|
||||
//待回传的说明还没做库存变动
|
||||
if (detail.getStatus().equals(StockReturnStatusEnum.FAIL.getCode())){//失败说明库存不足,直接跳过
|
||||
if (qty.compareTo(easQty)>0) {
|
||||
failDetailEAS.add(detail);
|
||||
continue;
|
||||
}
|
||||
final IOStorInvDtl ioStorInvDtl = new IOStorInvDtl();
|
||||
ioStorInvDtl.setIostorinv_id(ioStorInv.getIostorinv_id());
|
||||
ioStorInvDtl.setIostorinv_id(invId);
|
||||
ioStorInvDtl.setIostorinvdtl_id(IdUtil.getStringId());
|
||||
ioStorInvDtl.setSeq_no(String.valueOf(seq));
|
||||
ioStorInvDtl.setSeq_no(String.valueOf(seq++));
|
||||
ioStorInvDtl.setMaterial_code(materialCode);
|
||||
ioStorInvDtl.setMaterial_id(materialMap.get(materialCode).getMaterial_id());
|
||||
ioStorInvDtl.setQty_unit_id(materialMap.get(materialCode).getQty_unit_id());
|
||||
@@ -414,12 +414,12 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
||||
ioStorInvDtl.setUnassign_qty(BigDecimal.ZERO);
|
||||
ioStorInvDtl.setSource_bill_code(mst.getBillno());
|
||||
ioStorInvDtl.setSource_bill_type("work_order");
|
||||
ioStorInvDtls.add(ioStorInvDtl);
|
||||
|
||||
totalQty.add(qty);
|
||||
// 分配
|
||||
final IOStorInvDis ioStorInvDis = new IOStorInvDis();
|
||||
ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId());
|
||||
ioStorInvDis.setIostorinv_id(ioStorInv.getIostorinv_id()); // 修正变量名
|
||||
ioStorInvDis.setIostorinv_id(invId); // 修正变量名
|
||||
ioStorInvDis.setIostorinvdtl_id(ioStorInvDtl.getIostorinvdtl_id()); // 从对象获取,而不是从 JSON
|
||||
ioStorInvDis.setSeq_no("1"); // 直接用 int,不需要 String
|
||||
ioStorInvDis.setMaterial_id(materialMap.get(materialCode).getMaterial_id()); // 从 materialMap 获取
|
||||
@@ -434,6 +434,7 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
||||
ioStorInvDis.setQty_unit_name(materialMap.get(materialCode).getQty_unit_name()); // 从 materialMap 获取
|
||||
ioStorInvDis.setPlan_qty(qty); // 直接使用 qty 变量
|
||||
ioStorInvDis.setReal_qty(qty);
|
||||
ioStorInvDtls.add(ioStorInvDtl);
|
||||
iOStorInvDiss.add(ioStorInvDis);
|
||||
//更新组盘记录表
|
||||
outFinsParams.add(OutFinishParam.builder()
|
||||
@@ -443,63 +444,61 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
||||
.structCode("6.007.V")
|
||||
.materialCode(materialCode)
|
||||
.build());
|
||||
needDetail.add(detail);
|
||||
//内存更新库存,保证物料库存准确判断
|
||||
groupInventoryMap.put(materialCode,actualQty.subtract(qty));
|
||||
stockMap.put(materialCode,easQty.subtract(qty));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(ioStorInvDtls)){
|
||||
IOStorInv ioStorInv = new IOStorInv();
|
||||
ioStorInv.setIostorinv_id(IdUtil.getStringId());
|
||||
ioStorInv.setBill_code(CodeUtil.getNewCode("OUT_STORE_CODE"));
|
||||
ioStorInv.setIo_type(IOSEnum.IO_TYPE.code("出库"));
|
||||
ioStorInv.setBill_type(IOSEnum.BILL_TYPE.code("生产出库"));
|
||||
ioStorInv.setBiz_date(DateUtil.today());
|
||||
ioStorInv.setStor_code(storattr.getStor_code());
|
||||
ioStorInv.setStor_name(storattr.getStor_name());
|
||||
ioStorInv.setStor_id(storattr.getStor_id());
|
||||
ioStorInv.setDetail_count(materials.size());
|
||||
ioStorInv.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
|
||||
ioStorInv.setCreate_mode(IOSEnum.CREATE_MODE.code("终端产生"));
|
||||
ioStorInv.setInput_optid(currentUserId);
|
||||
ioStorInv.setInput_optname(currentNickName);
|
||||
ioStorInv.setInput_time(now);
|
||||
ioStorInv.setIs_delete(BaseDataEnum.IS_YES_NOT.code("否"));
|
||||
ioStorInv.setIs_upload(BaseDataEnum.IS_YES_NOT.code("是"));
|
||||
ioStorInvMapper.insert(ioStorInv);
|
||||
ioStorInvDtlMapper.batchInsert(ioStorInvDtls);
|
||||
ioStorInvDisMapper.batchSave(iOStorInvDiss);
|
||||
iStInventoryService.changeInventory(InventoryChangeType.OUT_FINS, outFinsParams);
|
||||
mst.setRequestId(mst.getRequestId()!=null?(mst.getRequestId()+ "," + ioStorInv.getBill_code()):ioStorInv.getBill_code());
|
||||
}
|
||||
mst.setRequestId(mst.getRequestId() + "," + ioStorInv.getBill_code());
|
||||
|
||||
final String warehouseno = entrys.get(0).getWarehouseno();
|
||||
final QueryEasStockRequest easStockRequest = new QueryEasStockRequest();
|
||||
easStockRequest.setOrgno("01.09.14");
|
||||
easStockRequest.setWarehouseno(warehouseno);
|
||||
final List<QueryEasStockResponse> easStockResponses = easApi.queryStock(easStockRequest);
|
||||
// 将库存列表转换为 Map,key 为 materialno,value 为 qty(转为 BigDecimal)
|
||||
Map<String, BigDecimal> stockMap = easStockResponses.stream()
|
||||
.collect(Collectors.toMap(
|
||||
QueryEasStockResponse::getMaterialno,
|
||||
response -> new BigDecimal(response.getQty()),
|
||||
(existing, replacement) -> existing // 如果有重复物料号,保留第一个
|
||||
));
|
||||
// 筛选出库存数量 >= 需求数量的 ReceiveOutReturnDetail
|
||||
List<ReceiveOutReturnDetail> satisfiedList = entrys.stream()
|
||||
.filter(detail -> {
|
||||
BigDecimal stockQty = stockMap.get(detail.getMaterialno());
|
||||
return stockQty != null && stockQty.compareTo(detail.getQty()) >= 0;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
//不满足条件的列表(库存不足)
|
||||
List<ReceiveOutReturnDetail> unsatisfiedList = entrys.stream()
|
||||
.filter(detail -> {
|
||||
BigDecimal stockQty = stockMap.get(detail.getMaterialno());
|
||||
return stockQty == null || stockQty.compareTo(detail.getQty()) < 0;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(unsatisfiedList)){
|
||||
if (!CollectionUtils.isEmpty(failDetailWMS)){
|
||||
receiveOutReturnDetailMapper.update(null,new LambdaUpdateWrapper<ReceiveOutReturnDetail>()
|
||||
// .set(ReceiveOutReturnDetail::getStatus,StockReturnStatusEnum.FAIL.getCode())
|
||||
.set(ReceiveOutReturnDetail::getRemark,"EAS库存不足")
|
||||
.set(ReceiveOutReturnDetail::getRemark,"WMS库存不足")
|
||||
.set(ReceiveOutReturnDetail::getStatus,StockReturnStatusEnum.TODO.getCode())
|
||||
.set(ReceiveOutReturnDetail::getUpdateTime,now)
|
||||
.in(ReceiveOutReturnDetail::getId,unsatisfiedList.stream()
|
||||
.in(ReceiveOutReturnDetail::getId,failDetailWMS.stream()
|
||||
.map(ReceiveOutReturnDetail::getId).collect(Collectors.toList())));
|
||||
sucess = Boolean.FALSE;
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(failDetailEAS)){
|
||||
receiveOutReturnDetailMapper.update(null,new LambdaUpdateWrapper<ReceiveOutReturnDetail>()
|
||||
.set(ReceiveOutReturnDetail::getRemark,"EAS库存不足")
|
||||
.set(ReceiveOutReturnDetail::getStatus,StockReturnStatusEnum.TODO.getCode())
|
||||
.set(ReceiveOutReturnDetail::getUpdateTime,now)
|
||||
.in(ReceiveOutReturnDetail::getId,failDetailEAS.stream()
|
||||
.map(ReceiveOutReturnDetail::getId).collect(Collectors.toList())));
|
||||
}
|
||||
log.info("======>请求EAS领料出库单数据条:"+needDetail.size());
|
||||
if (!CollectionUtils.isEmpty(needDetail)){
|
||||
final ErpUtil login = ErpUtil.create().login();
|
||||
log.info("======>请求EAS领料出库单数据条:"+satisfiedList.size());
|
||||
if (!CollectionUtils.isEmpty(satisfiedList)){
|
||||
Boolean callsucess = iReceiveOutReturnService.callEasByAllBill(entity, id, satisfiedList, now, login);
|
||||
this.refreshUploadResult(id,sucess&&callsucess);
|
||||
iReceiveOutReturnService.callEasByAllBill(entity, needDetail, now, login);
|
||||
this.refreshUploadResult(entity.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean callEasByAllBill(ReceiveOutReturn entity, Long id, List<ReceiveOutReturnDetail> details, String now, ErpUtil login) {
|
||||
if (id == null ) {
|
||||
throw new IllegalArgumentException("回传记录ID和明细ID不能为空");
|
||||
}
|
||||
public Boolean callEasByAllBill(ReceiveOutReturn entity, List<ReceiveOutReturnDetail> details, String now, ErpUtil login) {
|
||||
final ReceiveOutRequest receiveOutRequest = buildRequest(entity, details);
|
||||
try {
|
||||
JSONObject req = new JSONObject();
|
||||
@@ -509,8 +508,13 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
||||
log.info("======>请求EAS领料出库单接口:" + JSONObject.toJSONString(req));
|
||||
login.audit(req.toJSONString());
|
||||
} catch (Exception e) {
|
||||
log.error("请求EAS领料出库单接口失败,回传记录ID:{}", id, e);
|
||||
throw new BadRequestException(e.getMessage());
|
||||
log.error("请求EAS领料出库单接口失败,回传记录ID:{}", entity.getId(), e);
|
||||
receiveOutReturnDetailMapper.update(null,new LambdaUpdateWrapper<ReceiveOutReturnDetail>()
|
||||
.set(ReceiveOutReturnDetail::getStatus,StockReturnStatusEnum.ERROR.getCode())
|
||||
.set(ReceiveOutReturnDetail::getRemark,e.getMessage())
|
||||
.set(ReceiveOutReturnDetail::getUpdateTime,now)
|
||||
.in(ReceiveOutReturnDetail::getId,details.stream()
|
||||
.map(ReceiveOutReturnDetail::getId).collect(Collectors.toList())));
|
||||
}
|
||||
receiveOutReturnDetailMapper.update(null,new LambdaUpdateWrapper<ReceiveOutReturnDetail>()
|
||||
.set(ReceiveOutReturnDetail::getStatus,StockReturnStatusEnum.SUCESS.getCode())
|
||||
@@ -611,12 +615,22 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshUploadResult(Long id,Boolean sucess) {
|
||||
public void refreshUploadResult(Long id) {
|
||||
final List<ReceiveOutReturnDetail> receiveOutReturnDetails = receiveOutReturnDetailMapper.selectList(new LambdaQueryWrapper<ReceiveOutReturnDetail>()
|
||||
.eq(ReceiveOutReturnDetail::getReturnId, id).select(ReceiveOutReturnDetail::getStatus, ReceiveOutReturnDetail::getReturnId));
|
||||
final boolean present = receiveOutReturnDetails.stream()
|
||||
.anyMatch(a -> (!a.getStatus().equals(StockReturnStatusEnum.SUCESS.getCode())&&!a.getStatus().equals(StockReturnStatusEnum.IGNORE.getCode())));
|
||||
ReceiveOutReturn entity = new ReceiveOutReturn();
|
||||
entity.setId(id);
|
||||
entity.setStatus(sucess? StockReturnStatusEnum.SUCESS.getCode() : StockReturnStatusEnum.FAIL.getCode());
|
||||
entity.setRemark(sucess? "回传成功" : "存在回传失败明细");
|
||||
entity.setUpdateTime(DateUtil.now());
|
||||
if (present){
|
||||
entity.setStatus(StockReturnStatusEnum.FAIL.getCode());
|
||||
entity.setRemark("存在回传失败明细");
|
||||
entity.setUpdateTime(DateUtil.now());
|
||||
}else {
|
||||
entity.setStatus(StockReturnStatusEnum.SUCESS.getCode());
|
||||
entity.setRemark("回传成功");
|
||||
}
|
||||
this.updateById(entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import lombok.Getter;
|
||||
public enum StockReturnStatusEnum {
|
||||
TODO("0","待过账"),
|
||||
SUCESS("1","过账成功"),
|
||||
FAIL("2","过账失败"),
|
||||
FAIL("2","过账中"),
|
||||
ERROR("3","过账异常"),
|
||||
IGNORE("4","忽略过账"),
|
||||
;
|
||||
|
||||
@@ -67,24 +67,22 @@
|
||||
<udOperation :data="scope.row" :permission="permission" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="billno" label="工单号" min-width="140">
|
||||
<el-table-column prop="billno" label="工单号" min-width="160">
|
||||
<template slot-scope="scope">
|
||||
<el-link type="primary" @click="toView(scope.row)">{{ scope.row.billno }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="sn" label="序列码" min-width="140" />
|
||||
<el-table-column prop="trackNo" label="跟踪号" min-width="100" />
|
||||
<el-table-column prop="workArea" label="产线" min-width="100" />
|
||||
<el-table-column prop="status" label="回传状态" width="100">
|
||||
<el-table-column prop="sn" label="序列码" min-width="110" />
|
||||
<el-table-column prop="trackNo" label="跟踪号" min-width="110" />
|
||||
<el-table-column prop="workArea" label="产线" min-width="60" />
|
||||
<el-table-column prop="status" label="过账状态" width="80">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="statusTagType(scope.row.status)" size="mini">{{ statusLabel(scope.row.status) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="requestId" label="出入库单号" min-width="140" />
|
||||
<el-table-column prop="biztime" label="业务时间" min-width="160" />
|
||||
<el-table-column prop="createTime" label="创建时间" min-width="160" />
|
||||
<el-table-column prop="reportParam" label="报工参数" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column prop="biztime" label="业务时间" min-width="140" />
|
||||
<el-table-column prop="updateTime" label="更新时间" min-width="140" />
|
||||
</el-table>
|
||||
<pagination />
|
||||
</div>
|
||||
@@ -115,23 +113,23 @@
|
||||
<div slot="footer" class="dialog-footer"><el-button type="text" @click="crud.cancelCU">取消</el-button><el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button></div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog :visible.sync="viewShow" title="倒扣回传详情" width="1200px" :close-on-click-modal="false">
|
||||
<el-dialog :visible.sync="viewShow" title="倒扣回传详情" width="1300px" :close-on-click-modal="false">
|
||||
<el-descriptions :column="2" border size="mini">
|
||||
<el-descriptions-item label="工单号">{{ currentRow.billno }}</el-descriptions-item>
|
||||
<el-descriptions-item label="工单">{{ currentRow.billno }}</el-descriptions-item>
|
||||
<el-descriptions-item label="序列码">{{ currentRow.sn }}</el-descriptions-item>
|
||||
<el-descriptions-item label="跟踪号">{{ currentRow.trackNo }}</el-descriptions-item>
|
||||
<el-descriptions-item label="产线">{{ currentRow.workArea }}</el-descriptions-item>
|
||||
<el-descriptions-item label="跟踪号">{{ currentRow.trackNo }}</el-descriptions-item>
|
||||
<el-descriptions-item label="备注">{{ currentRow.comment }}</el-descriptions-item>
|
||||
<el-descriptions-item label="回传状态">{{ statusLabel(currentRow.status) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="回传备注" :span="2">{{ currentRow.remark }}</el-descriptions-item>
|
||||
<el-descriptions-item label="机构编号">{{ currentRow.orgno }}</el-descriptions-item>
|
||||
<el-descriptions-item label="业务类型">{{ currentRow.biztype }}</el-descriptions-item>
|
||||
<el-descriptions-item label="机构">{{ currentRow.orgno }}</el-descriptions-item>
|
||||
<el-descriptions-item label="业务">{{ currentRow.biztype }}</el-descriptions-item>
|
||||
<el-descriptions-item label="库存方案">{{ currentRow.invscheme }}</el-descriptions-item>
|
||||
<el-descriptions-item label="交易类型">{{ currentRow.transtype }}</el-descriptions-item>
|
||||
<el-descriptions-item label="业务时间">{{ currentRow.biztime }}</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">{{ currentRow.createTime }}</el-descriptions-item>
|
||||
<el-descriptions-item label="出入库单号">{{ currentRow.requestId }}</el-descriptions-item>
|
||||
<el-descriptions-item label=""></el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">{{ currentRow.updateTime }}</el-descriptions-item>
|
||||
<el-descriptions-item label="出入库单号" :span="2">{{ currentRow.requestId }}</el-descriptions-item>
|
||||
<el-descriptions-item label="报工参数" :span="2">{{ currentRow.reportParam }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-table :data="pagedDetails" size="mini" style="width: 100%; margin-top: 12px;">
|
||||
@@ -152,7 +150,7 @@
|
||||
<!-- <el-table-column prop="tracknumber" label="追踪号" min-width="120" />-->
|
||||
<el-table-column prop="updateTime" label="更新时间" min-width="130" />
|
||||
<!-- 新增操作列 -->
|
||||
<el-table-column label="操作" width="120" align="center" fixed="right">
|
||||
<el-table-column label="操作" width="140" align="center" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
@@ -240,10 +238,10 @@ export default {
|
||||
del: ['purchasemst:del']
|
||||
},
|
||||
statusOptions: [
|
||||
{ value: '0', label: '待回传' },
|
||||
{ value: '1', label: '回传成功' },
|
||||
{ value: '2', label: '回传失败' },
|
||||
{ value: '3', label: '回传异常' },
|
||||
{ value: '0', label: '待过账' },
|
||||
{ value: '1', label: '过账成功' },
|
||||
{ value: '2', label: '过账中' },
|
||||
{ value: '3', label: '过账异常' },
|
||||
{ value: '4', label: '忽略过账' },
|
||||
],
|
||||
rules: {
|
||||
|
||||
Reference in New Issue
Block a user