diff --git a/resource/sql/分权.sql b/resource/sql/分权.sql index 9f329ea24..ff55b57c1 100644 --- a/resource/sql/分权.sql +++ b/resource/sql/分权.sql @@ -133,4 +133,10 @@ ALTER TABLE hrsa_tax_agent ADD COLUMN payment_agency varchar(255) NULL COMMENT ' ALTER TABLE hrsa_salary_sob ADD COLUMN tax_agent_id bigint(0) NULL COMMENT '个税扣缴义务人的主键id' AFTER tenant_key; -INSERT INTO hrsa_tax_agent_base(id, devolution_status, create_time, update_time, creator, delete_type, tenant_key) VALUES (1653303537239, 0, '2022-05-23 18:58:53', '2022-05-23 19:12:12', 1, 0, 'all_teams'); +INSERT INTO hrsa_tax_agent_base(id, devolution_status, create_time, update_time, creator, delete_type, tenant_key) VALUES (1653303537239, 1, '2022-05-23 18:58:53', '2022-05-23 19:12:12', 1, 0, 'all_teams'); + +ALTER TABLE hrsa_bill_detail_temp ADD COLUMN payment_organization bigint(0) NULL COMMENT '个税扣缴义务人id' AFTER tenant_key; + +ALTER TABLE hrsa_bill_detail ADD COLUMN payment_organization bigint(0) NULL COMMENT '个税扣缴义务人id' AFTER tenant_key; + +ALTER TABLE hrsa_bill_batch ADD COLUMN payment_organization bigint(0) NULL COMMENT '个税扣缴义务人id' AFTER tenant_key; \ No newline at end of file diff --git a/resource/sql/分权sql server.sql b/resource/sql/分权sql server.sql new file mode 100644 index 000000000..c61507486 --- /dev/null +++ b/resource/sql/分权sql server.sql @@ -0,0 +1,333 @@ +IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[hrsa_tax_agent_emp]') AND type IN ('U')) + DROP TABLE [hrsa_tax_agent_emp] +GO + +CREATE TABLE [hrsa_tax_agent_emp] ( + [id] bigint NOT NULL, + [create_time] datetime NULL, + [update_time] datetime NULL, + [creator] bigint NULL, + [delete_type] int DEFAULT 0, + [tenant_key] varchar(10) COLLATE Chinese_PRC_CI_AS NULL, + [tax_agent_id] bigint NULL, + [employee_id] bigint NULL, + [employee_name] varchar(255) COLLATE Chinese_PRC_CI_AS NULL +) +GO + +ALTER TABLE [hrsa_tax_agent_emp] SET (LOCK_ESCALATION = TABLE) +GO + +CREATE NONCLUSTERED INDEX [idx_tenant_key] +ON [hrsa_tax_agent_emp] ( + [tenant_key] ASC +) +GO + +CREATE NONCLUSTERED INDEX [idx_tax_agent] +ON [hrsa_tax_agent_emp] ( + [tax_agent_id] ASC +) +GO +ALTER TABLE [hrsa_tax_agent_emp] ADD CONSTRAINT [PK__hrsa_tax__3213E83F1A221DC1] PRIMARY KEY CLUSTERED ([id]) +WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +ON [PRIMARY] +GO + + + + +IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[hrsa_tax_agent_base]') AND type IN ('U')) + DROP TABLE [hrsa_tax_agent_base] +GO + +CREATE TABLE [hrsa_tax_agent_base] ( + [id] bigint NOT NULL, + [devolution_status] int DEFAULT 0, + [create_time] datetime DEFAULT getdate(), + [update_time] datetime DEFAULT getdate(), + [creator] bigint DEFAULT 0, + [delete_type] int DEFAULT 0, + [tenant_key] varchar(10) COLLATE Chinese_PRC_CI_AS NULL +) +GO + +ALTER TABLE [hrsa_tax_agent_base] SET (LOCK_ESCALATION = TABLE) +GO + +CREATE NONCLUSTERED INDEX [idx_tenant_key] +ON [hrsa_tax_agent_base] ( + [tenant_key] ASC +) +GO + + +ALTER TABLE [hrsa_tax_agent_base] ADD CONSTRAINT [PK__hrsa_tax__3213E83FE121B302] PRIMARY KEY CLUSTERED ([id]) +WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +ON [PRIMARY] +GO + + + +IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[hrsa_tax_agent_manage_range]') AND type IN ('U')) + DROP TABLE [hrsa_tax_agent_manage_range] +GO + +CREATE TABLE [hrsa_tax_agent_manage_range] ( + [id] bigint NOT NULL, + [tax_agent_id] bigint DEFAULT 0, + [employee_id] bigint DEFAULT 0, + [tax_agent_sub_admin_id] bigint DEFAULT 0, + [target_type] tinyint DEFAULT 1, + [target_id] bigint DEFAULT 0, + [employee_status] varchar(100) COLLATE Chinese_PRC_CI_AS NULL, + [include_type] int DEFAULT 1, + [creator] bigint DEFAULT 0, + [create_time] datetime DEFAULT getdate(), + [update_time] datetime DEFAULT getdate(), + [delete_type] int DEFAULT 0, + [tenant_key] varchar(10) COLLATE Chinese_PRC_CI_AS NULL, + [range_type] int DEFAULT 0 +) +GO + +ALTER TABLE [hrsa_tax_agent_manage_range] SET (LOCK_ESCALATION = TABLE) +GO + +CREATE NONCLUSTERED INDEX [idx_tax_agent_sub_admin_id] +ON [hrsa_tax_agent_manage_range] ( + [tax_agent_sub_admin_id] ASC +) +GO + +CREATE NONCLUSTERED INDEX [idx_tenant_key] +ON [hrsa_tax_agent_manage_range] ( + [tenant_key] ASC +) +GO + +ALTER TABLE [hrsa_tax_agent_manage_range] ADD CONSTRAINT [PK__hrsa_tax__3213E83F877A395F] PRIMARY KEY CLUSTERED ([id]) +WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +ON [PRIMARY] +GO + +IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[hrsa_tax_agent_emp_change]') AND type IN ('U')) + DROP TABLE [hrsa_tax_agent_emp_change] +GO + +CREATE TABLE [hrsa_tax_agent_emp_change] ( + [id] bigint NOT NULL, + [create_time] datetime NULL, + [update_time] datetime NULL, + [creator] bigint NULL, + [delete_type] int DEFAULT 0, + [tenant_key] varchar(10) COLLATE Chinese_PRC_CI_AS NULL, + [tax_agent_id] bigint NULL, + [employee_id] bigint NULL, + [change_type] int DEFAULT 0, + [employee_name] varchar(255) COLLATE Chinese_PRC_CI_AS NULL, + [module_type] int DEFAULT 0 +) +GO + +ALTER TABLE [hrsa_tax_agent_emp_change] SET (LOCK_ESCALATION = TABLE) +GO + + +CREATE NONCLUSTERED INDEX [idx_tenant_key] +ON [hrsa_tax_agent_emp_change] ( + [tenant_key] ASC +) +GO + +CREATE NONCLUSTERED INDEX [idx_tax_agent] +ON [hrsa_tax_agent_emp_change] ( + [tax_agent_id] ASC +) +GO + +ALTER TABLE [hrsa_tax_agent_emp_change] ADD CONSTRAINT [PK__hrsa_tax__3213E83F2DC37AA6] PRIMARY KEY CLUSTERED ([id]) +WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +ON [PRIMARY] +GO + +IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[hrsa_tax_agent_sub_admin_emp]') AND type IN ('U')) + DROP TABLE [hrsa_tax_agent_sub_admin_emp] +GO + +CREATE TABLE [hrsa_tax_agent_sub_admin_emp] ( + [id] bigint NOT NULL, + [create_time] datetime NULL, + [update_time] datetime NULL, + [creator] bigint NULL, + [delete_type] int DEFAULT 0, + [tenant_key] varchar(10) COLLATE Chinese_PRC_CI_AS NULL, + [tax_agent_id] bigint DEFAULT 0, + [tax_agent_sub_admin_id] bigint DEFAULT 0, + [employee_id] bigint DEFAULT 0, + [employee_name] varchar(255) COLLATE Chinese_PRC_CI_AS NULL +) +GO + +ALTER TABLE [hrsa_tax_agent_sub_admin_emp] SET (LOCK_ESCALATION = TABLE) +GO + + +CREATE NONCLUSTERED INDEX [idx_tenant_key] +ON [hrsa_tax_agent_sub_admin_emp] ( + [tenant_key] ASC +) +GO + +CREATE NONCLUSTERED INDEX [idx_tax_agent] +ON [hrsa_tax_agent_sub_admin_emp] ( + [tax_agent_id] ASC +) +GO + +ALTER TABLE [hrsa_tax_agent_sub_admin_emp] ADD CONSTRAINT [PK__hrsa_tax__3213E83F2F2EE404] PRIMARY KEY CLUSTERED ([id]) +WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +ON [PRIMARY] +GO + +IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[hrsa_tax_agent_sub_admin]') AND type IN ('U')) + DROP TABLE [hrsa_tax_agent_sub_admin] +GO + +CREATE TABLE [hrsa_tax_agent_sub_admin] ( + [id] bigint NOT NULL, + [tax_agent_id] bigint NULL, + [employee_id] bigint NULL, + [description] varchar(100) COLLATE Chinese_PRC_CI_AS NULL, + [create_time] datetime NULL, + [update_time] datetime NULL, + [creator] bigint NULL, + [delete_type] int NULL, + [tenant_key] varchar(10) COLLATE Chinese_PRC_CI_AS NULL, + [remark] text COLLATE Chinese_PRC_CI_AS NULL +) +GO + +ALTER TABLE [hrsa_tax_agent_sub_admin] SET (LOCK_ESCALATION = TABLE) +GO + + +CREATE NONCLUSTERED INDEX [idx_tenant_key] +ON [hrsa_tax_agent_sub_admin] ( + [tenant_key] ASC +) +GO + +CREATE NONCLUSTERED INDEX [idx_tax_agent_id] +ON [hrsa_tax_agent_sub_admin] ( + [tax_agent_id] ASC +) +GO + +CREATE NONCLUSTERED INDEX [idx_employee_id] +ON [hrsa_tax_agent_sub_admin] ( + [employee_id] ASC +) +GO + +ALTER TABLE [hrsa_tax_agent_sub_admin] ADD CONSTRAINT [PK__hrsa_tax__3213E83F26DE578A] PRIMARY KEY CLUSTERED ([id]) +WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +ON [PRIMARY] +GO + +IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[hrsa_tax_agent_sub_admin]') AND type IN ('U')) + DROP TABLE [hrsa_tax_agent_sub_admin] +GO + +CREATE TABLE [hrsa_tax_agent_sub_admin] ( + [id] bigint NOT NULL, + [tax_agent_id] bigint NULL, + [employee_id] bigint NULL, + [description] varchar(100) COLLATE Chinese_PRC_CI_AS NULL, + [create_time] datetime NULL, + [update_time] datetime NULL, + [creator] bigint NULL, + [delete_type] int NULL, + [tenant_key] varchar(10) COLLATE Chinese_PRC_CI_AS NULL, + [remark] text COLLATE Chinese_PRC_CI_AS NULL +) +GO + +ALTER TABLE [hrsa_tax_agent_sub_admin] SET (LOCK_ESCALATION = TABLE) +GO + + +CREATE NONCLUSTERED INDEX [idx_tenant_key] +ON [hrsa_tax_agent_sub_admin] ( + [tenant_key] ASC +) +GO + +CREATE NONCLUSTERED INDEX [idx_tax_agent_id] +ON [hrsa_tax_agent_sub_admin] ( + [tax_agent_id] ASC +) +GO + +CREATE NONCLUSTERED INDEX [idx_employee_id] +ON [hrsa_tax_agent_sub_admin] ( + [employee_id] ASC +) +GO + +ALTER TABLE [hrsa_tax_agent_sub_admin] ADD CONSTRAINT [PK__hrsa_tax__3213E83F26DE578A] PRIMARY KEY CLUSTERED ([id]) +WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +ON [PRIMARY] +GO + + +IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[hrsa_tax_agent_admin]') AND type IN ('U')) + DROP TABLE [hrsa_tax_agent_admin] +GO + +CREATE TABLE [hrsa_tax_agent_admin] ( + [id] bigint NOT NULL, + [tax_agent_id] bigint NULL, + [employee_id] bigint NULL, + [create_time] datetime DEFAULT getdate(), + [update_time] datetime DEFAULT getdate(), + [creator] bigint DEFAULT 0, + [delete_type] int DEFAULT 0, + [tenant_key] varchar(10) COLLATE Chinese_PRC_CI_AS NULL +) +GO + +ALTER TABLE [hrsa_tax_agent_admin] SET (LOCK_ESCALATION = TABLE) +GO + +CREATE NONCLUSTERED INDEX [idx_tenant_key] +ON [hrsa_tax_agent_admin] ( + [tenant_key] ASC +) +GO + +CREATE NONCLUSTERED INDEX [idx_employee_id] +ON [hrsa_tax_agent_admin] ( + [employee_id] ASC +) +GO + +ALTER TABLE [hrsa_tax_agent_admin] ADD CONSTRAINT [PK__hrsa_tax__3213E83F01D6FDC9] PRIMARY KEY CLUSTERED ([id]) +WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +ON [PRIMARY] +GO + +ALTER TABLE hrsa_tax_agent ADD payment_agency varchar(255) NULL +GO + +ALTER TABLE hrsa_salary_sob ADD tax_agent_id bigint NULL +GO + +INSERT INTO hrsa_tax_agent_base(id, devolution_status, create_time, update_time, creator, delete_type, tenant_key) VALUES (1653303537239, 0, '2022-05-23 18:58:53', '2022-05-23 19:12:12', 1, 0, 'all_teams'); +GO +ALTER TABLE hrsa_bill_detail_temp ADD payment_organization bigint NULL +GO +ALTER TABLE hrsa_bill_detail ADD payment_organization bigint NULL +GO +ALTER TABLE hrsa_bill_batch ADD payment_organization bigint NULL +GO \ No newline at end of file diff --git a/src/com/engine/salary/biz/SIAccountBiz.java b/src/com/engine/salary/biz/SIAccountBiz.java index a58f1fb45..500b14d4e 100644 --- a/src/com/engine/salary/biz/SIAccountBiz.java +++ b/src/com/engine/salary/biz/SIAccountBiz.java @@ -1,8 +1,9 @@ package com.engine.salary.biz; -import com.alibaba.druid.support.json.JSONUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.encrypt.AESEncryptUtil; import com.engine.salary.encrypt.siaccount.InsuranceAccountDetailPOEncrypt; @@ -17,9 +18,13 @@ 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.*; +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.sicategory.po.ICategoryPO; import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO; import com.engine.salary.entity.taxrate.TaxAgent; import com.engine.salary.enums.siaccount.*; import com.engine.salary.enums.sicategory.*; @@ -30,9 +35,10 @@ 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.sicategory.ICategoryMapper; import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.TaxAgentServiceImpl; import com.engine.salary.util.SalaryAssert; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; @@ -40,6 +46,7 @@ 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.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; import com.google.common.collect.Lists; import dm.jdbc.util.IdGenerator; import lombok.extern.slf4j.Slf4j; @@ -47,7 +54,6 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.SqlSession; import org.springframework.beans.BeanUtils; - import weaver.conn.mybatis.MyBatisFactory; import java.math.BigDecimal; @@ -57,7 +63,6 @@ import java.util.concurrent.Executors; import java.util.function.Function; import java.util.regex.Pattern; import java.util.stream.Collectors; -import com.engine.core.impl.Service; /** * @Author weaver_cl @@ -66,10 +71,14 @@ import com.engine.core.impl.Service; * @Version V1.0 **/ @Slf4j -public class SIAccountBiz extends Service{ +public class SIAccountBiz extends Service { private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + private TaxAgentService getTaxAgentService() { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + public PageInfo listPage(InsuranceAccountBatchParam queryParam, Long employeeId) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); @@ -79,8 +88,10 @@ public class SIAccountBiz extends Service{ List list = insuranceAccountBatchMapper.list(queryParam); list = SiAccountEncrypt.decryptInsuranceAccountBatchList(list); PageInfo pageInfo = new PageInfo<>(list,InsuranceAccountBatchPO.class); + List list = insuranceAccountBatchMapper.list(queryParam); + PageInfo pageInfo = new PageInfo<>(list, InsuranceAccountBatchPO.class); return pageInfo; - }finally { + } finally { sqlSession.close(); } @@ -95,19 +106,24 @@ public class SIAccountBiz extends Service{ List list = insuranceAccountDetailMapper.list(queryParam); InsuranceAccountDetailPOEncrypt.decryptInsuranceAccountDetailPOList(list); PageInfo pageInfo = new PageInfo<>(list,InsuranceAccountDetailPO.class); + PageInfo pageInfo = new PageInfo<>(list, InsuranceAccountDetailPO.class); return pageInfo; - }finally { + } finally { sqlSession.close(); } } - public void save(boolean flag, AccountParam param,Long employeeId,String currentUserName) { + public void save(boolean flag, AccountParam param, Long employeeId, String currentUserName) { if (flag) { InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(param.getBillMonth()); insuranceAccountBatchPO = SiAccountEncrypt.decryptInsuranceAccountBatch(insuranceAccountBatchPO); SalaryAssert.isNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel( 100461, "所属月份存在核算数据")); + InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); + SalaryAssert.isNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(100461, "所属月份存在核算数据")); + InsuranceAccountBatchPO build = InsuranceAccountBatchPO.builder() - //.id(IdGenerator.generate()) + //.id(IdGenerator.generate()) + .paymentOrganization(param.getPaymentOrganization()) .accountant(currentUserName) .billMonth(param.getBillMonth()) .billStatus(BillStatusEnum.NOT_ARCHIVED.getValue()) @@ -117,6 +133,7 @@ public class SIAccountBiz extends Service{ .createTime(new Date()) .updateTime(new Date()) .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .paymentOrganization(param.getPaymentOrganization()) .build(); SiAccountEncrypt.encryptInsuranceAccountBatch(build); MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).insert(build); @@ -129,15 +146,16 @@ public class SIAccountBiz extends Service{ // insuranceSchemeContext.setNewValues(build); // siAccountLoggerTemplate.write(insuranceSchemeContext); } - account(param.getBillMonth(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY,currentUserName); + account(param, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName); } - public void account(String billMonth, Long employeeId, String tenantKey,String currentUserName) { - List employeeIds = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectAccountIds(SalaryDateUtil.getMonthBegin(billMonth)); + public void account(AccountParam param, Long employeeId, String tenantKey, String currentUserName) { + List employeeIds = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectAccountIds(SalaryDateUtil.getMonthBegin(param.getBillMonth()), param.getPaymentOrganization()); if (CollectionUtils.isEmpty(employeeIds)) { List list = Lists.newArrayList(MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(billMonth)); SiAccountEncrypt.decryptInsuranceAccountBatchList(list); + List list = Lists.newArrayList(MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(param.getBillMonth(), param.getPaymentOrganization())); if (CollectionUtils.isNotEmpty(list)) { list.stream().forEach(f -> { MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).deleteById(f.getId()); @@ -145,35 +163,41 @@ public class SIAccountBiz extends Service{ } } SalaryAssert.notEmpty(employeeIds, "no account data"); - AccountParam param = new AccountParam(); - param.setBillMonth(billMonth); + AccountParam selectParam = new AccountParam(); + selectParam.setBillMonth(param.getBillMonth()); + selectParam.setPaymentOrganization(param.getPaymentOrganization()); ExecutorService taskExecutor = Executors.newCachedThreadPool(); taskExecutor.execute(() -> { try { DSTenantKeyThreadVar.tenantKey.set(tenantKey); - accounting(param, employeeId, tenantKey,currentUserName); + accounting(selectParam, employeeId, tenantKey, currentUserName); } finally { DSTenantKeyThreadVar.tenantKey.remove(); } }); } - public void accounting(AccountParam param, Long employeeId, String tenantKey,String currentUserName) { + public void accounting(AccountParam param, Long employeeId, String tenantKey, String currentUserName) { //薪资核算进度暂未实现 // SalaryAcctProgressDTO salaryAcctProgressDTO = salaryAcctProgressService.getProgress(tenantKey + param.getBillMonth(), employeeId, tenantKey); // if (salaryAcctProgressDTO != null && salaryAcctProgressDTO.getProgress().compareTo(BigDecimal.ONE) < 0) { // return; // } - doAccounting(param, employeeId, tenantKey,currentUserName); + doAccounting(param, employeeId, tenantKey, currentUserName); } //@Transactional(propagation = Propagation.NEVER, rollbackFor = Exception.class) - public void doAccounting(AccountParam param, Long employeeId, String tenantKey,String currentUserName) { + public void doAccounting(AccountParam param, Long employeeId, String tenantKey, String currentUserName) { try { List ids; if (CollectionUtils.isEmpty(param.getIds())) { - ids = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectAccountIds(SalaryDateUtil.getMonthBegin(param.getBillMonth())); + // 需要分权的情况 + if(getTaxAgentService().isNeedAuth(employeeId)) { + ids = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectAccountIds(SalaryDateUtil.getMonthBegin(param.getBillMonth()), param.getPaymentOrganization()); + } else { + ids = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectAccountIds(SalaryDateUtil.getMonthBegin(param.getBillMonth()), null); + } } else { ids = param.getIds(); } @@ -181,13 +205,13 @@ public class SIAccountBiz extends Service{ //salaryAcctProgressService.fail(tenantKey + param.getBillMonth(), SalaryI18nUtil.getI18nLabel( 100468, "无需要核算的人员")); return; } - SalaryAcctProgressDTO salaryAcctProgressDTO = new SalaryAcctProgressDTO(SalaryI18nUtil.getI18nLabel( 97515, "核算中"), 97515L, ids.size(), 0, + SalaryAcctProgressDTO salaryAcctProgressDTO = new SalaryAcctProgressDTO(SalaryI18nUtil.getI18nLabel(97515, "核算中"), 97515L, ids.size(), 0, BigDecimal.ZERO, true, "", true); //salaryAcctProgressService.initProgress(tenantKey + param.getBillMonth(), salaryAcctProgressDTO, employeeId, tenantKey); /* List> partition = Lists.partition(ids, 100); CountDownLatch countDownLatch = new CountDownLatch(partition.size()); BlockingDeque results = new LinkedBlockingDeque<>(partition.size());*/ - commonAccount(/*countDownLatch, results, */param.getBillMonth(), ids, employeeId, tenantKey); + commonAccount(/*countDownLatch, results, */param.getBillMonth(), ids, employeeId, tenantKey, param.getPaymentOrganization()); /* for (List batchIds : partition) { taskExecutor.execute(() -> { commonAccount(countDownLatch, results, param.getBillMonth(), batchIds, simpleEmployee); @@ -196,13 +220,14 @@ public class SIAccountBiz extends Service{ countDownLatch.await(); boolean allSuccess = results.stream().allMatch(Boolean::booleanValue);*/ /* if (allSuccess) {*/ - handleData(ids, param.getBillMonth(), employeeId, tenantKey,currentUserName); + handleData(ids, param, employeeId, tenantKey, currentUserName); /*}*/ MapperProxyFactory.getProxy(SIAccountDetailTempMapper.class).batchDelAccountTempDetails(ids, param.getBillMonth()); } catch (Exception e) { log.error("account run fail", e); List list = Lists.newArrayList(MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(param.getBillMonth())); list = SiAccountEncrypt.decryptInsuranceAccountBatchList(list); + List list = Lists.newArrayList(MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(param.getBillMonth(), param.getPaymentOrganization())); if (CollectionUtils.isNotEmpty(list)) { list.stream().forEach(f -> { MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).deleteById(f.getId()); @@ -216,7 +241,7 @@ public class SIAccountBiz extends Service{ } - public void commonAccount(/*CountDownLatch countDownLatch, BlockingDeque results,*/ String billMonth, List ids, Long employeeId, String tenantKey) { + public void commonAccount(/*CountDownLatch countDownLatch, BlockingDeque results,*/ String billMonth, List ids, Long employeeId, String tenantKey, Long paymentOrganization) { /* try {*/ SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); Map insuranceArchivesAccountPOS = siArchivesBiz.buildBatchAccount(ids, tenantKey); @@ -237,6 +262,8 @@ public class SIAccountBiz extends Service{ insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.COMMON.getValue()); insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.SYSTEM.getValue()); insuranceAccountDetailPO.setTenantKey(tenantKey); + insuranceAccountDetailPO.setPaymentOrganization(paymentOrganization); + //核算社保 accountSocial(insuranceAccountDetailPO, v, tenantKey); //核算公积金 @@ -270,23 +297,23 @@ public class SIAccountBiz extends Service{ }*/ } - private List> splitList(List list , int groupSize){ + private List> splitList(List list, int groupSize) { int length = list.size(); // 计算可以分成多少组 - int num = ( length + groupSize - 1 )/groupSize ; + int num = (length + groupSize - 1) / groupSize; List> newList = new ArrayList<>(num); for (int i = 0; i < num; i++) { // 开始位置 int fromIndex = i * groupSize; // 结束位置 - int toIndex = (i+1) * groupSize < length ? ( i+1 ) * groupSize : length ; - newList.add(list.subList(fromIndex,toIndex)) ; + int toIndex = (i + 1) * groupSize < length ? (i + 1) * groupSize : length; + newList.add(list.subList(fromIndex, toIndex)); } - return newList ; + return newList; } - private void handleData(List ids, String billMonth, Long employeeId, String tenantKey,String currentUserName) { + private void handleData(List ids, AccountParam param, Long employeeId, String tenantKey, String currentUserName) { //事务后续处理 //TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition()); try { @@ -305,7 +332,7 @@ public class SIAccountBiz extends Service{ lists.forEach(subList -> { MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchSaveAccountDetails(subList); }); - updateBatchAccount(billMonth, employeeId, tenantKey,currentUserName); + updateBatchAccount(param, employeeId, tenantKey, currentUserName); } //transactionManager.commit(status); } catch (Exception e) { @@ -676,12 +703,12 @@ public class SIAccountBiz extends Service{ /** * 跟新台账接口 * - * @param billMonth 账单月份 * @param tenantKey 租户key */ - public void updateBatchAccount(String billMonth, Long employeeId, String tenantKey,String currentUserName) { + public void updateBatchAccount(AccountParam param, Long employeeId, String tenantKey, String currentUserName) { + String billMonth = param.getBillMonth(); - List insuranceAccountDetailPOS = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectList(billMonth); + List insuranceAccountDetailPOS = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectList(billMonth, String.valueOf(param.getPaymentOrganization())); Map> map = insuranceAccountDetailPOS.stream().filter(item -> item.getEmployeeId() != null) .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getEmployeeId)); int socialAccountPerson = 0; @@ -725,6 +752,8 @@ public class SIAccountBiz extends Service{ } InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(billMonth); SiAccountEncrypt.decryptInsuranceAccountBatch(insuranceAccountBatchPO); + InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(billMonth,param.getPaymentOrganization()); + DataCollectionEmployee simpleEmployee = MapperProxyFactory.getProxy(EmployMapper.class).getEmployeeById(employeeId); insuranceAccountBatchPO.setAccountant(currentUserName); insuranceAccountBatchPO.setUpdateTime(new Date()); @@ -748,28 +777,34 @@ public class SIAccountBiz extends Service{ } - public void saveCommonAccount(SaveCommonAccountParam param, Long employeeId,String currentUserName) { + public void saveCommonAccount(SaveCommonAccountParam param, Long employeeId, String currentUserName) { List collect; - SalaryAssert.notEmpty(param.getIncludes(), SalaryI18nUtil.getI18nLabel( 100466, "参数为空")); - SalaryAssert.notNull(param.getBillMonth(), SalaryI18nUtil.getI18nLabel( 100467, "账单月为空")); + SalaryAssert.notEmpty(param.getIncludes(), SalaryI18nUtil.getI18nLabel(100466, "参数为空")); + SalaryAssert.notNull(param.getBillMonth(), SalaryI18nUtil.getI18nLabel(100467, "账单月为空")); if (CollectionUtils.isNotEmpty(param.getExcludes())) { collect = param.getIncludes().stream().filter(item -> !param.getExcludes().contains(item)).collect(Collectors.toList()); } else { collect = param.getIncludes(); } - SalaryAssert.notEmpty(collect, SalaryI18nUtil.getI18nLabel( 99920, "无核算人员")); + SalaryAssert.notEmpty(collect, SalaryI18nUtil.getI18nLabel(99920, "无核算人员")); AccountParam accountParam = new AccountParam(); accountParam.setBillMonth(param.getBillMonth()); accountParam.setIds(collect); - accounting(accountParam, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY,currentUserName); + accounting(accountParam, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName); } public void delete(AccountParam param, Long employeeId) { InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(param.getBillMonth()); SiAccountEncrypt.decryptInsuranceAccountBatch(insuranceAccountBatchPO); SalaryAssert.notNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel( 84026, "参数错误")); +// if(param.getPaymentOrganization()==null){ +// throw new SalaryRunTimeException("个税扣缴义务人为空"); +// } + + InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(param.getBillMonth(),param.getPaymentOrganization()); + SalaryAssert.notNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(84026, "参数错误")); MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).deleteById(insuranceAccountBatchPO.getId()); - MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchDeleteNotFile(param.getBillMonth()); + MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchDeleteNotFile(param.getBillMonth(),param.getPaymentOrganization()); // LoggerContext insuranceSchemeContext = new LoggerContext(); // insuranceSchemeContext.setTargetId(String.valueOf(insuranceAccountBatchPO.getId())); // insuranceSchemeContext.setTargetName(insuranceAccountBatchPO.getBillMonth()); @@ -780,21 +815,21 @@ public class SIAccountBiz extends Service{ // siAccountLoggerTemplate.write(insuranceSchemeContext); } - public void saveSupplementaryAccount(SaveSupplementaryAccountParam param, Long employeeId,String currentUserName) { + public void saveSupplementaryAccount(SaveSupplementaryAccountParam param, Long employeeId, String currentUserName) { if (StringUtils.isBlank(param.getBillMonth()) || CollectionUtils.isEmpty(param.getBillMonthList()) || CollectionUtils.isEmpty(param.getProjects()) || CollectionUtils.isEmpty(param.getIncludes())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel( 84026, "参数错误")); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); } //需要补缴的月份 if (param.getBillMonthList().contains(param.getBillMonth())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel( 100481, "当前月走正常缴纳")); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100481, "当前月走正常缴纳")); } //需要补缴的员工id List employeeIds = param.getIncludes(); if (CollectionUtils.isNotEmpty(param.getExcludes())) { employeeIds = employeeIds.stream().filter(item -> !param.getExcludes().contains(item)).collect(Collectors.toList()); } - SalaryAssert.notEmpty(employeeIds, SalaryI18nUtil.getI18nLabel( 99920, "无核算人员")); + SalaryAssert.notEmpty(employeeIds, SalaryI18nUtil.getI18nLabel(99920, "无核算人员")); List baseList = new ArrayList<>(); employeeIds.stream().forEach(id -> { param.getBillMonthList().stream().forEach(month -> { @@ -808,8 +843,9 @@ public class SIAccountBiz extends Service{ }); }); //核算开始 - accountSupplement(baseList, employeeIds, param.getBillMonth(),employeeId); - updateBatchAccount(param.getBillMonth(), employeeId,SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY,currentUserName); + accountSupplement(baseList, employeeIds, param.getBillMonth(), employeeId); + + updateBatchAccount(AccountParam.builder().billMonth(param.getBillMonth()).paymentOrganization(param.getPaymentOrganization()).build(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName); } /** @@ -817,21 +853,21 @@ public class SIAccountBiz extends Service{ * @param employeeIds 需要补缴的员工id * @return */ - public String accountSupplement(List baseList, List employeeIds, String billMonth,Long employeeId) { + public String accountSupplement(List baseList, List employeeIds, String billMonth, Long employeeId) { //(k,v) k-员工id v-员工对应的福利档案数据 - Map longInsuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds,SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + Map longInsuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); //核算结果集 List pos = new ArrayList<>(); baseList.forEach(baseParam -> { - InsuranceAccountDetailPO insuranceAccountDetailPO = accountSingleEmployeeBill(baseParam, longInsuranceArchivesAccountPOMap.get(baseParam.getEmployeeId()),employeeId); + InsuranceAccountDetailPO insuranceAccountDetailPO = accountSingleEmployeeBill(baseParam, longInsuranceArchivesAccountPOMap.get(baseParam.getEmployeeId()), employeeId); pos.add(insuranceAccountDetailPO); }); - batchSaveSupplementAccount(pos, billMonth,SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + batchSaveSupplementAccount(pos, billMonth, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); return SalaryI18nUtil.getI18nLabel(100492, "核算完成,数据保存成功"); } - public InsuranceAccountDetailPO accountSingleEmployeeBill(SupplementAccountBaseParam baseParam, InsuranceArchivesAccountPO accountPO,Long employeeId) { + public InsuranceAccountDetailPO accountSingleEmployeeBill(SupplementAccountBaseParam baseParam, InsuranceArchivesAccountPO accountPO, Long employeeId) { InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); List projects = baseParam.getProjects(); insuranceAccountDetailPO.setBillMonth(baseParam.getBillMonth()); @@ -1218,19 +1254,19 @@ public class SIAccountBiz extends Service{ } - private List> splitDetailList(List list , int groupSize){ + private List> splitDetailList(List list, int groupSize) { int length = list.size(); // 计算可以分成多少组 - int num = ( length + groupSize - 1 )/groupSize ; // TODO + int num = (length + groupSize - 1) / groupSize; // TODO List> newList = new ArrayList<>(num); for (int i = 0; i < num; i++) { // 开始位置 int fromIndex = i * groupSize; // 结束位置 - int toIndex = (i+1) * groupSize < length ? ( i+1 ) * groupSize : length ; - newList.add(list.subList(fromIndex,toIndex)) ; + int toIndex = (i + 1) * groupSize < length ? (i + 1) * groupSize : length; + newList.add(list.subList(fromIndex, toIndex)); } - return newList ; + return newList; } //@Transactional @@ -1269,11 +1305,12 @@ public class SIAccountBiz extends Service{ // }); } - public void deleteCommonAccount(SaveCommonAccountParam param, Long employeeId,String currentUserName) { - SalaryAssert.notBlank(param.getBillMonth(), SalaryI18nUtil.getI18nLabel( 84026, "参数错误")); - SalaryAssert.notEmpty(param.getIncludes(), SalaryI18nUtil.getI18nLabel( 84026, "参数错误")); - MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchDelAccountDetails(param.getIncludes(), param.getBillMonth()); - //记录日志 + public void deleteCommonAccount(SaveCommonAccountParam param, Long employeeId, String currentUserName) { + ValidUtil.doValidator(param); + SalaryAssert.notBlank(param.getBillMonth(), SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + SalaryAssert.notEmpty(param.getIncludes(), SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchDelAccountDetails(param.getIncludes(), param.getBillMonth(),param.getPaymentOrganization()); + //记录日志 // LoggerContext insuranceSchemeContext = new LoggerContext(); // insuranceSchemeContext.setTargetId(String.join(",", param.getIncludes().stream().map(item -> String.valueOf(item)).collect(Collectors.toList()))); // insuranceSchemeContext.setTargetName(param.getBillMonth()); @@ -1282,10 +1319,10 @@ public class SIAccountBiz extends Service{ // insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账")); // insuranceSchemeContext.setNewValues(param); // siAccountLoggerTemplate.write(insuranceSchemeContext); - updateBatchAccount(param.getBillMonth(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY,currentUserName); + updateBatchAccount(AccountParam.builder().billMonth(param.getBillMonth()).paymentOrganization(param.getPaymentOrganization()).build(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName); } - public void deleteSupplementaryAccount(List param, Long employeeId,String currentUserName) { + public void deleteSupplementaryAccount(List param, Long employeeId, String currentUserName) { SalaryAssert.notEmpty(param, SalaryI18nUtil.getI18nLabel(84026, "参数错误")); boolean valid = param.stream().anyMatch(item -> item.getEmployeeId() == null || StringUtils.isBlank(item.getSupplementaryMonth()) @@ -1304,11 +1341,11 @@ public class SIAccountBiz extends Service{ // insuranceSchemeContext.setNewValues(item); // siAccountLoggerTemplate.write(insuranceSchemeContext); // }); - updateBatchAccount(param.get(0).getBillMonth(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY,currentUserName); + updateBatchAccount(AccountParam.builder().billMonth(param.get(0).getBillMonth()).paymentOrganization(param.get(0).getPaymentOrganization()).build(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName); } - public void file(String billMonth, Long employeeId) { - // TODO 归档前检查是否有核算异常 + public void file(String billMonth, Long employeeId, Long paymentOrganization) { + // 归档前检查是否有核算异常 // List insuranceAccountInspectPOS = MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class).getByInspectStatusAndBillMonth(InspectStatusEnum.IGNORE.getValue(),billMonth); // SalaryAssert.isEmpty(insuranceAccountInspectPOS, SalaryI18nUtil.getI18nLabel( 100500, "当前核算月存在核算异常数据")); @@ -1317,10 +1354,14 @@ public class SIAccountBiz extends Service{ SiAccountEncrypt.decryptInsuranceAccountBatch(insuranceAccountBatchPO); SalaryAssert.notNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel( 100503, "月份账单不存在")); SalaryAssert.isFalse(insuranceAccountBatchPO.getBillStatus() == BillStatusEnum.ARCHIVED.getValue(), SalaryI18nUtil.getI18nLabel( 100504, "月份账单已归档")); + InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillStatus(billMonth, BillStatusEnum.NOT_ARCHIVED.getValue(), paymentOrganization); + + SalaryAssert.notNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(100503, "月份账单不存在")); + SalaryAssert.isFalse(insuranceAccountBatchPO.getBillStatus() == BillStatusEnum.ARCHIVED.getValue(), SalaryI18nUtil.getI18nLabel(100504, "月份账单已归档")); insuranceAccountBatchPO.setBillStatus(BillStatusEnum.ARCHIVED.getValue()); SiAccountEncrypt.encryptInsuranceAccountBatch(insuranceAccountBatchPO); MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).updateById(insuranceAccountBatchPO); - //日志记录 + //日志记录 // LoggerContext insuranceSchemeContext = new LoggerContext(); // insuranceSchemeContext.setTargetId(String.valueOf(insuranceAccountBatchPO.getId())); // insuranceSchemeContext.setTargetName(insuranceAccountBatchPO.getBillMonth()); @@ -1332,9 +1373,9 @@ public class SIAccountBiz extends Service{ } - public void accountInspect(Collection ids, String billMonth, Long employeeId,String currentUserName) { + public void accountInspect(Collection ids, String billMonth, Long employeeId, String currentUserName) { List insuranceAccountInspectPOS = allInspects(ids, billMonth); - SalaryAssert.notEmpty(insuranceAccountInspectPOS, SalaryI18nUtil.getI18nLabel( 100515, "无核算数据")); + SalaryAssert.notEmpty(insuranceAccountInspectPOS, SalaryI18nUtil.getI18nLabel(100515, "无核算数据")); List commonInspects = insuranceAccountInspectPOS.stream() .filter(e -> Objects.equals(e.getPaymentStatus(), PaymentStatusEnum.COMMON.getValue())) .collect(Collectors.toList()); @@ -1346,7 +1387,7 @@ public class SIAccountBiz extends Service{ SaveCommonAccountParam param = new SaveCommonAccountParam(); param.setBillMonth(billMonth); param.setIncludes(commonInspects.stream().map(InsuranceAccountInspectPO::getEmployeeId).collect(Collectors.toList())); - saveCommonAccount(param, employeeId,currentUserName); + saveCommonAccount(param, employeeId, currentUserName); } //核算补缴 if (CollectionUtils.isNotEmpty(supplementInspects)) { @@ -1360,13 +1401,13 @@ public class SIAccountBiz extends Service{ base.setSupplementaryMonth(e.getSupplementaryMonth()); baseList.add(base); }); - accountSupplement(baseList, baseList.stream().map(SupplementAccountBaseParam::getEmployeeId).collect(Collectors.toList()), billMonth,employeeId); + accountSupplement(baseList, baseList.stream().map(SupplementAccountBaseParam::getEmployeeId).collect(Collectors.toList()), billMonth, employeeId); } } public List allInspects(Collection ids, String billMonth) { - List list = MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class).getList(billMonth,InspectStatusEnum.IGNORE.getValue(),ids); + List list = MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class).getList(billMonth, InspectStatusEnum.IGNORE.getValue(), ids); if (CollectionUtils.isNotEmpty(list)) { return list; @@ -1380,9 +1421,11 @@ public class SIAccountBiz extends Service{ // SalaryPageUtil.start(queryParam.getCurrent(),queryParam.getPageSize()); List insuranceAccountDetailPOS = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectList(queryParam.getBillMonth()); InsuranceAccountDetailPOEncrypt.decryptInsuranceAccountDetailPOList(insuranceAccountDetailPOS); + List insuranceAccountDetailPOS = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectList(queryParam.getBillMonth(), queryParam.getPaymentOrganization()); + //获取扣缴义务人信息 List paymentList = MapperProxyFactory.getProxy(TaxAgentMapper.class).listAll(); - SalaryAssert.notEmpty(paymentList, SalaryI18nUtil.getI18nLabel( 100341, "该租户无扣缴义务人")); + SalaryAssert.notEmpty(paymentList, SalaryI18nUtil.getI18nLabel(100341, "该租户无扣缴义务人")); Map paymentMap = paymentList.stream().collect(Collectors.toMap(TaxAgent::getId, Function.identity())); List insuranceAccountViewListDTOS = buildRecords(insuranceAccountDetailPOS, paymentMap); @@ -1391,7 +1434,7 @@ public class SIAccountBiz extends Service{ // Page insuranceAccountViewListDTOPage = new Page<>(page.getCurrent(), insuranceAccountViewListDTOS.size(), insuranceAccountViewListDTOS.size(), // page.isSearchCount()); - PageInfo insuranceAccountViewListDTOPage = new PageInfo<>(insuranceAccountViewListDTOS,InsuranceAccountViewListDTO.class); + PageInfo insuranceAccountViewListDTOPage = new PageInfo<>(insuranceAccountViewListDTOS, InsuranceAccountViewListDTO.class); insuranceAccountViewListDTOPage.setTotal(insuranceAccountViewListDTOS.size()); return insuranceAccountViewListDTOPage; } diff --git a/src/com/engine/salary/biz/SIArchivesBiz.java b/src/com/engine/salary/biz/SIArchivesBiz.java index 64d2743ae..42ee91956 100644 --- a/src/com/engine/salary/biz/SIArchivesBiz.java +++ b/src/com/engine/salary/biz/SIArchivesBiz.java @@ -46,6 +46,7 @@ import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; import lombok.Data; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.apache.ibatis.session.SqlSession; @@ -66,6 +67,7 @@ import java.util.stream.Collectors; * @Version V1.0 **/ @Data +@Slf4j public class SIArchivesBiz { Boolean needAuth ; @@ -648,11 +650,14 @@ public class SIArchivesBiz { PageInfo pageInfo = new PageInfo<>(InsuranceArchivesEmployeePO.class); if (needAuth) { Collection taxAgentEmployeeIds = param.getTaxAgentEmployeeIds(); + log.info("taxAgentEmployeeIds: ", taxAgentEmployeeIds); page = socialSchemeMapper.queryEmployeeList(param); + log.info("page size: ", page.size()); page = page.stream().filter(f -> // 作为管理员 taxAgentEmployeeIds.contains(f.getEmployeeId()) ).collect(Collectors.toList()); + log.info("page collect size: ", page.size()); // 填充总数和当页数据 // 分页参数 pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), InsuranceArchivesEmployeePO.class); diff --git a/src/com/engine/salary/entity/siaccount/bo/InsuranceAccountBO.java b/src/com/engine/salary/entity/siaccount/bo/InsuranceAccountBO.java index 5bc24bf01..aa39ab226 100644 --- a/src/com/engine/salary/entity/siaccount/bo/InsuranceAccountBO.java +++ b/src/com/engine/salary/entity/siaccount/bo/InsuranceAccountBO.java @@ -4,8 +4,10 @@ package com.engine.salary.entity.siaccount.bo; import com.engine.salary.entity.siaccount.dto.InsuranceAccountBatchListDTO; import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; import com.engine.salary.enums.siaccount.BillStatusEnum; +import com.engine.salary.mapper.TaxAgentMapper; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryEnumUtil; +import com.engine.salary.util.db.MapperProxyFactory; import org.apache.commons.collections.CollectionUtils; import java.text.SimpleDateFormat; @@ -61,6 +63,8 @@ public class InsuranceAccountBO { .remarks(e.getRemarks()) .socialNum(e.getSocialNum()) .socialPay(SalaryEntityUtil.thousandthConvert(e.getSocialPay())) + .paymentOrganization(e.getPaymentOrganization() != null ? MapperProxyFactory.getProxy(TaxAgentMapper.class).getById(e.getPaymentOrganization()).getName() : "") + .paymentOrganizationId(e.getPaymentOrganization()) .build() ).collect(Collectors.toList()); } diff --git a/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountBatchListDTO.java b/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountBatchListDTO.java index 4265676fe..c41e2138c 100644 --- a/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountBatchListDTO.java +++ b/src/com/engine/salary/entity/siaccount/dto/InsuranceAccountBatchListDTO.java @@ -41,6 +41,11 @@ public class InsuranceAccountBatchListDTO { @TableTitle(title = "账单月份", dataIndex = "billMonth", key = "billMonth") private String billMonth; + @TableTitle(title = "个税扣缴义务人", dataIndex = "paymentOrganization", key = "paymentOrganization") + private String paymentOrganization; + + private Long paymentOrganizationId; + /** * 账单状态 0-未归档 1-已归档 */ @@ -102,4 +107,6 @@ public class InsuranceAccountBatchListDTO { private String remarks; + + } diff --git a/src/com/engine/salary/entity/siaccount/param/AccountParam.java b/src/com/engine/salary/entity/siaccount/param/AccountParam.java index 9e67046d7..c6695da7c 100644 --- a/src/com/engine/salary/entity/siaccount/param/AccountParam.java +++ b/src/com/engine/salary/entity/siaccount/param/AccountParam.java @@ -35,4 +35,11 @@ public class AccountParam { // 是否是首次核算 private boolean flag = true; + + /** + * 个税扣缴义务人id + */ +// @DataCheck(require = true,message = "个税扣缴义务人不能为空") + private Long paymentOrganization; + } diff --git a/src/com/engine/salary/entity/siaccount/param/InsuranceAccountBatchParam.java b/src/com/engine/salary/entity/siaccount/param/InsuranceAccountBatchParam.java index 4fc596729..99894b6d3 100644 --- a/src/com/engine/salary/entity/siaccount/param/InsuranceAccountBatchParam.java +++ b/src/com/engine/salary/entity/siaccount/param/InsuranceAccountBatchParam.java @@ -6,6 +6,8 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + /** * @Author weaver_cl * @Description: TODO @@ -23,4 +25,6 @@ public class InsuranceAccountBatchParam extends BaseQueryParam { //结束时间 private String endTime; + + private List taxAgents; } diff --git a/src/com/engine/salary/entity/siaccount/param/InsuranceAccountDetailParam.java b/src/com/engine/salary/entity/siaccount/param/InsuranceAccountDetailParam.java index 293a4c172..bbe81cd98 100644 --- a/src/com/engine/salary/entity/siaccount/param/InsuranceAccountDetailParam.java +++ b/src/com/engine/salary/entity/siaccount/param/InsuranceAccountDetailParam.java @@ -25,4 +25,6 @@ public class InsuranceAccountDetailParam extends BaseQueryParam { private List employeeIds; private String userName; + + private String paymentOrganization; } diff --git a/src/com/engine/salary/entity/siaccount/param/SaveCommonAccountParam.java b/src/com/engine/salary/entity/siaccount/param/SaveCommonAccountParam.java index 14b6eded1..00c33f845 100644 --- a/src/com/engine/salary/entity/siaccount/param/SaveCommonAccountParam.java +++ b/src/com/engine/salary/entity/siaccount/param/SaveCommonAccountParam.java @@ -1,5 +1,6 @@ package com.engine.salary.entity.siaccount.param; +import com.engine.salary.util.valid.DataCheck; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -27,4 +28,10 @@ public class SaveCommonAccountParam { //账单月份") private String billMonth; + + /** + * 个税扣缴义务人id + */ + @DataCheck(require = true,message = "个税扣缴义务人不能为空") + private Long paymentOrganization; } diff --git a/src/com/engine/salary/entity/siaccount/param/SaveSupplementaryAccountParam.java b/src/com/engine/salary/entity/siaccount/param/SaveSupplementaryAccountParam.java index 2ce919024..9ca1d1688 100644 --- a/src/com/engine/salary/entity/siaccount/param/SaveSupplementaryAccountParam.java +++ b/src/com/engine/salary/entity/siaccount/param/SaveSupplementaryAccountParam.java @@ -2,6 +2,7 @@ package com.engine.salary.entity.siaccount.param; import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.serializer.ToStringSerializer; +import com.engine.salary.util.valid.DataCheck; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -38,4 +39,10 @@ public class SaveSupplementaryAccountParam { //账单月份") private String billMonth; + + /** + * 个税扣缴义务人id + */ + @DataCheck(require = true,message = "个税扣缴义务人不能为空") + private Long paymentOrganization; } diff --git a/src/com/engine/salary/entity/siaccount/param/SupplementAccountBaseParam.java b/src/com/engine/salary/entity/siaccount/param/SupplementAccountBaseParam.java index 09d8c3be2..1d70cabc4 100644 --- a/src/com/engine/salary/entity/siaccount/param/SupplementAccountBaseParam.java +++ b/src/com/engine/salary/entity/siaccount/param/SupplementAccountBaseParam.java @@ -1,5 +1,6 @@ package com.engine.salary.entity.siaccount.param; +import com.engine.salary.util.valid.DataCheck; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -25,6 +26,12 @@ public class SupplementAccountBaseParam { //账单月份") private String billMonth; + /** + * 个税扣缴义务人id + */ + @DataCheck(require = true,message = "个税扣缴义务人不能为空") + private Long paymentOrganization; + //补缴月份") private String supplementaryMonth; diff --git a/src/com/engine/salary/entity/siaccount/po/InsuranceAccountBatchPO.java b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountBatchPO.java index e00d9126e..3aec5159e 100644 --- a/src/com/engine/salary/entity/siaccount/po/InsuranceAccountBatchPO.java +++ b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountBatchPO.java @@ -100,4 +100,10 @@ public class InsuranceAccountBatchPO { */ private String tenantKey; + /** + * 个税扣缴义务人 + */ + private Long paymentOrganization; + + } diff --git a/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailPO.java b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailPO.java index 9b249b0e5..b1ed7db6e 100644 --- a/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailPO.java +++ b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailPO.java @@ -2,12 +2,10 @@ package com.engine.salary.entity.siaccount.po; import com.cloudstore.eccom.pc.table.WeaTableType; import com.engine.salary.annotation.SalaryTable; -import com.engine.salary.annotation.SalaryTableOperate; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; import java.util.Date; @@ -239,4 +237,9 @@ public class InsuranceAccountDetailPO { * 租户key */ private String tenantKey; + + /** + * 个税扣缴义务人 + */ + private Long paymentOrganization; } diff --git a/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailTempPO.java b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailTempPO.java index 37d376c61..f2090de3a 100644 --- a/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailTempPO.java +++ b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailTempPO.java @@ -4,7 +4,6 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; import java.util.Date; @@ -235,4 +234,9 @@ public class InsuranceAccountDetailTempPO { * 租户key */ private String tenantKey; + + /** + * 个税扣缴义务人 + */ + private Long paymentOrganization; } diff --git a/src/com/engine/salary/entity/siexport/param/InsuranceExportParam.java b/src/com/engine/salary/entity/siexport/param/InsuranceExportParam.java index 0e199aaae..b6a216a55 100644 --- a/src/com/engine/salary/entity/siexport/param/InsuranceExportParam.java +++ b/src/com/engine/salary/entity/siexport/param/InsuranceExportParam.java @@ -22,4 +22,6 @@ public class InsuranceExportParam { //@NotBlank @DataCheck(require = true,message = "账单月份不可为空") private String billMonth; + + private String paymentOrganization; } diff --git a/src/com/engine/salary/mapper/datacollection/EmployMapper.xml b/src/com/engine/salary/mapper/datacollection/EmployMapper.xml index da7125274..b3d45863f 100644 --- a/src/com/engine/salary/mapper/datacollection/EmployMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/EmployMapper.xml @@ -6,7 +6,8 @@ select e.ID as employeeId, e.LASTNAME as username, d.DEPARTMENTNAME as departmentName, - e.status + e.status, + e.mobile from hrmresource e left join hrmdepartment d on e.departmentid = d.id where e.status not in (7) and (e.accounttype is null or e.accounttype = 0) diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java index 24262cceb..5a33d0c95 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java @@ -4,7 +4,6 @@ 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; /** @@ -27,7 +26,7 @@ public interface InsuranceAccountBatchMapper { * @param billMonth * @return */ - InsuranceAccountBatchPO getByBillMonth(@Param("billMonth") String billMonth); + InsuranceAccountBatchPO getByBillMonth(@Param("billMonth") String billMonth,@Param("paymentOrganization") Long paymentOrganization); /** * 插入 @@ -56,7 +55,7 @@ public interface InsuranceAccountBatchMapper { * @param billStatus * @return */ - InsuranceAccountBatchPO getByBillStatus(@Param("billMonth") String billMonth,@Param("billStatus")Integer billStatus); + InsuranceAccountBatchPO getByBillStatus(@Param("billMonth") String billMonth,@Param("billStatus")Integer billStatus, @Param("paymentOrganization") Long paymentOrganization); List listByTimeRange(@Param("minDate") String minDate, @Param("maxDate") String maxDate); diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml index 578d953f6..c85470d7d 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml @@ -18,6 +18,7 @@ + @@ -38,6 +39,7 @@ , t.create_time , t.update_time , t.tenant_key + , t.payment_organization #{billMonth}, @@ -77,6 +80,7 @@ #{createTime}, #{updateTime}, #{tenantKey}, + #{paymentOrganization}, @@ -103,6 +107,7 @@ create_time, update_time, tenant_key, + payment_organization, #{billMonth}, @@ -120,6 +125,7 @@ #{createTime}, #{updateTime}, #{tenantKey}, + #{paymentOrganization}, @@ -130,14 +136,22 @@ AND t.bill_month between #{param.startTime} and #{param.endTime} + + AND + t.payment_organization in + + #{taxAgent} + + @@ -172,6 +189,9 @@ WHERE t.delete_type = 0 AND t.bill_month = #{billMonth} AND t.bill_status = #{billStatus} + + AND t.payment_organization = #{paymentOrganization} + @@ -197,6 +217,9 @@ bill_status=#{billStatus} WHERE id = #{id} AND delete_type = 0 + + AND payment_organization = #{paymentOrganization} + diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java index 3c7183a43..80c374f30 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java @@ -29,7 +29,7 @@ public interface InsuranceAccountDetailMapper { * @param time * @return */ - List selectAccountIds(@Param("time") String time); + List selectAccountIds(@Param("time") String time,@Param("paymentOrganization") Long paymentOrganization); /** * 根据id删除 @@ -40,7 +40,7 @@ public interface InsuranceAccountDetailMapper { /** * 批量删除 */ - void batchDelAccountDetails(@Param("employeeIds") Collection employeeIds, @Param("billMonth") String billMonth); + void batchDelAccountDetails(@Param("employeeIds") Collection employeeIds, @Param("billMonth") String billMonth,@Param("paymentOrganization") Long paymentOrganization); /** * 批量保存 @@ -54,7 +54,7 @@ public interface InsuranceAccountDetailMapper { * @param billMonth * @return */ - List selectList(@Param("billMonth") String billMonth); + List selectList(@Param("billMonth") String billMonth, @Param("paymentOrganization") String paymentOrganization); List queryList(@Param("billMonth") String billMonth,@Param("employeeIds") Collection employeeIds); @@ -63,7 +63,7 @@ public interface InsuranceAccountDetailMapper { * 根据账单月份删除 * @param billMonth */ - void batchDeleteNotFile(@Param("billMonth") String billMonth); + void batchDeleteNotFile(@Param("billMonth") String billMonth,@Param("paymentOrganization") Long paymentOrganization); /** diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml index ae917a135..d970f1cc6 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml @@ -45,6 +45,7 @@ + @@ -93,6 +94,7 @@ , t.create_time , t.update_time , t.tenant_key + , t.payment_organization @@ -104,6 +106,10 @@ AND t.payment_status = #{param.paymentStatus} + + AND + t.payment_organization = #{param.paymentOrganization} + @@ -156,6 +162,9 @@ hrsa_bill_detail t WHERE t.delete_type = 0 AND t.bill_month = #{billMonth} + + AND t.payment_organization = #{paymentOrganization} + + + @@ -183,7 +185,6 @@ - UPDATE hrsa_tax_agent diff --git a/src/com/engine/salary/service/SIAccountService.java b/src/com/engine/salary/service/SIAccountService.java index 39d96d030..70bbc7851 100644 --- a/src/com/engine/salary/service/SIAccountService.java +++ b/src/com/engine/salary/service/SIAccountService.java @@ -4,9 +4,8 @@ import com.engine.salary.entity.siaccount.dto.InsuranceAccountTabDTO; import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; import com.engine.salary.entity.siaccount.param.*; import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; -import com.engine.salary.entity.siexport.param.InsuranceExportParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.util.page.PageInfo; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.util.Collection; import java.util.List; @@ -134,7 +133,7 @@ public interface SIAccountService { * tab信息 * @param billMonth */ - InsuranceAccountTabDTO tabList(String billMonth); + InsuranceAccountTabDTO tabList(AccountParam build); /** * 人员异动 @@ -201,5 +200,7 @@ public interface SIAccountService { * @return */ List allInspects(Collection ids, String billMonth); + + Collection getAdminTaxAgentList(); } diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java index 3899bbd94..a9b2d2f5d 100644 --- a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -24,6 +24,7 @@ import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.enums.UserStatusEnum; import com.engine.salary.enums.siaccount.BillStatusEnum; import com.engine.salary.enums.siaccount.InspectStatusEnum; @@ -34,15 +35,7 @@ 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.sicategory.ICategoryMapper; -import com.engine.salary.service.ColumnBuildService; -import com.engine.salary.service.RecordsBuildService; -import com.engine.salary.service.SIAccountService; - -import java.math.BigDecimal; -import java.util.*; -import java.util.stream.Collectors; - -import com.engine.salary.service.SICategoryService; +import com.engine.salary.service.*; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryFormItemUtil; import com.engine.salary.util.SalaryI18nUtil; @@ -56,6 +49,10 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import weaver.hrm.User; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + /** * @Author weaver_cl @@ -65,7 +62,7 @@ import weaver.hrm.User; **/ public class SIAccountServiceImpl extends Service implements SIAccountService { - private SIAccountBiz siAccountBiz = new SIAccountBiz(); +// private SIAccountBiz siAccountBiz = new SIAccountBiz(); private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); @@ -73,6 +70,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { return ServiceUtil.getService(RecordsBuildServiceImpl.class,user); } + public SIAccountBiz getSiAccountBiz(User user) { + return ServiceUtil.getService(SIAccountBiz.class,user); + } + public ColumnBuildService getColumnBuildService(User user) { return ServiceUtil.getService(ColumnBuildServiceImpl.class,user); } @@ -81,14 +82,24 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { return ServiceUtil.getService(SICategoryServiceImpl.class,user); } + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } @Override public Map listPage(InsuranceAccountBatchParam queryParam) { Long employeeId = (long)user.getUID(); Map datas = new HashMap<>(); + // 分权逻辑 + if(getTaxAgentService(user).isNeedAuth((long) user.getUID())) { + Collection taxAgentPOS = getTaxAgentService(user).listAllTaxAgents((long) user.getUID()); + List taxAgents = taxAgentPOS.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + queryParam.setTaxAgents(taxAgents); + } + //福利台账列表 - PageInfo pageInfo = siAccountBiz.listPage(queryParam,employeeId); + PageInfo pageInfo = getSiAccountBiz(user).listPage(queryParam,employeeId); Collection insuranceAccountBatchPOS = pageInfo.getList(); List insuranceAccountBatchListDTOS = InsuranceAccountBO.buildAccountBatchDTOList(insuranceAccountBatchPOS); @@ -157,7 +168,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { Map datas = new HashMap<>(); //正常缴纳列表 - PageInfo pageInfo = siAccountBiz.listCommonPage(queryParam); + PageInfo pageInfo = getSiAccountBiz(user).listCommonPage(queryParam); List insuranceAccountDetailPOS = pageInfo.getList(); //数据组装 @@ -290,7 +301,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { Long employeeId = (long)user.getUID(); String lastName = user.getLastname(); ValidUtil.doValidator(param); - siAccountBiz.save(param.isFlag(),param,employeeId,lastName); + getSiAccountBiz(user).save(param.isFlag(),param,employeeId,lastName); } @Override @@ -298,49 +309,49 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { Long employeeId = (long)user.getUID(); ValidUtil.doValidator(param); String currentUserName = user.getLastname(); - siAccountBiz.saveCommonAccount(param,employeeId,currentUserName); + getSiAccountBiz(user).saveCommonAccount(param,employeeId,currentUserName); } @Override public void delete(AccountParam accountParam) { Long employeeId = (long)user.getUID(); - siAccountBiz.delete(accountParam,employeeId); + getSiAccountBiz(user).delete(accountParam,employeeId); } @Override public void saveCommonAccount(SaveCommonAccountParam accountParam) { Long employeeId = (long)user.getUID(); String currentUserName = user.getLastname(); - siAccountBiz.saveCommonAccount(accountParam,employeeId,currentUserName); + getSiAccountBiz(user).saveCommonAccount(accountParam,employeeId,currentUserName); } @Override public void saveSupplementaryAccount(SaveSupplementaryAccountParam saveSupplementaryAccountParam) { Long employeeId = (long)user.getUID(); String currentUserName = user.getLastname(); - siAccountBiz.saveSupplementaryAccount(saveSupplementaryAccountParam,employeeId,currentUserName); + getSiAccountBiz(user).saveSupplementaryAccount(saveSupplementaryAccountParam,employeeId,currentUserName); } @Override public void deleteCommonAccount(SaveCommonAccountParam param) { + ValidUtil.doValidator(param); Long employeeId = (long)user.getUID(); String currentUserName = user.getLastname(); - siAccountBiz.deleteCommonAccount(param,employeeId,currentUserName); + getSiAccountBiz(user).deleteCommonAccount(param,employeeId,currentUserName); } @Override public void deleteSummplementaryAccount(List supplementAccountBaseParams) { Long employeeId = (long)user.getUID(); String currentUserName = user.getLastname(); - - siAccountBiz.deleteSupplementaryAccount(supplementAccountBaseParams,employeeId,currentUserName); + getSiAccountBiz(user).deleteSupplementaryAccount(supplementAccountBaseParams,employeeId,currentUserName); } @Override public void file(AccountParam accountParam) { Long employeeId = (long)user.getUID(); String billMonth = accountParam.getBillMonth(); - siAccountBiz.file(billMonth,employeeId); + getSiAccountBiz(user).file(billMonth,employeeId, accountParam.getPaymentOrganization()); } @Override @@ -375,9 +386,9 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { } @Override - public InsuranceAccountTabDTO tabList(String billMonth) { + public InsuranceAccountTabDTO tabList(AccountParam build) { InsuranceAccountTabDTO insuranceAccountTabDTO = InsuranceAccountTabDTO.builder().build(); - InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(billMonth); + InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(build.getBillMonth(),build.getPaymentOrganization()); insuranceAccountBatchPO = SiAccountEncrypt.decryptInsuranceAccountBatch(insuranceAccountBatchPO); boolean isShow = false; if (insuranceAccountBatchPO == null || insuranceAccountBatchPO.getBillStatus() == BillStatusEnum.NOT_ARCHIVED.getValue()) { @@ -408,7 +419,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { tabList.add(overView); insuranceAccountTabDTO.setTabList(tabList); insuranceAccountTabDTO.setShow(isShow); - insuranceAccountTabDTO.setBillMonth(billMonth); + insuranceAccountTabDTO.setBillMonth(build.getBillMonth()); return insuranceAccountTabDTO; } @@ -471,7 +482,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { Long employeeId = (long)user.getUID(); ValidUtil.doValidator(param); String currentUserName = user.getLastname(); - siAccountBiz.accountInspect(param.getIds(),param.getBillMonth(),employeeId,currentUserName); + getSiAccountBiz(user).accountInspect(param.getIds(),param.getBillMonth(),employeeId,currentUserName); } @Override @@ -592,7 +603,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { @Override public PageInfo overView(InsuranceAccountDetailParam queryParam) { - PageInfo pageInfos = siAccountBiz.overView(queryParam); + PageInfo pageInfos = getSiAccountBiz(user).overView(queryParam); return pageInfos; } @@ -891,8 +902,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { return Collections.emptyList(); } - - + @Override + public Collection getAdminTaxAgentList() { + return getTaxAgentService(user).listAllTaxAgentsAsAdmin((long)user.getUID()); + } } diff --git a/src/com/engine/salary/service/impl/SIExportServiceImpl.java b/src/com/engine/salary/service/impl/SIExportServiceImpl.java index a451d1301..68537425c 100644 --- a/src/com/engine/salary/service/impl/SIExportServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIExportServiceImpl.java @@ -58,7 +58,7 @@ public class SIExportServiceImpl extends Service implements SIExportService { @Override public XSSFWorkbook exportOverView(InsuranceExportParam queryParam) { - List insuranceAccountDetailPOS = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectList(queryParam.getBillMonth()); + List insuranceAccountDetailPOS = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectList(queryParam.getBillMonth(), queryParam.getPaymentOrganization()); InsuranceAccountDetailPOEncrypt.decryptInsuranceAccountDetailPOList(insuranceAccountDetailPOS); //获取扣缴义务人信息 diff --git a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java index 66683a939..32da33207 100644 --- a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java @@ -680,11 +680,10 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { excelComments.add(errorMessageMap); isError = true; } - String exchangeUserStatus = userStateExchange(userStatus); List employees = employeeByIds.stream().filter(e -> (StringUtils.isBlank(userName) || Objects.equals(e.getUsername(), userName)) && (StringUtils.isBlank(deparmentName) || Objects.equals(e.getDepartmentName(), deparmentName)) && (StringUtils.isBlank(telephone) || Objects.equals(e.getMobile(), telephone)) - && (StringUtils.isBlank(exchangeUserStatus) || e.getStatus() == null || Objects.equals(e.getStatus(), exchangeUserStatus))).map(DataCollectionEmployee::getEmployeeId) + && (StringUtils.isBlank(userStatus) || Objects.equals(userStateExchange(e.getStatus()), userStatus))).map(DataCollectionEmployee::getEmployeeId) .collect(Collectors.toList()); if (CollectionUtils.isEmpty(employees) || employees.size() > 1) { Map errorMessageMap = Maps.newHashMap(); diff --git a/src/com/engine/salary/web/SIAccountController.java b/src/com/engine/salary/web/SIAccountController.java index 13f35404d..d481d7744 100644 --- a/src/com/engine/salary/web/SIAccountController.java +++ b/src/com/engine/salary/web/SIAccountController.java @@ -5,6 +5,7 @@ import com.engine.common.util.ServiceUtil; import com.engine.salary.entity.siaccount.dto.InsuranceAccountTabDTO; import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; import com.engine.salary.entity.siaccount.param.*; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.service.impl.SIAccountServiceImpl; import com.engine.salary.util.ResponseResult; import com.engine.salary.util.page.PageInfo; @@ -292,9 +293,10 @@ public class SIAccountController { @Path("/tabList") @Produces(MediaType.APPLICATION_JSON) public String tabList(@Context HttpServletRequest request, @Context HttpServletResponse response, - @QueryParam("billMonth") String billMonth) { + @QueryParam("billMonth") String billMonth,@QueryParam("paymentOrganization") Long paymentOrganization) { User user = HrmUserVarify.getUser(request, response); - return new ResponseResult(user).run(getService(user)::tabList, billMonth); + AccountParam build = AccountParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization).build(); + return new ResponseResult(user).run(getService(user)::tabList, build); } @POST @@ -347,5 +349,12 @@ public class SIAccountController { return new ResponseResult>(user).run(getService(user)::buttonCheck, billMonth); } + @GET + @Path("/getAdminTaxAgentList") + @Produces(MediaType.APPLICATION_JSON) + public String getAdminTaxAgentList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getService(user)::getAdminTaxAgentList); + } }