|
|
@@ -20,18 +20,30 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import io.seata.spring.annotation.GlobalTransactional;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.los.basic.cur.entity.BCurrency;
|
|
|
+import org.springblade.los.basic.cur.mapper.CurrencyMapper;
|
|
|
+import org.springblade.los.basic.fees.entity.FeesTemplateItems;
|
|
|
+import org.springblade.los.basic.fees.entity.LosBFeesTemplate;
|
|
|
+import org.springblade.los.basic.fees.mapper.FeesTemplateItemsMapper;
|
|
|
+import org.springblade.los.business.sea.entity.Bills;
|
|
|
+import org.springblade.los.business.sea.mapper.BillsMapper;
|
|
|
import org.springblade.los.finance.fee.entity.FeeCenter;
|
|
|
import org.springblade.los.finance.fee.mapper.FeeCenterMapper;
|
|
|
import org.springblade.los.finance.fee.service.IFeeCenterService;
|
|
|
import org.springblade.los.finance.fee.vo.FeeCenterVO;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 物流-费用中心-所有业务费用集中在该表中 服务实现类
|
|
|
@@ -44,6 +56,12 @@ import java.util.List;
|
|
|
public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter> implements IFeeCenterService {
|
|
|
private final ISysClient sysClient;
|
|
|
|
|
|
+ private final BillsMapper billsMapper;
|
|
|
+
|
|
|
+ private final FeesTemplateItemsMapper feesTemplateItemsMapper;
|
|
|
+
|
|
|
+ private final CurrencyMapper currencyMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<FeeCenterVO> selectFeeCenterPage(IPage<FeeCenterVO> page, FeeCenterVO feeCenter) {
|
|
|
return page.setRecords(baseMapper.selectFeeCenterPage(page, feeCenter));
|
|
|
@@ -88,4 +106,106 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
|
|
|
.in(FeeCenter::getPid, ids));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
|
|
|
+ public R<List<FeeCenter>> templateImport(LosBFeesTemplate losBFeesTemplate) {
|
|
|
+ List<FeeCenter> list = new ArrayList<>();
|
|
|
+ Bills bills = billsMapper.selectById(losBFeesTemplate.getBillNoId());
|
|
|
+ if (bills == null) {
|
|
|
+ throw new RuntimeException("未找到主表信息");
|
|
|
+ }
|
|
|
+ List<FeesTemplateItems> feesTemplateItemsList = feesTemplateItemsMapper.selectList(new LambdaQueryWrapper<FeesTemplateItems>()
|
|
|
+ .eq(FeesTemplateItems::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeesTemplateItems::getIsDeleted, 0)
|
|
|
+ .eq(FeesTemplateItems::getPid, losBFeesTemplate.getId()));
|
|
|
+ if (feesTemplateItemsList.size() > 0) {
|
|
|
+ String code = feesTemplateItemsList.stream().map(FeesTemplateItems::getCurCode).distinct().collect(Collectors.joining());
|
|
|
+ List<BCurrency> bCurrency = currencyMapper.selectList(new LambdaQueryWrapper<BCurrency>()
|
|
|
+ .eq(BCurrency::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BCurrency::getIsDeleted, 0)
|
|
|
+ .apply("find_in_set(code,'" + code + "')")
|
|
|
+ .eq(BCurrency::getStatus, 0));
|
|
|
+ int count = 1;
|
|
|
+ for (FeesTemplateItems items : feesTemplateItemsList) {
|
|
|
+ FeeCenter feeCenter = new FeeCenter();
|
|
|
+ feeCenter.setPid(bills.getId());
|
|
|
+ feeCenter.setBillNo(bills.getBillNo());
|
|
|
+ feeCenter.setBusinessType(bills.getBusinessType());
|
|
|
+ feeCenter.setBillType(bills.getBillType());
|
|
|
+ feeCenter.setBillDate(bills.getBillDate());
|
|
|
+ feeCenter.setBillCorpId(bills.getCorpId());
|
|
|
+ feeCenter.setBillCorpCnName(bills.getCorpCnName());
|
|
|
+ feeCenter.setBillCorpEnName(bills.getCorpEnName());
|
|
|
+ feeCenter.setLineId(bills.getLineId());
|
|
|
+ feeCenter.setLineCnName(bills.getLineCnName());
|
|
|
+ feeCenter.setLineEnName(bills.getLineEnName());
|
|
|
+ feeCenter.setVesselId(bills.getVesselId());
|
|
|
+ feeCenter.setVesselCnName(bills.getVesselCnName());
|
|
|
+ feeCenter.setVesselEnName(bills.getVesselEnName());
|
|
|
+ feeCenter.setVoyageNo(bills.getVoyageNo());
|
|
|
+ feeCenter.setMblno(bills.getMblno());
|
|
|
+ feeCenter.setHblno(bills.getHblno());
|
|
|
+ feeCenter.setEtd(bills.getEtd());
|
|
|
+ feeCenter.setEta(bills.getEta());
|
|
|
+ feeCenter.setPolId(bills.getPolId());
|
|
|
+ feeCenter.setPolCode(bills.getPolCode());
|
|
|
+ feeCenter.setPolCnName(bills.getPolCnName());
|
|
|
+ feeCenter.setPolEnName(bills.getPolEnName());
|
|
|
+ feeCenter.setPodId(bills.getPodId());
|
|
|
+ feeCenter.setPodCode(bills.getPodCode());
|
|
|
+ feeCenter.setPodCnName(bills.getPodCnName());
|
|
|
+ feeCenter.setPodEnName(bills.getPodEnName());
|
|
|
+ feeCenter.setDc(losBFeesTemplate.getDc());
|
|
|
+ feeCenter.setPaymode(bills.getMPaymode());
|
|
|
+ feeCenter.setSort(count);
|
|
|
+ count++;
|
|
|
+ feeCenter.setCorpId(items.getCorpId());
|
|
|
+ feeCenter.setCorpCnName(items.getCorpCnName());
|
|
|
+ feeCenter.setCorpEnName(items.getCorpEnName());
|
|
|
+ feeCenter.setFeeId(items.getFeeId());
|
|
|
+ feeCenter.setFeeCode(items.getFeeCode());
|
|
|
+ feeCenter.setFeeCnName(items.getFeeCnName());
|
|
|
+ feeCenter.setFeeEnName(items.getFeeEnName());
|
|
|
+ feeCenter.setUnitNo(items.getUnitNo());
|
|
|
+ feeCenter.setPrice(items.getPrice());
|
|
|
+ feeCenter.setCurCode(items.getCurCode());
|
|
|
+ if (ObjectUtils.isNotNull(feeCenter.getCurCode())) {
|
|
|
+ BCurrency currency = bCurrency.stream().filter(e -> e.getCode().equals(feeCenter.getCurCode())).findFirst().orElse(null);
|
|
|
+ if (currency != null) {
|
|
|
+ feeCenter.setExrate(currency.getExrate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("20GP".equals(items.getUnitNo())) {
|
|
|
+ feeCenter.setQuantity(new BigDecimal((ObjectUtils.isNotNull(bills.getQuantityV20()) ? bills.getQuantityV20() : 0) + ""));
|
|
|
+ feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
|
|
|
+ } else if ("40GP".equals(items.getUnitNo())) {
|
|
|
+ feeCenter.setQuantity(new BigDecimal((ObjectUtils.isNotNull(bills.getQuantityV40()) ? bills.getQuantityV40() : 0) + ""));
|
|
|
+ feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
|
|
|
+ } else if ("40HC".equals(items.getUnitNo())) {
|
|
|
+ feeCenter.setQuantity(new BigDecimal((ObjectUtils.isNotNull(bills.getQuantityV40hc()) ? bills.getQuantityV40hc() : 0) + ""));
|
|
|
+ feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
|
|
|
+ } else if ("45GP".equals(items.getUnitNo())) {
|
|
|
+ feeCenter.setQuantity(new BigDecimal((ObjectUtils.isNotNull(bills.getQuantityV45()) ? bills.getQuantityV45() : 0) + ""));
|
|
|
+ feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
|
|
|
+ } else if ("48GP".equals(items.getUnitNo())) {
|
|
|
+ feeCenter.setQuantity(new BigDecimal((ObjectUtils.isNotNull(bills.getQuantityV48()) ? bills.getQuantityV48() : 0) + ""));
|
|
|
+ feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
|
|
|
+ } else if ("TON".equals(items.getUnitNo())) {
|
|
|
+ feeCenter.setQuantity(bills.getGrossWeight());
|
|
|
+ feeCenter.setAmount(items.getPrice().multiply(bills.getGrossWeight()));
|
|
|
+ } else if ("PKGS".equals(items.getUnitNo())) {
|
|
|
+ feeCenter.setQuantity(bills.getQuantity());
|
|
|
+ feeCenter.setAmount(items.getPrice().multiply(bills.getQuantity()));
|
|
|
+ } else {
|
|
|
+ feeCenter.setQuantity(bills.getMeasurement());
|
|
|
+ feeCenter.setAmount(items.getPrice().multiply(bills.getMeasurement()));
|
|
|
+ }
|
|
|
+ list.add(feeCenter);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.saveOrUpdateBatch(list);
|
|
|
+ return R.data(list);
|
|
|
+ }
|
|
|
+
|
|
|
}
|