Browse Source

1.客户保存所属公司逻辑修改
2.费用请核报表打印接口修改

纪新园 7 months ago
parent
commit
7496142aee

+ 13 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/ExpenseApplication.java

@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.springblade.los.business.sea.entity.Bills;
 import org.springblade.los.check.entity.LosAuditPathsLevels;
 import org.springblade.los.finance.fee.entity.FeeCenter;
 import org.springblade.system.entity.Dept;
@@ -196,5 +197,17 @@ public class ExpenseApplication implements Serializable {
 	@TableField(exist = false)
 	private Dept dept;
 
+	/**
+	 * 海运进出口信息
+	 */
+	@TableField(exist = false)
+	private Bills bills;
+
+	/**
+	 * 箱管信息
+	 */
+	@TableField(exist = false)
+	private TradingBox tradingBox;
+
 
 }

+ 46 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/TradingBox.java

@@ -685,4 +685,50 @@ public class TradingBox implements Serializable {
 	@TableField(exist = false)
 	private Date date;
 
+	/**
+	 * 本位币应收(CNY)
+	 */
+	@TableField(exist = false)
+	private BigDecimal amountDr;
+	/**
+	 * 本位币应付(CNY)
+	 */
+	@TableField(exist = false)
+	private BigDecimal amountCr;
+	/**
+	 * 本位币利润(CNY)
+	 */
+	@TableField(exist = false)
+	private BigDecimal amountProfit;
+	/**
+	 * 综合 USD 应收(USD) - 非 USD 外币转换为 USD
+	 */
+	@TableField(exist = false)
+	private BigDecimal amountDrUsd;
+	/**
+	 * 综合 USD 应付(USD) - 非 USD 外币转换为 USD
+	 */
+	@TableField(exist = false)
+	private BigDecimal amountCrUsd;
+	/**
+	 * 综合 USD 利润(USD) - 非 USD 外币转换为 USD
+	 */
+	@TableField(exist = false)
+	private BigDecimal amountProfitUsd;
+	/**
+	 * 合计本位币应收(CNY )
+	 */
+	@TableField(exist = false)
+	private BigDecimal amountDrLoc;
+	/**
+	 * 合计本位币应付(CNY)
+	 */
+	@TableField(exist = false)
+	private BigDecimal amountCrLoc;
+	/**
+	 * 合计本位币利润(CNY)
+	 */
+	@TableField(exist = false)
+	private BigDecimal amountProfitLoc;
+
 }

+ 5 - 5
blade-service/blade-los/src/main/java/org/springblade/los/basic/corps/service/impl/BCorpsServiceImpl.java

