Files
scrq-hd/.svn/pristine/82/82c82fa23fbf4f79c65cb5e1a3fe4851b44d6c32.svn-base
2025-07-03 10:34:04 +08:00

537 lines
26 KiB
Plaintext

package com.cmeim.biz.service;
import com.cmeim.basic.api.RemoteCustomerService;
import com.cmeim.basic.api.RemoteMaterialService;
import com.cmeim.basic.api.RemoteSupplierService;
import com.cmeim.basic.api.RemoteSyDictService;
import com.cmeim.basic.api.dto.CustomerDto;
import com.cmeim.basic.api.dto.MaterialDto;
import com.cmeim.basic.api.dto.SupplierDto;
import com.cmeim.basic.api.dto.SyDictDto;
import com.cmeim.basic.api.enums.BaNumberRuleCode;
import com.cmeim.biz.po.MmArriveBill;
import com.cmeim.biz.po.MmArriveBillDetail;
import com.cmeim.biz.po.MmArriveBillDetailTemp;
import com.cmeim.biz.po.MmArriveBillTemp;
import com.cmeim.biz.po.MmBoxBarDetail;
import com.cmeim.biz.po.MmBoxBarDetailLog;
import com.cmeim.biz.repository.MmArriveBillDetailTempRepository;
import com.cmeim.biz.repository.MmArriveBillRepository;
import com.cmeim.biz.repository.MmArriveBillTempRepository;
import com.cmeim.biz.repository.MmBoxBarDetailLogRepository;
import com.cmeim.biz.repository.MmBoxBarDetailRepository;
import com.cmeim.biz.vo.app.ArriveBillDetailTempTransferVo;
import com.cmeim.biz.vo.app.ArriveBillDetailTempVo;
import com.cmeim.biz.vo.app.CreateArriveVo;
import com.cmeim.biz.vo.app.MaterialArr;
import com.cmeim.common.core.domain.R;
import com.cmeim.common.core.exception.ServiceException;
import com.cmeim.common.core.utils.BeanUtil;
import com.cmeim.common.core.utils.DateUtil;
import com.cmeim.common.core.utils.bean.BeanUtils;
import com.cmeim.common.core.web.domain.RespondEnum;
import com.cmeim.common.core.web.domain.TUserInfo;
import com.cmeim.stock.dto.WarehouseDto;
import com.cmeim.stock.po.BaWarehouse;
import com.cmeim.stock.repository.BaWareHouseRepository;
import com.cmeim.system.api.RemoteUserService;
import com.cmeim.system.api.domain.SysDept;
import com.cmeim.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;
@Service
@Transactional(rollbackFor = {ServiceException.class, RuntimeException.class, Exception.class})
public class ArriveBillTempService {
@Autowired
private RemoteMaterialService remoteMaterialService;
@Autowired
private InputRemoteService remoteService;
@Autowired
private BaWareHouseRepository baWareHouseRepository;
@Autowired
private RemoteSupplierService supplierService;
@Autowired
private RemoteCustomerService customerService;
@Autowired
private MmArriveBillTempRepository arriveBillTempRepository;
@Autowired
private MmArriveBillDetailTempRepository arriveBillDetailTempRepository;
@Autowired
private MmArriveBillRepository arriveBillRepository;
@Autowired
private RemoteUserService userService;
@Autowired
private MmBoxBarDetailRepository mmBoxBarDetailRepository;
@Autowired
private RemoteSyDictService remoteSyDictService;
@Autowired
private MmBoxBarDetailLogRepository mmBoxBarDetailLogRepository;
/**
* 判断值是否为null
*
* @param par 判断值
* @return 返回结果
*/
public String null2String(String par) {
if (par == null) {
return "";
}
return par;
}
private String getDictValue(List<SyDictDto> dtoList, String key) {
for (SyDictDto dto : dtoList) {
if (key.equals(dto.getGroupText())) {
return dto.getGroupKey().toString();
}
}
return "";
}
public String getArriveBillNumber(CreateArriveVo vo, TUserInfo userInfo) {
String dictMaterialAttr = vo.getDictMaterialAttr();
String createUser = vo.getCreateUser();
String arriveBillNumber = remoteService.getByCode(BaNumberRuleCode.ARRIVE_BILL);
//todo 插入 发货地点代号
arriveBillNumber = arriveBillNumber.substring(0, arriveBillNumber.indexOf("DHD") + 3)
+ null2String(vo.getAdrress())
+ arriveBillNumber.substring(arriveBillNumber.indexOf("DHD") + 3, arriveBillNumber.length());
SyDictDto syDictDto = new SyDictDto();
syDictDto.setGroupCode("mm_arrive_bill_material_attr");
// 单据类型
List<SyDictDto> materialAttrList = remoteSyDictService.query(syDictDto).getData();
// 新增临时主表信息
MmArriveBillTemp temp = new MmArriveBillTemp();
String warehouseCode = "";
if (dictMaterialAttr != null) {
warehouseCode = getDictValue(materialAttrList,dictMaterialAttr);
}
temp.setArriveBillNumber(arriveBillNumber);
temp.setSalesmanCode(createUser);
temp.setSalesmanName(vo.getNickName());
temp.setCreatedBy(userInfo != null ? userInfo.getUserName() : createUser);
temp.setCreatedDt(DateUtil.getCurrentDate());
temp.setDictStatus(0);
if (!"".equals(warehouseCode)) {
temp.setDictMaterialAttr(Integer.valueOf(warehouseCode));
BaWarehouse baWarehouse = baWareHouseRepository.findByWarehouseCode(warehouseCode);
if (baWarehouse != null) {
WarehouseDto warehouseDto = BeanUtil.copyProperties(baWarehouse, WarehouseDto.class);
temp.setWarehouseId(warehouseDto.getId());
temp.setWarehouseCode(warehouseDto.getWarehouseCode());
temp.setWarehouseName(warehouseDto.getWarehouseName());
}
}
String supplierCode = vo.getSupplierCode() == null ? "0202132" : vo.getSupplierCode();
temp.setSupplierCode(supplierCode);
temp.setSupplierName("重庆海康威视科技有限公司");
try {
SupplierDto supplierDto = new SupplierDto();
supplierDto.setSupplierCode(supplierCode);
R<List<SupplierDto>> query = supplierService.query(supplierDto);
if (query.getCode() == 200 && query.getData() != null && query.getData().size() > 0) {
List<SupplierDto> dtoList = query.getData();
for (SupplierDto dto : dtoList) {
if (supplierCode.equals(dto.getSupplierCode())) {
temp.setSupplierId(dto.getId());
temp.setSupplierName(dto.getSupplierName());
break;
}
}
}
if ("0202132".equals(supplierCode)) {
CustomerDto customerDto = new CustomerDto();
customerDto.setCustomerCode("020239");
R<List<CustomerDto>> querys = customerService.query(customerDto);
if (query.getCode() == 200 && query.getData() != null && query.getData().size() > 0) {
List<CustomerDto> dtoList = querys.getData();
for (CustomerDto dto : dtoList) {
if (customerDto.getCustomerCode().equals(dto.getCustomerCode())) {
temp.setCustomerCode(dto.getCustomerCode());
temp.setCustomerName(dto.getCustomerName());
break;
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
arriveBillTempRepository.save(temp);
return arriveBillNumber;
}
/**
* 根据 批次,到货单,物料编码, 合并物料条码数据
*
* @param vo 到货单合并数据
* @param userInfo 用户信息
*/
@Transactional
public void addArriveDetailTemp(ArriveBillDetailTempVo vo, TUserInfo userInfo) {
//判断物料条码是否已经被收货
MmBoxBarDetail boxBarDetailOld =
mmBoxBarDetailRepository.findByMaterialBarAndArriveBillNumber(vo.getMaterialBar(),
vo.getArriveBillNumber());
if (boxBarDetailOld != null) {
throw new ServiceException(RespondEnum.FAILURE,
"物料条码【" + vo.getMaterialBar() + "】已经创建到货单【" + boxBarDetailOld.getArriveBillNumber() + "】");
}
MmBoxBarDetail mmBoxBarDetail = new MmBoxBarDetail();
mmBoxBarDetail.setMaterialBar(vo.getMaterialBar());
mmBoxBarDetail.setBatchNo(vo.getBatchNo());
mmBoxBarDetail.setArriveBillNumber(vo.getArriveBillNumber());
mmBoxBarDetail.setCreatedBy(userInfo.getUserName());
mmBoxBarDetail.setCreatedDt(DateUtil.getCurrentDate());
mmBoxBarDetail.setPlanQty(vo.getPlanQty());
// 查询到货单临时表
MmArriveBillTemp arriveTemp = arriveBillTempRepository.findByArriveBillNumber(vo.getArriveBillNumber());
if (arriveTemp == null) throw new ServiceException(RespondEnum.FAILURE, "相关到货单不存在");
if (arriveTemp.getDictStatus() == 1) throw new ServiceException(RespondEnum.FAILURE, "该到货单已被提交,不能添加物料");
// 查询是否存在该物料的明细记录
MmArriveBillDetailTemp detailTemp = arriveBillDetailTempRepository
.findByArriveBillNumberAndMaterialCode(vo.getArriveBillNumber(), vo.getMaterialCode());
if (detailTemp == null) {
detailTemp = new MmArriveBillDetailTemp();
detailTemp.setArriveBillId(arriveTemp.getId());
detailTemp.setArriveBillNumber(arriveTemp.getArriveBillNumber());
detailTemp.setMaterialCode(vo.getMaterialCode());
detailTemp.setPlanQty(vo.getPlanQty());
detailTemp.setDictStatus(0);
if (userInfo != null) {
detailTemp.setCreatedBy(userInfo.getUserName());
detailTemp.setCreatedDt(DateUtil.getCurrentDate());
}
// 填充物料信息
R<MaterialDto> quertMaterial = remoteMaterialService.findByMaterialCode(vo.getMaterialCode());
if (quertMaterial.getCode() == 200 && quertMaterial.getData() != null) {
MaterialDto materialDto = quertMaterial.getData();
detailTemp.setMaterialId(materialDto.getId());
detailTemp.setMaterialName(materialDto.getMaterialName());
detailTemp.setMaterialSpec(materialDto.getMaterialSpec());
detailTemp.setUnitOfMeasure(materialDto.getUnitOfMeasure());
detailTemp.setMaterialCode(materialDto.getMaterialCode());
}
} else {
detailTemp.setPlanQty(detailTemp.getPlanQty().add(vo.getPlanQty()));
if (userInfo != null) {
detailTemp.setUpdatedBy(userInfo.getUserName());
detailTemp.setUpdatedDt(DateUtil.getCurrentDate());
}
}
MmArriveBillDetailTemp s = arriveBillDetailTempRepository.save(detailTemp);
//todo 新加一个箱条码明细表(mm_box_bar_detail 这个表的数据就是没合并的)
mmBoxBarDetail.setMaterialId(detailTemp.getMaterialId());
mmBoxBarDetail.setMaterialName(detailTemp.getMaterialName());
mmBoxBarDetail.setMaterialSpec(detailTemp.getMaterialSpec());
mmBoxBarDetail.setUnitOfMeasure(detailTemp.getUnitOfMeasure());
mmBoxBarDetail.setMaterialCode(detailTemp.getMaterialCode());
mmBoxBarDetail.setMmArriveBillTempId(s.getId());
mmBoxBarDetailRepository.save(mmBoxBarDetail);
}
/*
* @Author 谷宬膊
* @Description //TODO 修改到货单明细 删除明细 修改到货单temp
* @Date 14:59 2022/4/27
* @Param
* @return
**/
@Transactional
public void updateArriveDetailTemp(MmBoxBarDetail mmBoxBarDetail, TUserInfo userInfo, String doType) {
//修改 加 减数量
MmBoxBarDetail boxBarDetail =
mmBoxBarDetailRepository.findByMaterialBarAndArriveBillNumber(mmBoxBarDetail.getMaterialBar(),
mmBoxBarDetail.getArriveBillNumber());
if (boxBarDetail == null) {
throw new ServiceException(RespondEnum.FAILURE, "物料条码不存在【" + mmBoxBarDetail.getMaterialBar() + "】");
}
MmArriveBillDetailTemp detailTemp = new MmArriveBillDetailTemp();
Optional<MmArriveBillDetailTemp> byId = arriveBillDetailTempRepository.findById(boxBarDetail.getMmArriveBillTempId());
if (byId.isPresent()) {
detailTemp = byId.get();
}
if ("update".equals(doType)) {
//确实是修改了批次
//todo 记录修改日志
MmBoxBarDetailLog mmBoxBarDetailLog = new MmBoxBarDetailLog();
BeanUtils.copyProperties(boxBarDetail, mmBoxBarDetailLog);
mmBoxBarDetailLog.setNewPlanQty(mmBoxBarDetail.getPlanQty());
mmBoxBarDetailLog.setId(null);
mmBoxBarDetailLogRepository.save(mmBoxBarDetailLog);
if (!boxBarDetail.getBatchNo().equals(mmBoxBarDetail.getBatchNo())) {
// todo
MmArriveBillDetailTemp detailTemp2 =
arriveBillDetailTempRepository.findByArriveBillNumberAndMaterialCode(
mmBoxBarDetail.getArriveBillNumber(),
mmBoxBarDetail.getMaterialCode()
);
//todo 不存在这个批次 新建一个批次 拆分旧的到货明细零时表这个数据
if (detailTemp2 == null) {
//新建一个批次
detailTemp2 = new MmArriveBillDetailTemp();
detailTemp2.setArriveBillId(detailTemp.getArriveBillId());
detailTemp2.setArriveBillNumber(detailTemp.getArriveBillNumber());
detailTemp2.setMaterialCode(detailTemp.getMaterialCode());
detailTemp2.setPlanQty(mmBoxBarDetail.getPlanQty());
detailTemp2.setDictStatus(0);
if (userInfo != null) {
detailTemp2.setCreatedBy(userInfo.getUserName());
detailTemp2.setCreatedDt(DateUtil.getCurrentDate());
}
// 填充物料信息
detailTemp2.setMaterialId(detailTemp.getMaterialId());
detailTemp2.setMaterialName(detailTemp.getMaterialName());
detailTemp2.setMaterialSpec(detailTemp.getMaterialSpec());
detailTemp2.setUnitOfMeasure(detailTemp.getUnitOfMeasure());
detailTemp2.setMaterialCode(detailTemp.getMaterialCode());
MmArriveBillDetailTemp s = arriveBillDetailTempRepository.save(detailTemp2);
//todo 拆分旧的到货明细零时表这个数据
//判断是否是 最后一条明细 若是则删除 不是就更新数量
List<MmBoxBarDetail> mmBoxBarDetails =
mmBoxBarDetailRepository.findAllByMmArriveBillTempId(boxBarDetail.getMmArriveBillTempId());
if (mmBoxBarDetails.size() > 1) {
//对旧的批次进行数量赋值
detailTemp.setPlanQty(detailTemp.getPlanQty().subtract(boxBarDetail.getPlanQty()));
if (userInfo != null) {
detailTemp.setUpdatedDt(DateUtil.getCurrentDate());
detailTemp.setUpdatedBy(userInfo.getUserName());
}
arriveBillDetailTempRepository.save(detailTemp);
} else {
arriveBillDetailTempRepository.deleteById(detailTemp.getId());
}
//更新外键
boxBarDetail.setMmArriveBillTempId(s.getId());
} else {
//todo 修改了为一个已经存在的的批次 合并
//加新批次的数量
detailTemp2.setPlanQty(detailTemp2.getPlanQty().add(mmBoxBarDetail.getPlanQty()));
detailTemp2.setUpdatedBy(userInfo.getUserName());
detailTemp2.setUpdatedDt(DateUtil.getCurrentDate());
//修改原批次数据
detailTemp.setPlanQty(detailTemp2.getPlanQty().subtract(boxBarDetail.getPlanQty()));
detailTemp.setUpdatedBy(userInfo.getUserName());
detailTemp.setUpdatedDt(DateUtil.getCurrentDate());
MmArriveBillDetailTemp s = arriveBillDetailTempRepository.save(detailTemp);
//更新外键
boxBarDetail.setMmArriveBillTempId(s.getId());
arriveBillDetailTempRepository.save(detailTemp2);
}
} else {
//计算 差值 变化量
BigDecimal variation = boxBarDetail.getPlanQty().subtract(mmBoxBarDetail.getPlanQty());
//修改待提交 表数据
detailTemp.setPlanQty(detailTemp.getPlanQty().subtract(variation));
arriveBillDetailTempRepository.save(detailTemp);
}
//保存箱条码明细数据
boxBarDetail.setBatchNo(mmBoxBarDetail.getBatchNo());
boxBarDetail.setPlanQty(mmBoxBarDetail.getPlanQty());
if (userInfo != null) {
detailTemp.setUpdatedBy(userInfo.getUserName());
}
detailTemp.setUpdatedDt(DateUtil.getCurrentDate());
mmBoxBarDetailRepository.save(boxBarDetail);
}
//删除
if ("delete".equals(doType)) {
//减去明细数量
mmBoxBarDetailRepository.delete(boxBarDetail);
/*if(boxBarDetail.getPlanQty().equals(detailTemp.getPlanQty())){
mmBoxBarDetailRepository.delete(boxBarDetail);
}else{
boxBarDetail.setPlanQty(detailTemp.getPlanQty().subtract(boxBarDetail.getPlanQty()));
mmBoxBarDetailRepository.save(boxBarDetail);
}*/
//判断是否是最后一个明细
//判断是否是 最后一条明细 若是则删除 不是就更新数量
List<MmBoxBarDetail> mmBoxBarDetails =
mmBoxBarDetailRepository.findAllByMmArriveBillTempId(boxBarDetail.getMmArriveBillTempId());
if (mmBoxBarDetails.size() > 0) {
//对旧的批次进行数量赋值
detailTemp.setPlanQty(detailTemp.getPlanQty().subtract(boxBarDetail.getPlanQty()));
detailTemp.setUpdatedDt(DateUtil.getCurrentDate());
if (userInfo != null) {
detailTemp.setUpdatedBy(userInfo.getUserName());
}
arriveBillDetailTempRepository.save(detailTemp);
} else {
arriveBillDetailTempRepository.deleteById(detailTemp.getId());
}
}
}
public void updateArriveBillTempStatus(String arriveBillNumber, String createUser) {
R<LoginUser> userInfo = userService.getUserInfo(createUser);
LoginUser loginUser = userInfo.getData();
String nickName = null == loginUser ? "" : loginUser.getSysUser().getNickName();
final String currentDt = DateUtil.getCurrentDate();
MmArriveBillTemp arriveBillTemp = arriveBillTempRepository.findByArriveBillNumber(arriveBillNumber);
if (arriveBillTemp == null) throw new ServiceException(RespondEnum.FAILURE, "该到货单据不存在");
if (arriveBillTemp.getDictStatus() == 1) throw new ServiceException(RespondEnum.FAILURE, "该单据已提交");
if (arriveBillTemp.getItems().size() == 0) throw new ServiceException(RespondEnum.FAILURE, "该单据没有明细记录,不允许修改状态");
MmArriveBill mmArriveBill = BeanUtil.copyProperties(arriveBillTemp, MmArriveBill.class);
List<MmArriveBillDetail> items = BeanUtil.copyProperties(arriveBillTemp.getItems(), MmArriveBillDetail.class);
items.forEach(item -> {
item.setId(null);
item.setArriveBillId(null);
item.setDictStatus(5);
item.setIsInspect(0);
item.setRealQty(BigDecimal.ZERO);
item.setInspectQty(BigDecimal.ZERO);
item.setInputQty(BigDecimal.ZERO);
item.setRejectionQty(BigDecimal.ZERO);
item.setCreater(nickName);
});
mmArriveBill.setId(null);
mmArriveBill.setCurrency("人名币");
mmArriveBill.setExchangeRate(BigDecimal.ONE);
mmArriveBill.setTaxRate(new BigDecimal(13));
mmArriveBill.setIsInInspecting(0);
mmArriveBill.setDictStatus(5);
mmArriveBill.setIsThereLead(0);
mmArriveBill.setIsInspect(0);
mmArriveBill.setDictServiceType(1);
mmArriveBill.setDictPurchaseType(1);
mmArriveBill.setCreatedBy(createUser);
mmArriveBill.setCreatedDt(currentDt);
mmArriveBill.setCreater(nickName);
mmArriveBill.setItems(items);
if (null != loginUser) {
SysDept dept = loginUser.getSysUser().getDept();
mmArriveBill.setDepartmentId(dept.getDeptId());
mmArriveBill.setDepartmentCode(dept.getPhone());
mmArriveBill.setDepartmentName(dept.getDeptName());
}
arriveBillRepository.save(mmArriveBill);
arriveBillTemp.setUpdatedBy(createUser);
arriveBillTemp.setUpdatedDt(currentDt);
arriveBillTemp.setDictStatus(1);
arriveBillTempRepository.save(arriveBillTemp);
}
/**
* 转移物料
*
* @param vo 到货单转移信息
* @param userInfo 用户信息
*/
@Transactional
public void transferMaterial(ArriveBillDetailTempTransferVo vo, TUserInfo userInfo) {
List<MaterialArr> materialArr = vo.getMaterialArr();
String arriveBillNumber = vo.getArriveBillNumber();
String newArriveBillNumber = vo.getNewArriveBillNumber();
materialArr.forEach(material -> {
MmArriveBillTemp arriveBillTemp = arriveBillTempRepository.findByArriveBillNumber(arriveBillNumber);
if (arriveBillTemp == null) throw new ServiceException(RespondEnum.FAILURE, "转移单据不存在");
if (arriveBillTemp.getDictStatus() == 1) throw new ServiceException(RespondEnum.FAILURE, "修改失败,转移单据已提交");
MmArriveBillTemp transferArriveBillTemp =
arriveBillTempRepository.findByArriveBillNumber(newArriveBillNumber);
if (transferArriveBillTemp == null) throw new ServiceException(RespondEnum.FAILURE, "被转移单据不存在");
if (transferArriveBillTemp.getDictStatus() == 1) {
throw new ServiceException(RespondEnum.FAILURE, "修改失败,被转移单据已提交");
}
MmBoxBarDetail mmBoxBarDetail =
mmBoxBarDetailRepository.findByMaterialBarAndArriveBillNumber(material.getMaterialBar(),
arriveBillNumber);
if (mmBoxBarDetail == null) throw new ServiceException(RespondEnum.FAILURE, "修改失败,转移单据中不存在该物料明细");
if (mmBoxBarDetail.getPlanQty().compareTo(material.getPlanQty()) < 0) {
throw new ServiceException(RespondEnum.FAILURE, "修改失败,转移单据数量小于转移数量");
}
//转移的
MmArriveBillDetailTemp arriveBillDetailTemp =
arriveBillDetailTempRepository.findById(mmBoxBarDetail.getMmArriveBillTempId()).get();
//转移到---》
MmArriveBillDetailTemp transferArriveBillDetailTemp =
arriveBillDetailTempRepository.findByArriveBillNumberAndMaterialCode(newArriveBillNumber,
material.getMaterialCode());
if (transferArriveBillDetailTemp == null) {
//直接将这个数据
transferArriveBillDetailTemp = new MmArriveBillDetailTemp();
BeanUtils.copyProperties(arriveBillDetailTemp, transferArriveBillDetailTemp);
transferArriveBillDetailTemp.setId(null);
transferArriveBillDetailTemp.setArriveBillId(transferArriveBillTemp.getId());
transferArriveBillDetailTemp.setArriveBillNumber(transferArriveBillTemp.getArriveBillNumber());
transferArriveBillDetailTemp.setPlanQty(mmBoxBarDetail.getPlanQty());
if (userInfo != null) {
transferArriveBillDetailTemp.setCreatedBy(userInfo.getUserName());
} else {
transferArriveBillDetailTemp.setCreatedBy(arriveBillDetailTemp.getCreatedBy());
}
transferArriveBillDetailTemp.setCreatedDt(DateUtil.getCurrentDate());
} else {
transferArriveBillDetailTemp.setPlanQty(transferArriveBillDetailTemp.getPlanQty().add(material.getPlanQty()));
transferArriveBillDetailTemp.setUpdatedBy(userInfo != null ? userInfo.getUserName() :
arriveBillDetailTemp.getCreatedBy());
transferArriveBillDetailTemp.setUpdatedDt(DateUtil.getCurrentDate());
}
//修改就明细数据
//判断是否是最后一个明细
//判断是否是 最后一条明细 若是则删除 不是就更新数量
List<MmBoxBarDetail> mmBoxBarDetails =
mmBoxBarDetailRepository.findAllByMmArriveBillTempId(mmBoxBarDetail.getMmArriveBillTempId());
if (mmBoxBarDetails.size() > 1) {
//对旧的批次进行数量赋值
arriveBillDetailTemp.setPlanQty(arriveBillDetailTemp.getPlanQty().subtract(mmBoxBarDetail.getPlanQty()));
arriveBillDetailTemp.setUpdatedDt(DateUtil.getCurrentDate());
arriveBillDetailTemp.setUpdatedBy(userInfo.getUserName());
arriveBillDetailTempRepository.save(arriveBillDetailTemp);
} else {
arriveBillDetailTempRepository.deleteById(arriveBillDetailTemp.getId());
}
MmArriveBillDetailTemp s = arriveBillDetailTempRepository.save(transferArriveBillDetailTemp);
//修改明细表外键
mmBoxBarDetail.setArriveBillNumber(newArriveBillNumber);
mmBoxBarDetail.setMmArriveBillTempId(s.getId());
mmBoxBarDetailRepository.save(mmBoxBarDetail);
});
}
}