|
|
@@ -23,6 +23,8 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.client.entity.Message;
|
|
|
+import org.springblade.client.feign.IMessageClient;
|
|
|
import org.springblade.common.enums.CommonEnum;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
@@ -76,6 +78,8 @@ import org.springblade.los.trade.mapper.DispatchVehiclesMapper;
|
|
|
import org.springblade.los.trade.mapper.InOutStorageMapper;
|
|
|
import org.springblade.system.entity.Dept;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
+import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
@@ -159,6 +163,10 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
|
|
|
private final ISeaContainerNumberItemService seaContainerNumberItemService;
|
|
|
|
|
|
+ private final IMessageClient messageClient;
|
|
|
+
|
|
|
+ private final IUserClient userClient;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<BillsVO> selectBillsPage(IPage<BillsVO> page, BillsVO bills) {
|
|
|
return page.setRecords(baseMapper.selectBillsPage(page, bills));
|
|
|
@@ -188,12 +196,9 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
.eq(Bills::getCreateDept, branchId)
|
|
|
.eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(Bills::getIsDeleted, 0)
|
|
|
- .eq(Bills::getMblno, bills.getMblno()));
|
|
|
- if ("SE".equals(bills.getBusinessType())) {
|
|
|
- bills.setBillDate(bills.getEtd());
|
|
|
- } else {
|
|
|
- bills.setBillDate(bills.getEta());
|
|
|
- }
|
|
|
+ .eq(Bills::getMblno, bills.getMblno())
|
|
|
+ .eq(Bills::getBusinessType, bills.getBusinessType())
|
|
|
+ );
|
|
|
if (ObjectUtils.isNotNull(bills.getVesselCnName())) {
|
|
|
BVessels vessels = vesselsMapper.selectOne(new LambdaQueryWrapper<BVessels>()
|
|
|
.eq(BVessels::getTenantId, AuthUtil.getTenantId())
|
|
|
@@ -304,7 +309,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
}
|
|
|
// 每更新一次往上累加一次版本
|
|
|
// 旧数据处理
|
|
|
- int version = StringUtil.isBlank(dataSourceBill.getVersion()) ? 1 :Integer.parseInt(dataSourceBill.getVersion());
|
|
|
+ int version = StringUtil.isBlank(dataSourceBill.getVersion()) ? 1 : Integer.parseInt(dataSourceBill.getVersion());
|
|
|
bills.setVersion(String.valueOf(version + 1));
|
|
|
List<Long> ids = count.stream().map(Bills::getId).distinct().collect(Collectors.toList());
|
|
|
if (!"MH".equals(bills.getBillType())) {
|
|
|
@@ -317,158 +322,8 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
bills.setUpdateUser(AuthUtil.getUserId());
|
|
|
bills.setUpdateTime(new Date());
|
|
|
bills.setUpdateUserName(AuthUtil.getUserName());
|
|
|
-
|
|
|
//主单信息同步分单
|
|
|
- if ("MM".equals(bills.getBillType())) {
|
|
|
- Bills details = baseMapper.selectOne(new LambdaQueryWrapper<Bills>()
|
|
|
- .select(Bills::getId, Bills::getVesselId, Bills::getVoyageNo, Bills::getEtd, Bills::getEta)
|
|
|
- .eq(Bills::getId, bills.getId()));
|
|
|
- boolean status = false;
|
|
|
- if ("SE".equals(bills.getBillType())) {
|
|
|
- if (!details.getEtd().equals(bills.getEtd())) {
|
|
|
- status = true;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!details.getEta().equals(bills.getEta())) {
|
|
|
- status = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!details.getVesselId().equals(bills.getVesselId()) || !details.getVoyageNo().equals(bills.getVoyageNo()) || status) {
|
|
|
- List<Bills> billsList = baseMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
- .select(Bills::getId, Bills::getEtd, Bills::getVesselId, Bills::getVesselCnName, Bills::getVesselEnName, Bills::getVoyageNo, Bills::getPolId
|
|
|
- , Bills::getPolCnName, Bills::getPolEnName, Bills::getPolCode, Bills::getPolNamePrint, Bills::getPodId, Bills::getPodCnName
|
|
|
- , Bills::getPodEnName, Bills::getPodNamePrint, Bills::getPodCode, Bills::getPlaceReceiptId, Bills::getPlaceReceiptCode, Bills::getPlaceReceiptName
|
|
|
- , Bills::getPlaceReceiptNamePrint, Bills::getPlaceDeliveryId, Bills::getPlaceDeliveryCode, Bills::getPlaceDeliveryName, Bills::getPlaceDeliveryNamePrint, Bills::getDestinationId
|
|
|
- , Bills::getDestinationName, Bills::getDestinationCode, Bills::getDestinationNamePrint, Bills::getFinalDestinationId, Bills::getFinalDestinationCode, Bills::getFinalDestinationName
|
|
|
- , Bills::getFinalDestinationNamePrint, Bills::getCyId, Bills::getCyCode, Bills::getCyCnName, Bills::getCyEnName, Bills::getCyAddress
|
|
|
- , Bills::getCyTel, Bills::getCyRemarks, Bills::getCyTrailerTime, Bills::getCyReturnTime, Bills::getCarrierId, Bills::getCarrierCnName
|
|
|
- , Bills::getCarrierEnName, Bills::getCarrierArgreementNo, Bills::getBookingDate)
|
|
|
- .eq(Bills::getCreateDept, branchId)
|
|
|
- .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(Bills::getIsDeleted, 0)
|
|
|
- .eq(Bills::getMblno, bills.getMblno()));
|
|
|
- if (!billsList.isEmpty()) {
|
|
|
- for (Bills item : billsList) {
|
|
|
- item.setEtd(bills.getEtd());
|
|
|
- item.setVesselId(bills.getVesselId());
|
|
|
- item.setVesselCnName(bills.getVesselCnName());
|
|
|
- item.setVesselEnName(bills.getVesselEnName());
|
|
|
- item.setVoyageNo(bills.getVoyageNo());
|
|
|
- item.setPolId(bills.getPolId());
|
|
|
- item.setPolCnName(bills.getPolCnName());
|
|
|
- item.setPolEnName(bills.getPolEnName());
|
|
|
- item.setPolCode(bills.getPolCode());
|
|
|
- item.setPolNamePrint(bills.getPolNamePrint());
|
|
|
- item.setPodId(bills.getPodId());
|
|
|
- item.setPodCnName(bills.getPodCnName());
|
|
|
- item.setPodEnName(bills.getPodEnName());
|
|
|
- item.setPodNamePrint(bills.getPodNamePrint());
|
|
|
- item.setPodCode(bills.getPodCode());
|
|
|
- item.setPlaceReceiptId(bills.getPlaceReceiptId());
|
|
|
- item.setPlaceReceiptCode(bills.getPlaceReceiptCode());
|
|
|
- item.setPlaceReceiptName(bills.getPlaceReceiptName());
|
|
|
- item.setPlaceReceiptNamePrint(bills.getPlaceReceiptNamePrint());
|
|
|
- item.setPlaceDeliveryId(bills.getPlaceDeliveryId());
|
|
|
- item.setPlaceDeliveryCode(bills.getPlaceDeliveryCode());
|
|
|
- item.setPlaceDeliveryName(bills.getPlaceDeliveryName());
|
|
|
- item.setPlaceDeliveryNamePrint(bills.getPlaceDeliveryNamePrint());
|
|
|
- item.setDestinationId(bills.getDestinationId());
|
|
|
- item.setDestinationName(bills.getDestinationName());
|
|
|
- item.setDestinationCode(bills.getDestinationCode());
|
|
|
- item.setDestinationNamePrint(bills.getDestinationNamePrint());
|
|
|
- item.setFinalDestinationId(bills.getFinalDestinationId());
|
|
|
- item.setFinalDestinationCode(bills.getFinalDestinationCode());
|
|
|
- item.setFinalDestinationName(bills.getFinalDestinationName());
|
|
|
- item.setFinalDestinationNamePrint(bills.getFinalDestinationNamePrint());
|
|
|
- item.setCyId(bills.getCyId());
|
|
|
- item.setCyCode(bills.getCyCode());
|
|
|
- item.setCyCnName(bills.getCyCnName());
|
|
|
- item.setCyEnName(bills.getCyEnName());
|
|
|
- item.setCyAddress(bills.getCyAddress());
|
|
|
- item.setCyTel(bills.getCyTel());
|
|
|
- item.setCyRemarks(bills.getCyRemarks());
|
|
|
- item.setCyTrailerTime(bills.getCyTrailerTime());
|
|
|
- item.setCyReturnTime(bills.getCyReturnTime());
|
|
|
- item.setCarrierId(bills.getCarrierId());
|
|
|
- item.setCarrierCnName(bills.getCarrierCnName());
|
|
|
- item.setCarrierEnName(bills.getCarrierEnName());
|
|
|
- item.setCarrierArgreementNo(bills.getCarrierArgreementNo());
|
|
|
- item.setBookingDate(bills.getBookingDate());
|
|
|
- }
|
|
|
- if (!billsList.isEmpty()) {
|
|
|
- this.updateBatchById(billsList);
|
|
|
- }
|
|
|
- List<Long> billIds = billsList.stream().map(Bills::getId).collect(Collectors.toList());
|
|
|
- List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
- .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(FeeCenter::getIsDeleted, 0)
|
|
|
- .eq(FeeCenter::getPid, billIds));
|
|
|
- for (FeeCenter item : feeCenterList) {
|
|
|
- item.setVesselId(bills.getVesselId());
|
|
|
- item.setVesselCnName(bills.getVesselCnName());
|
|
|
- item.setVesselEnName(bills.getVesselEnName());
|
|
|
- item.setVoyageNo(bills.getVoyageNo());
|
|
|
- item.setPolId(bills.getPolId());
|
|
|
- item.setPolCnName(bills.getPolCnName());
|
|
|
- item.setPolEnName(bills.getPolEnName());
|
|
|
- item.setPolCode(bills.getPolCode());
|
|
|
- item.setPodId(bills.getPodId());
|
|
|
- item.setPodCnName(bills.getPodCnName());
|
|
|
- item.setPodEnName(bills.getPodEnName());
|
|
|
- item.setPodCode(bills.getPodCode());
|
|
|
- }
|
|
|
- feeCenterService.updateBatchById(feeCenterList);
|
|
|
- List<FinAccBills> finAccBillsList = finAccBillsService.list(new LambdaQueryWrapper<FinAccBills>()
|
|
|
- .eq(FinAccBills::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(FinAccBills::getIsDeleted, 0)
|
|
|
- .eq(FinAccBills::getBusinessBillDivideId, billIds));
|
|
|
- for (FinAccBills item : finAccBillsList) {
|
|
|
- item.setVesselId(bills.getVesselId());
|
|
|
- item.setVesselCnName(bills.getVesselCnName());
|
|
|
- item.setVesselEnName(bills.getVesselEnName());
|
|
|
- item.setVoyageNo(bills.getVoyageNo());
|
|
|
- item.setPolId(bills.getPolId());
|
|
|
- item.setPolCnName(bills.getPolCnName());
|
|
|
- item.setPolEnName(bills.getPolEnName());
|
|
|
- item.setPolCode(bills.getPolCode());
|
|
|
- item.setPodId(bills.getPodId());
|
|
|
- item.setPodCnName(bills.getPodCnName());
|
|
|
- item.setPodEnName(bills.getPodEnName());
|
|
|
- item.setPodCode(bills.getPodCode());
|
|
|
- }
|
|
|
- finAccBillsService.updateBatchById(finAccBillsList);
|
|
|
- for (Bills item : billsList) {
|
|
|
- item.setVesselId(bills.getVesselId());
|
|
|
- item.setVesselCnName(bills.getVesselCnName());
|
|
|
- item.setVesselEnName(bills.getVesselEnName());
|
|
|
- item.setVoyageNo(bills.getVoyageNo());
|
|
|
- item.setPolId(bills.getPolId());
|
|
|
- item.setPolCnName(bills.getPolCnName());
|
|
|
- item.setPolEnName(bills.getPolEnName());
|
|
|
- item.setPolCode(bills.getPolCode());
|
|
|
- item.setPodId(bills.getPodId());
|
|
|
- item.setPodCnName(bills.getPodCnName());
|
|
|
- item.setPodEnName(bills.getPodEnName());
|
|
|
- item.setPodCode(bills.getPodCode());
|
|
|
- item.setCyId(bills.getCyId());
|
|
|
- item.setCyCode(bills.getCyCode());
|
|
|
- item.setCyCnName(bills.getCyCnName());
|
|
|
- item.setCyEnName(bills.getCyEnName());
|
|
|
- item.setCyAddress(bills.getCyAddress());
|
|
|
- item.setCyTel(bills.getCyTel());
|
|
|
- item.setCyRemarks(bills.getCyRemarks());
|
|
|
- item.setCyTrailerTime(bills.getCyTrailerTime());
|
|
|
- item.setCyReturnTime(bills.getCyReturnTime());
|
|
|
- item.setCarrierId(bills.getCarrierId());
|
|
|
- item.setCarrierCnName(bills.getCarrierCnName());
|
|
|
- item.setCarrierEnName(bills.getCarrierEnName());
|
|
|
- item.setCarrierArgreementNo(bills.getCarrierArgreementNo());
|
|
|
- item.setBookingDate(bills.getBookingDate());
|
|
|
- }
|
|
|
- this.updateBatchById(billsList);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ this.synchronous(bills);
|
|
|
}
|
|
|
Integer V20 = 0;
|
|
|
Integer V40 = 0;
|
|
|
@@ -560,7 +415,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
.distinct().filter(Objects::nonNull).collect(Collectors.joining(",")));
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
bills.setQuantityCntrDescr(null);
|
|
|
}
|
|
|
bills.setQuantityV20(V20);
|
|
|
@@ -934,6 +789,141 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
return R.data(bills);
|
|
|
}
|
|
|
|
|
|
+ private void synchronous(Bills bills) {
|
|
|
+ if ("MM".equals(bills.getBillType())) {
|
|
|
+ Bills details = baseMapper.selectById(bills.getId());
|
|
|
+ boolean statusEtd = false;
|
|
|
+ boolean statusEta = false;
|
|
|
+ boolean statusAtd = false;
|
|
|
+ boolean statusAta = false;
|
|
|
+ if ("SE".equals(bills.getBillType())) {
|
|
|
+ if (!details.getEtd().equals(bills.getEtd())) {
|
|
|
+ statusEtd = true;
|
|
|
+ }
|
|
|
+ if (!details.getActualEtd().equals(bills.getActualEtd())) {
|
|
|
+ statusAtd = true;
|
|
|
+ }
|
|
|
+ } else if ("SI".equals(bills.getBillType())) {
|
|
|
+ if (!details.getEta().equals(bills.getEta())) {
|
|
|
+ statusEta = true;
|
|
|
+ }
|
|
|
+ if (!details.getActualEta().equals(bills.getActualEta())) {
|
|
|
+ statusAta = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean statusVessel = !details.getVesselId().equals(bills.getVesselId());
|
|
|
+ boolean statusVoyageNo = !details.getVoyageNo().equals(bills.getVoyageNo());
|
|
|
+ boolean statusMblno = !details.getMblno().equals(bills.getMblno());
|
|
|
+ boolean statusPolId = !details.getPolId().equals(bills.getPolId());
|
|
|
+ boolean statusPodId = !details.getPodId().equals(bills.getPodId());
|
|
|
+ boolean statusCyTrailerTime = !details.getCyTrailerTime().equals(bills.getCyTrailerTime());
|
|
|
+ boolean statusCyReturnTime = !details.getCyReturnTime().equals(bills.getCyReturnTime());
|
|
|
+ boolean statusLineId = !details.getLineId().equals(bills.getLineId());
|
|
|
+ boolean statusForwarding = !details.getForwarding().equals(bills.getForwarding());
|
|
|
+ boolean statusBookingAgentId = !details.getBookingAgentId().equals(bills.getBookingAgentId());
|
|
|
+ if (statusEtd || statusEta || statusAtd || statusAta || statusVessel || statusVoyageNo || statusMblno || statusPolId
|
|
|
+ || statusPodId || statusCyTrailerTime || statusCyReturnTime || statusLineId || statusForwarding || statusBookingAgentId) {
|
|
|
+ List<Bills> billsList = baseMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .eq(Bills::getMasterId, details.getId()));
|
|
|
+ if (!billsList.isEmpty()) {
|
|
|
+ for (Bills item : billsList) {
|
|
|
+ item.setEtd(bills.getEtd());
|
|
|
+ item.setEta(bills.getEta());
|
|
|
+ item.setActualEta(bills.getActualEta());
|
|
|
+ item.setActualEtd(bills.getActualEtd());
|
|
|
+ item.setVesselId(bills.getVesselId());
|
|
|
+ item.setVesselCnName(bills.getVesselCnName());
|
|
|
+ item.setVesselEnName(bills.getVesselEnName());
|
|
|
+ item.setVoyageNo(bills.getVoyageNo());
|
|
|
+ item.setPolId(bills.getPolId());
|
|
|
+ item.setPolCnName(bills.getPolCnName());
|
|
|
+ item.setPolEnName(bills.getPolEnName());
|
|
|
+ item.setPolCode(bills.getPolCode());
|
|
|
+ item.setPolNamePrint(bills.getPolNamePrint());
|
|
|
+ item.setPodId(bills.getPodId());
|
|
|
+ item.setPodCnName(bills.getPodCnName());
|
|
|
+ item.setPodEnName(bills.getPodEnName());
|
|
|
+ item.setPodNamePrint(bills.getPodNamePrint());
|
|
|
+ item.setPodCode(bills.getPodCode());
|
|
|
+ item.setMblno(bills.getMblno());
|
|
|
+ item.setCyTrailerTime(bills.getCyTrailerTime());
|
|
|
+ item.setCyReturnTime(bills.getCyReturnTime());
|
|
|
+ item.setLineId(bills.getLineId());
|
|
|
+ item.setLineCnName(bills.getLineCnName());
|
|
|
+ item.setLineEnName(bills.getLineEnName());
|
|
|
+ item.setForwarding(bills.getForwarding());
|
|
|
+ item.setBookingAgentId(bills.getBookingAgentId());
|
|
|
+ item.setBookingAgentCnName(bills.getBookingAgentCnName());
|
|
|
+ item.setBookingAgentEnName(bills.getBookingAgentEnName());
|
|
|
+ }
|
|
|
+ if (!billsList.isEmpty()) {
|
|
|
+ this.updateBatchById(billsList);
|
|
|
+ }
|
|
|
+ List<Long> billIds = billsList.stream().map(Bills::getId).collect(Collectors.toList());
|
|
|
+ List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .eq(FeeCenter::getPid, billIds));
|
|
|
+ for (FeeCenter item : feeCenterList) {
|
|
|
+ item.setVesselId(bills.getVesselId());
|
|
|
+ item.setVesselCnName(bills.getVesselCnName());
|
|
|
+ item.setVesselEnName(bills.getVesselEnName());
|
|
|
+ item.setVoyageNo(bills.getVoyageNo());
|
|
|
+ item.setPolId(bills.getPolId());
|
|
|
+ item.setPolCnName(bills.getPolCnName());
|
|
|
+ item.setPolEnName(bills.getPolEnName());
|
|
|
+ item.setPolCode(bills.getPolCode());
|
|
|
+ item.setPodId(bills.getPodId());
|
|
|
+ item.setPodCnName(bills.getPodCnName());
|
|
|
+ item.setPodEnName(bills.getPodEnName());
|
|
|
+ item.setPodCode(bills.getPodCode());
|
|
|
+ }
|
|
|
+ feeCenterService.updateBatchById(feeCenterList);
|
|
|
+ List<FinAccBills> finAccBillsList = finAccBillsService.list(new LambdaQueryWrapper<FinAccBills>()
|
|
|
+ .eq(FinAccBills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FinAccBills::getIsDeleted, 0)
|
|
|
+ .eq(FinAccBills::getBusinessBillDivideId, billIds));
|
|
|
+ for (FinAccBills item : finAccBillsList) {
|
|
|
+ item.setVesselId(bills.getVesselId());
|
|
|
+ item.setVesselCnName(bills.getVesselCnName());
|
|
|
+ item.setVesselEnName(bills.getVesselEnName());
|
|
|
+ item.setVoyageNo(bills.getVoyageNo());
|
|
|
+ item.setPolId(bills.getPolId());
|
|
|
+ item.setPolCnName(bills.getPolCnName());
|
|
|
+ item.setPolEnName(bills.getPolEnName());
|
|
|
+ item.setPolCode(bills.getPolCode());
|
|
|
+ item.setPodId(bills.getPodId());
|
|
|
+ item.setPodCnName(bills.getPodCnName());
|
|
|
+ item.setPodEnName(bills.getPodEnName());
|
|
|
+ item.setPodCode(bills.getPodCode());
|
|
|
+ }
|
|
|
+ finAccBillsService.updateBatchById(finAccBillsList);
|
|
|
+ }
|
|
|
+ if ("SI".equals(bills.getBillType())) {
|
|
|
+ Bills detailsCk = baseMapper.selectById(details.getSrcBusId());
|
|
|
+ if (detailsCk != null) {
|
|
|
+ List<Bills> billsListCkNew = new ArrayList<>();
|
|
|
+ detailsCk.setActualEta(bills.getActualEta());
|
|
|
+ billsListCkNew.add(detailsCk);
|
|
|
+ List<Bills> billsListCk = baseMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .eq(Bills::getMasterId, detailsCk.getId()));
|
|
|
+ if (!billsListCk.isEmpty()) {
|
|
|
+ for (Bills item : billsListCk) {
|
|
|
+ item.setActualEta(bills.getActualEta());
|
|
|
+ }
|
|
|
+ billsListCkNew.addAll(billsListCk);
|
|
|
+ }
|
|
|
+ this.updateBatchById(billsListCkNew);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Bills detail(Bills bills) {
|
|
|
if (bills.getId() == null) {
|
|
|
@@ -3513,13 +3503,519 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public R logisticsSubmission(Bills bills) {
|
|
|
- return null;
|
|
|
+ if (bills.getId() == null) {
|
|
|
+ throw new RuntimeException("缺少必要参数");
|
|
|
+ }
|
|
|
+ Bills detail = baseMapper.selectById(bills.getId());
|
|
|
+ if ("已提交".equals(detail.getLogisticsStatus())) {
|
|
|
+ throw new RuntimeException("已提交,请勿重复提交");
|
|
|
+ }
|
|
|
+ detail.setLogisticsStatus("已提交");
|
|
|
+ detail.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ detail.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ detail.setUpdateTime(new Date());
|
|
|
+ detail.setShippingStaffId(bills.getShippingStaffId());
|
|
|
+ detail.setShippingStaffName(bills.getShippingStaffName());
|
|
|
+ baseMapper.updateById(detail);
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String formatted = now.format(formatter);
|
|
|
+ //发送消息
|
|
|
+ if (ObjectUtils.isNotNull(bills.getShippingStaffId())) {
|
|
|
+ R<User> userR = userClient.userInfoById(bills.getShippingStaffId());
|
|
|
+ if (userR.isSuccess() && ObjectUtils.isNotNull(userR.getData())) {
|
|
|
+ User datum = userR.getData();
|
|
|
+ Message sendMessage = new Message();
|
|
|
+ sendMessage.setParameter(detail.getId() + "");
|
|
|
+ sendMessage.setUserName(AuthUtil.getUserName());
|
|
|
+ sendMessage.setUserId(null);
|
|
|
+ sendMessage.setToUserId(datum.getId());
|
|
|
+ sendMessage.setToUserName(datum.getName());
|
|
|
+ sendMessage.setMessageType(1);
|
|
|
+ sendMessage.setTenantId(AuthUtil.getTenantId());
|
|
|
+ sendMessage.setCreateUser(null);
|
|
|
+ sendMessage.setCreateTime(new Date());
|
|
|
+ sendMessage.setUrl("/iosBasicData/SeafreightExportF/bills/index");
|
|
|
+ sendMessage.setPageLabel("海运出口");
|
|
|
+ sendMessage.setPageStatus("this.$store.getters.domSaleStatus");
|
|
|
+ sendMessage.setMessageBody("您有新的海运出口物流已提交,请及时待处理!提单号:" + detail.getMblno() + "时间:" + formatted);
|
|
|
+ R save = messageClient.save(sendMessage);
|
|
|
+ System.out.println("发送结果:" + save);
|
|
|
+ if (!save.isSuccess()) {
|
|
|
+ throw new SecurityException("发送消息失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("未查到船务员工用户信息");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("请选择接收船务员工");
|
|
|
+ }
|
|
|
+ return R.data(detail);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public R logisticsRevokeSubmission(Bills bills) {
|
|
|
- return null;
|
|
|
+ if (bills.getId() == null) {
|
|
|
+ throw new RuntimeException("缺少必要参数");
|
|
|
+ }
|
|
|
+ Bills detail = baseMapper.selectById(bills.getId());
|
|
|
+ if ("录入".equals(detail.getLogisticsStatus())) {
|
|
|
+ throw new RuntimeException("已撤销提交,请勿重复撤销");
|
|
|
+ }
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String formatted = now.format(formatter);
|
|
|
+ //发送消息
|
|
|
+ if (ObjectUtils.isNotNull(detail.getShippingStaffId())) {
|
|
|
+ R<User> userR = userClient.userInfoById(detail.getShippingStaffId());
|
|
|
+ if (userR.isSuccess() && ObjectUtils.isNotNull(userR.getData())) {
|
|
|
+ User datum = userR.getData();
|
|
|
+ Message sendMessage = new Message();
|
|
|
+ sendMessage.setParameter(detail.getId() + "");
|
|
|
+ sendMessage.setUserName(AuthUtil.getUserName());
|
|
|
+ sendMessage.setUserId(null);
|
|
|
+ sendMessage.setToUserId(datum.getId());
|
|
|
+ sendMessage.setToUserName(datum.getName());
|
|
|
+ sendMessage.setMessageType(1);
|
|
|
+ sendMessage.setTenantId(AuthUtil.getTenantId());
|
|
|
+ sendMessage.setCreateUser(null);
|
|
|
+ sendMessage.setCreateTime(new Date());
|
|
|
+ sendMessage.setUrl("/iosBasicData/SeafreightExportF/bills/index");
|
|
|
+ sendMessage.setPageLabel("海运出口");
|
|
|
+ sendMessage.setPageStatus("this.$store.getters.domSaleStatus");
|
|
|
+ sendMessage.setMessageBody("您的海运出口物流提交已撤销!提单号:" + detail.getMblno() + "时间:" + formatted);
|
|
|
+ R save = messageClient.save(sendMessage);
|
|
|
+ System.out.println("发送结果:" + save);
|
|
|
+ if (!save.isSuccess()) {
|
|
|
+ throw new SecurityException("发送消息失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("未查到船务员工用户信息");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("请选择接收船务员工");
|
|
|
+ }
|
|
|
+ detail.setLogisticsStatus("录入");
|
|
|
+ detail.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ detail.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ detail.setUpdateTime(new Date());
|
|
|
+ detail.setShippingStaffId(null);
|
|
|
+ detail.setShippingStaffName("");
|
|
|
+ baseMapper.updateById(detail);
|
|
|
+ return R.data(detail);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R transferOrder(Bills bills) {
|
|
|
+ if (bills.getId() == null) {
|
|
|
+ throw new RuntimeException("缺少必要参数");
|
|
|
+ }
|
|
|
+ Bills detail = baseMapper.selectById(bills.getId());
|
|
|
+ detail.setTransferOrderStatus("已转单");
|
|
|
+ detail.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ detail.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ detail.setUpdateTime(new Date());
|
|
|
+ baseMapper.updateById(detail);
|
|
|
+ Bills billsJk = new Bills();
|
|
|
+ BeanUtil.copyProperties(detail, billsJk);
|
|
|
+ billsJk.setId(null);
|
|
|
+ billsJk.setUpdateUser(null);
|
|
|
+ billsJk.setUpdateUserName(null);
|
|
|
+ billsJk.setUpdateTime(null);
|
|
|
+ billsJk.setCheckDrStatus(null);
|
|
|
+ billsJk.setCheckDrStatusDescr(null);
|
|
|
+ billsJk.setCheckCrStatus(null);
|
|
|
+ billsJk.setCheckCrStatusDescr(null);
|
|
|
+ billsJk.setStlDrStatus(null);
|
|
|
+ billsJk.setStlDrStatusDescr(null);
|
|
|
+ billsJk.setStlCrStatus(null);
|
|
|
+ billsJk.setStlCrStatusDescr(null);
|
|
|
+ billsJk.setInvoiceDrStatus(null);
|
|
|
+ billsJk.setInvoiceDrStatusDescr(null);
|
|
|
+ billsJk.setInvoiceCrStatus(null);
|
|
|
+ billsJk.setInvoiceCrStatusDescr(null);
|
|
|
+ billsJk.setBillStatus(null);
|
|
|
+ billsJk.setAccountStatus(null);
|
|
|
+ billsJk.setExtendedData(null);
|
|
|
+ billsJk.setStatus(null);
|
|
|
+ billsJk.setCharData(null);
|
|
|
+ billsJk.setBillingStatus(null);
|
|
|
+ billsJk.setEdiStatus(null);
|
|
|
+ billsJk.setApprovedDate(null);
|
|
|
+ billsJk.setIssueStatus(null);
|
|
|
+ billsJk.setSrcBusId(detail.getId());
|
|
|
+ String deptId = billsJk.getPodCompanyId() + "";
|
|
|
+ String deptName = billsJk.getPodCompanyName();
|
|
|
+ String branchId = billsJk.getPodCompanyId() + "";
|
|
|
+ List<Bills> count = baseMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
+ .select(Bills::getId)
|
|
|
+ .eq(Bills::getCreateDept, branchId)
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .eq(Bills::getMblno, billsJk.getMblno())
|
|
|
+ .eq(Bills::getBusinessType, "SI")
|
|
|
+ .eq(Bills::getSeaType, "I")
|
|
|
+ );
|
|
|
+ if (ObjectUtils.isNotNull(billsJk.getBillDate())) {
|
|
|
+ LocalDate date = billsJk.getBillDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
+ int year = date.getYear();
|
|
|
+ int month = date.getMonthValue();
|
|
|
+ FinPeriod finPeriod = finPeriodMapper.selectOne(new LambdaQueryWrapper<FinPeriod>()
|
|
|
+ .eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FinPeriod::getIsDeleted, 0)
|
|
|
+ .eq(FinPeriod::getPeriodYear, year)
|
|
|
+ .eq(FinPeriod::getPeriodMonth, month));
|
|
|
+ if (finPeriod != null) {
|
|
|
+ if (1 == finPeriod.getIsClosed()) {
|
|
|
+ throw new RuntimeException(year + "年" + month + "月账期已结转,保存失败");
|
|
|
+ }
|
|
|
+ if (1 == finPeriod.getLockingStatus()) {
|
|
|
+ throw new RuntimeException(year + "年" + month + "月账期已锁定,保存失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(bills.getMblno())) {
|
|
|
+ if (!"MH".equals(bills.getBillType())) {
|
|
|
+ if (!count.isEmpty()) {
|
|
|
+ throw new RuntimeException("提单号不允许重复:" + bills.getMblno());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BusinessType businessType = bBusinessTypeService.getOne(new LambdaQueryWrapper<BusinessType>()
|
|
|
+ .select(BusinessType::getId)
|
|
|
+ .eq(BusinessType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BusinessType::getIsDeleted, 0)
|
|
|
+ .eq(BusinessType::getStatus, 0)
|
|
|
+ .eq(BusinessType::getCode, "HYJK"));
|
|
|
+ if (businessType == null) {
|
|
|
+ throw new RuntimeException("未找到可用业务类型");
|
|
|
+ }
|
|
|
+ BusinessBillNo businessBillNo = new BusinessBillNo();
|
|
|
+ businessBillNo.setBusinessTypeId(businessType.getId());
|
|
|
+ businessBillNo.setCode("HYJK");
|
|
|
+ R clientBillNo = businessBillNoService.getBillNoLos(businessBillNo);
|
|
|
+ if (!clientBillNo.isSuccess()) {
|
|
|
+ throw new RuntimeException("生成订单编号失败");
|
|
|
+ }
|
|
|
+ billsJk.setBillNo((String) clientBillNo.getData());
|
|
|
+ billsJk.setCreateTime(new Date());
|
|
|
+ billsJk.setCreateUser(AuthUtil.getUserId());
|
|
|
+ billsJk.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ billsJk.setTenantId(AuthUtil.getTenantId());
|
|
|
+ if (ObjectUtils.isNotNull(branchId)) {
|
|
|
+ billsJk.setBranchId(branchId);
|
|
|
+ billsJk.setCreateDept(deptId);
|
|
|
+ billsJk.setCreateDeptName(deptName);
|
|
|
+ }
|
|
|
+ // 初始创建为1
|
|
|
+ billsJk.setVersion("1");
|
|
|
+ baseMapper.insert(billsJk);
|
|
|
+ if (ObjectUtils.isNotNull(billsJk.getPreContainersList())) {
|
|
|
+ List<PreContainers> preContainersList = new ArrayList<>();
|
|
|
+ for (PreContainers item : billsJk.getPreContainersList()) {
|
|
|
+ item.setSrcId(item.getId());
|
|
|
+ item.setId(null);
|
|
|
+ item.setCreateTime(new Date());
|
|
|
+ item.setCreateUser(AuthUtil.getUserId());
|
|
|
+ item.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(branchId)) {
|
|
|
+ item.setBranchId(branchId);
|
|
|
+ item.setCreateDept(deptId);
|
|
|
+ item.setCreateDeptName(deptName);
|
|
|
+ }
|
|
|
+ item.setUpdateUser(null);
|
|
|
+ item.setUpdateTime(null);
|
|
|
+ item.setUpdateUserName(null);
|
|
|
+ item.setPid(billsJk.getId());
|
|
|
+ preContainersList.add(item);
|
|
|
+ }
|
|
|
+ preContainersService.saveBatch(preContainersList);
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(billsJk.getContainersList())) {
|
|
|
+ List<Containers> containersList = new ArrayList<>();
|
|
|
+ List<ContainersCommodity> containersCommodityList = new ArrayList<>();
|
|
|
+ List<ContainersBills> containersBillsList = new ArrayList<>();
|
|
|
+ for (Containers item : billsJk.getContainersList()) {
|
|
|
+ item.setSrcId(item.getId());
|
|
|
+ item.setId(null);
|
|
|
+ item.setCreateTime(new Date());
|
|
|
+ item.setCreateUser(AuthUtil.getUserId());
|
|
|
+ item.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(branchId)) {
|
|
|
+ item.setBranchId(branchId);
|
|
|
+ item.setCreateDept(deptId);
|
|
|
+ item.setCreateDeptName(deptName);
|
|
|
+ }
|
|
|
+ item.setUpdateUser(null);
|
|
|
+ item.setUpdateTime(null);
|
|
|
+ item.setUpdateUserName(null);
|
|
|
+ item.setPid(billsJk.getId());
|
|
|
+ if (ObjectUtils.isNotNull(item.getContainersCommodityList()) && !item.getContainersCommodityList().isEmpty()) {
|
|
|
+ containersCommodityList.addAll(item.getContainersCommodityList());
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(item.getContainersBillsList()) && !item.getContainersBillsList().isEmpty()) {
|
|
|
+ containersBillsList.addAll(item.getContainersBillsList());
|
|
|
+ }
|
|
|
+ containersList.add(item);
|
|
|
+ }
|
|
|
+ containersService.saveBatch(containersList);
|
|
|
+ if (!containersCommodityList.isEmpty()) {
|
|
|
+ for (ContainersCommodity item : containersCommodityList) {
|
|
|
+ Containers containers = containersList.stream().filter(e -> e.getSrcId().equals(item.getPid())).findFirst().orElse(null);
|
|
|
+ if (containers != null) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setCreateTime(new Date());
|
|
|
+ item.setCreateUser(AuthUtil.getUserId());
|
|
|
+ item.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(branchId)) {
|
|
|
+ item.setBranchId(branchId);
|
|
|
+ item.setCreateDept(deptId);
|
|
|
+ item.setCreateDeptName(deptName);
|
|
|
+ }
|
|
|
+ item.setUpdateUser(null);
|
|
|
+ item.setUpdateTime(null);
|
|
|
+ item.setUpdateUserName(null);
|
|
|
+ item.setPid(containers.getId());
|
|
|
+ item.setPpId(billsJk.getId());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("装箱明细数据错误,请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ containersCommodityService.saveBatch(containersCommodityList);
|
|
|
+ }
|
|
|
+ if (!containersBillsList.isEmpty()) {
|
|
|
+ for (ContainersBills item : containersBillsList) {
|
|
|
+ Containers containers = containersList.stream().filter(e -> e.getSrcId().equals(item.getPid())).findFirst().orElse(null);
|
|
|
+ if (containers != null) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setCreateTime(new Date());
|
|
|
+ item.setCreateUser(AuthUtil.getUserId());
|
|
|
+ item.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(branchId)) {
|
|
|
+ item.setBranchId(branchId);
|
|
|
+ item.setCreateDept(deptId);
|
|
|
+ item.setCreateDeptName(deptName);
|
|
|
+ }
|
|
|
+ item.setUpdateUser(null);
|
|
|
+ item.setUpdateTime(null);
|
|
|
+ item.setUpdateUserName(null);
|
|
|
+ item.setPid(containers.getId());
|
|
|
+ item.setPpId(billsJk.getId());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("装箱明细数据错误,请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ containersBillsService.saveBatch(containersBillsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal amountCr = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfit;
|
|
|
+ BigDecimal amountCrUsd = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfitUsd;
|
|
|
+ BigDecimal amountCrLoc = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfitLoc;
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+ BigDecimal exrateC = bCurrencyService.getCnyExrate(date, "USD", "C", "1");
|
|
|
+ //应收
|
|
|
+ int statusD = 0;
|
|
|
+ if (ObjectUtils.isNotNull(billsJk.getFeeCenterListD())) {
|
|
|
+ List<FeeCenter> feeCenterListAll = new ArrayList<>();
|
|
|
+ List<FeeCenter> feeCenterListD = billsJk.getFeeCenterListD()
|
|
|
+ .stream().filter(e -> e.getCorpId().equals(billsJk.getForeignAgencyId())).collect(Collectors.toList());
|
|
|
+ if (!feeCenterListD.isEmpty()) {
|
|
|
+ statusD += 1;
|
|
|
+ for (FeeCenter item : feeCenterListD) {
|
|
|
+ //计算字段null值处理
|
|
|
+ item.setQuantity(ObjectUtils.isNotNull(item.getQuantity()) ? item.getQuantity() : new BigDecimal("0.00"));
|
|
|
+ item.setPrice(ObjectUtils.isNotNull(item.getPrice()) ? item.getPrice() : new BigDecimal("0.00"));
|
|
|
+ item.setSurchargeRate(ObjectUtils.isNotNull(item.getSurchargeRate()) ? item.getSurchargeRate() : new BigDecimal("0.00"));
|
|
|
+ item.setTaxRate(ObjectUtils.isNotNull(item.getTaxRate()) ? item.getTaxRate() : new BigDecimal("0.00"));
|
|
|
+ item.setAmountDiscount(ObjectUtils.isNotNull(item.getAmountDiscount()) ? item.getAmountDiscount() : new BigDecimal("0.00"));
|
|
|
+ item.setStlTtlAmount(ObjectUtils.isNotNull(item.getStlTtlAmount()) ? item.getStlTtlAmount() : new BigDecimal("0.00"));
|
|
|
+
|
|
|
+ item.setId(null);
|
|
|
+ item.setPid(billsJk.getId());
|
|
|
+ item.setBillNo(bills.getBillNo());
|
|
|
+ item.setBusinessType(billsJk.getBusinessType());
|
|
|
+ item.setDc("C");
|
|
|
+ item.setCreateTime(new Date());
|
|
|
+ item.setCreateUser(AuthUtil.getUserId());
|
|
|
+ item.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ item.setCreateDept(deptId);
|
|
|
+ item.setBranchId(branchId);
|
|
|
+ item.setCreateDeptName(deptName);
|
|
|
+ }
|
|
|
+ item.setUpdateUser(null);
|
|
|
+ item.setUpdateTime(null);
|
|
|
+ item.setUpdateUserName(null);
|
|
|
+
|
|
|
+ // 去税金额 = 数量quantity * 单价price
|
|
|
+ BigDecimal amountNet = new BigDecimal("0.00");
|
|
|
+ // 税额 = 去税金额amountNet * 税率taxRateSum
|
|
|
+ BigDecimal amountTax = new BigDecimal("0.00");
|
|
|
+ // 金额,amountTax + 去税金额amountNet - 折扣金额amountDiscount
|
|
|
+ BigDecimal amount = new BigDecimal("0.00");
|
|
|
+ //总税率 = 税率taxRate + 附加税率surchargeRate
|
|
|
+ BigDecimal taxRate = new BigDecimal("0.00");
|
|
|
+ // 税率 = 总税率/100
|
|
|
+ BigDecimal taxRateSum = new BigDecimal("0.00");
|
|
|
+
|
|
|
+ amountNet = amountNet.add(item.getQuantity().multiply(item.getPrice()))
|
|
|
+ .setScale(2, RoundingMode.HALF_UP);
|
|
|
+ taxRate = taxRate.add(item.getTaxRate()).add(item.getSurchargeRate());
|
|
|
+ taxRateSum = taxRateSum.add(taxRate.divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP));
|
|
|
+ amountTax = amountTax.add(amountNet.multiply(taxRateSum)).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ amount = amount.add(amountNet.add(amountTax).subtract(item.getAmountDiscount()));
|
|
|
+
|
|
|
+ //判断是否是本位币
|
|
|
+ if ("CNY".equals(item.getCurCode())) {
|
|
|
+ item.setAmountNetLoc(amountNet);
|
|
|
+ item.setAmountTaxLoc(amountTax);
|
|
|
+ item.setAmountLoc(amount);
|
|
|
+ item.setAmountDiscountLoc(amount);
|
|
|
+ amountCr = amountCr.add(item.getAmount());
|
|
|
+ } else {
|
|
|
+ item.setAmountNetLoc(amountNet.multiply(exrateC));
|
|
|
+ item.setAmountTaxLoc(amountTax.multiply(exrateC));
|
|
|
+ item.setAmountLoc(amount.multiply(exrateC));
|
|
|
+ item.setAmountDiscountLoc(amount.multiply(exrateC));
|
|
|
+ amountCrUsd = amountCrUsd.add(item.getAmount());
|
|
|
+ }
|
|
|
+ item.setAmountNet(amountNet);
|
|
|
+ item.setAmountTax(amountTax);
|
|
|
+ item.setAmount(amount);
|
|
|
+ item.setUnsettledAmount(item.getAmount().subtract(item.getStlTtlAmount()));
|
|
|
+ feeCenterListAll.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!feeCenterListAll.isEmpty()) {
|
|
|
+ feeCenterService.saveBatch(feeCenterListAll);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (0 == statusD) {
|
|
|
+ billsJk.setAccountStatus(0);
|
|
|
+ } else if (1 == statusD) {
|
|
|
+ billsJk.setAccountStatus(2);
|
|
|
+ }
|
|
|
+ //主单应加上分单费用
|
|
|
+ if ("MM".equals(billsJk.getBillType()) && ObjectUtils.isNotNull(billsJk.getId())) {
|
|
|
+ List<Bills> details = baseMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .eq(Bills::getMasterId, bills.getId()));
|
|
|
+ if (!details.isEmpty()) {
|
|
|
+ for (Bills item : details) {
|
|
|
+ item.setSrcBusId(item.getId());
|
|
|
+ item.setId(null);
|
|
|
+ item.setUpdateUser(null);
|
|
|
+ item.setUpdateUserName(null);
|
|
|
+ item.setUpdateTime(null);
|
|
|
+ item.setCheckDrStatus(null);
|
|
|
+ item.setCheckDrStatusDescr(null);
|
|
|
+ item.setCheckCrStatus(null);
|
|
|
+ item.setCheckCrStatusDescr(null);
|
|
|
+ item.setStlDrStatus(null);
|
|
|
+ item.setStlDrStatusDescr(null);
|
|
|
+ item.setStlCrStatus(null);
|
|
|
+ item.setStlCrStatusDescr(null);
|
|
|
+ item.setInvoiceDrStatus(null);
|
|
|
+ item.setInvoiceDrStatusDescr(null);
|
|
|
+ item.setInvoiceCrStatus(null);
|
|
|
+ item.setInvoiceCrStatusDescr(null);
|
|
|
+ item.setBillStatus(null);
|
|
|
+ item.setAccountStatus(null);
|
|
|
+ item.setExtendedData(null);
|
|
|
+ item.setStatus(null);
|
|
|
+ item.setCharData(null);
|
|
|
+ item.setBillingStatus(null);
|
|
|
+ item.setEdiStatus(null);
|
|
|
+ item.setApprovedDate(null);
|
|
|
+ item.setIssueStatus(null);
|
|
|
+ item.setMasterId(billsJk.getId());
|
|
|
+ item.setMasterBillNo(billsJk.getBillNo());
|
|
|
+ BusinessBillNo businessBillNo1 = new BusinessBillNo();
|
|
|
+ businessBillNo1.setBusinessTypeId(businessType.getId());
|
|
|
+ businessBillNo1.setCode("HYJK");
|
|
|
+ R clientBillNo1 = businessBillNoService.getBillNoLos(businessBillNo1);
|
|
|
+ if (!clientBillNo1.isSuccess()) {
|
|
|
+ throw new RuntimeException("生成订单编号失败");
|
|
|
+ }
|
|
|
+ item.setBillNo((String) clientBillNo1.getData());
|
|
|
+ item.setCreateTime(new Date());
|
|
|
+ item.setCreateUser(AuthUtil.getUserId());
|
|
|
+ item.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ item.setTenantId(AuthUtil.getTenantId());
|
|
|
+ if (ObjectUtils.isNotNull(branchId)) {
|
|
|
+ item.setBranchId(branchId);
|
|
|
+ item.setCreateDept(deptId);
|
|
|
+ item.setCreateDeptName(deptName);
|
|
|
+ }
|
|
|
+ // 初始创建为1
|
|
|
+ item.setVersion("1");
|
|
|
+ }
|
|
|
+ this.saveBatch(details);
|
|
|
+ amountCr = amountCr.add(details.stream().map(Bills::getAmountCr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ amountCrUsd = amountCrUsd.add(details.stream().map(Bills::getAmountCrUsd).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ amountCrLoc = amountCrLoc.add(details.stream().map(Bills::getAmountCrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //利润 = 收 - 付
|
|
|
+ amountProfit = new BigDecimal("0.00").subtract(amountCr);
|
|
|
+ amountProfitUsd = new BigDecimal("0.00").subtract(amountCrUsd);
|
|
|
+ if (amountCrUsd.compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
+ amountCrLoc = amountCrLoc.add(amountCrUsd.multiply(exrateC)).add(amountCr);
|
|
|
+ } else {
|
|
|
+ amountCrLoc = amountCrLoc.add(amountCr);
|
|
|
+ }
|
|
|
+ amountProfitLoc = new BigDecimal("0.00").subtract(amountCrLoc);
|
|
|
+ billsJk.setAmountCr(amountCr);
|
|
|
+ billsJk.setAmountProfit(amountProfit);
|
|
|
+ billsJk.setAmountCrUsd(amountCrUsd);
|
|
|
+ billsJk.setAmountProfitUsd(amountProfitUsd);
|
|
|
+ billsJk.setAmountCrLoc(amountCrLoc);
|
|
|
+ billsJk.setAmountProfitLoc(amountProfitLoc);
|
|
|
+ this.updateById(billsJk);
|
|
|
+ if (ObjectUtils.isNotNull(billsJk.getDetail())) {
|
|
|
+ SeaBillsDetail seaBillsDetail = billsJk.getDetail();
|
|
|
+ seaBillsDetail.setUpdateUser(null);
|
|
|
+ seaBillsDetail.setUpdateUserName(null);
|
|
|
+ seaBillsDetail.setUpdateTime(null);
|
|
|
+ seaBillsDetail.setId(null);
|
|
|
+ seaBillsDetail.setPid(billsJk.getId());
|
|
|
+ seaBillsDetail.setBranchId(billsJk.getBranchId());
|
|
|
+ seaBillsDetail.setCreateUser(AuthUtil.getUserId());
|
|
|
+ seaBillsDetail.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ seaBillsDetail.setCreateDept(billsJk.getCreateDept());
|
|
|
+ seaBillsDetail.setCreateDeptName(billsJk.getCreateDeptName());
|
|
|
+ seaBillsDetail.setCreateTime(new Date());
|
|
|
+ seaBillsDetailService.save(seaBillsDetail);
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(billsJk.getFilesList())) {
|
|
|
+ List<FilesCenter> filesList = new ArrayList<>();
|
|
|
+ for (FilesCenter item : billsJk.getFilesList()) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setPid(billsJk.getId());
|
|
|
+ item.setCreateTime(new Date());
|
|
|
+ item.setCreateUser(AuthUtil.getUserId());
|
|
|
+ item.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ item.setCreateDeptName(deptName);
|
|
|
+ }
|
|
|
+ item.setUpdateUser(null);
|
|
|
+ item.setUpdateTime(null);
|
|
|
+ item.setUpdateUserName(null);
|
|
|
+ filesList.add(item);
|
|
|
+ }
|
|
|
+ filesCenterService.saveBatch(filesList);
|
|
|
+ }
|
|
|
+ return R.data(billsJk);
|
|
|
}
|
|
|
|
|
|
}
|