Commit 3d2a4f9d by huluobin

bug fix

parent 0dc76b10
......@@ -3,6 +3,8 @@ package com.blt.other.module.cost.dao;
import com.blt.other.module.cost.model.CostTemplateCol;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
* <p>
* 费用单模版 Mapper 接口
......@@ -13,4 +15,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface CostTemplateColMapper extends BaseMapper<CostTemplateCol> {
List<CostTemplateCol> selectByTemplateId(Integer costTemplateId);
}
......@@ -63,7 +63,6 @@ public class CostTemplateCol implements Serializable {
private String companyScope;
@TableField(exist = false)
private String companyScopeStr;
@TableField(exist = false)
......
......@@ -5,6 +5,7 @@ import com.bailuntec.common.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blt.other.common.exception.BizRuntimeException;
import com.blt.other.module.cost.dao.CostCompanyDao;
import com.blt.other.module.cost.dao.CostTemplateColMapper;
import com.blt.other.module.cost.dto.CostTemplateColApiReq;
import com.blt.other.module.cost.model.CostTemplate;
......@@ -12,6 +13,7 @@ import com.blt.other.module.cost.model.CostTemplateCol;
import com.blt.other.module.cost.service.ICostTemplateBaseColService;
import com.blt.other.module.cost.service.ICostTemplateColService;
import com.blt.other.module.cost.service.ICostTemplateService;
import com.google.common.collect.Lists;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -33,6 +35,8 @@ public class CostTemplateColServiceImpl extends ServiceImpl<CostTemplateColMappe
ICostTemplateService costTemplateService;
@Resource
ICostTemplateBaseColService costTemplateBaseColService;
@Resource
CostCompanyDao costCompanyDao;
@Override
public void delete(Integer id) {
......@@ -41,6 +45,13 @@ public class CostTemplateColServiceImpl extends ServiceImpl<CostTemplateColMappe
throw new BizRuntimeException("unable to remove default costTemplateCol");
}
this.removeById(id);
List<CostTemplateCol> costTemplateColList = baseMapper.selectByTemplateId(costTemplateCol.getCostTemplateId());
CostTemplate costTemplate = costTemplateService.getById(costTemplateCol.getCostTemplateId());
costTemplate.setSetAutoCheck(ListUtil.isNotEmpty(costTemplateColList.stream()
.filter(item -> item.getAutoRuleType() > 0)
.collect(Collectors.toList())));
costTemplateService.updateById(costTemplate);
}
@Override
......@@ -48,15 +59,38 @@ public class CostTemplateColServiceImpl extends ServiceImpl<CostTemplateColMappe
if (costTemplateCol.getIsDefault()) {
throw new BizRuntimeException("unable to modify default costTemplateCol");
}
costTemplateCol.setCompanyScopeStr(this.getCompanyScopeStr(costTemplateCol.getCompanyScope()));
this.updateById(costTemplateCol);
if (costTemplateCol.getCostTemplateBaseCol() != null) {
costTemplateBaseColService.updateById(costTemplateCol.getCostTemplateBaseCol());
}
}
@Override
public void add(CostTemplateCol costTemplateCol) {
costTemplateCol.setCompanyScopeStr(this.getCompanyScopeStr(costTemplateCol.getCompanyScope()));
this.save(costTemplateCol);
CostTemplate costTemplate = costTemplateService.getById(costTemplateCol.getCostTemplateId());
costTemplate.setSetAutoCheck(true);
costTemplateService.updateById(costTemplate);
}
/**
* 获取公司主体范围中文
*
* @param companyScope 公司主体范围no 逗号分割
* @return 取公司主体范围中文 逗号分割
*/
private String getCompanyScopeStr(String companyScope) {
return Lists.newArrayList(companyScope.split(","))
.stream()
.map(companyNo -> costCompanyDao.selectByNo(companyNo).getCompanyName())
.collect(Collectors.joining(","));
}
@Override
......
......@@ -2,4 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.blt.other.module.cost.dao.CostTemplateColMapper">
<select id="selectByTemplateId" resultType="com.blt.other.module.cost.model.CostTemplateCol">
select * from cost_template_col where cost_template_id = #{costTemplateId}
</select>
</mapper>
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