!17 台账保存核算

Merge pull request !17 from reset/archive
This commit is contained in:
reset 2022-04-14 03:56:10 +00:00 committed by Gitee
commit 23388ef017
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
22 changed files with 1661 additions and 52 deletions

View File

@ -1,18 +1,65 @@
package com.engine.salary.biz;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctProgressDTO;
import com.engine.salary.entity.siaccount.param.AccountParam;
import com.engine.salary.entity.siaccount.param.DSTenantKeyThreadVar;
import com.engine.salary.entity.siaccount.param.InsuranceAccountBatchParam;
import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam;
import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO;
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailTempPO;
import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesAccountPO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO;
import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO;
import com.engine.salary.enums.siaccount.BillStatusEnum;
import com.engine.salary.enums.siaccount.InspectStatusEnum;
import com.engine.salary.enums.siaccount.PaymentStatusEnum;
import com.engine.salary.enums.siaccount.ResourceFromEnum;
import com.engine.salary.enums.sicategory.DeleteTypeEnum;
import com.engine.salary.enums.sicategory.IsPaymentEnum;
import com.engine.salary.enums.sicategory.NonPaymentEnum;
import com.engine.salary.enums.sicategory.PaymentScopeEnum;
import com.engine.salary.mapper.datacollection.EmployMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountInspectMapper;
import com.engine.salary.mapper.siaccount.SIAccountDetailTempMapper;
import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper;
import com.engine.salary.util.SalaryAssert;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.PageUtil;
import dm.jdbc.util.IdGenerator;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.BeanUtils;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import weaver.conn.mybatis.MyBatisFactory;
import java.util.List;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* @Author weaver_cl
@ -50,4 +97,615 @@ public class SIAccountBiz {
sqlSession.close();
}
}
public void save(boolean flag, AccountParam param,Long employeeId,String username) {
if (flag) {
InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(param.getBillMonth());
SalaryAssert.isNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel( 100461, "所属月份存在核算数据"));
InsuranceAccountBatchPO build = InsuranceAccountBatchPO.builder()
//.id(IdGenerator.generate())
.accountant(username)
.billMonth(param.getBillMonth())
.billStatus(BillStatusEnum.NOT_ARCHIVED.getValue())
.remarks(param.getRemarks())
.creator(employeeId)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.createTime(new Date())
.updateTime(new Date())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.build();
MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).insert(build);
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.valueOf(build.getId()));
// insuranceSchemeContext.setTargetName(build.getBillMonth());
// insuranceSchemeContext.setOperateType(OperateTypeEnum.ADD.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账"));
// insuranceSchemeContext.setNewValues(build);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
}
account(param.getBillMonth(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
}
public void account(String billMonth, Long employeeId, String tenantKey) {
List<Long> employeeIds = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectAccountIds(SalaryDateUtil.getMonthBegin(billMonth));
if (CollectionUtils.isEmpty(employeeIds)) {
List<InsuranceAccountBatchPO> list = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getAllByBillMonth(billMonth);
if (CollectionUtils.isNotEmpty(list)) {
list.stream().forEach(f -> {
MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).deleteById(f.getId());
});
}
}
SalaryAssert.notEmpty(employeeIds, "no account data");
AccountParam param = new AccountParam();
param.setBillMonth(billMonth);
ExecutorService taskExecutor = Executors.newCachedThreadPool();
taskExecutor.execute(() -> {
try {
DSTenantKeyThreadVar.tenantKey.set(tenantKey);
accounting(param, employeeId, tenantKey);
} finally {
DSTenantKeyThreadVar.tenantKey.remove();
}
});
}
public void accounting(AccountParam param, Long employeeId, String tenantKey) {
//薪资核算进度暂未实现
// SalaryAcctProgressDTO salaryAcctProgressDTO = salaryAcctProgressService.getProgress(tenantKey + param.getBillMonth(), employeeId, tenantKey);
// if (salaryAcctProgressDTO != null && salaryAcctProgressDTO.getProgress().compareTo(BigDecimal.ONE) < 0) {
// return;
// }
doAccounting(param, employeeId, tenantKey);
}
@Transactional(propagation = Propagation.NEVER, rollbackFor = Exception.class)
public void doAccounting(AccountParam param, Long employeeId, String tenantKey) {
try {
List<Long> ids;
if (CollectionUtils.isEmpty(param.getIds())) {
ids = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectAccountIds(SalaryDateUtil.getMonthBegin(param.getBillMonth()));
} else {
ids = param.getIds();
}
if (CollectionUtils.isEmpty(ids)) {
//salaryAcctProgressService.fail(tenantKey + param.getBillMonth(), SalaryI18nUtil.getI18nLabel( 100468, "无需要核算的人员"));
return;
}
SalaryAcctProgressDTO salaryAcctProgressDTO = new SalaryAcctProgressDTO(SalaryI18nUtil.getI18nLabel( 97515, "核算中"), 97515L, ids.size(), 0,
BigDecimal.ZERO, true, "", true);
//salaryAcctProgressService.initProgress(tenantKey + param.getBillMonth(), salaryAcctProgressDTO, employeeId, tenantKey);
/* List<List<Long>> partition = Lists.partition(ids, 100);
CountDownLatch countDownLatch = new CountDownLatch(partition.size());
BlockingDeque<Boolean> results = new LinkedBlockingDeque<>(partition.size());*/
commonAccount(/*countDownLatch, results, */param.getBillMonth(), ids, employeeId, tenantKey);
/* for (List<Long> batchIds : partition) {
taskExecutor.execute(() -> {
commonAccount(countDownLatch, results, param.getBillMonth(), batchIds, simpleEmployee);
});
}
countDownLatch.await();
boolean allSuccess = results.stream().allMatch(Boolean::booleanValue);*/
/* if (allSuccess) {*/
handleData(ids, param.getBillMonth(), employeeId, tenantKey);
/*}*/
MapperProxyFactory.getProxy(SIAccountDetailTempMapper.class).batchDelAccountTempDetails(ids, param.getBillMonth());
} catch (Exception e) {
List<InsuranceAccountBatchPO> list = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getAllByBillMonth(param.getBillMonth());
if (CollectionUtils.isNotEmpty(list)) {
list.stream().forEach(f -> {
MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).deleteById(f.getId());
});
}
//薪资核算进度暂未实现
//salaryAcctProgressService.del(tenantKey + param.getBillMonth(), employeeId, tenantKey);
//logger.error("welfare account error:{}", e.getMessage(), e);
}
}
public void commonAccount(/*CountDownLatch countDownLatch, BlockingDeque<Boolean> results,*/ String billMonth, List<Long> ids, Long employeeId, String tenantKey) {
/* try {*/
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
Map<Long, InsuranceArchivesAccountPO> insuranceArchivesAccountPOS = siArchivesBiz.buildBatchAccount(ids, tenantKey);
List<InsuranceAccountDetailTempPO> list = new ArrayList<>();
int count = 0;
for (Map.Entry<Long, InsuranceArchivesAccountPO> entry : insuranceArchivesAccountPOS.entrySet()) {
Long k = entry.getKey();
InsuranceArchivesAccountPO v = entry.getValue();
InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO();
insuranceAccountDetailPO.setBillMonth(billMonth);
insuranceAccountDetailPO.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue());
insuranceAccountDetailPO.setCreator(employeeId);
insuranceAccountDetailPO.setCreateTime(new Date());
insuranceAccountDetailPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
//insuranceAccountDetailPO.setId(IdGenerator.generate());
insuranceAccountDetailPO.setEmployeeId(k);
insuranceAccountDetailPO.setUpdateTime(new Date());
insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.COMMON.getValue());
insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.SYSTEM.getValue());
insuranceAccountDetailPO.setTenantKey(tenantKey);
//核算社保
accountSocial(insuranceAccountDetailPO, v, tenantKey);
//核算公积金
accountFund(insuranceAccountDetailPO, v, tenantKey);
//核算其他福利
accountOther(insuranceAccountDetailPO, v, tenantKey);
//计算合计
account(insuranceAccountDetailPO);
//临时表PO
InsuranceAccountDetailTempPO insuranceAccountDetailTempPO = new InsuranceAccountDetailTempPO();
BeanUtils.copyProperties(insuranceAccountDetailPO, insuranceAccountDetailTempPO);
list.add(insuranceAccountDetailTempPO);
count++;
if (count % 50 == 0 || count >= ids.size()) {
//salaryAcctProgressService.getAndAddCalculatedQty(tenantKey + billMonth, count >= ids.size() ? count % 50 : 50);
}
}
if (CollectionUtils.isNotEmpty(list)) {
MapperProxyFactory.getProxy(SIAccountDetailTempMapper.class).batchSaveAccountTempDetails(list);
}
/* } catch (Exception e) {
logger.error("福利核算失败:{}", e.getMessage(), e);
results.add(false);
} finally {
countDownLatch.countDown();
}*/
}
private void handleData(List<Long> ids, String billMonth, Long employeeId, String tenantKey) {
//事务后续处理
//TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
try {
List<InsuranceAccountDetailTempPO> list = MapperProxyFactory.getProxy(SIAccountDetailTempMapper.class).getListByEmployeeIdsAndBillMonth(ids,billMonth);
MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchDelAccountDetails(ids, billMonth);
List<InsuranceAccountDetailPO> collect = list.stream().map(item -> {
InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO();
BeanUtils.copyProperties(item, insuranceAccountDetailPO);
return insuranceAccountDetailPO;
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
batchSaveAccountInspectDetail(collect, billMonth, tenantKey);
MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchSaveAccountDetails(collect);
updateBatchAccount(billMonth, employeeId, tenantKey);
}
//transactionManager.commit(status);
} catch (Exception e) {
//transactionManager.rollback(status);
throw e;
}
}
public InsuranceAccountDetailPO account(InsuranceAccountDetailPO insuranceAccountDetailPO) {
//个人合计
BigDecimal socialPerson =
StringUtils.isBlank(insuranceAccountDetailPO.getSocialPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialPerSum());
BigDecimal fundPerson =
StringUtils.isBlank(insuranceAccountDetailPO.getFundPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundPerSum());
BigDecimal otherPerson =
StringUtils.isBlank(insuranceAccountDetailPO.getOtherPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherPerSum());
BigDecimal perSum = socialPerson.add(fundPerson).add(otherPerson);
insuranceAccountDetailPO.setPerSum(perSum.toPlainString());
//单位合计
BigDecimal socialCom =
StringUtils.isBlank(insuranceAccountDetailPO.getSocialComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialComSum());
BigDecimal fundCom = StringUtils.isBlank(insuranceAccountDetailPO.getFundComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundComSum());
BigDecimal otherCom =
StringUtils.isBlank(insuranceAccountDetailPO.getOtherComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherComSum());
BigDecimal comSum = socialCom.add(fundCom).add(otherCom);
insuranceAccountDetailPO.setComSum(comSum.toPlainString());
//社保合计
insuranceAccountDetailPO.setSocialSum(socialPerson.add(socialCom).toPlainString());
//公积金合计
insuranceAccountDetailPO.setFundSum(fundPerson.add(fundCom).toPlainString());
//其他福利合计
insuranceAccountDetailPO.setOtherSum(otherPerson.add(otherCom).toPlainString());
//合计
insuranceAccountDetailPO.setTotal(perSum.add(comSum).toPlainString());
return insuranceAccountDetailPO;
}
public InsuranceAccountDetailPO accountOther(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String tenantKey) {
if (accountPO.getOther() != null) {
InsuranceArchivesOtherSchemePO otherPO = accountPO.getOther();
insuranceAccountDetailPO.setOtherPayOrg(otherPO.getPaymentOrganization());
insuranceAccountDetailPO.setOtherSchemeId(otherPO.getOtherSchemeId());
insuranceAccountDetailPO.setOtherPaymentBaseString(otherPO.getOtherPaymentBaseString());
if ((Objects.equals(NonPaymentEnum.YES.getValue(), otherPO.getNonPayment()) || otherPO.getNonPayment() == null) && otherPO.getOtherSchemeId() != null) {
List<InsuranceSchemeDetailPO> detailPOS = MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class).queryListBySchemeId(otherPO.getOtherSchemeId());
//方案中包含的需要缴纳其他的个人福利
Map<Long, InsuranceSchemeDetailPO> otherPerson = detailPOS.stream()
.filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && item.getPaymentScope() == PaymentScopeEnum.SCOPE_PERSON.getValue())
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesPerson = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算其他的福利id 个人
List<Long> needArchivesPerson = new ArrayList<>();
archivesPerson.forEach((id, value) -> {
if (otherPerson.containsKey(Long.valueOf(id))) {
needArchivesPerson.add(Long.valueOf(id));
}
});
List<BigDecimal> otherPer = new ArrayList<>();
Map<String, String> otherPerJsonMap = new HashMap<>();
needArchivesPerson.stream().forEach(e -> {
InsuranceSchemeDetailPO po = otherPerson.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal(StringUtils.isBlank(archivesPerson.get(String.valueOf(e))) ? "0" : archivesPerson.get(String.valueOf(e)));
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
;
otherPerJsonMap.put(String.valueOf(e), result.toPlainString());
otherPer.add(result);
});
insuranceAccountDetailPO.setOtherPerJson(JSON.toJSONString(otherPerJsonMap));
BigDecimal otherPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : otherPer) {
otherPerSum = otherPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString());
//方案中包含的需要缴纳公积金的单位福利
Map<Long, InsuranceSchemeDetailPO> otherCom = detailPOS.stream()
.filter(
item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && item.getPaymentScope() == PaymentScopeEnum.SCOPE_COMPANY.getValue())
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesCom = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算其他的福利id 单位
List<Long> needArchivesCom = new ArrayList<>();
archivesCom.forEach((id, value) -> {
if (otherCom.containsKey(Long.valueOf(id))) {
needArchivesCom.add(Long.valueOf(id));
}
});
List<BigDecimal> otherComList = new ArrayList<>();
Map<String, String> otherComJsonMap = new HashMap<>();
needArchivesCom.stream().forEach(e -> {
InsuranceSchemeDetailPO po = otherCom.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal(StringUtils.isBlank(archivesCom.get(String.valueOf(e))) ? "0" : archivesCom.get(String.valueOf(e)));
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
;
otherComJsonMap.put(String.valueOf(e), result.toPlainString());
otherComList.add(result);
});
insuranceAccountDetailPO.setOtherComJson(JSON.toJSONString(otherComJsonMap));
BigDecimal otherComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : otherComList) {
otherComSum = otherComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString());
}
}
return insuranceAccountDetailPO;
}
public InsuranceAccountDetailPO accountFund(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String tenantKey) {
if (accountPO.getFund() != null) {
InsuranceArchivesFundSchemePO fundPO = accountPO.getFund();
insuranceAccountDetailPO.setFundPayOrg(fundPO.getPaymentOrganization());
insuranceAccountDetailPO.setFundAccount(fundPO.getFundAccount());
insuranceAccountDetailPO.setSupplementFundAccount(fundPO.getSupplementFundAccount());
insuranceAccountDetailPO.setFundSchemeId(fundPO.getFundSchemeId());
insuranceAccountDetailPO.setFundPaymentBaseString(fundPO.getFundPaymentBaseString());
if ((NonPaymentEnum.YES.getValue() == fundPO.getNonPayment() || fundPO.getNonPayment() == null) && fundPO.getFundSchemeId() != null) {
List<InsuranceSchemeDetailPO> detailPOS = MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class).queryListBySchemeId(fundPO.getFundSchemeId());
//方案中包含的需要缴纳社保的个人福利
Map<Long, InsuranceSchemeDetailPO> fundperson = detailPOS.stream()
.filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_PERSON.getValue())
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesPerson = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算公积金的福利id 个人
List<Long> needArchivesPerson = new ArrayList<>();
archivesPerson.forEach((id, value) -> {
if (fundperson.containsKey(Long.valueOf(id))) {
needArchivesPerson.add(Long.valueOf(id));
}
});
List<BigDecimal> fundPer = new ArrayList<>();
Map<String, String> fundPerJsonMap = new HashMap<>();
needArchivesPerson.stream().forEach(e -> {
InsuranceSchemeDetailPO po = fundperson.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal(StringUtils.isBlank(archivesPerson.get(String.valueOf(e))) ? "0" : archivesPerson.get(String.valueOf(e)));
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
;
fundPerJsonMap.put(String.valueOf(e), result.toPlainString());
fundPer.add(result);
});
insuranceAccountDetailPO.setFundPerJson(JSON.toJSONString(fundPerJsonMap));
BigDecimal funPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : fundPer) {
funPerSum = funPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setFundPerSum(funPerSum.toPlainString());
//方案中包含的需要缴纳公积金的单位福利
Map<Long, InsuranceSchemeDetailPO> fundCom = detailPOS.stream()
.filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_COMPANY.getValue())
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesCom = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算公积金的福利id 单位
List<Long> needArchivesCom = new ArrayList<>();
archivesCom.forEach((id, value) -> {
if (fundCom.containsKey(Long.valueOf(id))) {
needArchivesCom.add(Long.valueOf(id));
}
});
List<BigDecimal> fundComList = new ArrayList<>();
Map<String, String> fundComJsonMap = new HashMap<>();
needArchivesCom.stream().forEach(e -> {
InsuranceSchemeDetailPO po = fundCom.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal(StringUtils.isBlank(archivesCom.get(String.valueOf(e))) ? "0" : archivesCom.get(String.valueOf(e)));
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
;
fundComJsonMap.put(String.valueOf(e), result.toPlainString());
fundComList.add(result);
});
insuranceAccountDetailPO.setFundComJson(JSON.toJSONString(fundComJsonMap));
BigDecimal fundComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : fundComList) {
fundComSum = fundComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString());
}
}
return insuranceAccountDetailPO;
}
public InsuranceAccountDetailPO accountSocial(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String tenantKey) {
if (accountPO.getSocial() != null) {
InsuranceArchivesSocialSchemePO socialPO = accountPO.getSocial();
insuranceAccountDetailPO.setSocialPayOrg(socialPO.getPaymentOrganization());
insuranceAccountDetailPO.setSocialAccount(socialPO.getSocialAccount());
insuranceAccountDetailPO.setSocialSchemeId(socialPO.getSocialSchemeId());
insuranceAccountDetailPO.setSocialPaymentBaseString(socialPO.getSocialPaymentBaseString());
if ((NonPaymentEnum.YES.getValue() == socialPO.getNonPayment() || socialPO.getNonPayment() == null) && socialPO.getSocialSchemeId() != null) {
List<InsuranceSchemeDetailPO> detailPOS = MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class).queryListBySchemeId(socialPO.getSocialSchemeId());
//方案中包含的需要缴纳社保的个人福利
Map<Long, InsuranceSchemeDetailPO> schemeperson = detailPOS.stream()
.filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_PERSON.getValue())
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算社保的福利id 个人
List<Long> needArchivesPerson = new ArrayList<>();
archivesPerson.forEach((id, value) -> {
if (schemeperson.containsKey(Long.valueOf(id))) {
needArchivesPerson.add(Long.valueOf(id));
}
});
List<BigDecimal> socialPer = new ArrayList<>();
Map<String, String> socialPerJsonMap = new HashMap<>();
needArchivesPerson.stream().forEach(e -> {
InsuranceSchemeDetailPO po = schemeperson.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal(StringUtils.isBlank(archivesPerson.get(String.valueOf(e))) ? "0" : archivesPerson.get(String.valueOf(e)));
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
;
socialPerJsonMap.put(String.valueOf(e), result.toPlainString());
socialPer.add(result);
});
insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerJsonMap));
BigDecimal socialPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : socialPer) {
socialPerSum = socialPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString());
//方案中包含的需要缴纳社保的单位福利
Map<Long, InsuranceSchemeDetailPO> schemeCom = detailPOS.stream()
.filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_COMPANY.getValue())
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算社保的福利id 单位
List<Long> needArchivesCom = new ArrayList<>();
archivesCom.forEach((id, value) -> {
if (schemeCom.containsKey(Long.valueOf(id))) {
needArchivesCom.add(Long.valueOf(id));
}
});
List<BigDecimal> socialCom = new ArrayList<>();
Map<String, String> sociaComJsonMap = new HashMap<>();
needArchivesCom.stream().forEach(e -> {
InsuranceSchemeDetailPO po = schemeCom.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal(StringUtils.isBlank(archivesCom.get(String.valueOf(e))) ? "0" : archivesCom.get(String.valueOf(e)));
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
sociaComJsonMap.put(String.valueOf(e), result.toPlainString());
socialCom.add(result);
});
insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(sociaComJsonMap));
BigDecimal socialComSum = new BigDecimal("0");
for (BigDecimal decimal : socialCom) {
socialComSum = socialComSum.add(decimal);
}
insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString());
}
}
return insuranceAccountDetailPO;
}
public void batchSaveAccountInspectDetail(List<InsuranceAccountDetailPO> list, String billMonth, String tenantKey) {
List<InsuranceAccountInspectPO> insuranceAccountInspectAllPOS = accountInspect(list, true);
batchDelInspectDetail(insuranceAccountInspectAllPOS);
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = accountInspect(list, false);
if (CollectionUtils.isNotEmpty(insuranceAccountInspectPOS)) {
batchSaveInspectDetail(insuranceAccountInspectPOS);
}
}
public List<InsuranceAccountInspectPO> accountInspect(List<InsuranceAccountDetailPO> list, boolean isAll) {
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = new ArrayList<>();
for (InsuranceAccountDetailPO e : list) {
if (isAll || detailCheck(e.getSocialPerJson()) || detailCheck(e.getSocialComJson())
|| detailCheck(e.getFundPerJson()) || detailCheck(e.getFundComJson())
|| detailCheck(e.getOtherPerJson()) || detailCheck(e.getOtherComJson())) {
InsuranceAccountInspectPO insuranceAccountInspectPO = InsuranceAccountInspectPO.builder().build();
insuranceAccountInspectPO.setId(IdGenerator.generate());
insuranceAccountInspectPO.setSupplementaryProjects(e.getSupplementaryProjects());
insuranceAccountInspectPO.setInspectStatus(InspectStatusEnum.IGNORE.getValue());
insuranceAccountInspectPO.setBillMonth(e.getBillMonth());
insuranceAccountInspectPO.setCreator(e.getCreator());
insuranceAccountInspectPO.setCreateTime(new Date());
insuranceAccountInspectPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
insuranceAccountInspectPO.setEmployeeId(e.getEmployeeId());
insuranceAccountInspectPO.setPaymentStatus(e.getPaymentStatus());
insuranceAccountInspectPO.setSupplementaryMonth(e.getSupplementaryMonth());
insuranceAccountInspectPO.setTenantKey(e.getTenantKey());
insuranceAccountInspectPO.setUpdateTime(new Date());
insuranceAccountInspectPOS.add(insuranceAccountInspectPO);
}
}
return insuranceAccountInspectPOS;
}
public boolean detailCheck(String baseString) {
if (StringUtils.isEmpty(baseString)) {
return false;
}
Map<String, String> baseStringMap = JSON.parseObject(baseString, new TypeReference<Map<String, String>>() {
});
if (baseStringMap == null || baseStringMap.size() == 0) {
return false;
}
return baseStringMap.values().stream().anyMatch(item -> StringUtils.isEmpty(item) || Pattern.matches("^([0].?[0]*)$", item));
}
public void batchDelInspectDetail(List<InsuranceAccountInspectPO> list) {
MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class).batchDelInspectDetails(list);
//上报删除日志
// list.forEach(item -> {
// LoggerContext<InsuranceAccountInspectPO> insuranceSchemeContext = new LoggerContext<>();
// insuranceSchemeContext.setTargetId(String.valueOf(item.getId()));
// insuranceSchemeContext.setTargetName(String.valueOf(item.getEmployeeId()));
// insuranceSchemeContext.setOperateType(OperateTypeEnum.DELETE.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(100445, "删除核算异常记录"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(100445, "删除核算异常记录"));
// insuranceSchemeContext.setNewValues(item);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
// });
}
public void batchSaveInspectDetail(List<InsuranceAccountInspectPO> list) {
MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class).batchSaveInspectDetails(list);
//上报新增日志
// list.forEach(item -> {
// LoggerContext<InsuranceAccountInspectPO> insuranceSchemeContext = new LoggerContext<>();
// insuranceSchemeContext.setTargetId(String.valueOf(item.getId()));
// insuranceSchemeContext.setTargetName(String.valueOf(item.getEmployeeId()));
// insuranceSchemeContext.setOperateType(OperateTypeEnum.ADD.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(100447, "新建核算异常记录"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(100447, "新建核算异常记录"));
// insuranceSchemeContext.setNewValues(item);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
// });
}
/**
* 跟新台账接口
*
* @param billMonth 账单月份
* @param tenantKey 租户key
*/
public void updateBatchAccount(String billMonth, Long employeeId, String tenantKey) {
List<InsuranceAccountDetailPO> insuranceAccountDetailPOS = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectList(billMonth);
Map<Long, List<InsuranceAccountDetailPO>> map = insuranceAccountDetailPOS.stream().filter(item -> item.getEmployeeId() != null)
.collect(Collectors.groupingBy(InsuranceAccountDetailPO::getEmployeeId));
int socialAccountPerson = 0;
int funcAccountPerson = 0;
int otherAccountPerson = 0;
BigDecimal socialSum = new BigDecimal("0");
BigDecimal fundSum = new BigDecimal("0");
BigDecimal otherSum = new BigDecimal("0");
for (Map.Entry<Long, List<InsuranceAccountDetailPO>> entry : map.entrySet()) {
List<InsuranceAccountDetailPO> v = entry.getValue();
BigDecimal socialTemp = new BigDecimal("0");
BigDecimal fundTemp = new BigDecimal("0");
BigDecimal otherTemp = new BigDecimal("0");
for (InsuranceAccountDetailPO item : v) {
BigDecimal socialPerson = StringUtils.isBlank(item.getSocialSum()) ? new BigDecimal("0") : new BigDecimal(item.getSocialSum());
BigDecimal fundPerson = StringUtils.isBlank(item.getFundSum()) ? new BigDecimal("0") : new BigDecimal(item.getFundSum());
BigDecimal otherPerson = StringUtils.isBlank(item.getOtherSum()) ? new BigDecimal("0") : new BigDecimal(item.getOtherSum());
socialTemp = socialTemp.add(socialPerson);
fundTemp = fundTemp.add(fundPerson);
otherTemp = otherTemp.add(otherPerson);
}
if (!"0".equals(socialTemp.toPlainString())) {
socialSum = socialSum.add(socialTemp);
socialAccountPerson += 1;
}
if (!"0".equals(fundTemp.toPlainString())) {
fundSum = fundSum.add(fundTemp);
funcAccountPerson += 1;
}
if (!"0".equals(otherTemp.toPlainString())) {
otherSum = otherSum.add(otherTemp);
otherAccountPerson += 1;
}
}
InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(billMonth);
DataCollectionEmployee simpleEmployee = MapperProxyFactory.getProxy(EmployMapper.class).getEmployeeById(employeeId);
insuranceAccountBatchPO.setAccountant(simpleEmployee.getUsername());
insuranceAccountBatchPO.setUpdateTime(new Date());
insuranceAccountBatchPO.setSocialPay(socialSum.toPlainString());
insuranceAccountBatchPO.setSocialNum(socialAccountPerson);
insuranceAccountBatchPO.setFundNum(funcAccountPerson);
insuranceAccountBatchPO.setFundPay(fundSum.toPlainString());
insuranceAccountBatchPO.setOtherNum(otherAccountPerson);
insuranceAccountBatchPO.setOtherPay(otherSum.toPlainString());
MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).updateById(insuranceAccountBatchPO);
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.valueOf(insuranceAccountBatchPO.getId()));
// insuranceSchemeContext.setTargetName(insuranceAccountBatchPO.getBillMonth());
// insuranceSchemeContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100491, "更新台账"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100491, "更新台账"));
// insuranceSchemeContext.setNewValues(insuranceAccountBatchPO);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
}
}