@@ -90,20 +90,20 @@ public class BCorpsServiceImpl extends ServiceImpl<CorpsMapper, BCorps> implemen
 	public R submit(BCorps bCorpss) throws Exception {
 		Object object = StringTools.handle(bCorpss, "BCorps");
 		BCorps bCorps = JSONObject.parseObject(JSONObject.toJSONString(object), BCorps.class);
-		String deptId ;
+		String deptId;
 		String deptName = "";
 		String branchId = null;
-		if (ObjectUtils.isNotNull(bCorps.getBranchId())){
+		if (ObjectUtils.isNotNull(bCorps.getBranchId())) {
 			deptId = bCorps.getBranchId();
 			branchId = bCorps.getBranchId();
 			deptName = bCorps.getBranchName();
-		}else{
+		} else {
 			deptId = AuthUtil.getDeptId();
 		}
 		//获取部门ids对应中文名
-		R<String> res = sysClient.getDeptName(Long.parseLong(deptId));
+		R<List<String>> res = sysClient.getDeptNames(deptId);
 		if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
-			deptName = res.getData();
+			deptName = String.join(",", res.getData());
 		}
 		List<BCorps> cname = baseMapper.selectList(new LambdaQueryWrapper<BCorps>()
 			.eq(BCorps::getCnName, bCorps.getCnName())

+ 245 - 5
blade-service/blade-los/src/main/java/org/springblade/los/basic/reports/service/impl/ReportsBoxServiceImpl.java

@@ -21,23 +21,33 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import lombok.AllArgsConstructor;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
+import org.springblade.los.Util.CurrencyUtils;
 import org.springblade.los.Util.IDeptUtils;
 import org.springblade.los.Util.MagicValues;
 import org.springblade.los.basic.corps.entity.BCorps;
 import org.springblade.los.basic.corps.service.IBCorpsService;
+import org.springblade.los.basic.cur.entity.BCurExrate;
 import org.springblade.los.basic.reports.service.IReportsBoxService;
 import org.springblade.los.box.entity.ExpenseApplication;
 import org.springblade.los.box.entity.TradingBox;
 import org.springblade.los.box.service.IExpenseApplicationService;
 import org.springblade.los.box.service.ITradingBoxService;
+import org.springblade.los.business.sea.entity.Bills;
+import org.springblade.los.business.sea.entity.SeaBillsDetail;
+import org.springblade.los.business.sea.service.IBillsService;
+import org.springblade.los.business.sea.service.ISeaBillsDetailService;
 import org.springblade.los.finance.fee.entity.FeeCenter;
 import org.springblade.los.finance.fee.service.IFeeCenterService;
 import org.springblade.system.entity.Dept;
+import org.springblade.system.entity.DictBiz;
+import org.springblade.system.feign.IDictBizClient;
 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 java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -65,6 +75,14 @@ public class ReportsBoxServiceImpl implements IReportsBoxService {
 
 	private final IFeeCenterService feeCenterService;
 
+	private final IBillsService billsService;
+
+	private final CurrencyUtils currencyUtils;
+
+	private final IDictBizClient dictBizClient;
+
+	private final ISeaBillsDetailService seaBillsDetailService;
+
 
 	@Override
 	public R getReportData(String billId, String reportCode, String groupCode, String corpIds, String itemIds, String type, String curCode) {
@@ -110,18 +128,149 @@ public class ReportsBoxServiceImpl implements IReportsBoxService {
 			|| MagicValues.BUY.equals(reportCode) || MagicValues.ZR.equals(reportCode)
 			|| MagicValues.DL.equals(reportCode) || MagicValues.XGFY.equals(reportCode)
 			|| MagicValues.XGDX.equals(reportCode) || MagicValues.CCSQ.equals(reportCode)
-			|| MagicValues.DXCB.equals(reportCode)|| MagicValues.HYCK.equals(reportCode)
-			|| MagicValues.HYJK.equals(reportCode)) && MagicValues.FYSQ.equals(groupCode) && MagicValues.FYSQ.equals(type)) {
+			|| MagicValues.DXCB.equals(reportCode)) && MagicValues.FYSQ.equals(groupCode) && MagicValues.FYSQ.equals(type)) {
 			ExpenseApplication expenseApplication = expenseApplicationService.getById(billId);
 			if (expenseApplication != null) {
+				TradingBox tradingBox = tradingBoxService.getById(expenseApplication.getSrcId());
+				if (tradingBox == null) {
+					throw new RuntimeException("未查到单据信息");
+				}
+				BigDecimal amountDr = new BigDecimal("0.00");
+				BigDecimal amountCr = new BigDecimal("0.00");
+				BigDecimal amountProfit;
+				BigDecimal amountDrUsd = new BigDecimal("0.00");
+				BigDecimal amountCrUsd = new BigDecimal("0.00");
+				BigDecimal amountProfitUsd;
+				BigDecimal amountDrLoc = new BigDecimal("0.00");
+				BigDecimal amountCrLoc = new BigDecimal("0.00");
+				BigDecimal amountProfitLoc;
+				String exrateType = currencyUtils.standardCurrency(AuthUtil.getDeptId());
+				List<BCurExrate> curExrateList = currencyUtils.obtainRate(new Date(), "1", AuthUtil.getDeptId());
 				LambdaQueryWrapper<FeeCenter> feeCenterLambdaQueryWrapper = new LambdaQueryWrapper<>();
 				feeCenterLambdaQueryWrapper.eq(FeeCenter::getIsDeleted, 0)
 					.eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
 					.eq(FeeCenter::getStlPid, expenseApplication.getId());
 				List<FeeCenter> feeCenterList = feeCenterService.list(feeCenterLambdaQueryWrapper);
-				if (!feeCenterList.isEmpty()){
-					List<FeeCenter> feeCenterListD = feeCenterList.stream().filter(e-> "D".equals(e.getDc())).collect(Collectors.toList());
-					List<FeeCenter> feeCenterListC = feeCenterList.stream().filter(e-> "C".equals(e.getDc())).collect(Collectors.toList());
+				if (!feeCenterList.isEmpty()) {
+					for (FeeCenter item : feeCenterList) {
+						if ("D".equals(item.getDc())){
+							if (exrateType.equals(item.getCurCode())) {
+								amountDr = amountDr.add(item.getAmount());
+								amountDrLoc = amountDrLoc.add(item.getAmount());
+							} else {
+								amountDrUsd = amountDrUsd.add(item.getAmount());
+								amountDrLoc = amountDrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+							}
+						}else{
+							if (exrateType.equals(item.getCurCode())) {
+								amountCr = amountCr.add(item.getAmount());
+								amountCrLoc = amountCrLoc.add(item.getAmount());
+							} else {
+								amountCrUsd = amountCrUsd.add(item.getAmount());
+								amountCrLoc = amountCrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+							}
+						}
+					}
+					amountProfit = amountDr.subtract(amountCr);
+					amountProfitUsd = amountDrUsd.subtract(amountCrUsd);
+					amountProfitLoc = amountDrLoc.subtract(amountCrLoc);
+					tradingBox.setAmountDr(amountDr);
+					tradingBox.setAmountCr(amountCr);
+					tradingBox.setAmountProfit(amountProfit);
+					tradingBox.setAmountDrUsd(amountDrUsd);
+					tradingBox.setAmountCrUsd(amountCrUsd);
+					tradingBox.setAmountProfitUsd(amountProfitUsd);
+					tradingBox.setAmountDrLoc(amountDrLoc);
+					tradingBox.setAmountCrLoc(amountCrLoc);
+					tradingBox.setAmountProfitLoc(amountProfitLoc);
+					expenseApplication.setTradingBox(tradingBox);
+					List<FeeCenter> feeCenterListD = feeCenterList.stream().filter(e -> "D".equals(e.getDc())).collect(Collectors.toList());
+					List<FeeCenter> feeCenterListC = feeCenterList.stream().filter(e -> "C".equals(e.getDc())).collect(Collectors.toList());
+					expenseApplication.setFeeCenterList(feeCenterListD.isEmpty() ? new ArrayList<>() : feeCenterListD);
+					expenseApplication.setFeeCenterListC(feeCenterListC.isEmpty() ? new ArrayList<>() : feeCenterListC);
+				}
+				expenseApplication.setDept(dept);
+				map.put(MagicValues.DATA, expenseApplication);
+			} else {
+				map.put(MagicValues.DATA, null);
+			}
+		} else if ((MagicValues.HYJK.equals(reportCode) || MagicValues.HYCK.equals(reportCode)) && MagicValues.FYSQ.equals(groupCode) && MagicValues.FYSQ.equals(type)) {
+			ExpenseApplication expenseApplication = expenseApplicationService.getById(billId);
+			if (expenseApplication != null) {
+				BigDecimal amountDr = new BigDecimal("0.00");
+				BigDecimal amountCr = new BigDecimal("0.00");
+				BigDecimal amountProfit;
+				BigDecimal amountDrUsd = new BigDecimal("0.00");
+				BigDecimal amountCrUsd = new BigDecimal("0.00");
+				BigDecimal amountProfitUsd;
+				BigDecimal amountDrLoc = new BigDecimal("0.00");
+				BigDecimal amountCrLoc = new BigDecimal("0.00");
+				BigDecimal amountProfitLoc;
+				Bills bills = billsService.getById(expenseApplication.getSrcId());
+				if (bills == null) {
+					throw new RuntimeException("未查到单据信息");
+				}
+				Date date;
+				if ("SE".equals(bills.getBusinessType())) {
+					date = bills.getEtd();
+				} else {
+					date = bills.getEta();
+				}
+				String exrateType = currencyUtils.standardCurrency(bills.getBranchId());
+				bills.setExrateType(exrateType);
+				this.dictionaryConversion(bills);
+				this.assignmentSeaBillsDetail(bills);
+				if (ObjectUtils.isNotNull(bills.getAmountProfitLoc()) && ObjectUtils.isNotNull(bills.getAmountDrLoc())) {
+					if (bills.getAmountProfitLoc().compareTo(new BigDecimal(MagicValues.ZERO)) == 0 ||
+						bills.getAmountDrLoc().compareTo(new BigDecimal(MagicValues.ZERO)) == 0) {
+						bills.setGrossMargin(new BigDecimal(MagicValues.ZERO));
+					} else {
+						bills.setGrossMargin(bills.getAmountProfitLoc().divide(bills.getAmountDrLoc(), 4, RoundingMode.HALF_UP));
+					}
+				} else {
+					bills.setGrossMargin(new BigDecimal(MagicValues.ZERO));
+				}
+				List<BCurExrate> curExrateList = currencyUtils.obtainRate(date, "1", bills.getBranchId());
+				LambdaQueryWrapper<FeeCenter> feeCenterLambdaQueryWrapper = new LambdaQueryWrapper<>();
+				feeCenterLambdaQueryWrapper.eq(FeeCenter::getIsDeleted, 0)
+					.eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
+					.eq(FeeCenter::getStlPid, expenseApplication.getId());
+				List<FeeCenter> feeCenterList = feeCenterService.list(feeCenterLambdaQueryWrapper);
+				if (!feeCenterList.isEmpty()) {
+					for (FeeCenter item : feeCenterList) {
+						if ("D".equals(item.getDc())){
+							if (exrateType.equals(item.getCurCode())) {
+								amountDr = amountDr.add(item.getAmount());
+								amountDrLoc = amountDrLoc.add(item.getAmount());
+							} else {
+								amountDrUsd = amountDrUsd.add(item.getAmount());
+								amountDrLoc = amountDrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+							}
+						}else{
+							if (exrateType.equals(item.getCurCode())) {
+								amountCr = amountCr.add(item.getAmount());
+								amountCrLoc = amountCrLoc.add(item.getAmount());
+							} else {
+								amountCrUsd = amountCrUsd.add(item.getAmount());
+								amountCrLoc = amountCrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+							}
+						}
+					}
+					amountProfit = amountDr.subtract(amountCr);
+					amountProfitUsd = amountDrUsd.subtract(amountCrUsd);
+					amountProfitLoc = amountDrLoc.subtract(amountCrLoc);
+					bills.setAmountDr(amountDr);
+					bills.setAmountCr(amountCr);
+					bills.setAmountProfit(amountProfit);
+					bills.setAmountDrUsd(amountDrUsd);
+					bills.setAmountCrUsd(amountCrUsd);
+					bills.setAmountProfitUsd(amountProfitUsd);
+					bills.setAmountDrLoc(amountDrLoc);
+					bills.setAmountCrLoc(amountCrLoc);
+					bills.setAmountProfitLoc(amountProfitLoc);
+					expenseApplication.setBills(bills);
+					List<FeeCenter> feeCenterListD = feeCenterList.stream().filter(e -> "D".equals(e.getDc())).collect(Collectors.toList());
+					List<FeeCenter> feeCenterListC = feeCenterList.stream().filter(e -> "C".equals(e.getDc())).collect(Collectors.toList());
 					expenseApplication.setFeeCenterList(feeCenterListD.isEmpty() ? new ArrayList<>() : feeCenterListD);
 					expenseApplication.setFeeCenterListC(feeCenterListC.isEmpty() ? new ArrayList<>() : feeCenterListC);
 				}
@@ -135,4 +284,95 @@ public class ReportsBoxServiceImpl implements IReportsBoxService {
 		}
 		return R.data(map);
 	}
+
+	/**
+	 * 海运进出口字典值转换
+	 *
+	 * @param bills 主表
+	 * @return 转换后数据
+	 */
+	private Bills dictionaryConversion(Bills bills) {
+		R<String> biz = dictBizClient.getOneValue("src_type_los", bills.getSrcType(), AuthUtil.getTenantId());
+		if (biz.isSuccess()) {
+			bills.setSrcType(biz.getData());
+		}
+		R<DictBiz> resDictBiz = dictBizClient.getDictBiz("payment_method_los", bills.getHpaymode(), AuthUtil.getTenantId());
+		if (resDictBiz.isSuccess() && ObjectUtils.isNotNull(resDictBiz.getData())) {
+			bills.setHpaymode(resDictBiz.getData().getRemark());
+		}
+		R<DictBiz> resDictBizM = dictBizClient.getDictBiz("payment_method_los", bills.getMpaymode(), AuthUtil.getTenantId());
+		if (resDictBizM.isSuccess() && ObjectUtils.isNotNull(resDictBizM.getData())) {
+			bills.setMpaymode(resDictBizM.getData().getRemark());
+		}
+		R<DictBiz> resDictBiz1 = dictBizClient.getDictBiz("issue_type_F", bills.getIssueType(), AuthUtil.getTenantId());
+		if (resDictBiz1.isSuccess() && ObjectUtils.isNotNull(resDictBiz1.getData())) {
+			bills.setIssueType(resDictBiz1.getData().getRemark());
+		}
+		return bills;
+	}
+
+	/**
+	 * 查询海运进出口明细从表并赋值到主表
+	 *
+	 * @param bills 主表
+	 * @return 赋值后数据
+	 */
+	private Bills assignmentSeaBillsDetail(Bills bills) {
+		// 提取分表
+		SeaBillsDetail seaBillsDetail = seaBillsDetailService.getOne(new LambdaQueryWrapper<SeaBillsDetail>()
+			.eq(SeaBillsDetail::getTenantId, AuthUtil.getTenantId())
+			.eq(SeaBillsDetail::getPid, bills.getId()));
+		if (seaBillsDetail != null) {
+			bills.setInttraToDoorCorpName(seaBillsDetail.getInttraToDoorCorpName());
+			bills.setInttraToDoorCorpAddr(seaBillsDetail.getInttraToDoorCorpAddr());
+			bills.setInttraToDoorCorpContacts(seaBillsDetail.getInttraToDoorCorpContacts());
+			bills.setInttraToDoorCorpTel(seaBillsDetail.getInttraToDoorCorpTel());
+			bills.setInttraDoorToCorpName(seaBillsDetail.getInttraDoorToCorpName());
+			bills.setInttraDoorToCorpAddr(seaBillsDetail.getInttraDoorToCorpAddr());
+			bills.setInttraDoorToCorpContacts(seaBillsDetail.getInttraDoorToCorpContacts());
+			bills.setInttraDoorToCorpTel(seaBillsDetail.getInttraDoorToCorpTel());
+			bills.setHshipperId(seaBillsDetail.getHshipperId());
+			bills.setHshipperCode(seaBillsDetail.getHshipperCode());
+			bills.setHshipperCnName(seaBillsDetail.getHshipperCnName());
+			bills.setHshipperEnName(seaBillsDetail.getHshipperEnName());
+			bills.setHshipperDetails(seaBillsDetail.getHshipperDetails());
+			bills.setHconsigneeId(seaBillsDetail.getHconsigneeId());
+			bills.setHconsigneeCode(seaBillsDetail.getHconsigneeCode());
+			bills.setHconsigneeCnName(seaBillsDetail.getHconsigneeCnName());
+			bills.setHconsigneeEnName(seaBillsDetail.getHconsigneeEnName());
+			bills.setHconsigneeDetails(seaBillsDetail.getHconsigneeDetails());
+			bills.setHnotifyId(seaBillsDetail.getHnotifyId());
+			bills.setHnotifyCode(seaBillsDetail.getHnotifyCode());
+			bills.setHnotifyCnName(seaBillsDetail.getHnotifyCnName());
+			bills.setHnotifyEnName(seaBillsDetail.getHnotifyEnName());
+			bills.setHnotifyDetails(seaBillsDetail.getHnotifyDetails());
+			bills.setHnotify2Id(seaBillsDetail.getHnotify2Id());
+			bills.setHnotify2Code(seaBillsDetail.getHnotify2Code());
+			bills.setHnotify2CnName(seaBillsDetail.getHnotify2CnName());
+			bills.setHnotify2EnName(seaBillsDetail.getHnotify2EnName());
+			bills.setHnotify2Details(seaBillsDetail.getHnotify2Details());
+			bills.setMshipperId(seaBillsDetail.getMshipperId());
+			bills.setMshipperCode(seaBillsDetail.getMshipperCode());
+			bills.setMshipperCnName(seaBillsDetail.getMshipperCnName());
+			bills.setMshipperEnName(seaBillsDetail.getMshipperEnName());
+			bills.setMshipperDetails(seaBillsDetail.getMshipperDetails());
+			bills.setMconsigneeId(seaBillsDetail.getMconsigneeId());
+			bills.setMconsigneeCode(seaBillsDetail.getMconsigneeCode());
+			bills.setMconsigneeCnName(seaBillsDetail.getMconsigneeCnName());
+			bills.setMconsigneeEnName(seaBillsDetail.getMconsigneeEnName());
+			bills.setMconsigneeDetails(seaBillsDetail.getMconsigneeDetails());
+			bills.setMnotifyId(seaBillsDetail.getMnotifyId());
+			bills.setMnotifyCode(seaBillsDetail.getMnotifyCode());
+			bills.setMnotifyCnName(seaBillsDetail.getMnotifyCnName());
+			bills.setMnotifyEnName(seaBillsDetail.getMnotifyEnName());
+			bills.setMnotifyDetails(seaBillsDetail.getMnotifyDetails());
+			bills.setMnotify2Id(seaBillsDetail.getMnotify2Id());
+			bills.setMnotify2Code(seaBillsDetail.getMnotify2Code());
+			bills.setMnotify2CnName(seaBillsDetail.getMnotify2CnName());
+			bills.setMnotify2EnName(seaBillsDetail.getMnotify2EnName());
+			bills.setMnotify2Details(seaBillsDetail.getMnotify2Details());
+			bills.setMforwarderDetails(seaBillsDetail.getMforwarderDetails());
+		}
+		return bills;
+	}
 }