Commit 4b5f9d11 by huluobin

Merge branch 'master' into 2.0

# Conflicts:
#	bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/cost/AbstractCostService.java
#	bailuntec-cost-core/src/main/resources/application-prod.yml
parents ad67fc05 11f8270a
......@@ -166,7 +166,9 @@ public class CostDetailController {
}
@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);
CostDetailDomain domain = createDomain(request);
......@@ -182,6 +184,7 @@ public class CostDetailController {
Integer update = costDetailService.update(domain);
if (null != update && update >= 1) {
costService.resetCost(domain.getCostNo());
result.put("detail", domain);
}
return result;
......@@ -199,7 +202,6 @@ public class CostDetailController {
domain.setCostReason(costReason);
domain.setAmount(new BigDecimal(amount));
domain.setKindNo(kindNo);
// domain.setDic(detailNo);
domain.setCostNo(costNo);
domain.setDetailNo(detailNo);
......
......@@ -20,12 +20,7 @@ import java.util.Map;
@Slf4j
@Api(tags = "费用计划接口")
@RestController
@RequestMapping(value = {"/cost/plan/"
//, "/cost/plan/new/lend1",
// "/cost/plan/new/lend2",
// "/cost/plan/new/pay",
// "/cost/plan/new/receipt"
})
@RequestMapping(value = {"/cost/plan/"})
public class CostPlanNewController {
......
......@@ -12,8 +12,6 @@ public interface CostDetailService {
void deleteFilePath(String detailNo);
CostDetailDomain getByCostNoAndKindNo(CostDetailDomain domain);
Integer update(CostDetailDomain domain);
}
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.service.CostDetailService;
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.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class CostDetailServiceImpl implements CostDetailService {
@Autowired
@Resource
private CostDetailDao costDetailDao;
@Resource
CostDao costDao;
@Override
public List<CostDetailDomain> getCostDetailListByCostNo(String costNo) {
List<CostDetailDomain> list = costDetailDao.selectListByCostNo(costNo);
return list;
return costDetailDao.selectListByCostNo(costNo);
}
@Override
......@@ -31,13 +37,31 @@ public class CostDetailServiceImpl implements CostDetailService {
costDetailDao.deletedFilePath(detailNo);
}
@Override
public CostDetailDomain getByCostNoAndKindNo(CostDetailDomain domain) {
return costDetailDao.selectListByCostNoAndKindNo(domain);
}
@Transactional
@Override
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);
}
}
......@@ -194,7 +194,6 @@ public abstract class AbstractCostService implements CostService {
// }
// }
if (ListUtil.isNotEmpty(costDomain.getAttach())) {
costDomain.getAttach().forEach(costAttach -> {
CostTemplateBaseCol costTemplateBaseCol = costTemplateBaseColMapper.selectById(costAttach.getCostTemplateBaseColId());
......@@ -214,20 +213,38 @@ public abstract class AbstractCostService implements CostService {
@Override
public void resetCost(String costNo) {
List<CostDetailDomain> costDetailDomains = costDetailDao.selectListByCostNo(costNo);
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) {
amount = amount.add(domain.getAmount());
}
CostDomain costDomain = new CostDomain();
costDomain.setCostNo(costNo);
CostDomain costDomain = costDao.selectByCostNo(costNo);
costDomain.setAmount(amount);
// costDomain.setKindNo(costDetailDomains.get(0).getKindNo());
// costDomain.setKindName(costDetailDomains.get(0).getKindName());
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.setKindName(costDetailDomains.get(0).getKindName());
costDomain.setTypeNo(costDetailDomains.get(0).getTypeNo());
costDomain.setTypeName(costDetailDomains.get(0).getTypeName());
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.update(costDomain, new LambdaQueryWrapper<CostDomain>()
.eq(CostDomain::getCostNo, costDomain.getCostNo()));
costDao.updateById(costDomain);
}
}
......
......@@ -83,8 +83,8 @@ public class CostPlanNewLend1ServiceImpl extends AbstractCostPlanService impleme
BigDecimal toRmbRate = CurUtils.getCur(costDomain.getDic(), "CNY");
costDomain.setToRmbRate(toRmbRate);
costDomain.setAmountRmb(costDomain.getAmount().multiply(toRmbRate).setScale(2, BigDecimal.ROUND_HALF_UP));
int insert = costDao.insert(costDomain);
int insert = costDao.insert(costDomain);
costLogService.save(costDomain.getCostNo(), costDomain.getCreateUserid(), "由费用计划:" + costDomain.getCostPlanNo() + " 生成借支单");
return insert;
}
......
......@@ -141,8 +141,8 @@ public class CostPlanTempServiceImpl implements CostPlanTempService {
return BigDecimal.ZERO;
}
@Override
@NonNull
public CostPlanTempDomain getByTempNo(@NonNull String tempNo) {
CostPlanTempDomain costPlanTempDomain = costPlanTempDao.selectByNo(tempNo);
if (costPlanTempDomain == null) {
......@@ -165,7 +165,6 @@ public class CostPlanTempServiceImpl implements CostPlanTempService {
if (req.getDelecteFile()) {
costPlanTempDao.deletedFilePath(req.getTempNo());
}
costPlanTempDao.update(costPlanTempDomain);
this.chalkResetDec(costPlanTempDomain.getCostPlanNo());
......@@ -184,7 +183,7 @@ public class CostPlanTempServiceImpl implements CostPlanTempService {
BigDecimal newAmount = tempListByPlanNo.stream().map(CostPlanTempDomain::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
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));
}
costPlanDao.update(plan, new LambdaQueryWrapper<CostPlanDomain>()
......
......@@ -154,4 +154,10 @@ class AbstractCostServiceTest {
@Test
void cashierCallbackPass() {
}
@Test
void resetCost() {
CostService costService = CostServiceFactory.getCostService();
costService.resetCost("F016523");
}
}
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