View File

@ -3,7 +3,6 @@ package com.engine.salary.biz;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
import com.api.browser.bean.SearchConditionGroup;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
@ -21,10 +20,7 @@ import com.engine.salary.entity.siarchives.dto.InsuranceArchivesFundSchemeDTO;
import com.engine.salary.entity.siarchives.dto.InsuranceArchivesOtherSchemeDTO;
import com.engine.salary.entity.siarchives.dto.InsuranceArchivesSocialSchemeDTO;
import com.engine.salary.entity.siarchives.param.*;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO;
import com.engine.salary.entity.siarchives.po.*;
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO;
import com.engine.salary.entity.sischeme.po.InsuranceSchemePO;
@ -43,8 +39,10 @@ import com.engine.salary.util.SalaryAssert;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryFormItemUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.PageUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.ibatis.session.SqlSession;
import weaver.conn.mybatis.MyBatisFactory;
import weaver.general.Util;
@ -994,8 +992,43 @@ public class SIArchivesBiz {
addGroups.add(new SearchConditionGroup("常用条件",true,conditionItems));
apidatas.put("condition",addGroups);
return apidatas;
}
/**
* 组装员工的社保公积金其他福利数据
*
* @param ids 员工id集合
* @param tenantKey 租户key
* @return map
*/
public Map<Long, InsuranceArchivesAccountPO> buildBatchAccount(List<Long> ids, String tenantKey) {
if (CollectionUtils.isEmpty(ids)) {
return new HashMap<>();
}
Map<Long, InsuranceArchivesAccountPO> result = new HashMap<>();
Map<Long, InsuranceArchivesSocialSchemePO> socialMap = new HashMap<>();
Map<Long, InsuranceArchivesFundSchemePO> funMap = new HashMap<>();
Map<Long, InsuranceArchivesOtherSchemePO> otherMap = new HashMap<>();
List<InsuranceArchivesSocialSchemePO> socialPOS = MapperProxyFactory.getProxy(SocialSchemeMapper.class).getSocialByEmployeeId(ids);
if (CollectionUtils.isNotEmpty(socialPOS)) {
socialMap = socialPOS.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity()));
}
List<InsuranceArchivesFundSchemePO> fundPOS = MapperProxyFactory.getProxy(FundSchemeMapper.class).getFundByEmployeeId(ids);
if (CollectionUtils.isNotEmpty(fundPOS)) {
funMap = fundPOS.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity()));
}
List<InsuranceArchivesOtherSchemePO> otherPOS = MapperProxyFactory.getProxy(OtherSchemeMapper.class).getOtherByEmployeeId(ids);
if (CollectionUtils.isNotEmpty(otherPOS)) {
otherMap = otherPOS.stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getEmployeeId, Function.identity()));
}
for (Long id : ids) {
InsuranceArchivesAccountPO po = new InsuranceArchivesAccountPO();
po.setSocial(socialMap.get(id));
po.setFund(funMap.get(id));
po.setOther(otherMap.get(id));
result.put(id, po);
}
return result;
}
}

