opt:中鼎同步
This commit is contained in:
@@ -30,6 +30,7 @@ public class EXTConstant {
|
||||
*/
|
||||
public final static String QUERY_INVENTORY_ZD_API = "/app/restful/api/v3/wms/getInventoryList";
|
||||
|
||||
public static final List<String> ZD_STOR_SET = Arrays.asList("6001");
|
||||
public static final String ZD_STOR_SET = "ZD_STOR_SET";
|
||||
// Arrays.asList("6001","6.011");
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.wms.ext_manage.enums.EXTConstant;
|
||||
import org.nl.wms.ext_manage.purchase.service.dto.BillChangeDto;
|
||||
import org.nl.wms.ext_manage.service.WmsToZDWmdService;
|
||||
import org.nl.wms.pm_manage.purchase.service.enums.PurchaseBillStatus;
|
||||
@@ -13,11 +15,19 @@ import org.nl.wms.pm_manage.purchase.service.dao.Purchasedtl;
|
||||
import org.nl.wms.pm_manage.purchase.service.dao.Purchasemst;
|
||||
import org.nl.wms.pm_manage.purchase.service.dao.mapper.PurchasedtlMapper;
|
||||
import org.nl.wms.pm_manage.purchase.service.dao.mapper.PurchasemstMapper;
|
||||
import org.nl.wms.system_manage.enums.SysParamConstant;
|
||||
import org.nl.wms.system_manage.service.param.ISysParamService;
|
||||
import org.nl.wms.system_manage.service.param.dao.Param;
|
||||
import org.nl.wms.system_manage.service.param.impl.SysParamServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -35,62 +45,64 @@ public class InboundEasSyncServiceImpl implements InboundEasSyncService {
|
||||
@Autowired
|
||||
private WmsToZDWmdService wmsToZDWmdService;
|
||||
|
||||
@Autowired
|
||||
private ISysParamService iSysParamService;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncPurchaseBill(BillChangeDto billChangeDto) {
|
||||
public void syncPurchaseBill(BillChangeDto billChangeDto) {
|
||||
String billId = billChangeDto.getBillid();
|
||||
Integer status = billChangeDto.getStatus();//1:已提交;2:更新;3:删除;
|
||||
//更新单据
|
||||
final Purchasemst purchasemst = purchasemstMapper.selectOne(new LambdaQueryWrapper<Purchasemst>()
|
||||
.eq(Purchasemst::getBill_id, billId));
|
||||
if (purchasemst!=null && !purchasemst.getBill_status().equals(PurchaseBillStatus.CREATED.getCode())){
|
||||
throw new BadRequestException("EAS采购单同步失败:当前单据在WMS系统中已经执行 " + billId);
|
||||
}
|
||||
Param zdStorParam = iSysParamService.findByCode(EXTConstant.ZD_STOR_SET);
|
||||
List ZD_STOR_SET;
|
||||
if (zdStorParam!=null){
|
||||
ZD_STOR_SET = JSONObject.parseObject(zdStorParam.getValue(), List.class);
|
||||
} else {
|
||||
ZD_STOR_SET = new ArrayList<>();
|
||||
}
|
||||
switch (status){
|
||||
case 1:
|
||||
case 2:
|
||||
//增加单据
|
||||
Purchasemst easMst = easQueryService.queryMst(billId);
|
||||
if (easMst == null) {
|
||||
throw new BadRequestException("EAS采购单同步失败:EAS系统中未找到单据: " + billId);
|
||||
}
|
||||
easMst.setBill_status(PurchaseBillStatus.CREATED.getCode());
|
||||
easMst.setModify_date(DateUtil.now());
|
||||
List<Purchasedtl> easDtlList = easQueryService.queryDtlList(billId);
|
||||
for (Purchasedtl dtl : easDtlList) {
|
||||
purchasedtlMapper.insert(dtl);
|
||||
if (dtl.getHouse_code().contains("ZDLK")){
|
||||
//中鼎立库
|
||||
easMst.setForwardZD(1);
|
||||
//TODO 转发中鼎参数待确定
|
||||
wmsToZDWmdService.syncPurchaseReceiving(new JSONObject());
|
||||
}
|
||||
}
|
||||
purchasemstMapper.insert(easMst);
|
||||
|
||||
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
|
||||
break;
|
||||
case 2:
|
||||
//更新单据
|
||||
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
|
||||
.eq(Purchasedtl::getBill_id, billId));
|
||||
purchasemstMapper.delete(new LambdaQueryWrapper<Purchasemst>()
|
||||
.eq(Purchasemst::getBill_id, billId));
|
||||
|
||||
//增加单据
|
||||
Purchasemst easMstUpdate = easQueryService.queryMst(billId);
|
||||
if (easMstUpdate == null) {
|
||||
throw new BadRequestException("EAS采购单同步失败:EAS系统中未找到单据: " + billId);
|
||||
}
|
||||
easMstUpdate.setBill_status(PurchaseBillStatus.CREATED.getCode());
|
||||
easMstUpdate.setModify_date(DateUtil.now());
|
||||
List<Purchasedtl> easDtlListUpdate = easQueryService.queryDtlList(billId);
|
||||
for (Purchasedtl dtl : easDtlListUpdate) {
|
||||
purchasedtlMapper.insert(dtl);
|
||||
if (dtl.getHouse_code().contains("ZDLK")){
|
||||
//更新单据
|
||||
List<Purchasedtl> easDtlList = easQueryService.queryDtlList(billId);
|
||||
Boolean allZD = true;
|
||||
for (Purchasedtl dtl : easDtlList) {
|
||||
if (ZD_STOR_SET.contains(dtl.getHouse_code())){
|
||||
//中鼎立库
|
||||
easMstUpdate.setForwardZD(1);
|
||||
//TODO 转发中鼎参数待确定
|
||||
wmsToZDWmdService.syncPurchaseReceiving(new JSONObject());
|
||||
dtl.setInstock_qty(dtl.getQty());
|
||||
easMst.setForwardZD(1);
|
||||
easMst.setBill_status(PurchaseBillStatus.EXECUTING.getCode());
|
||||
}else {
|
||||
allZD = false;
|
||||
}
|
||||
}
|
||||
purchasemstMapper.insert(easMstUpdate);
|
||||
|
||||
log.info("EAS采购入库单更新完成, billId: {}", billId);
|
||||
if (easMst.getForwardZD()==1){
|
||||
if (allZD){
|
||||
//如果全部都是中鼎的则由中鼎回传EAS
|
||||
easMst.setBill_status(PurchaseBillStatus.COMPLETED.getCode());
|
||||
}
|
||||
//转发中鼎
|
||||
wmsToZDWmdService.syncPurchaseReceiving(billChangeDto);
|
||||
}
|
||||
purchasedtlMapper.batchSave(easDtlList);
|
||||
purchasemstMapper.insert(easMst);
|
||||
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
|
||||
break;
|
||||
case 3:
|
||||
//删除单据
|
||||
@@ -105,56 +117,55 @@ public class InboundEasSyncServiceImpl implements InboundEasSyncService {
|
||||
public void syncTransferBill(BillChangeDto billChangeDto) {
|
||||
String billId = billChangeDto.getBillid();
|
||||
Integer status = billChangeDto.getStatus();//1:已提交;2:更新;3:删除;
|
||||
//更新单据
|
||||
final Purchasemst purchasemst = purchasemstMapper.selectOne(new LambdaQueryWrapper<Purchasemst>()
|
||||
.eq(Purchasemst::getBill_id, billId));
|
||||
if (purchasemst!=null && !purchasemst.getBill_status().equals(PurchaseBillStatus.CREATED.getCode())){
|
||||
throw new BadRequestException("EAS采购单同步失败:当前单据在WMS系统中已经执行 " + billId);
|
||||
}
|
||||
Param zdStorParam = iSysParamService.findByCode(EXTConstant.ZD_STOR_SET);
|
||||
List ZD_STOR_SET;
|
||||
if (zdStorParam!=null){
|
||||
ZD_STOR_SET = JSONObject.parseObject(zdStorParam.getValue(), List.class);
|
||||
} else {
|
||||
ZD_STOR_SET = new ArrayList<>();
|
||||
}
|
||||
switch (status){
|
||||
case 1:
|
||||
case 2:
|
||||
//增加单据
|
||||
Purchasemst easMst = easQueryService.queryMstByTransfer(billId);
|
||||
if (easMst == null) {
|
||||
throw new BadRequestException("EAS采购单同步失败:EAS系统中未找到单据: " + billId);
|
||||
}
|
||||
easMst.setBill_status(PurchaseBillStatus.CREATED.getCode());
|
||||
easMst.setModify_date(DateUtil.now());
|
||||
List<Purchasedtl> easDtlList = easQueryService.queryDtlListByTransfer(billId);
|
||||
for (Purchasedtl dtl : easDtlList) {
|
||||
purchasedtlMapper.insert(dtl);
|
||||
if (dtl.getHouse_code().contains("ZDLK")){
|
||||
//中鼎立库
|
||||
easMst.setForwardZD(1);
|
||||
//TODO 转发中鼎参数待确定
|
||||
wmsToZDWmdService.syncPurchaseReceiving(new JSONObject());
|
||||
}
|
||||
}
|
||||
purchasemstMapper.insert(easMst);
|
||||
|
||||
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
|
||||
break;
|
||||
case 2:
|
||||
//更新单据
|
||||
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
|
||||
.eq(Purchasedtl::getBill_id, billId));
|
||||
purchasemstMapper.delete(new LambdaQueryWrapper<Purchasemst>()
|
||||
.eq(Purchasemst::getBill_id, billId));
|
||||
|
||||
//增加单据
|
||||
Purchasemst easMstUpdate = easQueryService.queryMstByTransfer(billId);
|
||||
if (easMstUpdate == null) {
|
||||
throw new BadRequestException("EAS采购单同步失败:EAS系统中未找到单据: " + billId);
|
||||
}
|
||||
easMstUpdate.setBill_status(PurchaseBillStatus.CREATED.getCode());
|
||||
easMstUpdate.setModify_date(DateUtil.now());
|
||||
List<Purchasedtl> easDtlListUpdate = easQueryService.queryDtlListByTransfer(billId);
|
||||
for (Purchasedtl dtl : easDtlListUpdate) {
|
||||
purchasedtlMapper.insert(dtl);
|
||||
if (dtl.getHouse_code().contains("ZDLK")){
|
||||
//更新单据
|
||||
List<Purchasedtl> easDtlList = easQueryService.queryDtlListByTransfer(billId);
|
||||
Boolean allZD = true;
|
||||
for (Purchasedtl dtl : easDtlList) {
|
||||
if (ZD_STOR_SET.contains(dtl.getHouse_code())){
|
||||
//中鼎立库
|
||||
easMstUpdate.setForwardZD(1);
|
||||
//TODO 转发中鼎参数待确定
|
||||
wmsToZDWmdService.syncPurchaseReceiving(new JSONObject());
|
||||
dtl.setInstock_qty(dtl.getQty());
|
||||
easMst.setForwardZD(1);
|
||||
easMst.setBill_status(PurchaseBillStatus.EXECUTING.getCode());
|
||||
}else {
|
||||
allZD = false;
|
||||
}
|
||||
}
|
||||
purchasemstMapper.insert(easMstUpdate);
|
||||
|
||||
log.info("EAS采购入库单更新完成, billId: {}", billId);
|
||||
if (easMst.getForwardZD()==1){
|
||||
if (allZD){
|
||||
//如果全部都是中鼎的则由中鼎回传EAS
|
||||
easMst.setBill_status(PurchaseBillStatus.COMPLETED.getCode());
|
||||
}
|
||||
//转发中鼎
|
||||
wmsToZDWmdService.syncPurchaseReceiving(billChangeDto);
|
||||
}
|
||||
purchasedtlMapper.batchSave(easDtlList);
|
||||
purchasemstMapper.insert(easMst);
|
||||
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
|
||||
break;
|
||||
case 3:
|
||||
//删除单据
|
||||
@@ -169,56 +180,55 @@ public class InboundEasSyncServiceImpl implements InboundEasSyncService {
|
||||
public void syncOtherBill(BillChangeDto billChangeDto) {
|
||||
String billId = billChangeDto.getBillid();
|
||||
Integer status = billChangeDto.getStatus();//1:已提交;2:更新;3:删除;
|
||||
//更新单据
|
||||
final Purchasemst purchasemst = purchasemstMapper.selectOne(new LambdaQueryWrapper<Purchasemst>()
|
||||
.eq(Purchasemst::getBill_id, billId));
|
||||
if (purchasemst!=null && !purchasemst.getBill_status().equals(PurchaseBillStatus.CREATED.getCode())){
|
||||
throw new BadRequestException("EAS采购单同步失败:当前单据在WMS系统中已经执行 " + billId);
|
||||
}
|
||||
Param zdStorParam = iSysParamService.findByCode(EXTConstant.ZD_STOR_SET);
|
||||
List ZD_STOR_SET;
|
||||
if (zdStorParam!=null){
|
||||
ZD_STOR_SET = JSONObject.parseObject(zdStorParam.getValue(), List.class);
|
||||
} else {
|
||||
ZD_STOR_SET = new ArrayList<>();
|
||||
}
|
||||
switch (status){
|
||||
case 1:
|
||||
case 2:
|
||||
//增加单据
|
||||
Purchasemst easMst = easQueryService.queryMstByOther(billId);
|
||||
if (easMst == null) {
|
||||
throw new BadRequestException("EAS采购单同步失败:EAS系统中未找到单据: " + billId);
|
||||
}
|
||||
easMst.setBill_status(PurchaseBillStatus.CREATED.getCode());
|
||||
easMst.setModify_date(DateUtil.now());
|
||||
List<Purchasedtl> easDtlList = easQueryService.queryDtlListByOther(billId);
|
||||
for (Purchasedtl dtl : easDtlList) {
|
||||
purchasedtlMapper.insert(dtl);
|
||||
if (dtl.getHouse_code().contains("ZDLK")){
|
||||
//中鼎立库
|
||||
easMst.setForwardZD(1);
|
||||
//TODO 转发中鼎参数待确定
|
||||
wmsToZDWmdService.syncPurchaseReceiving(new JSONObject());
|
||||
}
|
||||
}
|
||||
purchasemstMapper.insert(easMst);
|
||||
|
||||
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
|
||||
break;
|
||||
case 2:
|
||||
//更新单据
|
||||
purchasedtlMapper.delete(new LambdaQueryWrapper<Purchasedtl>()
|
||||
.eq(Purchasedtl::getBill_id, billId));
|
||||
purchasemstMapper.delete(new LambdaQueryWrapper<Purchasemst>()
|
||||
.eq(Purchasemst::getBill_id, billId));
|
||||
|
||||
//增加单据
|
||||
Purchasemst easMstUpdate = easQueryService.queryMstByOther(billId);
|
||||
if (easMstUpdate == null) {
|
||||
throw new BadRequestException("EAS采购单同步失败:EAS系统中未找到单据: " + billId);
|
||||
}
|
||||
easMstUpdate.setBill_status(PurchaseBillStatus.CREATED.getCode());
|
||||
easMstUpdate.setModify_date(DateUtil.now());
|
||||
List<Purchasedtl> easDtlListUpdate = easQueryService.queryDtlListByOther(billId);
|
||||
for (Purchasedtl dtl : easDtlListUpdate) {
|
||||
purchasedtlMapper.insert(dtl);
|
||||
if (dtl.getHouse_code().contains("ZDLK")){
|
||||
//更新单据
|
||||
List<Purchasedtl> easDtlList = easQueryService.queryDtlListByOther(billId);
|
||||
Boolean allZD = true;
|
||||
for (Purchasedtl dtl : easDtlList) {
|
||||
if (ZD_STOR_SET.contains(dtl.getHouse_code())){
|
||||
//中鼎立库
|
||||
easMstUpdate.setForwardZD(1);
|
||||
//TODO 转发中鼎参数待确定
|
||||
wmsToZDWmdService.syncPurchaseReceiving(new JSONObject());
|
||||
dtl.setInstock_qty(dtl.getQty());
|
||||
easMst.setForwardZD(1);
|
||||
easMst.setBill_status(PurchaseBillStatus.EXECUTING.getCode());
|
||||
}else {
|
||||
allZD = false;
|
||||
}
|
||||
}
|
||||
purchasemstMapper.insert(easMstUpdate);
|
||||
|
||||
log.info("EAS采购入库单更新完成, billId: {}", billId);
|
||||
if (easMst.getForwardZD()==1){
|
||||
if (allZD){
|
||||
//如果全部都是中鼎的则由中鼎回传EAS
|
||||
easMst.setBill_status(PurchaseBillStatus.COMPLETED.getCode());
|
||||
}
|
||||
//转发中鼎
|
||||
wmsToZDWmdService.syncPurchaseReceiving(billChangeDto);
|
||||
}
|
||||
purchasedtlMapper.batchSave(easDtlList);
|
||||
purchasemstMapper.insert(easMst);
|
||||
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
|
||||
break;
|
||||
case 3:
|
||||
//删除单据
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package org.nl.wms.ext_manage.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.wms.ext_manage.purchase.service.dto.BillChangeDto;
|
||||
import org.nl.wms.ext_manage.service.dto.ZDInventory;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandDto;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -17,6 +20,8 @@ import java.util.List;
|
||||
*/
|
||||
public interface WmsToZDWmdService {
|
||||
|
||||
public static Map<String,String> ZD_LOS_MAPPING = MapOf.of("EP2","6.002");
|
||||
|
||||
/**
|
||||
* 生产领料需求单下发
|
||||
*
|
||||
@@ -28,9 +33,9 @@ public interface WmsToZDWmdService {
|
||||
ResponseEntity syncDemandOrder(List<PmDemandDto> demands);
|
||||
|
||||
/**
|
||||
* 采购入库单下发
|
||||
* EAS入库单下发
|
||||
*/
|
||||
ResponseEntity syncPurchaseReceiving(JSONObject whereJson);
|
||||
ResponseEntity syncPurchaseReceiving(BillChangeDto billChangeDto);
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -5,9 +5,10 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.annotation.Mock;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.wms.ext_manage.enums.EXTConstant;
|
||||
import org.nl.wms.ext_manage.purchase.service.dto.BillChangeDto;
|
||||
import org.nl.wms.ext_manage.service.WmsToZDWmdService;
|
||||
import org.nl.wms.ext_manage.service.dto.ZDInventory;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandDto;
|
||||
@@ -20,6 +21,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -27,13 +29,41 @@ public class WmsToZDWmdServiceImpl implements WmsToZDWmdService {
|
||||
@Override
|
||||
public ResponseEntity syncDemandOrder(List<PmDemandDto> demands) {
|
||||
log.info("syncDemandOrder生产领料需求单下发输入参数:-------------------" + demands.size());
|
||||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.ZD_URL).getValue();
|
||||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.ZD_URL_REQUISITION).getValue();
|
||||
try {
|
||||
//数据转换
|
||||
List<Map<String, Object>> targetList = new ArrayList<>();
|
||||
for (PmDemandDto demand : demands) {
|
||||
java.util.Map<String, Object> map = new java.util.HashMap<>();
|
||||
map.put("Id", demand.getId());
|
||||
map.put("Creator", demand.getCreator());
|
||||
map.put("CreateTime", demand.getCreateTime());
|
||||
map.put("Priority", demand.getPriority());
|
||||
map.put("Status", 0);
|
||||
map.put("WorkOrder", demand.getWorkOrder());
|
||||
map.put("SkuCode", demand.getSkuCode());
|
||||
map.put("SkuName", demand.getSkuName());
|
||||
map.put("Qty", demand.getQty().intValue());
|
||||
map.put("Unit", demand.getUnit());
|
||||
map.put("TargetArea", demand.getTargetArea());
|
||||
map.put("ProductionLine", demand.getProductionLine());
|
||||
map.put("Source", demand.getProductionLine());
|
||||
map.put("CarrierType", demand.getCarrierType());
|
||||
map.put("TargetHouseCode", demand.getTargetHouseCode());
|
||||
map.put("SN", demand.getSn());
|
||||
targetList.add(map);
|
||||
}
|
||||
final String param = JSON.toJSONString(targetList);
|
||||
log.info("syncDemandOrder需求单请求参数:-------------------" + param);
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(JSONArray.parseArray(JSON.toJSONString(demands)).toJSONString())
|
||||
.body(JSONArray.parseArray(param).toJSONString())
|
||||
.execute().body();
|
||||
JSONObject result = JSONObject.parseObject(resultMsg);
|
||||
log.info("syncDemandOrder需求单下发输出参数:-------------------" + result.toString());
|
||||
Integer respCode = result.getInteger("respCode");
|
||||
if (respCode == null || respCode != 0) {
|
||||
throw new BadRequestException("中鼎库存查询失败:" + result.getString("respMsg"));
|
||||
}
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("中鼎需求单下发失败:" + e.getMessage());
|
||||
@@ -41,38 +71,42 @@ public class WmsToZDWmdServiceImpl implements WmsToZDWmdService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity syncPurchaseReceiving(JSONObject whereJson) {
|
||||
log.info("syncPurchaseReceiving采购入库单下发输入参数:-------------------" + whereJson.toString());
|
||||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.ZD_URL).getValue();
|
||||
public ResponseEntity syncPurchaseReceiving(BillChangeDto billChangeDto) {
|
||||
final String param = JSON.toJSONString(billChangeDto);
|
||||
log.info("syncPurchaseReceiving采购入库单下发输入参数:-------------------" + param);
|
||||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.ZD_URL_REQUISITION).getValue();
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(whereJson.toString())
|
||||
.body(param)
|
||||
.execute().body();
|
||||
JSONObject result = JSONObject.parseObject(resultMsg);
|
||||
Integer respCode = result.getInteger("respCode");
|
||||
if (respCode == null || respCode != 0) {
|
||||
throw new BadRequestException("中鼎单据下推失败:" + result.getString("respMsg"));
|
||||
}
|
||||
log.info("syncPurchaseReceiving采购入库单下发输出参数:-------------------" + result.toString());
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("中鼎采购入库单下发失败:" + e.getMessage());
|
||||
throw new BadRequestException("中鼎单据下推失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Mock(desc = "库存查询mock",enable = true)
|
||||
public ResponseEntity<List<ZDInventory>> queryInventory(String skuCode) {
|
||||
List<ZDInventory> inventorys = new ArrayList<>();
|
||||
log.info("queryInventory查询SKU库存输入参数:skuCode={}", skuCode);
|
||||
Param param = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.ZD_URL);
|
||||
Param param = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.ZD_URL_LOC);
|
||||
if (param==null){
|
||||
return new ResponseEntity<>(inventorys, HttpStatus.OK);
|
||||
// throw new BadRequestException("查询中鼎库存失败,接口地址未配置");
|
||||
}
|
||||
String baseUrl = param.getValue();
|
||||
String url = baseUrl + EXTConstant.QUERY_INVENTORY_ZD_API;
|
||||
|
||||
String url = param.getValue();
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("SkuCode", "");
|
||||
requestBody.put("SkuCode", skuCode);
|
||||
requestBody.put("HouseCode", "");
|
||||
requestBody.put("HouseCode", "6.002");
|
||||
requestBody.put("HouseCodeLis", new JSONArray());
|
||||
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.contentType("application/json")
|
||||
|
||||
@@ -47,6 +47,12 @@ public class PmDemand extends Model<PmDemand> {
|
||||
@TableField("target_area")
|
||||
private String target_area;
|
||||
|
||||
@TableField("target_house_code")
|
||||
private String target_house_code;
|
||||
|
||||
@TableField("carrier_type")
|
||||
private String carrier_type;
|
||||
|
||||
@TableField("production_line")
|
||||
private String production_line;
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
<result property="assignQty" column="assign_qty"/>
|
||||
<result property="unit" column="unit"/>
|
||||
<result property="targetArea" column="target_area"/>
|
||||
<result property="targetHouseCode" column="target_house_code"/>
|
||||
<result property="carrierType" column="carrier_type"/>
|
||||
<result property="productionLine" column="production_line"/>
|
||||
<result property="sn" column="sn"/>
|
||||
<result property="createAt" column="create_at"/>
|
||||
|
||||
@@ -21,6 +21,8 @@ public class PmDemandDto implements Serializable {
|
||||
private BigDecimal assignQty;
|
||||
private String unit;
|
||||
private String targetArea;
|
||||
private String targetHouseCode;
|
||||
private String carrierType;
|
||||
private String productionLine;
|
||||
private String sn;
|
||||
private String createAt;
|
||||
|
||||
@@ -19,58 +19,65 @@ import java.math.BigDecimal;
|
||||
public class PmDemandParam {
|
||||
|
||||
@NotBlank(message = "单据唯一ID不能为空")
|
||||
@JsonProperty(value = "Id")
|
||||
private String Id;
|
||||
@JsonProperty(value = "id")
|
||||
private String id;
|
||||
|
||||
@NotBlank(message = "操作人不能为空")
|
||||
@JsonProperty(value = "Creator")
|
||||
private String Creator;
|
||||
@JsonProperty(value = "creator")
|
||||
private String creator;
|
||||
|
||||
@NotBlank(message = "需求日期不能为空")
|
||||
@JsonProperty(value = "CreateTime")
|
||||
private String CreateTime;
|
||||
@JsonProperty(value = "createTime")
|
||||
private String createTime;
|
||||
|
||||
@NotNull(message = "优先级不能为空")
|
||||
@JsonProperty(value = "Priority")
|
||||
private Integer Priority;
|
||||
@JsonProperty(value = "priority")
|
||||
private Integer priority;
|
||||
|
||||
@JsonProperty(value = "Status")
|
||||
private String Status;
|
||||
@JsonProperty(value = "status")
|
||||
private String status;
|
||||
|
||||
@NotBlank(message = "工单编号不能为空")
|
||||
@JsonProperty(value = "WorkOrder")
|
||||
private String WorkOrder;
|
||||
@JsonProperty(value = "workOrder")
|
||||
private String workOrder;
|
||||
|
||||
@NotBlank(message = "物料编码不能为空")
|
||||
@JsonProperty(value = "SkuCode")
|
||||
private String SkuCode;
|
||||
@JsonProperty(value = "skuCode")
|
||||
private String skuCode;
|
||||
|
||||
@NotBlank(message = "物料名称不能为空")
|
||||
@JsonProperty(value = "SkuName")
|
||||
private String SkuName;
|
||||
@JsonProperty(value = "skuName")
|
||||
private String skuName;
|
||||
|
||||
@NotNull(message = "数量不能为空")
|
||||
@DecimalMin(value = "0", inclusive = false, message = "数量必须大于0")
|
||||
@JsonProperty(value = "Qty")
|
||||
private BigDecimal Qty;
|
||||
@JsonProperty(value = "qty")
|
||||
private BigDecimal qty;
|
||||
|
||||
@DecimalMin(value = "0", inclusive = false, message = "数量必须大于0")
|
||||
@JsonProperty(value = "QssignQty")
|
||||
private BigDecimal QssignQty;
|
||||
@JsonProperty(value = "qssignQty")
|
||||
private BigDecimal qssignQty;
|
||||
|
||||
@NotBlank(message = "单位不能为空")
|
||||
@JsonProperty(value = "Unit")
|
||||
private String Unit;
|
||||
@JsonProperty(value = "unit")
|
||||
private String unit;
|
||||
|
||||
@NotBlank(message = "目标库存地点不能为空")
|
||||
@JsonProperty(value = "TargetArea")
|
||||
private String TargetArea;
|
||||
@JsonProperty(value = "targetArea")
|
||||
private String targetArea;
|
||||
|
||||
@NotBlank(message = "产线不能为空")
|
||||
@JsonProperty(value = "ProductionLine")
|
||||
private String ProductionLine;
|
||||
@JsonProperty(value = "productionLine")
|
||||
private String productionLine;
|
||||
@NotBlank(message = "目标库存地点不能为空")
|
||||
@JsonProperty(value = "targetHouseCode")
|
||||
private String targetHouseCode;
|
||||
|
||||
@JsonProperty(value = "SN")
|
||||
private String SN;
|
||||
@NotBlank(message = "产线不能为空")
|
||||
@JsonProperty(value = "carrierType")
|
||||
private String carrierType;
|
||||
|
||||
@JsonProperty(value = "sn")
|
||||
private String sn;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ public class PmDemandQuery extends BaseQuery<PmDemand> {
|
||||
private Integer status;
|
||||
private String workOrder;
|
||||
private String skuCode;
|
||||
private String targetHouseCode;
|
||||
private String carrierType;
|
||||
private String productionLine;
|
||||
private String targetArea;
|
||||
private String startTime;
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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;
|
||||
@@ -26,6 +27,9 @@ import org.nl.wms.pm_manage.demand.service.dto.PmDemandParam;
|
||||
import org.nl.wms.pm_manage.demand.service.dto.PmDemandQuery;
|
||||
import org.nl.wms.pm_manage.demand.service.enums.DemandStatus;
|
||||
import org.nl.wms.sch_manage.enums.StatusEnum;
|
||||
import org.nl.wms.system_manage.service.param.ISysParamService;
|
||||
import org.nl.wms.system_manage.service.param.dao.Param;
|
||||
import org.nl.wms.system_manage.service.param.impl.SysParamServiceImpl;
|
||||
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;
|
||||
@@ -57,7 +61,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
@Autowired
|
||||
private IMdMeMaterialbaseService iMdMeMaterialbaseService;
|
||||
@Autowired
|
||||
private IMdPbMeasureunitService iMdPbMeasureunitService;
|
||||
private ISysParamService iSysParamService;
|
||||
|
||||
@Override
|
||||
public Page<PmDemandDto> queryPage(PmDemandQuery query, PageQuery pageQuery) {
|
||||
@@ -84,8 +88,10 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
demand.setQty(param.getQty());
|
||||
demand.setUnit(param.getUnit());
|
||||
demand.setTarget_area(param.getTargetArea());
|
||||
demand.setTarget_house_code(param.getTargetHouseCode());
|
||||
demand.setCarrier_type(param.getCarrierType());
|
||||
demand.setProduction_line(param.getProductionLine());
|
||||
demand.setSn(param.getSN());
|
||||
demand.setSn(param.getSn());
|
||||
demand.setCreate_at(DateUtil.now());
|
||||
this.save(demand);
|
||||
}
|
||||
@@ -171,7 +177,12 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
demandDto.setSkuCode(item.getSkuCode());
|
||||
demandDto.setSkuName(null);
|
||||
demandDto.setQty(item.getQty());
|
||||
demandDto.setHouseCode(item.getHouseCode());
|
||||
//中鼎库存有映射
|
||||
String houseMapping = WmsToZDWmdService.ZD_LOS_MAPPING.get(item.getHouseCode());
|
||||
if (StringUtils.isEmpty(houseMapping)){
|
||||
throw new BadRequestException("分配失败,当前中鼎仓库编码未配置映射");
|
||||
}
|
||||
demandDto.setHouseCode(houseMapping);
|
||||
demandDto.setHouseName(null);
|
||||
resultList.add(demandDto);
|
||||
}
|
||||
@@ -190,8 +201,15 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
throw new BadRequestException("下推失败,单据状态不为已分配不能下推");
|
||||
}
|
||||
// 一次性分成两组
|
||||
Param zdStorParam = iSysParamService.findByCode(EXTConstant.ZD_STOR_SET);
|
||||
List ZD_STOR_SET;
|
||||
if (zdStorParam!=null){
|
||||
ZD_STOR_SET = JSONObject.parseObject(zdStorParam.getValue(), List.class);
|
||||
} else {
|
||||
ZD_STOR_SET = new ArrayList<>();
|
||||
}
|
||||
Map<Boolean, List<PmDemandDto>> partitioned = pmDemandDtos.stream()
|
||||
.collect(Collectors.partitioningBy(a -> EXTConstant.ZD_STOR_SET
|
||||
.collect(Collectors.partitioningBy(a -> ZD_STOR_SET
|
||||
.contains(JSONObject.parseObject(a.getInventoryDis()).getString("horseCode"))));
|
||||
List<PmDemandDto> zdDemands = partitioned.get(true);
|
||||
List<PmDemandDto> otherDemands = partitioned.get(false);
|
||||
@@ -235,7 +253,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
for (PmDemandDto demand : demands) {
|
||||
JSONObject detailRow = new JSONObject();
|
||||
detailRow.put("material_code", demand.getSkuCode());
|
||||
detailRow.put("material_id", codeToIdMap.get(demand.getSkuCode()).getMaterial_id());
|
||||
MdMeMaterialbase materialbase = codeToIdMap.get(demand.getSkuCode());
|
||||
if (materialbase == null){
|
||||
throw new BadRequestException("下推失败,"+demand.getSkuCode()+"在WMS中不存在");
|
||||
}
|
||||
detailRow.put("material_id", materialbase.getMaterial_id());
|
||||
detailRow.put("qty_unit_name", demand.getUnit());
|
||||
detailRow.put("qty_unit_id", codeToIdMap.get(demand.getSkuCode()).getQty_unit_id());
|
||||
detailRow.put("qty", demand.getQty());
|
||||
|
||||
@@ -8,6 +8,9 @@ import lombok.EqualsAndHashCode;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 采购入库单分录信息表实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("st_ivt_purchasedtl")
|
||||
@@ -15,36 +18,84 @@ public class Purchasedtl implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 自增主键ID
|
||||
*/
|
||||
@TableId("id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 分录id
|
||||
*/
|
||||
private String entry_id;
|
||||
|
||||
/**
|
||||
* 单据主表关联id
|
||||
*/
|
||||
private String bill_id;
|
||||
|
||||
/**
|
||||
* 行号
|
||||
*/
|
||||
private String item_no;
|
||||
|
||||
/**
|
||||
* 品类编码
|
||||
*/
|
||||
private String category_code;
|
||||
|
||||
/**
|
||||
* 品类名称
|
||||
*/
|
||||
private String category_name;
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
private String sku_code;
|
||||
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
private String sku_name;
|
||||
|
||||
/**
|
||||
* 物料规格
|
||||
*/
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 仓库号
|
||||
*/
|
||||
private String house_code;
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String batch_no;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private BigDecimal qty;
|
||||
|
||||
/**
|
||||
* 单位编码
|
||||
*/
|
||||
private String unit_code;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String unit;
|
||||
|
||||
/**
|
||||
* 跟踪号
|
||||
*/
|
||||
private String track_no;
|
||||
|
||||
/**
|
||||
* 已入库数量
|
||||
*/
|
||||
private BigDecimal instock_qty;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.nl.wms.pm_manage.purchase.service.dao.Purchasedtl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PurchasedtlMapper extends BaseMapper<Purchasedtl> {
|
||||
|
||||
void batchSave(List<Purchasedtl> entitys);
|
||||
}
|
||||
|
||||
@@ -2,4 +2,44 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.wms.pm_manage.purchase.service.dao.mapper.PurchasedtlMapper">
|
||||
|
||||
<insert id="batchSave" parameterType="java.util.List">
|
||||
INSERT INTO st_ivt_purchasedtl (
|
||||
id,
|
||||
entry_id,
|
||||
bill_id,
|
||||
item_no,
|
||||
category_code,
|
||||
category_name,
|
||||
sku_code,
|
||||
sku_name,
|
||||
model,
|
||||
house_code,
|
||||
batch_no,
|
||||
qty,
|
||||
unit_code,
|
||||
unit,
|
||||
track_no,
|
||||
instock_qty
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.id},
|
||||
#{item.entryId},
|
||||
#{item.billId},
|
||||
#{item.itemNo},
|
||||
#{item.categoryCode},
|
||||
#{item.categoryName},
|
||||
#{item.skuCode},
|
||||
#{item.skuName},
|
||||
#{item.model},
|
||||
#{item.houseCode},
|
||||
#{item.batchNo},
|
||||
#{item.qty},
|
||||
#{item.unitCode},
|
||||
#{item.unit},
|
||||
#{item.trackNo},
|
||||
#{item.instockQty}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
|
||||
@@ -25,7 +25,9 @@ public class SysParamConstant {
|
||||
/**
|
||||
* 中鼎系统URL
|
||||
*/
|
||||
public final static String ZD_URL = "zd_url";
|
||||
public final static String ZD_URL_REQUISITION = "ZD_URL_REQUISITION";
|
||||
public final static String ZD_URL_LOC = "ZD_URL_LOC";
|
||||
public final static String ZD_URL_IOORDER = "ZD_URL_IOORDER";
|
||||
/**
|
||||
* MES URL
|
||||
*/
|
||||
|
||||
@@ -64,6 +64,9 @@ public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param> impl
|
||||
param.setUpdate_id(currentUserId);
|
||||
param.setUpdate_name(nickName);
|
||||
param.setUpdate_time(now);
|
||||
param.setZh_name(param.getName());
|
||||
param.setEn_name(param.getName());
|
||||
param.setIn_name(param.getName());
|
||||
paramMapper.insert(param);
|
||||
}
|
||||
|
||||
|
||||
@@ -284,6 +284,9 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
|
||||
}
|
||||
bsrealStorattr = iBsrealStorattrService.findByCode(storCode);
|
||||
}
|
||||
if (bsrealStorattr == null){
|
||||
throw new BadRequestException("生成出库单失败,仓库编码不存在");
|
||||
}
|
||||
map.put("iostorinv_id", iostorinv_id);
|
||||
map.put("bill_code", CodeUtil.getNewCode("OUT_STORE_CODE"));
|
||||
map.put("biz_date", map.getString("biz_date").substring(0, 10));
|
||||
|
||||
@@ -52,17 +52,17 @@
|
||||
物料:<strong>{{ currentDemand.skuCode }} {{ currentDemand.skuName }}</strong> |
|
||||
需求数量:<strong style="color:#E6A23C;">{{ currentDemand.qty }} {{ currentDemand.unit }}</strong>
|
||||
</div>
|
||||
<el-table ref="allocateTable" :data="inventoryList" size="small" border v-loading="inventoryLoading" @selection-change="handleInventorySelection">
|
||||
<el-table ref="allocateTable" v-loading="inventoryLoading" :data="inventoryList" size="small" border @selection-change="handleInventorySelection">
|
||||
<el-table-column type="selection" width="45" />
|
||||
<el-table-column prop="houseCode" label="仓库编号" min-width="130" show-overflow-tooltip />
|
||||
<el-table-column prop="houseName" label="仓库名称" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="skuCode" label="物料编码" min-width="130" show-overflow-tooltip />
|
||||
<el-table-column prop="qty" label="库存数量" width="110" />
|
||||
<el-table-column label="分配数量" width="160">
|
||||
<template slot-scope="scope">
|
||||
<el-input-number v-model="scope.row.allocQty" :min="0" :max="scope.row.qty" :precision="4" size="mini" style="width:130px;" :disabled="!scope.row._selected" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="分配数量" width="160">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <el-input-number v-model="scope.row.allocQty" :min="0" :max="scope.row.qty" :precision="4" size="mini" style="width:130px;" :disabled="!scope.row._selected" />-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
</el-table>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button size="mini" @click="closeAllocateDialog">取消</el-button>
|
||||
@@ -88,6 +88,8 @@
|
||||
<el-table-column prop="assignQty" label="已分配数量" width="100" />
|
||||
<el-table-column prop="unit" label="单位" width="80" />
|
||||
<el-table-column prop="targetArea" label="目标库存地点" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="targetHouseCode" label="目标库" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="carrierType" label="托盘类型" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="productionLine" label="产线" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="sn" label="车辆序列号" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="createAt" label="创建时间" min-width="160" show-overflow-tooltip />
|
||||
@@ -118,7 +120,7 @@ export default {
|
||||
components: { pagination, crudOperation, rrOperation, udOperation },
|
||||
mixins: [presenter(), header(), form(createDefaultForm()), crud()],
|
||||
cruds() {
|
||||
return CRUD({ title: '需求单', url: 'api/pmDemand', idField: 'id', sort: 'priority,desc', crudMethod: { ...crudDemand }, optShow: { add: true, reset: true } })
|
||||
return CRUD({ title: '需求单', url: 'api/pmDemand', idField: 'id', sort: 'priority,desc', crudMethod: { ...crudDemand }, optShow: { add: true, reset: true }})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -182,11 +184,12 @@ export default {
|
||||
this.allocateVisible = true
|
||||
this.inventoryLoading = true
|
||||
queryInventory(row.skuCode).then(res => {
|
||||
const demandQty = Number(row.qty) || 0
|
||||
// const demandQty = Number(row.qty) || 0
|
||||
this.inventoryList = (res || []).map(item => ({
|
||||
...item,
|
||||
_selected: false,
|
||||
allocQty: Math.min(Number(item.qty) || 0, demandQty)
|
||||
allocQty: row.qty
|
||||
// Math.min(Number(item.qty) || 0, demandQty)
|
||||
}))
|
||||
if (row.inventoryDis) {
|
||||
try {
|
||||
@@ -215,9 +218,32 @@ export default {
|
||||
this.selectedInventory = []
|
||||
},
|
||||
handleInventorySelection(selection) {
|
||||
this.selectedInventory = selection
|
||||
// 如果选中了多个,只保留最后一个
|
||||
if (selection.length > 1) {
|
||||
const lastSelected = selection[selection.length - 1]
|
||||
this.$refs.allocateTable.clearSelection()
|
||||
this.$refs.allocateTable.toggleRowSelection(lastSelected, true)
|
||||
// 更新选中的数据
|
||||
this.selectedInventory = [lastSelected]
|
||||
this.updateSelectedStatus(lastSelected)
|
||||
} else if (selection.length === 1) {
|
||||
// 单选
|
||||
this.selectedInventory = selection
|
||||
this.updateSelectedStatus(selection[0])
|
||||
} else {
|
||||
// 取消选中
|
||||
this.selectedInventory = []
|
||||
this.inventoryList.forEach(item => {
|
||||
item._selected = false
|
||||
})
|
||||
}
|
||||
},
|
||||
updateSelectedStatus(selectedRow) {
|
||||
this.inventoryList.forEach(item => {
|
||||
item._selected = selection.some(s => s.houseCode === item.houseCode)
|
||||
// 根据唯一标识判断是否选中(使用 houseCode + skuCode 或其他唯一组合)
|
||||
item._selected = selectedRow &&
|
||||
item.houseCode === selectedRow.houseCode &&
|
||||
item.skuCode === selectedRow.skuCode
|
||||
})
|
||||
},
|
||||
saveAllocate() {
|
||||
|
||||
Reference in New Issue
Block a user