opt:优化倒扣
This commit is contained in:
@@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import org.nl.wms.ext_manage.mes.service.MesReportService;
|
||||
import org.nl.wms.ext_manage.mes.service.dto.WorkReportParam;
|
||||
import org.nl.wms.system_manage.service.logserver.lucene.BaseCode;
|
||||
import org.nl.wms.system_manage.service.logserver.lucene.LuceneAppender;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.amqp.support.AmqpHeaders;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,6 +23,13 @@ public class WorkReportConsumer {
|
||||
public void consume(String param, Channel channel,
|
||||
@Header(AmqpHeaders.DELIVERY_TAG) long tag) {
|
||||
System.out.println("======WorkReportConsumer======"+tag);
|
||||
mesReportService.workReportReturn(JSONObject.parseObject(param,WorkReportParam.class));
|
||||
try {
|
||||
LuceneAppender.traceIdTL.set(BaseCode.intToChars(org.nl.common.utils.IdUtil.getLongId()));
|
||||
mesReportService.workReportReturn(JSONObject.parseObject(param,WorkReportParam.class));
|
||||
}finally {
|
||||
LuceneAppender.traceIdTL.remove();
|
||||
MDC.clear();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package org.nl.wms.ext_manage.mes.mq.producer;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.wms.ext_manage.mes.service.MesReportService;
|
||||
import org.nl.wms.ext_manage.mes.service.dto.WorkReportParam;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dao.ReceiveOutReturn;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.service.IReceiveOutReturnService;
|
||||
@@ -15,14 +17,12 @@ public class WorkReportProducer {
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
@Autowired
|
||||
private MesReportService mesReportService;
|
||||
@Autowired
|
||||
private IReceiveOutReturnService receiveOutReturnService;
|
||||
|
||||
public void send(WorkReportParam param) {
|
||||
if (!StringUtils.isEmpty(param.getSn())){
|
||||
ReceiveOutReturn one = receiveOutReturnService.getOne(new LambdaQueryWrapper<ReceiveOutReturn>()
|
||||
.eq(ReceiveOutReturn::getSn, param.getSn()));
|
||||
if (one != null) return;//已存在跳过
|
||||
}
|
||||
rabbitTemplate.convertAndSend("Mes", "workReport", JSON.toJSONString(param));
|
||||
mesReportService.workReportReturn(param);
|
||||
// rabbitTemplate.convertAndSend("Mes", "workReport", JSON.toJSONString(param));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.nl.wms.ext_manage.mes.service.impl;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
@@ -24,6 +25,7 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MesReportServiceImpl implements MesReportService {
|
||||
|
||||
@Autowired
|
||||
@@ -38,11 +40,21 @@ public class MesReportServiceImpl implements MesReportService {
|
||||
@Override
|
||||
public void workReportReturn(WorkReportParam workReportParam) {
|
||||
try {
|
||||
if (!StringUtils.isEmpty(workReportParam.getSn())){
|
||||
int count = iReceiveOutReturnService.count(new LambdaQueryWrapper<ReceiveOutReturn>()
|
||||
.eq(ReceiveOutReturn::getSn, workReportParam.getSn()));
|
||||
if (count > 0) {
|
||||
throw new BadRequestException("报工倒扣同步失败,SN码重复");
|
||||
}
|
||||
}
|
||||
String SrcBillNo = workReportParam.getSrcBillNo();
|
||||
BigDecimal qty = workReportParam.getReportedQty();
|
||||
if (StringUtils.isEmpty(SrcBillNo)||qty == null){
|
||||
if (StringUtils.isEmpty(SrcBillNo)){
|
||||
throw new BadRequestException("报工倒扣同步失败,ERP源单号不存在为空");
|
||||
}
|
||||
if (qty == null ||qty.intValue() <=0 ){
|
||||
throw new BadRequestException("报工倒扣同步失败,报工数量不正确");
|
||||
}
|
||||
//TODO: 查询哪些是大件哪些是小件
|
||||
//workAreag根据功能做区域查看对于的库区,工作区域与库区编码一直
|
||||
final SchBaseRegion region = iSchBaseRegionService.getOne(new LambdaQueryWrapper<SchBaseRegion>()
|
||||
@@ -72,6 +84,7 @@ public class MesReportServiceImpl implements MesReportService {
|
||||
sideDto.setWorkArea(workReportParam.getWorkArea());
|
||||
pdaIosOutService.directConfirm(sideDto);
|
||||
}catch (Exception ex){
|
||||
log.error("报工回传异常:{}",ex);
|
||||
ReceiveOutReturn entity = new ReceiveOutReturn();
|
||||
entity.setOrgno(workReportParam.getOrgNo());
|
||||
entity.setSn(workReportParam.getSn());
|
||||
|
||||
@@ -290,12 +290,14 @@ public class PdaIosOutServiceImpl implements PdaIosOutService {
|
||||
entry.setSrcbillno(param.getSrcBillNo());
|
||||
entry.setSrcbillid(param.getSrcBillId());
|
||||
entry.setSrcbillentryid(bomItem.getItemId());
|
||||
if (qty.compareTo(actualQty) > 0) {
|
||||
if (bomQty.intValue() == 0 || qty.compareTo(actualQty) > 0) {
|
||||
status = StockReturnStatusEnum.FAIL.getCode();
|
||||
entry.setStatus(StockReturnStatusEnum.FAIL.getCode());
|
||||
entry.setRemark(materialCode+"WMS库存不足:当前" + actualQty + "需求" + qty.intValue());
|
||||
if (entry.getBaseqty().compareTo(BigDecimal.ZERO) == 0){
|
||||
if (bomQty.intValue() == 0 ){
|
||||
entry.setRemark("bom数量为0");
|
||||
entry.setStatus(StockReturnStatusEnum.IGNORE.getCode());
|
||||
}else {
|
||||
entry.setStatus(StockReturnStatusEnum.FAIL.getCode());
|
||||
entry.setRemark("WMS库存不足:当前" + actualQty + "需求" + qty.intValue());
|
||||
}
|
||||
entrys.add(entry);
|
||||
}else {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
@@ -9,6 +10,9 @@ 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;
|
||||
import org.nl.wms.ext_manage.service.WmsToErpService;
|
||||
import org.nl.wms.warehouse_manage.inventory.IStInventoryService;
|
||||
import org.nl.wms.warehouse_manage.inventory.dto.StInventoryDto;
|
||||
import org.nl.wms.warehouse_manage.inventory.dto.StInventoryQuery;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dao.ReceiveOutReturn;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dto.ReceiveOutReturnDto;
|
||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dto.ReceiveOutReturnQuery;
|
||||
@@ -20,6 +24,8 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -30,6 +36,10 @@ public class ReceiveOutReturnController {
|
||||
@Resource
|
||||
private IReceiveOutReturnService receiveOutReturnService;
|
||||
|
||||
|
||||
@Resource
|
||||
private IStInventoryService iStInventoryService;
|
||||
|
||||
@Resource
|
||||
private EasApi easApi;
|
||||
|
||||
@@ -87,5 +97,32 @@ public class ReceiveOutReturnController {
|
||||
.sum(); }
|
||||
return ResponseData.build(MapOf.of("qty",totalQty));
|
||||
}
|
||||
@GetMapping("/allStock")
|
||||
public ResponseEntity<Object> allStock(String warehouseno,String materialno) {
|
||||
QueryEasStockRequest easRequest = new QueryEasStockRequest();
|
||||
easRequest.setOrgno("01.09.14");
|
||||
easRequest.setWarehouseno(warehouseno);
|
||||
easRequest.setMaterialno(materialno);
|
||||
List<QueryEasStockResponse> easStocks = easApi.queryStock(easRequest);
|
||||
int totalQty = 0;
|
||||
if (!CollectionUtils.isEmpty(easStocks)){
|
||||
totalQty = easStocks.stream()
|
||||
.mapToInt(item -> Integer.parseInt(item.getQty()))
|
||||
.sum();
|
||||
}
|
||||
String result;
|
||||
result="EAS:"+totalQty;
|
||||
final List<StInventoryDto> stInventoryDtos = iStInventoryService.queryInventory(StInventoryQuery.builder()
|
||||
.materialCode(materialno)
|
||||
.sectCode(Arrays.asList(warehouseno)).build());
|
||||
int wmsTotalQty = 0;
|
||||
if (!CollectionUtils.isEmpty(stInventoryDtos)){
|
||||
wmsTotalQty = stInventoryDtos.stream()
|
||||
.mapToInt(item -> item.getQty().intValue())
|
||||
.sum();
|
||||
}
|
||||
result=result+",WMS:"+wmsTotalQty;
|
||||
return ResponseData.build(result);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ public class ReceiveOutReturnDto {
|
||||
private Long id;
|
||||
private String orgno;
|
||||
private String sn;
|
||||
private String trackNo;
|
||||
private String workArea;
|
||||
private String billno;
|
||||
private String biztype;
|
||||
private String invscheme;
|
||||
|
||||
@@ -251,6 +251,8 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
||||
dto.setId(entity.getId());
|
||||
dto.setOrgno(entity.getOrgno());
|
||||
dto.setSn(entity.getSn());
|
||||
dto.setTrackNo(entity.getTrackNo());
|
||||
dto.setWorkArea(entity.getWorkArea());
|
||||
dto.setBillno(entity.getBillno());
|
||||
dto.setBiztype(entity.getBiztype());
|
||||
dto.setInvscheme(entity.getInvscheme());
|
||||
|
||||
Reference in New Issue
Block a user