View File

@ -221,7 +221,7 @@ public class
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class);
return insuranceSchemeDetailMapper.listByPrimaryId(primaryId);
return insuranceSchemeDetailMapper.queryListBySchemeId(primaryId);
} finally {
sqlSession.close();
@ -344,7 +344,7 @@ public class
.build();
insuranceSchemeMapper.insert(batchPO);
List<InsuranceSchemeDetailPO> detailList = insuranceSchemeDetailMapper.listByPrimaryId(batchPO.getId());
List<InsuranceSchemeDetailPO> detailList = insuranceSchemeDetailMapper.queryListBySchemeId(batchPO.getId());
if (CollectionUtils.isNotEmpty(detailList)) {
List<InsuranceSchemeDetailPO> detailPOS = detailList.stream().map(item -> InsuranceSchemeDetailPO.builder()
//.id(IdGenerator.generate())

View File

@ -1,6 +1,7 @@
package com.engine.salary.entity.siaccount.param;
import com.engine.salary.util.valid.DataCheck;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -21,10 +22,12 @@ public class AccountParam {
//账单月份")
//@NotNull
@DataCheck(require = true,message = "账单月份不能为空")
private String billMonth;
//备注")
//@Length(max = 60)
@DataCheck(max = 60,message = "备注长度不能超过60个字符")
private String remarks;
//核算人员id集合")

View File

@ -0,0 +1,15 @@
package com.engine.salary.entity.siaccount.param;
/**
* @Author weaver_cl
* @Description: TODO
* @Date 2022/4/13
* @Version V1.0
**/
public class DSTenantKeyThreadVar {
public static ThreadLocal<String> tenantKey = new ThreadLocal();
public static ThreadLocal<Boolean> notDesensitization = new ThreadLocal();
public DSTenantKeyThreadVar() {
}
}

View File

@ -2,6 +2,7 @@ package com.engine.salary.entity.siaccount.param;
import com.engine.salary.common.BaseQueryParam;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -14,6 +15,7 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class InsuranceAccountBatchParam extends BaseQueryParam {
//开始时间

View File

@ -0,0 +1,25 @@
package com.engine.salary.entity.siarchives.po;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Description:
* @Author: zhangheng
* @CreateDate: 2021/12/7 19:05
* @Version: v1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class InsuranceArchivesAccountPO {
private InsuranceArchivesSocialSchemePO social;
private InsuranceArchivesFundSchemePO fund;
private InsuranceArchivesOtherSchemePO other;
}

View File

@ -4,6 +4,7 @@ import com.engine.salary.entity.siaccount.param.InsuranceAccountBatchParam;
import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/**
@ -20,4 +21,34 @@ public interface InsuranceAccountBatchMapper {
* @return
*/
List<InsuranceAccountBatchPO> list(@Param("param")InsuranceAccountBatchParam queryParam);
/**
* 根据账单月份查询单条记录
* @param billMonth
* @return
*/
InsuranceAccountBatchPO getByBillMonth(@Param("billMonth") String billMonth);
/**
* 插入
* @param insuranceAccountBatchPO
*/
void insert(InsuranceAccountBatchPO insuranceAccountBatchPO);
List<InsuranceAccountBatchPO> getAllByBillMonth(@Param("billMonth") String billMonth);
/**
* 根据主键删除
* @param id
*/
void deleteById(@Param("id") Long id);
/**
* 更新
* @param pos
*/
void updateById(@Param("pos") InsuranceAccountBatchPO pos);
}

View File

@ -40,6 +40,46 @@
, t.tenant_key
</sql>
<insert id="insert" parameterType="com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO"
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
>
INSERT INTO hrsa_bill_batch
<trim prefix="(" suffix=")" suffixOverrides=",">
bill_month,
bill_status,
social_num,
fund_num,
other_num,
social_pay,
fund_pay,
other_pay,
accountant,
remarks,
creator,
delete_type,
create_time,
update_time,
tenant_key,
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
#{billMonth},
#{billStatus},
#{socialNum},
#{fundNum},
#{otherNum},
#{socialPay},
#{fundPay},
#{otherPay},
#{accountant},
#{remarks},
#{creator},
#{deleteType},
#{createTime},
#{updateTime},
#{tenantKey},
</trim>
</insert>
<sql id="paramSql">
<if test="param.startTime != null and param.startTime != '' and param.endTime != null and param.endTime != ''">
AND
@ -59,6 +99,48 @@
</select>
<select id="getByBillMonth" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM
hrsa_bill_batch t
WHERE t.delete_type = 0
AND t.bill_month = #{billMonth}
</select>
<select id="getAllByBillMonth" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM
hrsa_bill_batch t
WHERE t.delete_type = 0
AND t.bill_month = #{billMonth}
</select>
<delete id="deleteById">
UPDATE hrsa_bill_batch
SET delete_type = 1
WHERE delete_type = 0
AND id = #{id}
</delete>
<update id="updateById" parameterType="com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO">
UPDATE hrsa_bill_batch
<set>
accountant=#{accountant},
update_time=#{updateTime},
social_pay=#{socialPay},
social_num=#{socialNum},
fund_num=#{fundNum},
fund_pay=#{fundPay},
other_num=#{otherNum},
other_pay=#{otherPay},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
</mapper>

View File

@ -4,6 +4,7 @@ import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam;
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/**
@ -20,4 +21,31 @@ public interface InsuranceAccountDetailMapper {
* @return
*/
List<InsuranceAccountDetailPO> list(@Param("param")InsuranceAccountDetailParam queryParam);
/**
* 根据账单月份获取所有员工
* @param billMonth
* @return
*/
List<Long> selectAccountIds(@Param("billMonth") String billMonth);
/**
* 根据id删除
* @param id
*/
void deleteById(@Param("id")Long id);
/**
* 批量删除
*/
void batchDelAccountDetails(@Param("employeeIds") Collection<Long> employeeIds, @Param("billMonth") String billMonth);
/**
* 批量保存
* @param accounts
*/
void batchSaveAccountDetails(@Param("accounts") Collection<InsuranceAccountDetailPO> accounts);
List<InsuranceAccountDetailPO> selectList(@Param("billMonth") String billMonth);
}

View File

@ -123,6 +123,210 @@
ORDER BY t.update_time DESC
</select>
<select id="selectList" resultMap="BaseResultMap">
SELECT
t.employee_id,t.social_sum,t.fund_sum,t.other_sum
FROM
hrsa_bill_detail t
WHERE t.delete_type = 0
AND t.bill_month = #{billMonth}
</select>
<select id="selectAccountIds" resultMap="Long">
SELECT
t.employee_id
FROM
hrsa_bill_detail t
WHERE t.delete_type = 0
AND t.bill_month = #{billMonth}
</select>
<!-- 根据主键删除记录 -->
<delete id="delete" parameterType="com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO">
UPDATE hrsa_bill_detail
SET delete_type = 1
WHERE id = #{id}
AND delete_type = 0
</delete>
<!-- 批量删除 -->
<delete id="batchDelAccountDetails">
UPDATE hrsa_bill_detail
SET delete_type = 1
WHERE delete_type = 0
AND bill_month = #{billMonth}
AND employee_id IN
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</delete>
<insert id="batchSaveAccountDetails">
INSERT INTO hrsa_bill_detail
(employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,fund_pay_org,
fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json,
social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,
fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key)
VALUES
<foreach collection="accounts" item="item" separator=",">
(
#{item.employeeId},
#{item.billMonth},
#{item.billStatus},
#{item.paymentStatus},
#{item.supplementaryMonth},
#{item.supplementaryProjects},
#{item.resourceFrom},
#{item.socialPayOrg},
#{item.socialAccount},
#{item.fundPayOrg},
#{item.fundAccount}
#{item.supplementFundAccount}
#{item.otherPayOrg}
#{item.socialSchemeId}
#{item.socialPaymentBaseString}
#{item.fundSchemeId}
#{item.fundPaymentBaseString}
#{item.otherSchemeId}
#{item.otherPaymentBaseString}
#{item.socialPerJson}
#{item.socialPerSum}
#{item.fundPerJson}
#{item.fundPerSum}
#{item.otherPerJson}
#{item.otherPerSum}
#{item.perSum}
#{item.socialComJson}
#{item.socialComSum}
#{item.fundComJson}
#{item.fundComSum}
#{item.otherComJson}
#{item.otherComSum}
#{item.comSum}
#{item.socialSum}
#{item.fundSum}
#{item.otherSum}
#{item.total}
#{item.creator}
#{item.deleteType}
#{item.createTime}
#{item.updateTime}
#{item.tenantKey}
)
</foreach>
</insert>
<insert id="hrsa_bill_detail" databaseId="oracle">
INSERT INTO hrsa_bill_detail
(employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,fund_pay_org,
fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json,
social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,
fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key)
<foreach collection="accounts" item="item" separator="union all">
select
#{item.employeeId},
#{item.billMonth},
#{item.billStatus},
#{item.paymentStatus},
#{item.supplementaryMonth},
#{item.supplementaryProjects},
#{item.resourceFrom},
#{item.socialPayOrg},
#{item.socialAccount},
#{item.fundPayOrg},
#{item.fundAccount}
#{item.supplementFundAccount}
#{item.otherPayOrg}
#{item.socialSchemeId}
#{item.socialPaymentBaseString}
#{item.fundSchemeId}
#{item.fundPaymentBaseString}
#{item.otherSchemeId}
#{item.otherPaymentBaseString}
#{item.socialPerJson}
#{item.socialPerSum}
#{item.fundPerJson}
#{item.fundPerSum}
#{item.otherPerJson}
#{item.otherPerSum}
#{item.perSum}
#{item.socialComJson}
#{item.socialComSum}
#{item.fundComJson}
#{item.fundComSum}
#{item.otherComJson}
#{item.otherComSum}
#{item.comSum}
#{item.socialSum}
#{item.fundSum}
#{item.otherSum}
#{item.total}
#{item.creator}
#{item.deleteType}
#{item.createTime}
#{item.updateTime}
#{item.tenantKey}
from dual
</foreach>
</insert>
<insert id="hrsa_bill_detail" databaseId="sqlserver">
INSERT INTO hrsa_bill_detail
(employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,fund_pay_org,
fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json,
social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,
fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key)
VALUES
<foreach collection="accounts" item="item" separator=",">
(
#{item.employeeId},
#{item.billMonth},
#{item.billStatus},
#{item.paymentStatus},
#{item.supplementaryMonth},
#{item.supplementaryProjects},
#{item.resourceFrom},
#{item.socialPayOrg},
#{item.socialAccount},
#{item.fundPayOrg},
#{item.fundAccount}
#{item.supplementFundAccount}
#{item.otherPayOrg}
#{item.socialSchemeId}
#{item.socialPaymentBaseString}
#{item.fundSchemeId}
#{item.fundPaymentBaseString}
#{item.otherSchemeId}
#{item.otherPaymentBaseString}
#{item.socialPerJson}
#{item.socialPerSum}
#{item.fundPerJson}
#{item.fundPerSum}
#{item.otherPerJson}
#{item.otherPerSum}
#{item.perSum}
#{item.socialComJson}
#{item.socialComSum}
#{item.fundComJson}
#{item.fundComSum}
#{item.otherComJson}
#{item.otherComSum}
#{item.comSum}
#{item.socialSum}
#{item.fundSum}
#{item.otherSum}
#{item.total}
#{item.creator}
#{item.deleteType}
#{item.createTime}
#{item.updateTime}
#{item.tenantKey}
)
</foreach>
</insert>

View File

@ -0,0 +1,28 @@
package com.engine.salary.mapper.siaccount;
import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
/**
* @Author weaver_cl
* @Description: TODO
* @Date 2022/4/14
* @Version V1.0
**/
public interface InsuranceAccountInspectMapper {
/**
* 批量删除
* @param pos
*/
void batchDelInspectDetails(@Param("pos") Collection<InsuranceAccountInspectPO> pos);
/**
* 批量保存
* @param pos
*/
void batchSaveInspectDetails(@Param("pos") Collection<InsuranceAccountInspectPO> pos);
}

View File

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.salary.mapper.siaccount.InsuranceAccountInspectMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO">
<result column="id" property="id"/>
<result column="employee_id" property="employeeId"/>
<result column="bill_month" property="billMonth"/>
<result column="payment_status" property="paymentStatus"/>
<result column="inspect_status" property="inspectStatus"/>
<result column="supplementary_month" property="supplementaryMonth"/>
<result column="supplementary_projects" property="supplementaryProjects"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="tenant_key" property="tenantKey"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t.id
, t.employee_id
, t.bill_month
, t.payment_status
, t.inspect_status
, t.supplementary_month
, t.supplementary_projects
, t.creator
, t.delete_type
, t.create_time
, t.update_time
, t.tenant_key
</sql>
<!-- 批量删除 -->
<delete id="batchDelInspectDetails">
UPDATE hrsa_bill_inspect
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="pos" open="(" item="po" separator="," close=")">
#{po.id}
</foreach>
</delete>
<!--- 批量保存-->
<insert id="batchSaveInspectDetails">
INSERT INTO hrsa_bill_inspect
(employee_id,bill_month,payment_status,inspect_status,supplementary_month,
supplementary_projects,creator,delete_type,create_time,update_time.tenant_key)
VALUES
<foreach collection="pos" item="item" separator=",">
(
#{item.employeeId},
#{item.billMonth},
#{item.paymentStatus},
#{item.inspectStatus},
#{item.supplementaryMonth},
#{item.supplementaryProjects},
#{item.creator}
#{item.deleteType}
#{item.createTime}
#{item.updateTime}
#{item.tenantKey}
)
</foreach>
</insert>
<insert id="batchSaveInspectDetails" databaseId="oracle">
INSERT INTO hrsa_bill_inspect
(employee_id,bill_month,payment_status,inspect_status,supplementary_month,
supplementary_projects,creator,delete_type,create_time,update_time.tenant_key)
<foreach collection="pos" item="item" separator="union all">
select
#{item.employeeId},
#{item.billMonth},
#{item.paymentStatus},
#{item.inspectStatus},
#{item.supplementaryMonth},
#{item.supplementaryProjects},
#{item.creator}
#{item.deleteType}
#{item.createTime}
#{item.updateTime}
#{item.tenantKey}
from dual
</foreach>
</insert>
<insert id="batchSaveInspectDetails" databaseId="sqlserver">
INSERT INTO hrsa_bill_inspect
(employee_id,bill_month,payment_status,inspect_status,supplementary_month,
supplementary_projects,creator,delete_type,create_time,update_time.tenant_key)
VALUES
<foreach collection="pos" item="item" separator=",">
(
#{item.employeeId},
#{item.billMonth},
#{item.paymentStatus},
#{item.inspectStatus},
#{item.supplementaryMonth},
#{item.supplementaryProjects},
#{item.creator}
#{item.deleteType}
#{item.createTime}
#{item.updateTime}
#{item.tenantKey}
)
</foreach>
</insert>
</mapper>

View File

@ -0,0 +1,38 @@
package com.engine.salary.mapper.siaccount;
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailTempPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/**
* @Author weaver_cl
* @Description: TODO
* @Date 2022/4/13
* @Version V1.0
**/
public interface SIAccountDetailTempMapper {
/**
* 批量删除
* @param employeeIds
* @param billMonth
*/
void batchDelAccountTempDetails(@Param("employeeIds") Collection<Long> employeeIds, @Param("billMonth") String billMonth);
/**
* 批量保存
* @param accounts
*/
void batchSaveAccountTempDetails(@Param("accounts") Collection<InsuranceAccountDetailTempPO> accounts);
/**
* 获取
* @param employeeIds
* @param billMonth
* @return
*/
List<InsuranceAccountDetailTempPO> getListByEmployeeIdsAndBillMonth(@Param("employeeIds") Collection<Long> employeeIds, @Param("billMonth") String billMonth);
}

View File

@ -0,0 +1,292 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.siaccount.po.InsuranceAccountDetailTempPO">
<result column="id" property="id"/>
<result column="employee_id" property="employeeId"/>
<result column="bill_month" property="billMonth"/>
<result column="bill_status" property="billStatus"/>
<result column="payment_status" property="paymentStatus"/>
<result column="supplementary_month" property="supplementaryMonth"/>
<result column="supplementary_projects" property="supplementaryProjects"/>
<result column="resource_from" property="resourceFrom"/>
<result column="social_pay_org" property="socialPayOrg"/>
<result column="social_account" property="socialAccount"/>
<result column="fund_pay_org" property="fundPayOrg"/>
<result column="fund_account" property="fundAccount"/>
<result column="supplement_fund_account" property="supplementFundAccount"/>
<result column="other_pay_org" property="otherPayOrg"/>
<result column="social_scheme_id" property="socialSchemeId"/>
<result column="social_payment_base_string" property="socialPaymentBaseString"/>
<result column="fund_scheme_id" property="fundSchemeId"/>
<result column="fund_payment_base_string" property="fundPaymentBaseString"/>
<result column="other_scheme_id" property="otherSchemeId"/>
<result column="other_payment_base_string" property="otherPaymentBaseString"/>
<result column="social_per_json" property="socialPerJson"/>
<result column="social_per_sum" property="socialPerSum"/>
<result column="fund_per_json" property="fundPerJson"/>
<result column="fund_per_sum" property="fundPerSum"/>
<result column="other_per_json" property="otherPerJson"/>
<result column="other_per_sum" property="otherPerSum"/>
<result column="per_sum" property="perSum"/>
<result column="social_com_json" property="socialComJson"/>
<result column="social_com_sum" property="socialComSum"/>
<result column="fund_com_json" property="fundComJson"/>
<result column="fund_com_sum" property="fundComSum"/>
<result column="other_com_json" property="otherComJson"/>
<result column="other_com_sum" property="otherComSum"/>
<result column="com_sum" property="comSum"/>
<result column="social_sum" property="socialSum"/>
<result column="fund_sum" property="fundSum"/>
<result column="other_sum" property="otherSum"/>
<result column="total" property="total"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="tenant_key" property="tenantKey"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t.id
, t.employee_id
, t.bill_month
, t.bill_status
, t.payment_status
, t.supplementary_month
, t.supplementary_projects
, t.resource_from
, t.social_pay_org
, t.social_account
, t.fund_pay_org
, t.fund_account
, t.supplement_fund_account
, t.other_pay_org
, t.social_scheme_id
, t.social_payment_base_string
, t.fund_scheme_id
, t.fund_payment_base_string
, t.other_scheme_id
, t.other_payment_base_string
, t.social_per_json
, t.social_per_sum
, t.fund_per_json
, t.fund_per_sum
, t.other_per_json
, t.other_per_sum
, t.per_sum
, t.social_com_json
, t.social_com_sum
, t.fund_com_json
, t.fund_com_sum
, t.other_com_json
, t.other_com_sum
, t.com_sum
, t.social_sum
, t.fund_sum
, t.other_sum
, t.total
, t.creator
, t.delete_type
, t.create_time
, t.update_time
, t.tenant_key
</sql>
<!-- 批量删除 -->
<delete id="batchDelAccountTempDetails">
UPDATE hrsa_bill_detail_temp
SET delete_type = 1
WHERE delete_type = 0
AND bill_month = #{billMonth}
AND employee_id IN
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</delete>
<insert id="batchSaveAccountTempDetails">
INSERT INTO hrsa_bill_detail_temp
(employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,fund_pay_org,
fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json,
social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,
fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key)
VALUES
<foreach collection="accounts" item="item" separator=",">
(
#{item.employeeId},
#{item.billMonth},
#{item.billStatus},
#{item.paymentStatus},
#{item.supplementaryMonth},
#{item.supplementaryProjects},
#{item.resourceFrom},
#{item.socialPayOrg},
#{item.socialAccount},
#{item.fundPayOrg},
#{item.fundAccount}
#{item.supplementFundAccount}
#{item.otherPayOrg}
#{item.socialSchemeId}
#{item.socialPaymentBaseString}
#{item.fundSchemeId}
#{item.fundPaymentBaseString}
#{item.otherSchemeId}
#{item.otherPaymentBaseString}
#{item.socialPerJson}
#{item.socialPerSum}
#{item.fundPerJson}
#{item.fundPerSum}
#{item.otherPerJson}
#{item.otherPerSum}
#{item.perSum}
#{item.socialComJson}
#{item.socialComSum}
#{item.fundComJson}
#{item.fundComSum}
#{item.otherComJson}
#{item.otherComSum}
#{item.comSum}
#{item.socialSum}
#{item.fundSum}
#{item.otherSum}
#{item.total}
#{item.creator}
#{item.deleteType}
#{item.createTime}
#{item.updateTime}
#{item.tenantKey}
)
</foreach>
</insert>
<insert id="batchSaveAccountTempDetails" databaseId="oracle">
INSERT INTO hrsa_bill_detail_temp
(employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,fund_pay_org,
fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json,
social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,
fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key)
<foreach collection="accounts" item="item" separator="union all">
select
#{item.employeeId},
#{item.billMonth},
#{item.billStatus},
#{item.paymentStatus},
#{item.supplementaryMonth},
#{item.supplementaryProjects},
#{item.resourceFrom},
#{item.socialPayOrg},
#{item.socialAccount},
#{item.fundPayOrg},
#{item.fundAccount}
#{item.supplementFundAccount}
#{item.otherPayOrg}
#{item.socialSchemeId}
#{item.socialPaymentBaseString}
#{item.fundSchemeId}
#{item.fundPaymentBaseString}
#{item.otherSchemeId}
#{item.otherPaymentBaseString}
#{item.socialPerJson}
#{item.socialPerSum}
#{item.fundPerJson}
#{item.fundPerSum}
#{item.otherPerJson}
#{item.otherPerSum}
#{item.perSum}
#{item.socialComJson}
#{item.socialComSum}
#{item.fundComJson}
#{item.fundComSum}
#{item.otherComJson}
#{item.otherComSum}
#{item.comSum}
#{item.socialSum}
#{item.fundSum}
#{item.otherSum}
#{item.total}
#{item.creator}
#{item.deleteType}
#{item.createTime}
#{item.updateTime}
#{item.tenantKey}
from dual
</foreach>
</insert>
<insert id="batchSaveAccountTempDetails" databaseId="sqlserver">
INSERT INTO hrsa_bill_detail_temp
(employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,fund_pay_org,
fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json,
social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,
fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key)
VALUES
<foreach collection="accounts" item="item" separator=",">
(
#{item.employeeId},
#{item.billMonth},
#{item.billStatus},
#{item.paymentStatus},
#{item.supplementaryMonth},
#{item.supplementaryProjects},
#{item.resourceFrom},
#{item.socialPayOrg},
#{item.socialAccount},
#{item.fundPayOrg},
#{item.fundAccount}
#{item.supplementFundAccount}
#{item.otherPayOrg}
#{item.socialSchemeId}
#{item.socialPaymentBaseString}
#{item.fundSchemeId}
#{item.fundPaymentBaseString}
#{item.otherSchemeId}
#{item.otherPaymentBaseString}
#{item.socialPerJson}
#{item.socialPerSum}
#{item.fundPerJson}
#{item.fundPerSum}
#{item.otherPerJson}
#{item.otherPerSum}
#{item.perSum}
#{item.socialComJson}
#{item.socialComSum}
#{item.fundComJson}
#{item.fundComSum}
#{item.otherComJson}
#{item.otherComSum}
#{item.comSum}
#{item.socialSum}
#{item.fundSum}
#{item.otherSum}
#{item.total}
#{item.creator}
#{item.deleteType}
#{item.createTime}
#{item.updateTime}
#{item.tenantKey}
)
</foreach>
</insert>
<select id="getListByEmployeeIdsAndBillMonth" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM
hrsa_bill_detail_temp t
WHERE t.delete_type = 0
AND t.bill_month = #{billMonth}
AND t.employee_id IN
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</select>
</mapper>

View File

@ -19,7 +19,7 @@ public interface InsuranceSchemeDetailMapper {
*
* @return list
*/
List<InsuranceSchemeDetailPO> listByPrimaryId(Long primaryId);
List<InsuranceSchemeDetailPO> queryListBySchemeId(Long schemeId);
/**
* 新增插入所有字段

View File

@ -42,6 +42,7 @@ public interface InsuranceSchemeMapper {
*/
List<InsuranceSchemePO> listByName(String schemeName);
/**
* 查询所有
* @return

View File

@ -1,5 +1,6 @@
package com.engine.salary.service;
import com.engine.salary.entity.siaccount.param.AccountParam;
import com.engine.salary.entity.siaccount.param.InsuranceAccountBatchParam;
import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam;
@ -12,6 +13,7 @@ import java.util.Map;
* @Version V1.0
**/
public interface SIAccountService {
Map<String,Object> listPage(InsuranceAccountBatchParam insuranceAccountBatchParam);
Map<String,Object> listCommonPage(InsuranceAccountDetailParam insuranceAccountDetailParam);
@ -24,5 +26,6 @@ public interface SIAccountService {
Map<String, Object> getForm(Map<String, Object> params);
Map<String, Object> save(AccountParam param);
}

View File

@ -2,10 +2,7 @@ package com.engine.salary.service.impl;
import com.api.browser.bean.SearchConditionGroup;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.util.ConditionFactory;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.cloudstore.eccom.pc.table.WeaTableOperate;
import com.cloudstore.eccom.pc.table.WeaTableOperates;
import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
@ -16,6 +13,7 @@ import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO;
import com.engine.salary.entity.siaccount.bo.InsuranceAccountBO;
import com.engine.salary.entity.siaccount.dto.InsuranceAccountBatchListDTO;
import com.engine.salary.entity.siaccount.param.AccountParam;
import com.engine.salary.entity.siaccount.param.InsuranceAccountBatchParam;
import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam;
import com.engine.salary.entity.siaccount.param.Permission;
@ -24,6 +22,7 @@ import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
import com.engine.salary.enums.siaccount.BillStatusEnum;
import com.engine.salary.enums.siaccount.PaymentStatusEnum;
import com.engine.salary.mapper.datacollection.EmployMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper;
import com.engine.salary.service.ColumnBuildService;
import com.engine.salary.service.RecordsBuildService;
@ -33,8 +32,10 @@ import java.util.*;
import java.util.stream.Collectors;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryFormItemUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.valid.ValidUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.hrm.User;
@ -216,47 +217,61 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
@Override
public Map<String, Object> getForm(Map<String, Object> params) {
ConditionFactory conditionFactory = new ConditionFactory(user);
Map<String, Object> apidatas = new HashMap<>();
//条件组
List<SearchConditionGroup> addGroups = new ArrayList<>();
List<SearchConditionItem> conditionItems = new ArrayList<>();
SearchConditionItem datePickerItem = SalaryFormItemUtil.datePickerItem(user, 2, 16, true, 1, "账单月份", "billMonth");
String minDate = SalaryDateUtil.getYearMonth(-1, 0);
String maxDate = SalaryDateUtil.getYearMonth(0, 6);
datePickerItem.getOtherParams().put("minDate",minDate);
datePickerItem.getOtherParams().put("maxDate",maxDate);
InsuranceAccountBatchParam queryParam = InsuranceAccountBatchParam.builder().startTime(minDate).endTime(maxDate).build();
//
// WeaForm weaForm = new WeaForm();
// WeaFormItem weaFormItem = new WeaFormItem(WeaFormItemType.DATEPICKER);
// weaFormItem.setRequired(true);
// String minDate = SalaryDateUtil.getYearMonth(-1, 0);
// String maxDate = SalaryDateUtil.getYearMonth(0, 6);
// weaFormItem.getOtherParams().put("minDate", minDate);
// weaFormItem.getOtherParams().put("maxDate", maxDate);
// List<InsuranceAccountBatchPO> billMonthList = siAccountService.listByTimeRange(minDate, maxDate, tenantKey);
// if (CollectionUtils.isEmpty(billMonthList)) {
// weaFormItem.getOtherParams().put("disabledData", Collections.emptyList());
// } else {
// weaFormItem.getOtherParams().put("disabledData", billMonthList.stream().map(InsuranceAccountBatchPO::getBillMonth).collect(Collectors.toList()));
// }
// weaFormItem.getOtherParams().put("type", "month");
// weaFormItem.getOtherParams().put("format", "YYYY-MM");
// weaFormItem.getOtherParams().put("showFormat", "YYYY-MM");
// weaForm.getItems().put("billMonth", weaFormItem);
//
//
//
//
// WeaFormItem remarksItem = new WeaFormItem(WeaFormItemType.TEXTAREA);
// remarksItem.setMaxLength("60");
// weaForm.getItems().put("remarks", remarksItem);
// List<WeaFormLayout> one = new ArrayList<>();
// one.add(new WeaFormLayout("billMonth", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 92146, "账单月份"), new String[]{"billMonth"}));
// List<WeaFormLayout> two = new ArrayList<>();
// two.add(new WeaFormLayout("remarks", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 84961, "备注"), new String[]{"remarks"}));
// weaForm.getLayout().add(one);
// weaForm.getLayout().add(two);
// Map<String, Object> data = new HashMap<>();
// data.put("billMonth", SalaryDateUtil.getYearMonth(0, 0));
// weaForm.setData(data);
return null;
List<InsuranceAccountBatchPO> billMonthList = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).list(queryParam);
if (CollectionUtils.isEmpty(billMonthList)) {
datePickerItem.getOtherParams().put("disabledData", Collections.emptyList());
} else {
datePickerItem.getOtherParams().put("disabledData", billMonthList.stream().map(InsuranceAccountBatchPO::getBillMonth).collect(Collectors.toList()));
}
datePickerItem.getOtherParams().put("type", "month");
datePickerItem.getOtherParams().put("format", "YYYY-MM");
datePickerItem.getOtherParams().put("showFormat", "YYYY-MM");
conditionItems.add(datePickerItem);
SearchConditionItem textareaItem = SalaryFormItemUtil.textareaItem(user, 2, 16, true, 1, 60, "备注", "remarks");
conditionItems.add(textareaItem);
addGroups.add(new SearchConditionGroup("常用条件",true,conditionItems));
apidatas.put("billMonth", SalaryDateUtil.getYearMonth(0, 0));
apidatas.put("condition",addGroups);
return apidatas;
}
/**
* 保存月份和备注信息并进入核算
*
* @param param 请求入参
* <p>
* 接口逻辑
* 1检查当前月份是否已经归档如果已经归档直接返回状态为未归档继续执行
* 2从基础人员表左连接部门和离职表以及档案表查询出来符合缴纳的人员清单
* 1离职日期在当月一号零时之后
* 2档案中配置了福利缴纳开始缴纳月开始时间包含当前月
* 3forkjoin核算并入库
* 4更新台账
*/
@Override
public Map<String, Object> save(AccountParam param) {
Map<String, Object> apidatas = new HashMap<>();
Long employeeId = (long)user.getUID();
String lastname = user.getLastname();
ValidUtil.doValidator(param);
siAccountBiz.save(true,param,employeeId,lastname);
return apidatas;
}

View File

@ -7,6 +7,7 @@ import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.Collection;
import java.util.List;
@ -172,4 +173,20 @@ public class SalaryEntityUtil {
return BigDecimal.ZERO;
}
}
public static BigDecimal carryRule(Integer newScale, Integer rententionRule, BigDecimal value) {
if (BigDecimal.ROUND_UNNECESSARY == rententionRule) {
String tempValue = value.toPlainString().concat("000");
int i = tempValue.indexOf(".");
String s = String.valueOf(tempValue.charAt(i + newScale + 1));
if ("0".equals(s)) {
return value.setScale(newScale, RoundingMode.DOWN);
} else {
return value.setScale(newScale, RoundingMode.UP);
}
}
return value.setScale(newScale, rententionRule);
}
}

View File

@ -166,6 +166,7 @@ public class SalaryFormItemUtil {
return textarea;
}
/**
* 日期
* @param user
@ -192,4 +193,6 @@ public class SalaryFormItemUtil {
}

View File

@ -2,14 +2,15 @@ package com.engine.salary.web;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.siaccount.param.AccountParam;
import com.engine.salary.entity.siaccount.param.InsuranceAccountBatchParam;
import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam;
import com.engine.salary.service.SIAccountService;
import com.engine.salary.service.impl.SIAccountServiceImpl;
import com.engine.salary.util.ResponseResult;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import com.engine.salary.service.SIAccountService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -124,6 +125,23 @@ public class SIAccountController {
}
/**
* 保存并进入核算
* @param request
* @param response
* @param param
* @return
*/
@POST
@Path("/save")
@Produces(MediaType.APPLICATION_JSON)
public String save(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody AccountParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<AccountParam, Map<String, Object>>().run(getService(user)::save, param);
}