Commit 816a7edc by huluobin

bug fix

parent ba179149
...@@ -166,7 +166,9 @@ public class CostDetailController { ...@@ -166,7 +166,9 @@ public class CostDetailController {
} }
@PostMapping("/resetItem/file") @PostMapping("/resetItem/file")
public Map<String, Object> resetFile(HttpServletResponse response, HttpServletRequest request, @RequestParam("fileSelect2") MultipartFile file) { public Map<String, Object> resetFile(HttpServletResponse response,
HttpServletRequest request,
@RequestParam("fileSelect2") MultipartFile file) {
AxiosUtil.setCors(response, request); AxiosUtil.setCors(response, request);
CostDetailDomain domain = createDomain(request); CostDetailDomain domain = createDomain(request);
...@@ -182,6 +184,7 @@ public class CostDetailController { ...@@ -182,6 +184,7 @@ public class CostDetailController {
Integer update = costDetailService.update(domain); Integer update = costDetailService.update(domain);
if (null != update && update >= 1) { if (null != update && update >= 1) {
costService.resetCost(domain.getCostNo());
result.put("detail", domain); result.put("detail", domain);
} }
return result; return result;
...@@ -199,7 +202,6 @@ public class CostDetailController { ...@@ -199,7 +202,6 @@ public class CostDetailController {
domain.setCostReason(costReason); domain.setCostReason(costReason);
domain.setAmount(new BigDecimal(amount)); domain.setAmount(new BigDecimal(amount));
domain.setKindNo(kindNo); domain.setKindNo(kindNo);
// domain.setDic(detailNo);
domain.setCostNo(costNo); domain.setCostNo(costNo);
domain.setDetailNo(detailNo); domain.setDetailNo(detailNo);
......
...@@ -20,12 +20,7 @@ import java.util.Map; ...@@ -20,12 +20,7 @@ import java.util.Map;
@Slf4j @Slf4j
@Api(tags = "费用计划接口") @Api(tags = "费用计划接口")
@RestController @RestController
@RequestMapping(value = {"/cost/plan/" @RequestMapping(value = {"/cost/plan/"})
//, "/cost/plan/new/lend1",
// "/cost/plan/new/lend2",
// "/cost/plan/new/pay",
// "/cost/plan/new/receipt"
})
public class CostPlanNewController { public class CostPlanNewController {
......
...@@ -12,8 +12,6 @@ public interface CostDetailService { ...@@ -12,8 +12,6 @@ public interface CostDetailService {
void deleteFilePath(String detailNo); void deleteFilePath(String detailNo);
CostDetailDomain getByCostNoAndKindNo(CostDetailDomain domain);
Integer update(CostDetailDomain domain); Integer update(CostDetailDomain domain);
} }
package com.blt.other.module.cost.service.impl; package com.blt.other.module.cost.service.impl;
import com.blt.other.common.util.CurUtils;
import com.blt.other.module.cost.dao.CostDao;
import com.blt.other.module.cost.dao.CostDetailDao; import com.blt.other.module.cost.dao.CostDetailDao;
import com.blt.other.module.cost.service.CostDetailService;
import com.blt.other.module.cost.model.CostDetailDomain; import com.blt.other.module.cost.model.CostDetailDomain;
import org.springframework.beans.factory.annotation.Autowired; import com.blt.other.module.cost.model.CostDomain;
import com.blt.other.module.cost.service.CostDetailService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Service @Service
public class CostDetailServiceImpl implements CostDetailService { public class CostDetailServiceImpl implements CostDetailService {
@Autowired @Resource
private CostDetailDao costDetailDao; private CostDetailDao costDetailDao;
@Resource
CostDao costDao;
@Override @Override
public List<CostDetailDomain> getCostDetailListByCostNo(String costNo) { public List<CostDetailDomain> getCostDetailListByCostNo(String costNo) {
return costDetailDao.selectListByCostNo(costNo);
List<CostDetailDomain> list = costDetailDao.selectListByCostNo(costNo);
return list;
} }
@Override @Override
...@@ -31,13 +37,31 @@ public class CostDetailServiceImpl implements CostDetailService { ...@@ -31,13 +37,31 @@ public class CostDetailServiceImpl implements CostDetailService {
costDetailDao.deletedFilePath(detailNo); costDetailDao.deletedFilePath(detailNo);
} }
@Override
public CostDetailDomain getByCostNoAndKindNo(CostDetailDomain domain) {
return costDetailDao.selectListByCostNoAndKindNo(domain);
}
@Transactional
@Override @Override
public Integer update(CostDetailDomain domain) { public Integer update(CostDetailDomain domain) {
List<CostDetailDomain> costDetailDomainList = costDetailDao.selectListByCostNo(domain.getCostNo());
CostDomain costDomain = costDao.selectByCostNo(domain.getCostNo());
// //费用单总金额重新计算
// if (costDetailDomainList.stream().collect(Collectors.groupingBy(CostDetailDomain::getDic)).keySet().size() > 1) {
// throw new RuntimeException("请统一货币单位");
// }
// BigDecimal totalAmount = costDetailDomainList.stream().map(CostDetailDomain::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
// BigDecimal toRmbRate = CurUtils.getCur(costDomain.getDic(), "CNY");
//
// costDomain.setToRmbRate(toRmbRate);
// costDomain.setAmount(totalAmount);
// costDomain.setAmountRmb(totalAmount.multiply(toRmbRate).setScale(2, BigDecimal.ROUND_HALF_UP));
// costDomain.setDic(domain.getDic())
//更新费用单
return costDetailDao.update(domain); return costDetailDao.update(domain);
} }
} }
...@@ -213,7 +213,6 @@ public abstract class AbstractCostService implements CostService { ...@@ -213,7 +213,6 @@ public abstract class AbstractCostService implements CostService {
} }
} }
if (ListUtil.isNotEmpty(costDomain.getAttach())) { if (ListUtil.isNotEmpty(costDomain.getAttach())) {
costDomain.getAttach().forEach(costAttach -> { costDomain.getAttach().forEach(costAttach -> {
CostTemplateBaseCol costTemplateBaseCol = costTemplateBaseColMapper.selectById(costAttach.getCostTemplateBaseColId()); CostTemplateBaseCol costTemplateBaseCol = costTemplateBaseColMapper.selectById(costAttach.getCostTemplateBaseColId());
...@@ -233,20 +232,36 @@ public abstract class AbstractCostService implements CostService { ...@@ -233,20 +232,36 @@ public abstract class AbstractCostService implements CostService {
@Override @Override
public void resetCost(String costNo) { public void resetCost(String costNo) {
List<CostDetailDomain> costDetailDomains = costDetailDao.selectListByCostNo(costNo); List<CostDetailDomain> costDetailDomains = costDetailDao.selectListByCostNo(costNo);
BigDecimal amount = new BigDecimal(0); BigDecimal amount = new BigDecimal(0);
if (null != costDetailDomains && costDetailDomains.size() >= 1) { if (ListUtil.isNotEmpty(costDetailDomains)) {
//费用单总金额重新计算
if (costDetailDomains.stream().collect(Collectors.groupingBy(CostDetailDomain::getDic)).keySet().size() > 1) {
throw new RuntimeException("请统一货币单位");
}
for (CostDetailDomain domain : costDetailDomains) { for (CostDetailDomain domain : costDetailDomains) {
amount = amount.add(domain.getAmount()); amount = amount.add(domain.getAmount());
} }
CostDomain costDomain = new CostDomain(); CostDomain costDomain = costDao.selectByCostNo(costNo);
costDomain.setCostNo(costNo);
costDomain.setAmount(amount); costDomain.setAmount(amount);
BigDecimal toRmbRate = CurUtils.getCur(costDomain.getDic(), "CNY");
costDomain.setToRmbRate(toRmbRate);
costDomain.setAmountRmb(costDomain.getAmount().multiply(toRmbRate).setScale(2, BigDecimal.ROUND_HALF_UP));
costDomain.setKindNo(costDetailDomains.get(0).getKindNo()); costDomain.setKindNo(costDetailDomains.get(0).getKindNo());
costDomain.setKindName(costDetailDomains.get(0).getKindName()); costDomain.setKindName(costDetailDomains.get(0).getKindName());
costDomain.setTypeNo(costDetailDomains.get(0).getTypeNo());
costDomain.setTypeName(costDetailDomains.get(0).getTypeName());
costDomain.setLastModifyDate(LocalDateTime.now()); costDomain.setLastModifyDate(LocalDateTime.now());
costDao.update(costDomain, new LambdaQueryWrapper<CostDomain>()
.eq(CostDomain::getCostNo, costDomain.getCostNo())); costDao.updateById(costDomain);
} }
} }
...@@ -332,7 +347,6 @@ public abstract class AbstractCostService implements CostService { ...@@ -332,7 +347,6 @@ public abstract class AbstractCostService implements CostService {
public void cashierCallback(CashierCallbackUrlVo cashierCallbackUrlVo) { public void cashierCallback(CashierCallbackUrlVo cashierCallbackUrlVo) {
CostCashiercallbackDomain costCashiercallbackDomain = new CostCashiercallbackDomain(); CostCashiercallbackDomain costCashiercallbackDomain = new CostCashiercallbackDomain();
CashierCallbackUrlDataDataVo cashierCallbackUrlDataDataVo = JsonUtilByFsJson.jsonToBean( CashierCallbackUrlDataDataVo cashierCallbackUrlDataDataVo = JsonUtilByFsJson.jsonToBean(
cashierCallbackUrlVo.getData().getData().replaceAll("/^['|\"](.*)['|\"]$/", ""), cashierCallbackUrlVo.getData().getData().replaceAll("/^['|\"](.*)['|\"]$/", ""),
......
...@@ -6,7 +6,10 @@ import com.blt.other.common.util.CurUtils; ...@@ -6,7 +6,10 @@ import com.blt.other.common.util.CurUtils;
import com.blt.other.common.util.PathUtil; import com.blt.other.common.util.PathUtil;
import com.blt.other.module.cost.dao.CostPlanDao; import com.blt.other.module.cost.dao.CostPlanDao;
import com.blt.other.module.cost.dao.CostPlanTempDao; import com.blt.other.module.cost.dao.CostPlanTempDao;
import com.blt.other.module.cost.dto.*; import com.blt.other.module.cost.dto.AddItemReq;
import com.blt.other.module.cost.dto.AddItemResp;
import com.blt.other.module.cost.dto.GetCostTempByPlanNoResp;
import com.blt.other.module.cost.dto.ResetItemReq;
import com.blt.other.module.cost.service.CostPlanTempService; import com.blt.other.module.cost.service.CostPlanTempService;
import com.blt.other.module.cost.service.CostTypeKindService; import com.blt.other.module.cost.service.CostTypeKindService;
import com.blt.other.module.cost.utils.CostFileUtil; import com.blt.other.module.cost.utils.CostFileUtil;
...@@ -15,7 +18,6 @@ import com.blt.other.module.database.model.CostPlanTempDomain; ...@@ -15,7 +18,6 @@ import com.blt.other.module.database.model.CostPlanTempDomain;
import com.blt.other.module.database.model.CostTypeKindDomain; import com.blt.other.module.database.model.CostTypeKindDomain;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.lang.NonNull; import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -139,8 +141,8 @@ public class CostPlanTempServiceImpl implements CostPlanTempService { ...@@ -139,8 +141,8 @@ public class CostPlanTempServiceImpl implements CostPlanTempService {
return BigDecimal.ZERO; return BigDecimal.ZERO;
} }
@Override @Override
@NonNull
public CostPlanTempDomain getByTempNo(@NonNull String tempNo) { public CostPlanTempDomain getByTempNo(@NonNull String tempNo) {
CostPlanTempDomain costPlanTempDomain = costPlanTempDao.selectByNo(tempNo); CostPlanTempDomain costPlanTempDomain = costPlanTempDao.selectByNo(tempNo);
if (costPlanTempDomain == null) { if (costPlanTempDomain == null) {
...@@ -163,7 +165,6 @@ public class CostPlanTempServiceImpl implements CostPlanTempService { ...@@ -163,7 +165,6 @@ public class CostPlanTempServiceImpl implements CostPlanTempService {
if (req.getDelecteFile()) { if (req.getDelecteFile()) {
costPlanTempDao.deletedFilePath(req.getTempNo()); costPlanTempDao.deletedFilePath(req.getTempNo());
} }
costPlanTempDao.update(costPlanTempDomain); costPlanTempDao.update(costPlanTempDomain);
this.chalkResetDec(costPlanTempDomain.getCostPlanNo()); this.chalkResetDec(costPlanTempDomain.getCostPlanNo());
...@@ -182,7 +183,7 @@ public class CostPlanTempServiceImpl implements CostPlanTempService { ...@@ -182,7 +183,7 @@ public class CostPlanTempServiceImpl implements CostPlanTempService {
BigDecimal newAmount = tempListByPlanNo.stream().map(CostPlanTempDomain::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal newAmount = tempListByPlanNo.stream().map(CostPlanTempDomain::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
plan.setPlanAmount(newAmount); plan.setPlanAmount(newAmount);
if (1 == plan.getCostForm() && (null != plan.getIsLend() && 2 == plan.getIsLend())) { if (plan.getCostForm() == 1 && (null != plan.getIsLend() && 2 == plan.getIsLend())) {
plan.setPayPlanAmount(newAmount.divide(plan.getPayCur(), 4)); plan.setPayPlanAmount(newAmount.divide(plan.getPayCur(), 4));
} }
costPlanDao.update(plan, new LambdaQueryWrapper<CostPlanDomain>() costPlanDao.update(plan, new LambdaQueryWrapper<CostPlanDomain>()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment