add:回传增加EAS库存校验
This commit is contained in:
@@ -23,6 +23,7 @@ public class ReceiveOutRequest {
|
||||
@Data
|
||||
public static class Entrys {
|
||||
private Integer seq;
|
||||
private String mstBillCode;
|
||||
private String materialno;
|
||||
private String unitno;
|
||||
private BigDecimal qty;
|
||||
|
||||
@@ -12,6 +12,8 @@ import org.nl.wms.ext_manage.mes.service.dto.WorkReportParam;
|
||||
import org.nl.wms.ext_manage.service.WmsToZDWmdService;
|
||||
import org.nl.wms.pda_manage.ios_manage.service.PdaIosOutService;
|
||||
import org.nl.wms.pda_manage.outBound.dto.LineSideDto;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseRegionService;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseRegion;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -28,7 +30,7 @@ public class MesReportServiceImpl implements MesReportService {
|
||||
@Autowired
|
||||
private IStructattrService iStructattrService;
|
||||
@Autowired
|
||||
private MesApi mesApi;
|
||||
private ISchBaseRegionService iSchBaseRegionService;
|
||||
|
||||
@Override
|
||||
public void workReportReturn(WorkReportParam workReportParam) {
|
||||
@@ -39,10 +41,14 @@ public class MesReportServiceImpl implements MesReportService {
|
||||
}
|
||||
//TODO: 查询哪些是大件哪些是小件
|
||||
//workAreag根据功能做区域查看对于的库区,工作区域与库区编码一直
|
||||
final String sectCode = WmsToZDWmdService.ZD_LOS_MAPPING.get(workReportParam.getWorkArea());
|
||||
if (sectCode == null){
|
||||
final SchBaseRegion region = iSchBaseRegionService.getOne(new LambdaQueryWrapper<SchBaseRegion>()
|
||||
.select(SchBaseRegion::getPoint_type_explain)
|
||||
.eq(SchBaseRegion::getRegion_code, workReportParam.getWorkArea()));
|
||||
// final String sectCode = WmsToZDWmdService.ZD_LOS_MAPPING.get(workReportParam.getWorkArea());
|
||||
if (region == null || StringUtils.isEmpty(region.getPoint_type_explain())){
|
||||
throw new BadRequestException("当前工作区域"+workReportParam.getWorkArea()+"未配置库区映射");
|
||||
}
|
||||
final String sectCode = region.getPoint_type_explain();
|
||||
final Structattr one = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
|
||||
.eq(Structattr::getSect_code, sectCode));
|
||||
if (one == null){
|
||||
|
||||
@@ -328,7 +328,7 @@ public class PdaIosOutServiceImpl implements PdaIosOutService {
|
||||
ReceiveOutRequest.Entrys entry = new ReceiveOutRequest.Entrys();
|
||||
entry.setSeq(Integer.valueOf(bomItem.getItemNo()));
|
||||
entry.setMaterialno(materialCode);
|
||||
entry.setUnitno("PCS");
|
||||
entry.setUnitno(bomItem.getUnit());
|
||||
entry.setQty(qty);
|
||||
entry.setBaseqty(bomItem.getBomQty());
|
||||
entry.setWarehouseno(param.getSectCode());
|
||||
@@ -343,11 +343,16 @@ public class PdaIosOutServiceImpl implements PdaIosOutService {
|
||||
ioStorInvDisMapper.batchSave(iOStorInvDiss);
|
||||
ReceiveOutRequest receiveOutRequest = new ReceiveOutRequest();
|
||||
receiveOutRequest.setOrgno(param.getOrgNo());
|
||||
receiveOutRequest.setBillno(param.getWorkOrder());
|
||||
//这个单号存自己的
|
||||
receiveOutRequest.setBillno(ioStorInv.getIostorinv_id());
|
||||
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.setEntrys(entrys);
|
||||
ReceiveOutReturn entity = receiveOutReturnService.saveFromRequest(
|
||||
receiveOutRequest, StockReturnStatusEnum.TODO.getCode(), null);
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.wms.ext_manage.api.EasApi;
|
||||
import org.nl.wms.ext_manage.api.request.QueryEasStockRequest;
|
||||
import org.nl.wms.ext_manage.api.response.QueryEasStockResponse;
|
||||
@@ -14,6 +15,7 @@ import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dto.ReceiveOutRet
|
||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.service.IReceiveOutReturnService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -78,7 +80,12 @@ public class ReceiveOutReturnController {
|
||||
easRequest.setWarehouseno(warehouseno);
|
||||
easRequest.setMaterialno(materialno);
|
||||
List<QueryEasStockResponse> easStocks = easApi.queryStock(easRequest);
|
||||
return ResponseData.build(easStocks);
|
||||
int totalQty = 0;
|
||||
if (!CollectionUtils.isEmpty(easStocks)){
|
||||
totalQty = easStocks.stream()
|
||||
.mapToInt(item -> Integer.parseInt(item.getQty()))
|
||||
.sum(); }
|
||||
return ResponseData.build(MapOf.of("qty",totalQty));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,10 +4,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.ext_manage.api.request.ReceiveOutRequest;
|
||||
import org.nl.wms.ext_manage.util.ErpUtil;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dao.ReceiveOutReturn;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dao.ReceiveOutReturnDetail;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dto.ReceiveOutReturnDto;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dto.ReceiveOutReturnQuery;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface IReceiveOutReturnService extends IService<ReceiveOutReturn> {
|
||||
@@ -32,4 +35,8 @@ public interface IReceiveOutReturnService extends IService<ReceiveOutReturn> {
|
||||
|
||||
void uploadErp(ReceiveOutReturn mst);
|
||||
|
||||
/**
|
||||
* 抽出事物方法
|
||||
*/
|
||||
Boolean callEasByAllBill(ReceiveOutReturn entity, Long id, List<ReceiveOutReturnDetail> details, String now, ErpUtil login);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -12,7 +13,9 @@ import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.ext_manage.api.EasApi;
|
||||
import org.nl.wms.ext_manage.api.request.QueryEasStockRequest;
|
||||
import org.nl.wms.ext_manage.api.request.ReceiveOutRequest;
|
||||
import org.nl.wms.ext_manage.api.response.QueryEasStockResponse;
|
||||
import org.nl.wms.ext_manage.service.WmsToErpService;
|
||||
import org.nl.wms.ext_manage.util.ErpUtil;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dao.ReceiveOutReturn;
|
||||
@@ -24,14 +27,19 @@ import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.mapper.ReceiveOut
|
||||
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.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -43,7 +51,8 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
||||
private EasApi easApi;
|
||||
|
||||
@Autowired
|
||||
private WmsToErpService wmsToErpService;
|
||||
@Lazy
|
||||
private IReceiveOutReturnService iReceiveOutReturnService;
|
||||
|
||||
@Override
|
||||
public IPage<ReceiveOutReturn> queryPage(ReceiveOutReturnQuery query, PageQuery page) {
|
||||
@@ -253,7 +262,6 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void uploadErp(ReceiveOutReturn mst) {
|
||||
if (mst == null || mst.getId() == null) {throw new BadRequestException("请选择需要回传的数据");}
|
||||
ReceiveOutReturn entity = this.getById(mst.getId());
|
||||
@@ -267,12 +275,88 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
||||
.isNull(ReceiveOutReturnDetail::getStatus))
|
||||
.orderByAsc(ReceiveOutReturnDetail::getSeq)
|
||||
.orderByAsc(ReceiveOutReturnDetail::getId));
|
||||
|
||||
if (details.isEmpty()) {
|
||||
this.refreshUploadResult(id,sucess);
|
||||
}else {
|
||||
//TODO:增加库存校验
|
||||
final String warehouseno = details.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 = details.stream()
|
||||
.filter(detail -> {
|
||||
BigDecimal stockQty = stockMap.get(detail.getMaterialno());
|
||||
return stockQty != null && stockQty.compareTo(detail.getQty()) >= 0;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
// 不满足条件的列表(库存不足)
|
||||
List<ReceiveOutReturnDetail> unsatisfiedList = details.stream()
|
||||
.filter(detail -> {
|
||||
BigDecimal stockQty = stockMap.get(detail.getMaterialno());
|
||||
return stockQty == null || stockQty.compareTo(detail.getQty()) < 0;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
final String now = DateUtil.now();
|
||||
if (!CollectionUtils.isEmpty(unsatisfiedList)){
|
||||
receiveOutReturnDetailMapper.update(null,new LambdaUpdateWrapper<ReceiveOutReturnDetail>()
|
||||
.set(ReceiveOutReturnDetail::getStatus,StockReturnStatusEnum.FAIL.getCode())
|
||||
.set(ReceiveOutReturnDetail::getRemark,"EAS库存不足")
|
||||
.set(ReceiveOutReturnDetail::getUpdateTime,now)
|
||||
.in(ReceiveOutReturnDetail::getId,unsatisfiedList.stream()
|
||||
.map(ReceiveOutReturnDetail::getId).collect(Collectors.toList())));
|
||||
sucess = Boolean.FALSE;
|
||||
}
|
||||
final ErpUtil login = ErpUtil.create().login();
|
||||
log.info("======>请求EAS领料出库单数据条:"+details.size());
|
||||
log.info("======>请求EAS领料出库单数据条:"+satisfiedList.size());
|
||||
if (!CollectionUtils.isEmpty(satisfiedList)){
|
||||
Boolean callsucess = iReceiveOutReturnService.callEasByAllBill(entity, id, satisfiedList, now, login);
|
||||
this.refreshUploadResult(id,sucess&&callsucess);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Transactional
|
||||
public Boolean callEasByAllBill(ReceiveOutReturn entity, Long id, List<ReceiveOutReturnDetail> details, String now, ErpUtil login) {
|
||||
String status;
|
||||
String remark = "";
|
||||
Boolean sucess =Boolean.TRUE;
|
||||
if (id == null ) {
|
||||
throw new IllegalArgumentException("回传记录ID和明细ID不能为空");
|
||||
}
|
||||
final ReceiveOutRequest receiveOutRequest = buildRequest(entity, details);
|
||||
try {
|
||||
JSONObject req = new JSONObject();
|
||||
req.put("type", "MES");
|
||||
req.put("method", "DealLLCKBill");
|
||||
req.put("data", receiveOutRequest);
|
||||
log.info("======>请求EAS领料出库单接口:" + JSONObject.toJSONString(req));
|
||||
login.audit(req.toJSONString());
|
||||
status = StockReturnStatusEnum.SUCESS.getCode();
|
||||
} catch (Exception e) {
|
||||
sucess = Boolean.FALSE;
|
||||
log.error("请求EAS领料出库单接口失败,回传记录ID:{}", id, e);
|
||||
status = StockReturnStatusEnum.FAIL.getCode();
|
||||
remark = e.getMessage();
|
||||
}
|
||||
receiveOutReturnDetailMapper.update(null,new LambdaUpdateWrapper<ReceiveOutReturnDetail>()
|
||||
.set(ReceiveOutReturnDetail::getStatus,status)
|
||||
.set(ReceiveOutReturnDetail::getRemark,remark)
|
||||
.set(ReceiveOutReturnDetail::getUpdateTime,now)
|
||||
.in(ReceiveOutReturnDetail::getId,details.stream()
|
||||
.map(ReceiveOutReturnDetail::getId).collect(Collectors.toList())));
|
||||
return sucess;
|
||||
}
|
||||
|
||||
private Boolean callEasByOneBill(ReceiveOutReturn entity, Boolean sucess, Long id, List<ReceiveOutReturnDetail> details, String now, ErpUtil login) {
|
||||
for (ReceiveOutReturnDetail detail : details) {
|
||||
final Long detailId = detail.getId();
|
||||
String status;
|
||||
@@ -302,14 +386,13 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
||||
updateItem.setUpdateTime(now);
|
||||
receiveOutReturnDetailMapper.updateById(updateItem);
|
||||
}
|
||||
this.refreshUploadResult(id,sucess);
|
||||
}
|
||||
return sucess;
|
||||
}
|
||||
|
||||
private ReceiveOutRequest buildRequest(ReceiveOutReturn entity, List<ReceiveOutReturnDetail> details) {
|
||||
ReceiveOutRequest request = new ReceiveOutRequest();
|
||||
request.setOrgno(entity.getOrgno());
|
||||
request.setBillno(entity.getBillno());
|
||||
request.setBillno("");
|
||||
request.setBiztype(entity.getBiztype());
|
||||
request.setInvscheme(entity.getInvscheme());
|
||||
request.setTranstype(entity.getTranstype());
|
||||
|
||||
@@ -122,12 +122,26 @@
|
||||
<el-table-column prop="qty" label="数量" min-width="100" />
|
||||
<el-table-column prop="baseqty" label="基础数量" min-width="100" />
|
||||
<el-table-column prop="warehouseno" label="仓库编号" min-width="120" />
|
||||
<el-table-column prop="easQty" label="eas库存" min-width="120" />
|
||||
<el-table-column prop="updateTime" label="更新时间" min-width="120" />
|
||||
<el-table-column prop="remark" label="说明" min-width="120" />
|
||||
<el-table-column prop="srcbillno" label="源单据编号" min-width="140" />
|
||||
<el-table-column prop="srcbillno" label="源单据编号" min-width="140" />
|
||||
<el-table-column prop="lotnumber" label="批号" min-width="100" />
|
||||
<el-table-column prop="tracknumber" label="追踪号" min-width="120" />
|
||||
<!-- 新增操作列 -->
|
||||
<el-table-column label="操作" width="140" align="center" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="primary"
|
||||
plain
|
||||
@click="handleSyncEasStock(scope.row)"
|
||||
>
|
||||
EAS库存
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div slot="footer" class="dialog-footer"><el-button type="primary" @click="viewShow = false">关闭</el-button></div>
|
||||
</el-dialog>
|
||||
@@ -211,6 +225,28 @@ export default {
|
||||
this.query.endTime = ''
|
||||
}
|
||||
},
|
||||
handleSyncEasStock(row) {
|
||||
// 检查必要参数
|
||||
if (!row.materialno) {
|
||||
this.$message.warning('物料编号不能为空')
|
||||
return
|
||||
}
|
||||
if (!row.warehouseno) {
|
||||
this.$message.warning('仓库编号不能为空')
|
||||
return
|
||||
}
|
||||
crudReceiveOutReturn.easStock({ 'warehouseno': row.warehouseno, 'materialno': row.materialno }).then(res => {
|
||||
if (res.code === 200) {
|
||||
// 显示同步结果
|
||||
const qty = res.data.qty
|
||||
this.$message.success(`EAS库存同步成功!当前库存数量:${qty}`)
|
||||
// 可选:在行中显示查询到的库存数量
|
||||
this.$set(row, 'easQty', qty)
|
||||
} else {
|
||||
this.$message.error(res.message || 'EAS库存同步失败')
|
||||
}
|
||||
})
|
||||
},
|
||||
upload() {
|
||||
const rows = this.crud.selections || []
|
||||
if (rows.length < 1) {
|
||||
|
||||
@@ -30,5 +30,12 @@ export function get(id) {
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
export function easStock(param) {
|
||||
return request({
|
||||
url: '/api/receiveOutReturn/easStock',
|
||||
method: 'get',
|
||||
params: param
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, get }
|
||||
export default { add, edit, del, get, easStock }
|
||||
|
||||
Reference in New Issue
Block a user