更新名称

This commit is contained in:
钱涛 2023-02-17 17:19:17 +08:00
parent dc24b03efd
commit c7d1bbfa35
4 changed files with 55 additions and 2 deletions

View File

@ -0,0 +1,7 @@
update hrsa_tax_agent_emp set delete_type = 1
where id in(
select id from hrsa_tax_agent_emp
where tax_agent_id =27 and delete_type = 0 and employee_id not in (select employee_id from hrsa_salary_archive where tax_agent_id =27 and delete_type = 0)
)

View File

@ -47,4 +47,12 @@ public interface SalaryFormulaService {
void deleteNotIn(List<Long> formulaIds);
List<FormulaVar> listVarByFormulaIds(List<Long> effectiveFormulaIds);
List<FormulaVar> listByCode(String code);
void updateVar(FormulaVar formulaVar);
List<FormulaPO> listByIds(List<Long> formulaIds);
void update(FormulaPO formulaPO);
}

View File

@ -385,4 +385,24 @@ public class SalaryFormulaServiceImpl extends Service implements SalaryFormulaSe
return vars;
}
@Override
public List<FormulaVar> listByCode(String code) {
return getFormulaVarMapper().listSome(FormulaVar.builder().fieldId(code).build());
}
@Override
public void updateVar(FormulaVar formulaVar) {
getFormulaVarMapper().updateIgnoreNull(formulaVar);
}
@Override
public List<FormulaPO> listByIds(List<Long> formulaIds) {
return getFormulaMapper().listByIds(formulaIds);
}
@Override
public void update(FormulaPO formulaPO) {
getFormulaMapper().updateIgnoreNull(formulaPO);
}
}

View File

@ -5,6 +5,7 @@ import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.SalaryItemBiz;
import com.engine.salary.biz.SysSalaryItemBiz;
import com.engine.salary.entity.salaryformula.po.FormulaPO;
import com.engine.salary.entity.salaryformula.po.FormulaVar;
import com.engine.salary.entity.salaryitem.bo.SalaryItemBO;
import com.engine.salary.entity.salaryitem.param.SalaryItemSaveParam;
@ -223,6 +224,25 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
String oldName = salaryItemPO.getName();
String newName = saveParam.getName();
if (!StringUtils.equals(oldName, newName)) {
String code = "salaryItem_" + salaryItemPO.getCode();
List<FormulaVar> formulaVars = getSalaryFormulaService(user).listByCode(code);
formulaVars.forEach(v -> {
FormulaVar formulaVar = new FormulaVar();
formulaVar.setId(v.getId());
formulaVar.setName("薪资项目." + newName);
getSalaryFormulaService(user).updateVar(formulaVar);
});
List<Long> formulaIds = SalaryEntityUtil.properties(formulaVars, FormulaVar::getFormulaId, Collectors.toList());
List<FormulaPO> formulaPOS = getSalaryFormulaService(user).listByIds(formulaIds);
formulaPOS.forEach(f->{
String formula = f.getFormula();
formula = formula.replace(String.format("{薪资项目.%s}", oldName), String.format("{薪资项目.%s}", newName));
FormulaPO formulaPO = new FormulaPO();
formulaPO.setId(f.getId());
formulaPO.setFormula(formula);
getSalaryFormulaService(user).update(formulaPO);
});
}
@ -336,7 +356,6 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
}
public UsingItem getUsingItem(Long id) {
//薪资项目
@ -349,7 +368,6 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
List<SalarySobBackItemPO> backItems = getSalarySobBackItemService(user).listBySalaryItemIds(Collections.singleton(id));
// //账套里的项目项目里的项目
// List<Long> sobItemIds = SalaryEntityUtil.properties(sobItems, SalarySobItemPO::getSalaryItemId, Collectors.toList());
// List<Long> backItemIds = SalaryEntityUtil.properties(backItems, SalarySobBackItemPO::getSalaryItemId, Collectors.toList());