diff --git a/src/com/api/salary/web/OtherDeductionController.java b/src/com/api/salary/web/OtherDeductionController.java new file mode 100644 index 000000000..8684ef641 --- /dev/null +++ b/src/com/api/salary/web/OtherDeductionController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/otherDeduction") +public class OtherDeductionController extends com.engine.salary.web.OtherDeductionController { + +} diff --git a/src/com/engine/salary/annotation/SalaryTable.java b/src/com/engine/salary/annotation/SalaryTable.java index 189650802..705f0b16a 100644 --- a/src/com/engine/salary/annotation/SalaryTable.java +++ b/src/com/engine/salary/annotation/SalaryTable.java @@ -1,5 +1,8 @@ package com.engine.salary.annotation; + +import com.weaverboot.tools.enumTools.weaComponent.WeaTableTypeEnum; + import java.lang.annotation.*; /** @@ -32,6 +35,12 @@ public @interface SalaryTable { */ String where() default ""; + /** + * 分组 + */ + String groupby() default ""; + + /** * 排序 */ @@ -52,4 +61,9 @@ public @interface SalaryTable { */ SalaryTableOperate[] operates() default {}; + /** + * 列表选择框 + */ + WeaTableTypeEnum tableType() default WeaTableTypeEnum.NONE; + } diff --git a/src/com/engine/salary/biz/AddUpDeductionBiz.java b/src/com/engine/salary/biz/AddUpDeductionBiz.java index 5276aa94e..b392e2fef 100644 --- a/src/com/engine/salary/biz/AddUpDeductionBiz.java +++ b/src/com/engine/salary/biz/AddUpDeductionBiz.java @@ -1,7 +1,6 @@ package com.engine.salary.biz; import com.engine.salary.entity.datacollection.AddUpDeduction; -import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO; import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO; import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam; @@ -122,20 +121,6 @@ public class AddUpDeductionBiz extends BaseBean { } - /** - * 查询人员列表 - * - * @return - */ - public List listEmployee() { - SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); - try { - AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class); - return mapper.listEmployee(); - } finally { - sqlSession.close(); - } - } /** @@ -146,14 +131,11 @@ public class AddUpDeductionBiz extends BaseBean { */ public XSSFWorkbook export(AddUpDeductionQueryParam param) { - //excel标题 - List title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人"); - //获取操作按钮资源 - List> rowList = getExcelRowList(title, param); + List> rowList = getExcelRowList(param); //获取excel - return ExcelUtil.genWorkbook(rowList); + return ExcelUtil.genWorkbook(rowList,"累计专项附加扣除"); } @@ -162,7 +144,10 @@ public class AddUpDeductionBiz extends BaseBean { * * @return 导出数据行集合 */ - private List> getExcelRowList(List title, AddUpDeductionQueryParam param) { + private List> getExcelRowList(AddUpDeductionQueryParam param) { + //excel标题 + List title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人"); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); List list = list(param); final List> dataRowList = Optional.ofNullable(list) @@ -204,7 +189,7 @@ public class AddUpDeductionBiz extends BaseBean { List> rowList = getExcelRowDetailList(param); //获取excel - return ExcelUtil.genWorkbook(rowList); + return ExcelUtil.genWorkbook(rowList,"累计专项附加扣除明细"); } diff --git a/src/com/engine/salary/biz/AddUpSituationBiz.java b/src/com/engine/salary/biz/AddUpSituationBiz.java index 85ada43a7..744638fe8 100644 --- a/src/com/engine/salary/biz/AddUpSituationBiz.java +++ b/src/com/engine/salary/biz/AddUpSituationBiz.java @@ -133,7 +133,7 @@ public class AddUpSituationBiz extends BaseBean { List> rowList = getExcelRowList(param); //获取excel - return ExcelUtil.genWorkbook(rowList); + return ExcelUtil.genWorkbook(rowList,"累计情况"); } @@ -196,7 +196,7 @@ public class AddUpSituationBiz extends BaseBean { List> rowList = getExcelRowDetailList(param); //获取excel - return ExcelUtil.genWorkbook(rowList); + return ExcelUtil.genWorkbook(rowList,"累计情况明细"); } @@ -209,7 +209,7 @@ public class AddUpSituationBiz extends BaseBean { private List> getExcelRowDetailList(AddUpSituationQueryParam param) { //excel标题 - List title = Arrays.asList("税款所属期", "个税扣缴义务人", "部门", "工号", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人"); + List title = Arrays.asList("姓名", "税款所属期", "个税扣缴义务人", "部门", "手机号", "工号", "累计收入额", "累计减除费用", "累计社保个人合计", "累计公积金个人合计", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计企业(职业)年金及其他福利", "累计其他扣除", "累计免税收入", "累计准予扣除的捐赠额", "累计已预扣预缴税额"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); //查询详细信息 diff --git a/src/com/engine/salary/biz/EmployBiz.java b/src/com/engine/salary/biz/EmployBiz.java new file mode 100644 index 000000000..564dc18eb --- /dev/null +++ b/src/com/engine/salary/biz/EmployBiz.java @@ -0,0 +1,37 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.mapper.datacollection.EmployMapper; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.general.BaseBean; + +import java.util.List; + +public class EmployBiz extends BaseBean { + + /** + * 查询人员列表 + * + * @return + */ + public List listEmployee() { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + return mapper.listEmployee(); + } finally { + sqlSession.close(); + } + } + + public List getEmployeeByIds(List list) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + return mapper.getEmployeeByIds(list); + } finally { + sqlSession.close(); + } + } +} diff --git a/src/com/engine/salary/biz/OtherDeductionBiz.java b/src/com/engine/salary/biz/OtherDeductionBiz.java new file mode 100644 index 000000000..859fac28b --- /dev/null +++ b/src/com/engine/salary/biz/OtherDeductionBiz.java @@ -0,0 +1,294 @@ +package com.engine.salary.biz; + +import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.OtherDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.OtherDeductionQueryParam; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.mapper.datacollection.OtherDeductionMapper; +import com.engine.salary.util.excel.ExcelUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.general.BaseBean; +import weaver.general.Util; + +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +public class OtherDeductionBiz extends BaseBean { + + + /** + * 关联查询查询列表 + * + * @param param + * @return + */ + public List list(OtherDeductionQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + return mapper.list(param); + + } finally { + sqlSession.close(); + } + } + + /** + * 条件查询 + * + * @param param + * @return + */ + public List listSome(OtherDeductionPO param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + return mapper.listSome(param); + } finally { + sqlSession.close(); + } + } + + + /** + * 根据id获取 + * + * @param id + * @return + */ + public OtherDeductionPO getById(Long id) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + return mapper.getById(id); + } finally { + sqlSession.close(); + } + } + + /** + * 详情列表 + * + * @param param + * @return + */ + public List recordList(OtherDeductionQueryParam param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + return mapper.recordList(param); + } finally { + sqlSession.close(); + } + } + + /** + * 批量插入 + * + * @param param + * @return + */ + public void batchSave(List param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + mapper.insertData(param); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + /** + * 批量插入 + * + * @param param + * @return + */ + public void batchUpdate(List param) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class); + mapper.updateData(param); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + /** + * 导出 + * + * @param param + * @return + */ + public XSSFWorkbook export(OtherDeductionQueryParam param) { + + //获取操作按钮资源 + List> rowList = getExcelRowList(param); + + //获取excel + return ExcelUtil.genWorkbook(rowList,"其他免税扣除"); + } + + + /** + * 获取excel数据行 + * + * @return 导出数据行集合 + */ + private List> getExcelRowList(OtherDeductionQueryParam param) { + //excel标题 + List title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "商业健康保险", "税延养老保险", "其他", "准予扣除的捐赠额"); + + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + List list = list(param); + final List> dataRowList = Optional.ofNullable(list) + .map(List::stream) + .map(operatorStream -> operatorStream.map(dto -> { + List cellList = new ArrayList<>(); + cellList.add(Util.null2String(dto.getUsername())); + cellList.add(Util.null2String(dto.getTaxAgentName())); + cellList.add(Util.null2String(dto.getDepartmentName())); + cellList.add(Util.null2String(dto.getMobile())); + cellList.add(Util.null2String(dto.getJobNum())); + cellList.add(Util.null2String(dto.getIdNo())); + cellList.add(dto.getHiredate() == null ? "" : formatter.format(dto.getHiredate())); + cellList.add(Util.null2String(dto.getBusinessHealthyInsurance())); + cellList.add(Util.null2String(dto.getTaxDelayEndowmentInsurance())); + cellList.add(Util.null2String(dto.getOtherDeduction())); + cellList.add(Util.null2String(dto.getDeductionAllowedDonation())); + return cellList; + }).collect(Collectors.toList())) + .orElse(Collections.emptyList()); + + List> rowList = new ArrayList<>(); + rowList.add(title); + rowList.addAll(dataRowList); + return rowList; + } + + + /** + * 导出详情列表 + * + * @param param + * @return + */ + public XSSFWorkbook exportDetail(OtherDeductionQueryParam param) { + + //获取操作按钮资源 + List> rowList = getExcelRowDetailList(param); + + //获取excel + return ExcelUtil.genWorkbook(rowList,"其他免税扣除明细"); + } + + + /** + * 导出详情 + * + * @param param + * @return + */ + private List> getExcelRowDetailList(OtherDeductionQueryParam param) { + //excel标题 + List title = Arrays.asList("姓名", "申报月份", "个税扣缴义务人", "部门", "手机号", "工号", "商业健康保险", "税延养老保险", "其他", "准予扣除的捐赠额"); + + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); + //查询详细信息 + List list = recordList(param); + final List> dataRowList = Optional.ofNullable(list) + .map(List::stream) + .map(operatorStream -> operatorStream.map(dto -> { + List cellList = new ArrayList<>(); + cellList.add(Util.null2String(dto.getUsername())); + cellList.add(Util.null2String(dto.getDeclareMonth() == null ? "" : formatter.format(dto.getDeclareMonth()))); + cellList.add(Util.null2String(dto.getTaxAgentName())); + cellList.add(Util.null2String(dto.getDepartmentName())); + cellList.add(Util.null2String(dto.getMobile())); + cellList.add(Util.null2String(dto.getJobNum())); + cellList.add(Util.null2String(dto.getBusinessHealthyInsurance())); + cellList.add(Util.null2String(dto.getTaxDelayEndowmentInsurance())); + cellList.add(Util.null2String(dto.getOtherDeduction())); + cellList.add(Util.null2String(dto.getDeductionAllowedDonation())); + return cellList; + }).collect(Collectors.toList())) + .orElse(Collections.emptyList()); + + List> rowList = new ArrayList<>(); + rowList.add(title); + rowList.addAll(dataRowList); + return rowList; + } + + /** + * 处理导入数据 + * + * @param pos + */ + public void handleImportData(List pos) { + if (CollectionUtils.isEmpty(pos)) { + return; + } + OtherDeductionPO po = pos.get(0); + // 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos); + // 去重(通过记录的唯一条件(申报月份,人员id,个税扣缴义务人id)拼接) + List finalPos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), ArrayList::new)); + // 查询已有数据 + List list = listSome(OtherDeductionPO.builder().declareMonth(po.getDeclareMonth()).build()); + // 待修改的 本地已存在则更新【交集】 + List updateList = list.stream().map(m -> { + Optional optional = finalPos.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); + OtherDeductionPO temp = null; + if (optional.isPresent()) { + temp = optional.get(); + // 换成本地库的id + temp.setId(m.getId()); + } + return temp; + }).filter(Objects::nonNull).collect(Collectors.toList()); + // 待新增的 导入比本地多,则新增【差集(导入 - local)】 + List saveList = finalPos.stream().map(m -> { + Optional optional = list.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst(); + OtherDeductionPO temp = null; + if (!optional.isPresent()) { + temp = m; + } + return temp; + }).filter(Objects::nonNull).collect(Collectors.toList()); + + // 修改 + if (CollectionUtils.isNotEmpty(updateList)) { + batchUpdate(updateList); + } + // 保存 + if (CollectionUtils.isNotEmpty(saveList)) { + batchSave(saveList); + } + // 记录操作日志 +// saveList.addAll(updateList); +// +// if (CollectionUtils.isNotEmpty(saveList)) { +// LoggerContext loggerContext = new LoggerContext(); +// loggerContext.setTargetId(String.valueOf(IdGenerator.generate())); +// loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100351, "导入累计专项附加扣除")); +// loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); +// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100351, "导入累计专项附加扣除")); +// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100351, "导入累计专项附加扣除")); +// loggerContext.setNewValueList(saveList); +// loggerContext.setTenant_key(message.getTenantKey()); +// loggerContext.setOperator(message.getUserId().toString()); +// loggerContext.setOperatorName(message.getOpreator()); +// loggerContext.setClientIp(message.getClientIp()); +// addUpDeductionLoggerTemplate.write(loggerContext); +// } + } + + +} diff --git a/src/com/engine/salary/cmd/datacollection/AddUpDeductionGetDetailListCmd.java b/src/com/engine/salary/cmd/datacollection/AddUpDeductionGetDetailListCmd.java index 2d6c615a3..1b0456835 100644 --- a/src/com/engine/salary/cmd/datacollection/AddUpDeductionGetDetailListCmd.java +++ b/src/com/engine/salary/cmd/datacollection/AddUpDeductionGetDetailListCmd.java @@ -56,7 +56,7 @@ public class AddUpDeductionGetDetailListCmd extends AbstractCommonCommand table = new SalaryWeaTable(user, AddUpDeductionRecordDTO.class); - table.setBackfields(fileds); + table.setBackfields(fields); table.setSqlform(fromSql); table.setSqlwhere(makeSqlWhere(queryParam)); table.setSqlorderby("t1.declare_month DESC"); diff --git a/src/com/engine/salary/cmd/datacollection/AddUpDeductionImportCmd.java b/src/com/engine/salary/cmd/datacollection/AddUpDeductionImportCmd.java index c5b27e749..4258ad2e5 100644 --- a/src/com/engine/salary/cmd/datacollection/AddUpDeductionImportCmd.java +++ b/src/com/engine/salary/cmd/datacollection/AddUpDeductionImportCmd.java @@ -4,6 +4,7 @@ import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; import com.engine.core.interceptor.CommandContext; import com.engine.salary.biz.AddUpDeductionBiz; +import com.engine.salary.biz.EmployBiz; import com.engine.salary.biz.TaxAgentBiz; import com.engine.salary.entity.datacollection.AddUpDeduction; import com.engine.salary.entity.datacollection.DataCollectionEmployee; @@ -51,6 +52,7 @@ public class AddUpDeductionImportCmd extends AbstractCommonCommand execute(CommandContext commandContext) { Map apidatas = new HashMap(); + EmployBiz employBiz = new EmployBiz(); AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz(); //检验参数 @@ -83,7 +85,7 @@ public class AddUpDeductionImportCmd extends AbstractCommonCommand employees = addUpDeductionBiz.listEmployee(); + List employees = employBiz.listEmployee(); List taxAgents = new TaxAgentBiz().listAll(); //税款所属期 diff --git a/src/com/engine/salary/cmd/datacollection/AddUpDeductionListCmd.java b/src/com/engine/salary/cmd/datacollection/AddUpDeductionListCmd.java index de3a882aa..9ffebccfc 100644 --- a/src/com/engine/salary/cmd/datacollection/AddUpDeductionListCmd.java +++ b/src/com/engine/salary/cmd/datacollection/AddUpDeductionListCmd.java @@ -1,5 +1,6 @@ package com.engine.salary.cmd.datacollection; +import com.cloudstore.eccom.pc.table.WeaTableCheckboxpopedom; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; @@ -29,7 +30,7 @@ public class AddUpDeductionListCmd extends AbstractCommonCommand execute(CommandContext commandContext) { - String fileds = " t1.id," + + String fields = " t1.id," + " t1.declare_month as declareMonth," + " t1.employee_id as employeeId," + " e.lastname as username," + @@ -51,15 +52,19 @@ public class AddUpDeductionListCmd extends AbstractCommonCommand table = new SalaryWeaTable(user, AddUpDeductionDTO.class); - table.setBackfields(fileds); + table.setBackfields(fields); table.setSqlform(fromSql); table.setSqlwhere(makeSqlWhere()); table.setSqlorderby("t1.id DESC"); table.setSqlprimarykey("t1.id"); table.setSqlisdistinct("false"); - table.setCheckboxList(new ArrayList<>()); - table.setCheckboxpopedom(null); + //设置check是否可用 + List checkboxpopedomList = new ArrayList<>(); + WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom(); + checkboxpopedom.setPopedompara("column:enable"); + checkboxpopedomList.add(checkboxpopedom); + table.setCheckboxList(checkboxpopedomList); WeaResultMsg result = new WeaResultMsg(false); result.putAll(table.makeDataResult()); diff --git a/src/com/engine/salary/cmd/datacollection/AddUpSituationGetDetailListCmd.java b/src/com/engine/salary/cmd/datacollection/AddUpSituationGetDetailListCmd.java index 623d4855c..9e3778338 100644 --- a/src/com/engine/salary/cmd/datacollection/AddUpSituationGetDetailListCmd.java +++ b/src/com/engine/salary/cmd/datacollection/AddUpSituationGetDetailListCmd.java @@ -29,7 +29,7 @@ public class AddUpSituationGetDetailListCmd extends AbstractCommonCommand execute(CommandContext commandContext) { - String fileds = " t1.id," + + String fields = " t1.id," + " t1.tax_year_month," + " t1.employee_id as employeeId," + " e.lastname as username," + @@ -63,7 +63,7 @@ public class AddUpSituationGetDetailListCmd extends AbstractCommonCommand table = new SalaryWeaTable(user, AddUpSituationRecordDTO.class); - table.setBackfields(fileds); + table.setBackfields(fields); table.setSqlform(fromSql); table.setSqlwhere(makeSqlWhere()); table.setSqlorderby("t1.id DESC"); diff --git a/src/com/engine/salary/cmd/datacollection/AddUpSituationImportCmd.java b/src/com/engine/salary/cmd/datacollection/AddUpSituationImportCmd.java index 2b55168ee..7e7d943f1 100644 --- a/src/com/engine/salary/cmd/datacollection/AddUpSituationImportCmd.java +++ b/src/com/engine/salary/cmd/datacollection/AddUpSituationImportCmd.java @@ -3,8 +3,8 @@ package com.engine.salary.cmd.datacollection; import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; import com.engine.core.interceptor.CommandContext; -import com.engine.salary.biz.AddUpDeductionBiz; import com.engine.salary.biz.AddUpSituationBiz; +import com.engine.salary.biz.EmployBiz; import com.engine.salary.biz.TaxAgentBiz; import com.engine.salary.entity.datacollection.AddUpSituation; import com.engine.salary.entity.datacollection.DataCollectionEmployee; @@ -49,7 +49,7 @@ public class AddUpSituationImportCmd extends AbstractCommonCommand execute(CommandContext commandContext) { Map apidatas = new HashMap(); - AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz(); + EmployBiz employBiz = new EmployBiz(); AddUpSituationBiz biz = new AddUpSituationBiz(); //检验参数 @@ -80,7 +80,7 @@ public class AddUpSituationImportCmd extends AbstractCommonCommand employees = addUpDeductionBiz.listEmployee(); + List employees = employBiz.listEmployee(); List taxAgents = new TaxAgentBiz().listAll(); //税款所属期 diff --git a/src/com/engine/salary/cmd/datacollection/AddUpSituationListCmd.java b/src/com/engine/salary/cmd/datacollection/AddUpSituationListCmd.java index f501f9c5a..b32a4c6a2 100644 --- a/src/com/engine/salary/cmd/datacollection/AddUpSituationListCmd.java +++ b/src/com/engine/salary/cmd/datacollection/AddUpSituationListCmd.java @@ -1,5 +1,6 @@ package com.engine.salary.cmd.datacollection; +import com.cloudstore.eccom.pc.table.WeaTableCheckboxpopedom; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; @@ -29,7 +30,7 @@ public class AddUpSituationListCmd extends AbstractCommonCommand execute(CommandContext commandContext) { - String fileds = " t1.id," + + String fields = " t1.id," + " t1.tax_year_month," + " t1.employee_id as employeeId," + " e.lastname as username," + @@ -63,15 +64,19 @@ public class AddUpSituationListCmd extends AbstractCommonCommand table = new SalaryWeaTable(user, AddUpSituationDTO.class); - table.setBackfields(fileds); + table.setBackfields(fields); table.setSqlform(fromSql); table.setSqlwhere(makeSqlWhere()); table.setSqlorderby("t1.id DESC"); table.setSqlprimarykey("t1.id"); table.setSqlisdistinct("false"); - table.setCheckboxList(new ArrayList<>()); - table.setCheckboxpopedom(null); + //设置check是否可用 + List checkboxpopedomList = new ArrayList<>(); + WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom(); + checkboxpopedom.setPopedompara("column:enable"); + checkboxpopedomList.add(checkboxpopedom); + table.setCheckboxList(checkboxpopedomList); WeaResultMsg result = new WeaResultMsg(false); result.putAll(table.makeDataResult()); diff --git a/src/com/engine/salary/cmd/datacollection/AddUpSituationPreviewCmd.java b/src/com/engine/salary/cmd/datacollection/AddUpSituationPreviewCmd.java index 3937d1384..4cbcaf367 100644 --- a/src/com/engine/salary/cmd/datacollection/AddUpSituationPreviewCmd.java +++ b/src/com/engine/salary/cmd/datacollection/AddUpSituationPreviewCmd.java @@ -4,14 +4,17 @@ import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; import com.engine.core.interceptor.CommandContext; import com.engine.salary.entity.datacollection.dto.AddUpSituationDTO; +import com.engine.salary.entity.datacollection.param.AddUpSituationImportParam; +import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.util.excel.ExcelParseHelper; import lombok.SneakyThrows; +import org.apache.commons.lang3.StringUtils; import org.apache.poi.util.IOUtils; +import weaver.file.ImageFileManager; +import weaver.general.Util; import weaver.hrm.User; import javax.servlet.http.HttpServletRequest; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.InputStream; import java.util.HashMap; import java.util.List; @@ -37,13 +40,21 @@ public class AddUpSituationPreviewCmd extends AbstractCommonCommand execute(CommandContext commandContext) { Map apidatas = new HashMap(); + //检验参数 + checkImportParam(); + + //导入参数 + AddUpSituationImportParam importParam = (AddUpSituationImportParam) params.get("importParam"); + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + InputStream fileInputStream = null; - try { -// fileInputStream = ImageFileManager.getInputStreamById(Integer.valueOf(imageId)); - fileInputStream = new FileInputStream("C:\\Users\\钱涛\\Desktop\\salary\\addUpSituation\\importTemplate.xlsx"); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } +// try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.valueOf(imageId)); +// fileInputStream = new FileInputStream("C:\\Users\\钱涛\\Desktop\\salary\\addUpSituation\\importTemplate.xlsx"); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } try { List excelDates = ExcelParseHelper.parse(fileInputStream, AddUpSituationDTO.class, 0, 1, 21, "template.xlsx"); apidatas.put("preview", excelDates); @@ -53,4 +64,22 @@ public class AddUpSituationPreviewCmd extends AbstractCommonCommand { + + public OtherDeductionExportCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public XSSFWorkbook execute(CommandContext commandContext) { + OtherDeductionQueryParam OtherDeductionQueryParam = (OtherDeductionQueryParam) params.get("queryParam"); + + OtherDeductionBiz OtherDeductionBiz = new OtherDeductionBiz(); + XSSFWorkbook workbook = OtherDeductionBiz.export(OtherDeductionQueryParam); + + return workbook; + } +} diff --git a/src/com/engine/salary/cmd/datacollection/OtherDeductionExportDetailCmd.java b/src/com/engine/salary/cmd/datacollection/OtherDeductionExportDetailCmd.java new file mode 100644 index 000000000..97e2307fb --- /dev/null +++ b/src/com/engine/salary/cmd/datacollection/OtherDeductionExportDetailCmd.java @@ -0,0 +1,46 @@ +package com.engine.salary.cmd.datacollection; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.OtherDeductionBiz; +import com.engine.salary.entity.datacollection.param.OtherDeductionQueryParam; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.exception.SalaryRunTimeException; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.util.Map; + +public class OtherDeductionExportDetailCmd extends AbstractCommonCommand { + + public OtherDeductionExportDetailCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public XSSFWorkbook execute(CommandContext commandContext) { + OtherDeductionQueryParam queryParam = (OtherDeductionQueryParam) params.get("queryParam"); + OtherDeductionBiz biz = new OtherDeductionBiz(); + + Long id = queryParam.getOtherTaxExemptDeductionId(); + if (id == null) { + throw new SalaryRunTimeException("id不能为空"); + } + + OtherDeductionPO po = biz.getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format("其他免税扣除不存在"+"[id:%s]", id)); + } + + XSSFWorkbook workbook = biz.exportDetail(queryParam); + + return workbook; + } +} diff --git a/src/com/engine/salary/cmd/datacollection/OtherDeductionGetDetailListCmd.java b/src/com/engine/salary/cmd/datacollection/OtherDeductionGetDetailListCmd.java new file mode 100644 index 000000000..cd5903b8c --- /dev/null +++ b/src/com/engine/salary/cmd/datacollection/OtherDeductionGetDetailListCmd.java @@ -0,0 +1,170 @@ +package com.engine.salary.cmd.datacollection; + +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.EmployBiz; +import com.engine.salary.biz.OtherDeductionBiz; +import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.OtherDeductionQueryParam; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.exception.SalaryRunTimeException; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +public class OtherDeductionGetDetailListCmd extends AbstractCommonCommand> { + + public OtherDeductionGetDetailListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + + EmployBiz employBiz = new EmployBiz(); + OtherDeductionBiz biz = new OtherDeductionBiz(); + + OtherDeductionQueryParam queryParam = (OtherDeductionQueryParam) params.get("queryParam"); + if (queryParam == null) { + throw new SalaryRunTimeException("参数异常"); + } + + Long id = queryParam.getOtherTaxExemptDeductionId(); + if (id == null) { + throw new SalaryRunTimeException("其他免税扣除id不能为空"); + } + + OtherDeductionPO po = biz.getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format("其他免税扣除不存在[id:%s]", id)); + } + + List employeeList = employBiz.getEmployeeByIds(Collections.singletonList(po.getEmployeeId())); + if (CollectionUtils.isEmpty(employeeList)) { + throw new SalaryRunTimeException("员工信息不存在"); + } + + queryParam.setEmployeeId(po.getEmployeeId()); + + String fields = " t1.id," + + " t1.declare_month," + + " t1.employee_id," + + " t2.name AS tax_agent_name," + + " e.lastname as username," + + " d.departmentname AS departmentName," + + " e.mobile," + + " e.workcode as job_num," + + " e.companystartdate as hiredate," + + " t1.business_healthy_insurance," + + " t1.tax_delay_endowment_insurance," + + " t1.other_deduction," + + " t1.deduction_allowed_donation"; + + String fromSql = " FROM" + + " hrsa_other_deduction t1" + + " LEFT JOIN hrsa_tax_agent t2 ON t1.tax_agent_id = t2.id" + + " LEFT JOIN hrmresource e ON e.id = t1.employee_id" + + " LEFT JOIN hrmdepartment d ON d.id = e.departmentid"; + + SalaryWeaTable table = new SalaryWeaTable(user, AddUpDeductionRecordDTO.class); + table.setBackfields(fields); + table.setSqlform(fromSql); + table.setSqlwhere(makeSqlWhere(queryParam)); + table.setSqlorderby("t1.declare_month DESC"); + table.setSqlprimarykey("t1.id"); + table.setSqlisdistinct("false"); + + table.setCheckboxList(new ArrayList<>()); + table.setCheckboxpopedom(null); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + return result.getResultMap(); + } + + + private String makeSqlWhere(OtherDeductionQueryParam queryParam) { + + //申报月份 + List declareMonth = queryParam.getDeclareMonth(); + if (CollectionUtils.isNotEmpty(declareMonth)) { + queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + } + + String sqlWhere = "t1.delete_type = 0 AND t2.delete_type = 0"; + Collection ids = queryParam.getIds(); + if (CollectionUtils.isNotEmpty(ids)) { + String idsStr = ids.stream().map(String::valueOf).collect(Collectors.joining(",")); + sqlWhere += " AND t1.id IN (" + idsStr + ")"; + } + Long employeeId = queryParam.getEmployeeId(); + if (employeeId != null) { + sqlWhere += " AND t1.employee_id =" + employeeId; + } + String keyword = queryParam.getKeyword(); + if (StringUtils.isNotBlank(keyword)) { + sqlWhere += " AND (" + + " e.lastname like '%" + keyword + "%'" + + " OR d.departmentname like '%" + keyword + "%'" + + " OR e.workcode like ''%" + keyword + "%'" + + " )"; + } + // 申报月份 + List declareMonths = queryParam.getDeclareMonth(); + if (CollectionUtils.isNotEmpty(declareMonths)) { + if (declareMonths.size() == 1) { + sqlWhere += " AND t1.declare_month = '" + declareMonths.get(0) + ","; + } + if (declareMonths.size() == 2) { + sqlWhere += " AND (t1.declare_month BETWEEN '" + declareMonths.get(0) + "' AND '" + declareMonths.get(1) + "')"; + } + } + //姓名 + String username = queryParam.getUsername(); + if (StringUtils.isNotBlank(username)) { + sqlWhere += " AND e.lastname like '%" + username + "%'"; + } + //个税扣缴义务人 + Long taxAgentId = queryParam.getTaxAgentId(); + if (taxAgentId != null) { + sqlWhere += " AND t1.tax_agent_id = " + taxAgentId; + } + //部门 + List departmentIds = queryParam.getDepartmentIds(); + if (CollectionUtils.isNotEmpty(departmentIds)) { + String departmentStrIds = departmentIds.stream().map(String::valueOf).collect(Collectors.joining(",")); + sqlWhere += " AND d.id IN (" + departmentStrIds + ")"; + } + //工号 + String jobNum = queryParam.getJobNum(); + if (StringUtils.isNotBlank(jobNum)) { + sqlWhere += " AND e.workcode like '%" + jobNum + "%'"; + } + //入职日期 + List hiredate = queryParam.getHiredate(); + if (CollectionUtils.isNotEmpty(hiredate) && hiredate.size() == 2) { + sqlWhere += " AND (e.companystartdate BETWEEN " + hiredate.get(0) + " AND " + hiredate.get(1) + ")"; + } + //手机号 + String mobile = queryParam.getMobile(); + if (StringUtils.isNotBlank(mobile)) { + sqlWhere += " AND e.mobile like '%" + mobile + "%'"; + } + + return sqlWhere; + } +} diff --git a/src/com/engine/salary/cmd/datacollection/OtherDeductionGetSearchConditionCmd.java b/src/com/engine/salary/cmd/datacollection/OtherDeductionGetSearchConditionCmd.java new file mode 100644 index 000000000..fbd14e719 --- /dev/null +++ b/src/com/engine/salary/cmd/datacollection/OtherDeductionGetSearchConditionCmd.java @@ -0,0 +1,105 @@ +package com.engine.salary.cmd.datacollection; + +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class OtherDeductionGetSearchConditionCmd extends AbstractCommonCommand> { + + public OtherDeductionGetSearchConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(); + ConditionFactory conditionFactory = new ConditionFactory(user); + + //条件组 + List addGroups = new ArrayList(); + + List conditionItems = new ArrayList(); + + //文本输入框 + SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT,25034, "username"); + username.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + username.setFieldcol(16); //条件输入框所占宽度,默认值18 + username.setLabelcol(8); + username.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + username.setLabel("姓名"); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(username); + + + SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER,502227,"departmentName","4"); + departmentName.setColSpan(2); + departmentName.setFieldcol(12); + departmentName.setLabelcol(6); + departmentName.setViewAttr(2); + departmentName.setIsQuickSearch(false); + departmentName.setLabel("部门"); + conditionItems.add(departmentName); + + + SearchConditionItem jobNum = conditionFactory.createCondition(ConditionType.INPUT,25034, "jobNum"); + jobNum.setColSpan(2); + jobNum.setFieldcol(16); + jobNum.setLabelcol(8); + jobNum.setViewAttr(2); + jobNum.setLabel("工号"); + conditionItems.add(jobNum); + + + + SearchConditionItem idNo = conditionFactory.createCondition(ConditionType.INPUT,25034, "idNo"); + idNo.setColSpan(2); + idNo.setFieldcol(16); + idNo.setLabelcol(8); + idNo.setViewAttr(2); + idNo.setLabel("证件号码"); + conditionItems.add(idNo); + + //日期范围选项 + List dateOptions = new ArrayList(); + dateOptions.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(32530, user.getLanguage()),true));//指定日期范围(必须为6) + SearchConditionItem hiredate = conditionFactory.createCondition(ConditionType.RANGEPICKER, 18648, new String[]{"hiredate","hiredate"}); + hiredate.setFieldcol(16); + hiredate.setLabelcol(8); + hiredate.setViewAttr(2); + hiredate.setLabel("入职日期"); + hiredate.setOptions(dateOptions); + conditionItems.add(hiredate); + + + SearchConditionItem mobile = conditionFactory.createCondition(ConditionType.INPUT,25034, "mobile"); + mobile.setColSpan(2); + mobile.setFieldcol(16); + mobile.setLabelcol(8); + mobile.setViewAttr(2); + mobile.setLabel("手机号"); + conditionItems.add(mobile); + + addGroups.add(new SearchConditionGroup("常用条件",true,conditionItems)); + + apidatas.put("condition",addGroups); + return apidatas; + } + +} diff --git a/src/com/engine/salary/cmd/datacollection/OtherDeductionImportCmd.java b/src/com/engine/salary/cmd/datacollection/OtherDeductionImportCmd.java new file mode 100644 index 000000000..e9e25387e --- /dev/null +++ b/src/com/engine/salary/cmd/datacollection/OtherDeductionImportCmd.java @@ -0,0 +1,237 @@ +package com.engine.salary.cmd.datacollection; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.EmployBiz; +import com.engine.salary.biz.OtherDeductionBiz; +import com.engine.salary.biz.TaxAgentBiz; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO; +import com.engine.salary.entity.datacollection.param.OtherDeductionImportParam; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.entity.taxrate.TaxAgent; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.google.common.collect.Maps; +import lombok.SneakyThrows; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.poi.util.IOUtils; +import weaver.general.Util; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; + +public class OtherDeductionImportCmd extends AbstractCommonCommand> { + + protected HttpServletRequest request; + + public OtherDeductionImportCmd(Map params, User user) { + this.user = user; + this.params = params; + + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @SneakyThrows + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(); + EmployBiz employBiz = new EmployBiz(); + OtherDeductionBiz OtherDeductionBiz = new OtherDeductionBiz(); + + //检验参数 + checkImportParam(); + + //导入参数 + OtherDeductionImportParam importParam = (OtherDeductionImportParam) params.get("importParam"); + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + //税款所属期 + String declareMonthStr = Util.null2String(importParam.getDeclareMonth()); + //个税扣缴义务人 + String taxAgentId = Util.null2String(importParam.getTaxAgentId()); + + InputStream fileInputStream = null; +// fileInputStream = ImageFileManager.getInputStreamById(Integer.valueOf(imageId)); + try { + fileInputStream = new FileInputStream("C:\\Users\\钱涛\\Desktop\\salary\\OtherDeduction\\importTemplate.xlsx"); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + try { + + List OtherDeductions = ExcelParseHelper.parse(fileInputStream, OtherDeductionListDTO.class, 0, 1, 11, "OtherDeductionTemplate.xlsx"); + + int total = OtherDeductions.size(); + int index = 0; + int successCount = 0; + int errorCount = 0; + + //人员信息 + List employees = employBiz.listEmployee(); + List taxAgents = new TaxAgentBiz().listAll(); + + //税款所属期 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date declareMonth = simpleDateFormat.parse(declareMonthStr + "-01"); + + + // 错误excel内容 + List errorData = new ArrayList<>(); + //合规数据 + List eligibleData = new ArrayList<>(); + + + for (int i = 0; i < OtherDeductions.size(); i++) { + OtherDeductionListDTO dto = OtherDeductions.get(i); + + Date now = new Date(); + //待插入数据库对象 + OtherDeductionPO po = OtherDeductionPO.builder() + .tenantKey(DEFAULT_TENANT_KEY) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .declareMonth(declareMonth).build(); + + //异常点数量 + int errorSum = 0; + + //行号 + String rowIndex = String.format("第%s行", i + 2); + + //相同的姓名 + String userName = dto.getUsername(); + String deparmentName = dto.getDepartmentName(); + List employeeSameIds = employees.stream().filter(e -> (StringUtils.isBlank(userName) || Objects.equals(e.getUsername(), userName)) + && (StringUtils.isBlank(deparmentName) || Objects.equals(e.getDeparmentName(), deparmentName))).map(DataCollectionEmployee::getEmployeeId) + .collect(Collectors.toList()); + + + if (StringUtils.isBlank(userName)) { + //姓名 不能为空 + //错误消息对象 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "姓名不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "员工信息不能为空且不可重复(姓名与部门同时确认唯一)"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null; + if (employeeId != null && employeeId > 0) { + po.setEmployeeId(employeeId); + } else { + //姓名错误,系统内不存在该姓名 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + + String taxAgentName = dto.getTaxAgentName(); + if (StringUtils.isBlank(taxAgentName)) { + //个税扣缴义务人不能为空 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Optional optionalTemp = taxAgents.stream().filter(m -> m.getName().equals(taxAgentName)).findFirst(); + if (optionalTemp.isPresent()) { + if (StringUtils.isNotEmpty(taxAgentId) && !optionalTemp.get().getId().equals(Long.valueOf(taxAgentId))) { + //个税扣缴义务人与导入时选择的不一致 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人与导入时选择的不一致"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + po.setTaxAgentId(optionalTemp.get().getId()); + } + } else { + //个税扣缴义务人不存在 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + //商业健康保险 + String businessHealthyInsurance = dto.getBusinessHealthyInsurance(); + po.setBusinessHealthyInsurance(businessHealthyInsurance); + //税延养老保险 + String taxDelayEndowmentInsurance = dto.getTaxDelayEndowmentInsurance(); + po.setTaxDelayEndowmentInsurance(taxDelayEndowmentInsurance); + //其他 + String otherDeduction = dto.getOtherDeduction(); + po.setOtherDeduction(otherDeduction); + //准予扣除的捐赠额 + String deductionAllowedDonation = dto.getDeductionAllowedDonation(); + po.setDeductionAllowedDonation(deductionAllowedDonation); + + if (errorSum == 0) { + successCount += 1; + // 合格数据 + eligibleData.add(po); + } else { + errorCount += 1; + // 添加错误数据 + } + } + + //入库 + OtherDeductionBiz.handleImportData(eligibleData); + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorData", errorData); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + private void checkImportParam() { + + OtherDeductionImportParam importParam = (OtherDeductionImportParam) params.get("importParam"); + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + //税款所属期 + String declareMonthStr = Util.null2String(importParam.getDeclareMonth()); + //个税扣缴义务人 + String taxAgentId = Util.null2String(importParam.getTaxAgentId()); + + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException("文件不存在"); + } + if (StringUtils.isBlank(declareMonthStr)) { + throw new SalaryRunTimeException("税款所属期为空"); + } + } + + +} diff --git a/src/com/engine/salary/cmd/datacollection/OtherDeductionListCmd.java b/src/com/engine/salary/cmd/datacollection/OtherDeductionListCmd.java new file mode 100644 index 000000000..33dd7e334 --- /dev/null +++ b/src/com/engine/salary/cmd/datacollection/OtherDeductionListCmd.java @@ -0,0 +1,146 @@ +package com.engine.salary.cmd.datacollection; + +import com.cloudstore.eccom.pc.table.WeaTableCheckboxpopedom; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO; +import com.engine.salary.entity.datacollection.param.OtherDeductionQueryParam; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; + +import java.util.*; +import java.util.stream.Collectors; + +public class OtherDeductionListCmd extends AbstractCommonCommand> { + + public OtherDeductionListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + + String fields = " t1.id," + + " t1.declare_month," + + " t1.employee_id," + + " t2.name AS tax_agent_name," + + " e.lastname as username," + + " d.departmentname AS departmentName," + + " e.mobile," + + " e.workcode as job_num," + + " e.companystartdate as hiredate," + + " t1.business_healthy_insurance," + + " t1.tax_delay_endowment_insurance," + + " t1.other_deduction," + + " t1.deduction_allowed_donation"; + + String fromSql = " FROM" + + " hrsa_other_deduction t1" + + " LEFT JOIN hrsa_tax_agent t2 ON t1.tax_agent_id = t2.id" + + " LEFT JOIN hrmresource e ON e.id = t1.employee_id" + + " LEFT JOIN hrmdepartment d ON d.id = e.departmentid"; + + SalaryWeaTable table = new SalaryWeaTable(user, OtherDeductionListDTO.class); + table.setBackfields(fields); + table.setSqlform(fromSql); + table.setSqlwhere(makeSqlWhere()); + table.setSqlorderby("t1.id DESC"); + table.setSqlprimarykey("t1.id"); + table.setSqlisdistinct("false"); + + //设置check是否可用 + List checkboxpopedomList = new ArrayList<>(); + WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom(); + checkboxpopedom.setPopedompara("column:enable"); + checkboxpopedomList.add(checkboxpopedom); + table.setCheckboxList(checkboxpopedomList); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + return result.getResultMap(); + } + + + private String makeSqlWhere() { + + OtherDeductionQueryParam queryParam = (OtherDeductionQueryParam) params.get("queryParam"); + //申报月份 + List declareMonth = queryParam.getDeclareMonth(); + if (CollectionUtils.isNotEmpty(declareMonth)) { + queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); + } + + String sqlWhere = "t1.delete_type = 0 AND t2.delete_type = 0 AND e.status not in (7)"; + Collection ids = queryParam.getIds(); + if (CollectionUtils.isNotEmpty(ids)) { + String idsStr = ids.stream().map(String::valueOf).collect(Collectors.joining(",")); + sqlWhere += " AND t1.id IN (" + idsStr + ")"; + } + Long employeeId = queryParam.getEmployeeId(); + if (employeeId != null) { + sqlWhere += " AND t1.employee_id =" + employeeId; + } + String keyword = queryParam.getKeyword(); + if (StringUtils.isNotBlank(keyword)) { + sqlWhere += " AND (" + + " e.lastname like '%" + keyword + "%'" + + " OR d.departmentname like '%" + keyword + "%'" + + " OR e.workcode like ''%" + keyword + "%'" + + " )"; + } + // 税款所属期 + List declareMonth1 = queryParam.getDeclareMonth(); + if (CollectionUtils.isNotEmpty(declareMonth1)) { + if (declareMonth1.size() == 1) { + sqlWhere += " AND t1.declare_month = '" + declareMonth1.get(0) + "'"; + } + if (declareMonth1.size() == 2) { + sqlWhere += " AND (t1.declare_month BETWEEN '" + declareMonth1.get(0) + "' AND '" + declareMonth1.get(1) + "')"; + } + } + //姓名 + String username = queryParam.getUsername(); + if (StringUtils.isNotBlank(username)) { + sqlWhere += " AND e.lastname like '%" + username + "%'"; + } + //个税扣缴义务人 + Long taxAgentId = queryParam.getTaxAgentId(); + if (taxAgentId != null) { + sqlWhere += " AND t1.tax_agent_id = " + taxAgentId; + } + //部门 + List departmentIds = queryParam.getDepartmentIds(); + if (CollectionUtils.isNotEmpty(departmentIds)) { + String departmentStrIds = departmentIds.stream().map(String::valueOf).collect(Collectors.joining(",")); + sqlWhere += " AND d.id IN (" + departmentStrIds + ")"; + } + //工号 + String jobNum = queryParam.getJobNum(); + if (StringUtils.isNotBlank(jobNum)) { + sqlWhere += " AND e.workcode like '%" + jobNum + "%'"; + } + //入职日期 + List hiredate = queryParam.getHiredate(); + if (CollectionUtils.isNotEmpty(hiredate) && hiredate.size() == 2) { + sqlWhere += " AND (e.companystartdate BETWEEN '" + hiredate.get(0) + "' AND '" + hiredate.get(1) + "')"; + } + //手机号 + String mobile = queryParam.getMobile(); + if (StringUtils.isNotBlank(mobile)) { + sqlWhere += " AND e.mobile like '%" + mobile + "%'"; + } + + return sqlWhere; + } +} diff --git a/src/com/engine/salary/cmd/datacollection/OtherDeductionPreviewCmd.java b/src/com/engine/salary/cmd/datacollection/OtherDeductionPreviewCmd.java new file mode 100644 index 000000000..f861c4617 --- /dev/null +++ b/src/com/engine/salary/cmd/datacollection/OtherDeductionPreviewCmd.java @@ -0,0 +1,66 @@ +package com.engine.salary.cmd.datacollection; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO; +import com.engine.salary.entity.datacollection.param.OtherDeductionImportParam; +import com.engine.salary.util.excel.ExcelParseHelper; +import lombok.SneakyThrows; +import org.apache.commons.lang3.Validate; +import org.apache.poi.util.IOUtils; +import weaver.general.Util; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class OtherDeductionPreviewCmd extends AbstractCommonCommand> { + + protected HttpServletRequest request; + + public OtherDeductionPreviewCmd(Map params, User user) { + this.user = user; + this.params = params; + + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @SneakyThrows + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(); + + //导入参数 + OtherDeductionImportParam importParam = (OtherDeductionImportParam) params.get("importParam"); + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + + InputStream fileInputStream = null; +// fileInputStream = ImageFileManager.getInputStreamById(Integer.valueOf(imageId)); + try { + fileInputStream = new FileInputStream("C:\\Users\\钱涛\\Desktop\\salary\\OtherDeduction\\importTemplate.xlsx"); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + try { + List OtherDeductions = ExcelParseHelper.parse(fileInputStream, OtherDeductionListDTO.class, 0, 1, 11, "OtherDeductionTemplate.xlsx"); + apidatas.put("preview", OtherDeductions); + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + +} diff --git a/src/com/engine/salary/component/SalaryWeaTable.java b/src/com/engine/salary/component/SalaryWeaTable.java index 45517ad22..489888040 100644 --- a/src/com/engine/salary/component/SalaryWeaTable.java +++ b/src/com/engine/salary/component/SalaryWeaTable.java @@ -1,13 +1,11 @@ package com.engine.salary.component; import com.cloudstore.eccom.constant.WeaBoolAttr; -import com.cloudstore.eccom.pc.table.WeaTable; -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.pc.table.*; import com.engine.salary.annotation.SalaryTable; import com.engine.salary.annotation.SalaryTableColumn; import com.engine.salary.annotation.SalaryTableOperate; +import com.weaverboot.tools.enumTools.weaComponent.WeaTableTypeEnum; import org.apache.commons.lang3.StringUtils; import weaver.general.PageIdConst; import weaver.hrm.User; @@ -36,13 +34,23 @@ public class SalaryWeaTable extends WeaTable { String sql = table.fromSql(); super.setSqlform(sql); String where = table.where(); - super.setSqlwhere(where); + if (StringUtils.isNotBlank(where)) { + super.setSqlwhere(where); + } String orderby = table.orderby(); - super.setSqlorderby(orderby); + if (StringUtils.isNotBlank(orderby)) { + super.setSqlorderby(orderby); + } + String groupby = table.groupby(); + if (StringUtils.isNotBlank(groupby)) { + super.setSqlgroupby(groupby); + } boolean distinct = table.distinct(); super.setSqlisdistinct(String.valueOf(distinct)); String primarykey = table.primarykey(); - super.setSqlprimarykey(primarykey); + if (StringUtils.isNotBlank(primarykey)) { + super.setSqlprimarykey(primarykey); + } SalaryTableOperate[] operates = table.operates(); if (operates != null && operates.length > 0) { List operateList = new ArrayList<>(); @@ -61,9 +69,14 @@ public class SalaryWeaTable extends WeaTable { super.setOperates(weaTableOperates); } + WeaTableTypeEnum weaTableTypeEnum = table.tableType(); //设置check是否可用 - super.setCheckboxList(null); - super.setCheckboxpopedom(null); + if (weaTableTypeEnum == WeaTableTypeEnum.CHECKBOX) { + WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom(); + checkboxpopedom.setShowmethod("true"); + super.setCheckboxpopedom(checkboxpopedom); + } + } Field[] fields = clazz.getDeclaredFields(); @@ -83,7 +96,7 @@ public class SalaryWeaTable extends WeaTable { boolean display = columnAnn.display(); WeaTableColumn weaTableColumn = new WeaTableColumn(width, text, column, orderkey); String transmethod = columnAnn.transmethod(); - if(StringUtils.isNotBlank(transmethod)){ + if (StringUtils.isNotBlank(transmethod)) { weaTableColumn.setTransmethod(transmethod); } if (!display) { diff --git a/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionDTO.java b/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionDTO.java index 799a2eab7..91e1f6399 100644 --- a/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionDTO.java +++ b/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionDTO.java @@ -5,6 +5,7 @@ import com.engine.salary.annotation.SalaryTableColumn; import com.engine.salary.annotation.SalaryTableOperate; import com.engine.salary.util.excel.ExcelProperty; import com.fasterxml.jackson.annotation.JsonFormat; +import com.weaverboot.tools.enumTools.weaComponent.WeaTableTypeEnum; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -25,7 +26,7 @@ import java.util.Date; @Builder @NoArgsConstructor @AllArgsConstructor -@SalaryTable(pageId = "a4f85287-e3f9-4275-adn9-7d06e54y6rj8", operates = { +@SalaryTable(pageId = "a4f85287-e3f9-4275-adn9-7d06e54y6rj8", tableType = WeaTableTypeEnum.CHECKBOX, operates = { @SalaryTableOperate(text = "查看明细") }) public class AddUpDeductionDTO { @@ -88,7 +89,7 @@ public class AddUpDeductionDTO { */ @JsonFormat(pattern = "yyyy-MM-dd") @ExcelProperty(index = 6) - @SalaryTableColumn(text = "入职日期", width = "10%", column = "hiredate",transmethod="com.engine.salary.transmethod.TransMethod.timeToDate") + @SalaryTableColumn(text = "入职日期", width = "10%", column = "hiredate", transmethod = "com.engine.salary.transmethod.TransMethod.timeToDate") private Date hiredate; /** diff --git a/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionRecordDTO.java b/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionRecordDTO.java index 43879dbcd..4a3865d85 100644 --- a/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionRecordDTO.java +++ b/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionRecordDTO.java @@ -20,6 +20,7 @@ import java.util.Date; //数据采集-累计专项附加扣除记录 @SalaryTable(pageId = "a4f85287-3354-4275-adn9-7d06e54y6rj8") public class AddUpDeductionRecordDTO { + //主键id @SalaryTableColumn(column = "id", display = false) private Long id; @@ -27,20 +28,24 @@ public class AddUpDeductionRecordDTO { //员工id private Long employeeId; + @ExcelProperty(index = 0) + private String username; + //申报月份 @JsonFormat(pattern = "yyyy-MM") - @SalaryTableColumn(text = "入职日期", width = "10%", column = "hiredate",transmethod="com.engine.salary.transmethod.TransMethod.timeToMoth") + @SalaryTableColumn(text = "申报月份", width = "10%", column = "hiredate", transmethod = "com.engine.salary.transmethod.TransMethod.timeToMoth") + @ExcelProperty(index = 1) private Date declareMonth; //个税扣缴义务人 @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @ExcelProperty(index = 2) private String taxAgentName; - @SalaryTableColumn(text = "姓名", width = "10%", column = "username") - private String username; //部门 @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @ExcelProperty(index = 3) private String departmentName; //手机号 @@ -49,40 +54,41 @@ public class AddUpDeductionRecordDTO { //工号 @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @ExcelProperty(index = 4) private String jobNum; /** * 累计子女教育 */ - @ExcelProperty(index = 7) + @ExcelProperty(index = 5) @SalaryTableColumn(text = "累计子女教育", width = "10%", column = "addUpChildEducation") private BigDecimal addUpChildEducation; /** * 累计继续教育 */ - @ExcelProperty(index = 8) + @ExcelProperty(index = 6) @SalaryTableColumn(text = "累计继续教育", width = "10%", column = "addUpContinuingEducation") private BigDecimal addUpContinuingEducation; /** * 累计住房贷款利息 */ - @ExcelProperty(index = 9) + @ExcelProperty(index = 7) @SalaryTableColumn(text = "累计住房贷款利息", width = "10%", column = "addUpHousingLoanInterest") private BigDecimal addUpHousingLoanInterest; /** * 累计住房租金 */ - @ExcelProperty(index = 10) + @ExcelProperty(index = 8) @SalaryTableColumn(text = "累计住房租金", width = "10%", column = "addUpHousingRent") private BigDecimal addUpHousingRent; /** * 累计赡养老人 */ - @ExcelProperty(index = 11) + @ExcelProperty(index = 9) @SalaryTableColumn(text = "累计赡养老人", width = "10%", column = "addUpSupportElderly") private BigDecimal addUpSupportElderly; diff --git a/src/com/engine/salary/entity/datacollection/dto/AddUpSituationRecordDTO.java b/src/com/engine/salary/entity/datacollection/dto/AddUpSituationRecordDTO.java index 40a6755c1..a1933ec2e 100644 --- a/src/com/engine/salary/entity/datacollection/dto/AddUpSituationRecordDTO.java +++ b/src/com/engine/salary/entity/datacollection/dto/AddUpSituationRecordDTO.java @@ -1,6 +1,7 @@ package com.engine.salary.entity.datacollection.dto; import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.util.excel.ExcelProperty; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; import lombok.Builder; @@ -27,65 +28,85 @@ public class AddUpSituationRecordDTO { @SalaryTableColumn(column = "id", display = false) private Long id; + @ExcelProperty(index = 0) + private String username; + @JsonFormat(pattern = "yyyy-MM") @SalaryTableColumn(text = "税款所属期", width = "10%", column = "taxYearMonth", transmethod = "com.engine.salary.transmethod.TransMethod.timeToMoth") + @ExcelProperty(index = 1) private Date taxYearMonth; private Long employeeId; @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @ExcelProperty(index = 2) private String taxAgentName; @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @ExcelProperty(index = 3) private String departmentName; @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @ExcelProperty(index = 4) private String mobile; @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @ExcelProperty(index = 5) private String jobNum; @SalaryTableColumn(text = "累计收入额", width = "10%", column = "addUpIncome") + @ExcelProperty(index = 6) private String addUpIncome; @SalaryTableColumn(text = "累计减除费用", width = "10%", column = "addUpSubtraction") + @ExcelProperty(index = 7) private String addUpSubtraction; @SalaryTableColumn(text = "累计社保个人合计", width = "10%", column = "addUpSocialSecurityTotal") + @ExcelProperty(index = 8) private String addUpSocialSecurityTotal; @SalaryTableColumn(text = "累计公积金个人合计", width = "10%", column = "addUpAccumulationFundTotal") + @ExcelProperty(index = 9) private String addUpAccumulationFundTotal; + @ExcelProperty(index = 10) @SalaryTableColumn(text = "累计子女教育", width = "10%", column = "addUpChildEducation") private String addUpChildEducation; + @ExcelProperty(index = 11) @SalaryTableColumn(text = "累计继续教育", width = "10%", column = "addUpContinuingEducation") private String addUpContinuingEducation; + @ExcelProperty(index = 12) @SalaryTableColumn(text = "累计住房贷款利息", width = "10%", column = "addUpHousingLoanInterest") private String addUpHousingLoanInterest; + @ExcelProperty(index = 13) @SalaryTableColumn(text = "累计住房租金", width = "10%", column = "addUpHousingRent") private String addUpHousingRent; + @ExcelProperty(index = 14) @SalaryTableColumn(text = "累计赡养老人", width = "10%", column = "addUpSupportElderly") private String addUpSupportElderly; + @ExcelProperty(index = 15) @SalaryTableColumn(text = "累计企业(职业)年金及其他福利", width = "10%", column = "addUpEnterpriseAndOther") private String addUpEnterpriseAndOther; + @ExcelProperty(index = 16) @SalaryTableColumn(text = "累计其他扣除", width = "10%", column = "addUpOtherDeduction") private String addUpOtherDeduction; - + @ExcelProperty(index = 17) @SalaryTableColumn(text = "累计免税收入", width = "10%", column = "addUpTaxExemptIncome") private String addUpTaxExemptIncome; + @ExcelProperty(index = 18) @SalaryTableColumn(text = "累计准予扣除的捐赠额", width = "10%", column = "addUpAllowedDonation") private String addUpAllowedDonation; - + @ExcelProperty(index = 19) @SalaryTableColumn(text = "累计已预扣预缴税额", width = "10%", column = "addUpAdvanceTax") private String addUpAdvanceTax; } diff --git a/src/com/engine/salary/entity/datacollection/dto/OtherDeductionListDTO.java b/src/com/engine/salary/entity/datacollection/dto/OtherDeductionListDTO.java new file mode 100644 index 000000000..a67b85f27 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/OtherDeductionListDTO.java @@ -0,0 +1,85 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; + +/** + * 数据采集-其他免税扣除列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-6612-adn9-7d06e54y6rj8", operates = { + @SalaryTableOperate(text = "查看明细") +}) +public class OtherDeductionListDTO { + + + //主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //员工id + private Long employeeId; + + //姓名 + + @SalaryTableColumn(text = "姓名", width = "10%", column = "username") + private String username; + + //个税扣缴义务人 + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + private String taxAgentName; + + //部门 + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + private String departmentName; + + //手机号 + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + private String mobile; + + //工号 + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + private String jobNum; + + //证件号码 + @SalaryTableColumn(text = "证件号码", width = "10%", column = "idNo") + private String idNo; + + //入职日期 + @SalaryTableColumn(text = "入职日期", width = "10%", column = "hiredate", transmethod = "com.engine.salary.transmethod.TransMethod.timeToDate") + private LocalDate hiredate; + + //商业健康保险 + @SalaryTableColumn(text = "商业健康保险", width = "10%", column = "businessHealthyInsurance") + private String businessHealthyInsurance; + + //税延养老保险 + @SalaryTableColumn(text = "税延养老保险", width = "10%", column = "taxDelayEndowmentInsurance") + private String taxDelayEndowmentInsurance; + + //其他 + @SalaryTableColumn(text = "其他", width = "10%", column = "otherDeduction") + private String otherDeduction; + + //准予扣除的捐赠额 + @SalaryTableColumn(text = "准予扣除的捐赠额", width = "10%", column = "deductionAllowedDonation") + private String deductionAllowedDonation; + + @SalaryTableColumn(text = "操作", width = "20%", column = "operate") + private String operate; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/OtherDeductionRecordDTO.java b/src/com/engine/salary/entity/datacollection/dto/OtherDeductionRecordDTO.java new file mode 100644 index 000000000..f0d437c66 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/OtherDeductionRecordDTO.java @@ -0,0 +1,72 @@ +package com.engine.salary.entity.datacollection.dto; + +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 其他免税扣除记录列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-6612-adn9-7d98e54y6rj8") +public class OtherDeductionRecordDTO { + + //主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //申报月份 + + @SalaryTableColumn(text = "申报月份", width = "10%", column = "declareMonth", transmethod = "com.engine.salary.transmethod.TransMethod.timeToMoth") + private Date declareMonth; + + //员工id + private Long employeeId; + + private String username; + + //个税扣缴义务人 + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + private String taxAgentName; + + //部门 + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + private String departmentName; + + //手机号 + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + private String mobile; + + //工号 + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + private String jobNum; + + //商业健康保险 + @SalaryTableColumn(text = "商业健康保险", width = "10%", column = "businessHealthyInsurance") + private String businessHealthyInsurance; + + //税延养老保险 + @SalaryTableColumn(text = "税延养老保险", width = "10%", column = "taxDelayEndowmentInsurance") + private String taxDelayEndowmentInsurance; + + //其他 + @SalaryTableColumn(text = "其他", width = "10%", column = "otherDeduction") + private String otherDeduction; + + //准予扣除的捐赠额 + @SalaryTableColumn(text = "准予扣除的捐赠额", width = "10%", column = "deductionAllowedDonation") + private String deductionAllowedDonation; +} diff --git a/src/com/engine/salary/entity/datacollection/param/OtherDeductionImportParam.java b/src/com/engine/salary/entity/datacollection/param/OtherDeductionImportParam.java new file mode 100644 index 000000000..3ac3a98c9 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/OtherDeductionImportParam.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-累计专项附加扣除导入参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OtherDeductionImportParam { + + //上传文件id + String imageId; + + //税款所属期 + String declareMonth; + + //个税扣缴义务人 + String taxAgentId; + +} diff --git a/src/com/engine/salary/entity/datacollection/param/OtherDeductionQueryParam.java b/src/com/engine/salary/entity/datacollection/param/OtherDeductionQueryParam.java new file mode 100644 index 000000000..534fd2157 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/OtherDeductionQueryParam.java @@ -0,0 +1,58 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-其他免税扣除查询参数 +public class OtherDeductionQueryParam { + + //主键id + private Collection ids; + + //关键字(姓名、部门、工号) + private String keyword; + + //主键id + private Long id; + + //申报年月 + private List declareMonth; + + //姓名 + private String username; + + //员工id + private Long employeeId; + + //个税扣缴义务人的主键id + private Long taxAgentId; + + //部门id + private List departmentIds; + + //工号 + private String jobNum; + + //证件号 + private String idNo; + + //入职日期 + private List hiredate; + + //手机号 + private String mobile; + + //其他免税扣除id(获取明细) + private Long otherTaxExemptDeductionId; +} diff --git a/src/com/engine/salary/entity/datacollection/po/OtherDeductionPO.java b/src/com/engine/salary/entity/datacollection/po/OtherDeductionPO.java new file mode 100644 index 000000000..18658f4b8 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/po/OtherDeductionPO.java @@ -0,0 +1,74 @@ +package com.engine.salary.entity.datacollection.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +/** + * 数据采集-其他免税扣除表 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OtherDeductionPO { + /** + * 主键 + */ + private Long id; + /** + * 人员信息表的主键id + */ + private Long employeeId; + /** + * 个税扣缴义务人的主键id + */ + private Long taxAgentId; + /** + * 申报年月 + */ + private Date declareMonth; + /** + * 商业健康保险 + */ + private String businessHealthyInsurance; + /** + * 税延养老保险 + */ + private String taxDelayEndowmentInsurance; + /** + * 其他 + */ + private String otherDeduction; + /** + * 准予扣除的捐赠额 + */ + private String deductionAllowedDonation; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 创建人 + */ + private Long creator; + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + /** + * 租户ID + */ + private String tenantKey; + + private List employeeIds; + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AddUpSituationMapper.xml b/src/com/engine/salary/mapper/datacollection/AddUpSituationMapper.xml index 4697648b4..5b95bbe77 100644 --- a/src/com/engine/salary/mapper/datacollection/AddUpSituationMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/AddUpSituationMapper.xml @@ -453,9 +453,9 @@ AND ( - e.username like CONCAT('%',#{param.keyword},'%') - OR d.name like CONCAT('%',#{param.keyword},'%') - OR e.job_num like CONCAT('%',#{param.keyword},'%') + e.lastname like CONCAT('%',#{param.keyword},'%') + OR d.departmentname like CONCAT('%',#{param.keyword},'%') + OR e.workcode like CONCAT('%',#{param.keyword},'%') ) @@ -469,7 +469,7 @@ - AND e.username like CONCAT('%',#{param.username},'%') + AND e.lastname like CONCAT('%',#{param.username},'%') AND t1.tax_agent_id = #{param.taxAgentId} @@ -483,11 +483,11 @@ - AND e.job_num like CONCAT('%',#{param.jobNum},'%') + AND e.workcode like CONCAT('%',#{param.jobNum},'%') - AND (e.hiredate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) @@ -511,9 +511,9 @@ AND ( - e.username like '%'||#{param.keyword}||'%' - OR d.name like '%'||#{param.keyword}||'%' - OR e.job_num like '%'||#{param.keyword}||'%' + e.lastname like '%'||#{param.keyword}||'%' + OR d.departmentname like '%'||#{param.keyword}||'%' + OR e.workcode like '%'||#{param.keyword}||'%' ) @@ -527,7 +527,7 @@ - AND e.username like '%'||#{param.username}||'%' + AND e.lastname like '%'||#{param.username}||'%' AND t1.tax_agent_id = #{param.taxAgentId} @@ -541,11 +541,11 @@ - AND e.job_num like '%'||#{param.jobNum}||'%' + AND e.workcode like '%'||#{param.jobNum}||'%' - AND (e.hiredate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) @@ -569,9 +569,9 @@ AND ( - e.username like '%'+#{param.keyword}+'%' - OR d.name like '%'+#{param.keyword}+'%' - OR e.job_num like '%'+#{param.keyword}+'%' + e.lastname like '%'+#{param.keyword}+'%' + OR d.departmentname like '%'+#{param.keyword}+'%' + OR e.workcode like '%'+#{param.keyword}+'%' ) @@ -585,7 +585,7 @@ - AND e.username like '%'+#{param.username}+'%' + AND e.lastname like '%'+#{param.username}+'%' AND t1.tax_agent_id = #{param.taxAgentId} @@ -599,11 +599,11 @@ - AND e.job_num like '%'+#{param.jobNum}+'%' + AND e.workcode like '%'+#{param.jobNum}+'%' - AND (e.hiredate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) diff --git a/src/com/engine/salary/mapper/datacollection/EmployMapper.java b/src/com/engine/salary/mapper/datacollection/EmployMapper.java new file mode 100644 index 000000000..7d55529ec --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/EmployMapper.java @@ -0,0 +1,18 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface EmployMapper { + /** + * 获取所有员工 + * @return + */ + List listEmployee(); + + List getEmployeeByIds(@Param("collection") List ids); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/EmployMapper.xml b/src/com/engine/salary/mapper/datacollection/EmployMapper.xml new file mode 100644 index 000000000..fa597bb80 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/EmployMapper.xml @@ -0,0 +1,28 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.java b/src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.java new file mode 100644 index 000000000..b63db1d74 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.java @@ -0,0 +1,87 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.OtherDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.OtherDeductionQueryParam; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface OtherDeductionMapper { + + /** + * 查询所有记录 + * + * @return 返回集合,没有返回空List + */ + List listAll(); + + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + OtherDeductionPO getById(Long id); + + /** + * 新增,忽略null字段 + * + * @param OtherDeductionPO 新增的记录 + * @return 返回影响行数 + */ + int insertIgnoreNull(OtherDeductionPO OtherDeductionPO); + + /** + * 修改,修改所有字段 + * + * @param OtherDeductionPO 修改的记录 + * @return 返回影响行数 + */ + int update(OtherDeductionPO OtherDeductionPO); + + /** + * 修改,忽略null字段 + * + * @param OtherDeductionPO 修改的记录 + * @return 返回影响行数 + */ + int updateIgnoreNull(OtherDeductionPO OtherDeductionPO); + + /** + * 删除记录 + * + * @param OtherDeductionPO 待删除的记录 + * @return 返回影响行数 + */ + int delete(OtherDeductionPO OtherDeductionPO); + + /** + * 查询数据采集-其他免税扣除列表 + * @param param + * @return + */ + List list(@Param("param") OtherDeductionQueryParam param); + + + List recordList(@Param("param") OtherDeductionQueryParam param); + + List listSome(@Param("param") OtherDeductionPO param); + + /** + * 批量插入 + * @param pos + */ + void insertData(@Param("collection") List pos); + + /** + * 批量修改 + * @param pos + */ + void updateData(@Param("collection") List pos); + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.xml new file mode 100644 index 000000000..aeddd2389 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.xml @@ -0,0 +1,592 @@ + + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.employee_id + , t.tax_agent_id + , t.declare_month + , t.business_healthy_insurance + , t.tax_delay_endowment_insurance + , t.other_deduction + , t.deduction_allowed_donation + , t.create_time + , t.update_time + , t.creator + , t.delete_type + , t.tenant_key + + + + + + + + + + + INSERT INTO hrsa_other_deduction + + + + id, + + + employee_id, + + + tax_agent_id, + + + declare_month, + + + business_healthy_insurance, + + + tax_delay_endowment_insurance, + + + other_deduction, + + + deduction_allowed_donation, + + + create_time, + + + update_time, + + + creator, + + + delete_type, + + + tenant_key, + + + + + #{id}, + + + #{employeeId}, + + + #{taxAgentId}, + + + #{declareMonth}, + + + #{businessHealthyInsurance}, + + + #{taxDelayEndowmentInsurance}, + + + #{otherDeduction}, + + + #{deductionAllowedDonation}, + + + #{createTime}, + + + #{updateTime}, + + + #{creator}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + UPDATE hrsa_other_deduction + + employee_id=#{employeeId}, + tax_agent_id=#{taxAgentId}, + declare_month=#{declareMonth}, + business_healthy_insurance=#{businessHealthyInsurance}, + tax_delay_endowment_insurance=#{taxDelayEndowmentInsurance}, + other_deduction=#{otherDeduction}, + deduction_allowed_donation=#{deductionAllowedDonation}, + create_time=#{createTime}, + update_time=#{updateTime}, + creator=#{creator}, + delete_type=#{deleteType}, + tenant_key=#{tenantKey}, + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_other_deduction + + + employee_id=#{employeeId}, + + + tax_agent_id=#{taxAgentId}, + + + declare_month=#{declareMonth}, + + + business_healthy_insurance=#{businessHealthyInsurance}, + + + tax_delay_endowment_insurance=#{taxDelayEndowmentInsurance}, + + + other_deduction=#{otherDeduction}, + + + deduction_allowed_donation=#{deductionAllowedDonation}, + + + create_time=#{createTime}, + + + update_time=#{updateTime}, + + + creator=#{creator}, + + + delete_type=#{deleteType}, + + + tenant_key=#{tenantKey}, + + + WHERE id = #{id} AND delete_type = 0 + + + + + + UPDATE hrsa_other_deduction + SET delete_type=1 + WHERE id = #{id} + AND delete_type = 0 + + + + + t1 + . + id + , + t1.declare_month, + t1.employee_id, + t2.name AS tax_agent_name, + e.lastname as username, + d.departmentname AS departmentName, + e.mobile, + e.workcode as job_num, + e.companystartdate as hiredate, + t1.business_healthy_insurance, + t1.tax_delay_endowment_insurance, + t1.other_deduction, + t1.deduction_allowed_donation + + + + + AND t1.id IN + + #{id} + + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like CONCAT('%',#{param.keyword},'%') + OR d.departmentname like CONCAT('%',#{param.keyword},'%') + OR e.workcode like CONCAT('%',#{param.keyword},'%') + ) + + + + + AND t1.declare_month = #{param.declareMonth[0]} + + + AND (t1.declare_month BETWEEN #{param.declareMonth[0]} AND #{param.declareMonth[1]}) + + + + + AND e.lastname like CONCAT('%',#{param.username},'%') + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like CONCAT('%',#{param.jobNum},'%') + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like CONCAT('%',#{param.mobile},'%') + + + + + AND t1.id IN + + #{id} + + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like '%'||#{param.keyword}||'%' + OR d.departmentname like '%'||#{param.keyword}||'%' + OR e.workcode like '%'||#{param.keyword}||'%' + ) + + + + + AND t1.declare_month = #{param.declareMonth[0]} + + + AND (t1.declare_month BETWEEN #{param.declareMonth[0]} AND #{param.declareMonth[1]}) + + + + + AND e.lastname like '%'||#{param.username}||'%' + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like '%'||#{param.jobNum}||'%' + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like '%'||#{param.mobile}||'%' + + + + + AND t1.id IN + + #{id} + + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like '%'+#{param.keyword}+'%' + OR d.departmentname like '%'+#{param.keyword}+'%' + OR e.workcode like '%'+#{param.keyword}+'%' + ) + + + + + AND t1.declare_month = #{param.declareMonth[0]} + + + AND (t1.declare_month BETWEEN #{param.declareMonth[0]} AND #{param.declareMonth[1]}) + + + + + AND e.lastname like '%'+#{param.username}+'%' + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like '%'+#{param.jobNum}+'%' + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like '%'+#{param.mobile}+'%' + + + + + + + + + + + INSERT INTO hrsa_other_deduction( + id, + employee_id, + tax_agent_id, + declare_month, + business_healthy_insurance, + tax_delay_endowment_insurance, + other_deduction, + deduction_allowed_donation, + create_time, + update_time, + creator, + tenant_key + ) + VALUES + + ( + #{item.id}, + #{item.employeeId}, + #{item.taxAgentId}, + #{item.declareMonth}, + #{item.businessHealthyInsurance}, + #{item.taxDelayEndowmentInsurance}, + #{item.otherDeduction}, + #{item.deductionAllowedDonation}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_other_deduction( + id, + employee_id, + tax_agent_id, + declare_month, + business_healthy_insurance, + tax_delay_endowment_insurance, + other_deduction, + deduction_allowed_donation, + create_time, + update_time, + creator, + tenant_key + ) + + + select + #{item.id}, + #{item.employeeId}, + #{item.taxAgentId}, + #{item.declareMonth}, + #{item.businessHealthyInsurance}, + #{item.taxDelayEndowmentInsurance}, + #{item.otherDeduction}, + #{item.deductionAllowedDonation}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + from dual + + + + INSERT INTO hrsa_other_deduction( + id, + employee_id, + tax_agent_id, + declare_month, + business_healthy_insurance, + tax_delay_endowment_insurance, + other_deduction, + deduction_allowed_donation, + create_time, + update_time, + creator, + tenant_key + ) + VALUES + + ( + #{item.id}, + #{item.employeeId}, + #{item.taxAgentId}, + #{item.declareMonth}, + #{item.businessHealthyInsurance}, + #{item.taxDelayEndowmentInsurance}, + #{item.otherDeduction}, + #{item.deductionAllowedDonation}, + #{item.createTime}, + #{item.updateTime}, + #{item.creator}, + #{item.tenantKey} + ) + + + + + update hrsa_other_deduction + + + + + when id=#{item.id} then #{item.businessHealthyInsurance} + + + + + + + when id=#{item.id} then #{item.taxDelayEndowmentInsurance} + + + + + + + when id=#{item.id} then #{item.otherDeduction} + + + + + + + when id=#{item.id} then #{item.deductionAllowedDonation} + + + + + where + id in + + #{item.id} + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/service/AddUpSituationService.java b/src/com/engine/salary/service/AddUpSituationService.java index 1f1755612..4950c9e37 100644 --- a/src/com/engine/salary/service/AddUpSituationService.java +++ b/src/com/engine/salary/service/AddUpSituationService.java @@ -15,4 +15,8 @@ public interface AddUpSituationService { Map importAddUpSituation(Map params); XSSFWorkbook exportDetail(Map params); + + Map getDetailList(Map params); + + Map preview(Map params); } diff --git a/src/com/engine/salary/service/OtherDeductionService.java b/src/com/engine/salary/service/OtherDeductionService.java new file mode 100644 index 000000000..915b89c2f --- /dev/null +++ b/src/com/engine/salary/service/OtherDeductionService.java @@ -0,0 +1,53 @@ +package com.engine.salary.service; + +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.Map; + +/** + * 数据采集-其他免税扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface OtherDeductionService { + + /** + * 数据采集-其他免税扣除列表的高级搜索 + */ + Map getSearchCondition(Map params); + + /** + * 数据采集-其他免税扣除列表 + */ + Map list(Map params); + + /** + * 获取数据采集-其他免税扣除表单 + */ + Map getDetailList(Map params); + + /** + * 预览 + */ + Map preview(Map params); + + /** + * 导入数据 + */ + Map importData(Map params); + + + /** + * 导出 + */ + XSSFWorkbook export(Map params); + + /** + * 导出详情 + */ + XSSFWorkbook exportDetail(Map params); + +} diff --git a/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java b/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java index f18c9436f..610c58153 100644 --- a/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java @@ -33,4 +33,14 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation public XSSFWorkbook exportDetail(Map params) { return commandExecutor.execute(new AddUpSituationExportDetailCmd(params, user)); } + + @Override + public Map getDetailList(Map params) { + return commandExecutor.execute(new AddUpSituationGetDetailListCmd(params, user)); + } + + @Override + public Map preview(Map params) { + return commandExecutor.execute(new AddUpSituationPreviewCmd(params, user)); + } } diff --git a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java new file mode 100644 index 000000000..329723959 --- /dev/null +++ b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java @@ -0,0 +1,51 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.cmd.datacollection.*; +import com.engine.salary.service.OtherDeductionService; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.util.Map; + +public class OtherDeductionServiceImpl extends Service implements OtherDeductionService { + + @Override + public Map getSearchCondition(Map params) { + return commandExecutor.execute(new OtherDeductionGetSearchConditionCmd(params, user)); + } + + @Override + public Map list(Map params) { + return commandExecutor.execute(new OtherDeductionListCmd(params, user)); + } + + @Override + public Map preview(Map params) { + return commandExecutor.execute(new OtherDeductionPreviewCmd(params, user)); + } + + @Override + public Map importData(Map params) { + return commandExecutor.execute(new OtherDeductionImportCmd(params, user)); + } + + @Override + public XSSFWorkbook export(Map params) { + return commandExecutor.execute(new OtherDeductionExportCmd(params, user)); + } + + + @Override + public XSSFWorkbook exportDetail(Map params) { + return commandExecutor.execute(new OtherDeductionExportDetailCmd(params, user)); + } + + + + @Override + public Map getDetailList(Map params) { + return commandExecutor.execute(new OtherDeductionGetDetailListCmd(params, user)); + } + + +} diff --git a/src/com/engine/salary/util/excel/ExcelUtil.java b/src/com/engine/salary/util/excel/ExcelUtil.java index a9e85256a..816553305 100644 --- a/src/com/engine/salary/util/excel/ExcelUtil.java +++ b/src/com/engine/salary/util/excel/ExcelUtil.java @@ -14,7 +14,7 @@ public class ExcelUtil { * @param rowList * @return */ - public static XSSFWorkbook genWorkbook(List> rowList) { + public static XSSFWorkbook genWorkbook(List> rowList,String sheetName) { XSSFWorkbook workbook = new XSSFWorkbook(); // 设置title样式 @@ -36,7 +36,7 @@ public class ExcelUtil { cellStyle.setFont(font);// 选择需要用到的字体格式 cellStyle.setWrapText(true); - XSSFSheet sheet = workbook.createSheet("累计专项附加扣除明细"); + XSSFSheet sheet = workbook.createSheet(sheetName); //自适应宽度 sheet.autoSizeColumn(0, true); //默认列宽 diff --git a/src/com/engine/salary/web/OtherDeductionController.java b/src/com/engine/salary/web/OtherDeductionController.java new file mode 100644 index 000000000..fd14ea439 --- /dev/null +++ b/src/com/engine/salary/web/OtherDeductionController.java @@ -0,0 +1,274 @@ +package com.engine.salary.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.datacollection.param.OtherDeductionQueryParam; +import com.engine.salary.entity.datacollection.param.OtherDeductionImportParam; +import com.engine.salary.service.OtherDeductionService; +import com.engine.salary.service.impl.OtherDeductionServiceImpl; +import com.engine.salary.util.ResponseResult; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jetbrains.annotations.Nullable; +import weaver.general.GCONST; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 数据采集-其他免税扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class OtherDeductionController { + + private OtherDeductionService getService(User user) { + return (OtherDeductionService) ServiceUtil.getService(OtherDeductionServiceImpl.class, user); + } + + /** + * 数据采集-累计专项附加扣除列表的高级搜索 + * + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.APPLICATION_JSON) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return ResponseResult.run(getService(user)::getSearchCondition, ParamUtil.request2Map(request)); + } + + + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("queryParam", queryParam); + return ResponseResult.run(getService(user)::list, map); + } + + + @POST + @Path("/getDetailList") + @Produces(MediaType.APPLICATION_JSON) + public String getDetailList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("queryParam", queryParam); + return ResponseResult.run(getService(user)::getDetailList, map); + } + + + @GET + @Path("/downloadTemplate") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response getAll(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + //模板文件路径 + String templateFilePath = GCONST.getRootPath() + "salary/otherDeduction/importTemplate.xlsx"; + + File file = new File(templateFilePath); + + if (!file.exists()) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + String fileName = null; + try { + fileName = URLEncoder.encode("其他免税扣除导入模板.xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return Response + .ok(file) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } + + + /** + * 导出 + * + * @param + * @return + */ + @GET + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + + OtherDeductionQueryParam param = buildParam(request); + + Map map = ParamUtil.request2Map(request); + map.put("queryParam", param); + + XSSFWorkbook workbook = getService(user).export(map); + + String fileName = null; + try { + fileName = URLEncoder.encode("累计专项附加扣除.xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } + + + @GET + @Path("/exportDetail") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + + OtherDeductionQueryParam param = buildParam(request); + + Map map = ParamUtil.request2Map(request); + map.put("queryParam", param); + + XSSFWorkbook workbook = getService(user).exportDetail(map); + + String fileName = null; + try { + fileName = URLEncoder.encode("累计专项附加扣除明细.xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } + + @Nullable + private OtherDeductionQueryParam buildParam(HttpServletRequest request) { + OtherDeductionQueryParam param = new OtherDeductionQueryParam(); + String ids = request.getParameter("ids"); + if(StringUtils.isNotBlank(ids)){ + param.setIds( Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String keyword = request.getParameter("keyword"); + if(StringUtils.isNotBlank(keyword)){ + param.setKeyword(keyword); + } + String id = request.getParameter("id"); + if(StringUtils.isNotBlank(id)){ + param.setId(Long.valueOf(id)); + } + String declareMonth = request.getParameter("declareMonth"); + if(StringUtils.isNotBlank(declareMonth)){ + param.setDeclareMonth(Arrays.asList(declareMonth.split(","))); + } + + String username = request.getParameter("username"); + if(StringUtils.isNotBlank(username)){ + param.setUsername(username); + } + String employeeId = request.getParameter("employeeId"); + if(StringUtils.isNotBlank(employeeId)){ + param.setEmployeeId(Long.valueOf(employeeId)); + } + String taxAgentId = request.getParameter("taxAgentId"); + if(StringUtils.isNotBlank(taxAgentId)){ + param.setTaxAgentId(Long.valueOf(taxAgentId)); + } + String departmentIds = request.getParameter("departmentIds"); + if(StringUtils.isNotBlank(departmentIds)){ + param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String jobNum = request.getParameter("jobNum"); + if(StringUtils.isNotBlank(jobNum)){ + param.setJobNum(jobNum); + } + String idNo = request.getParameter("idNo"); + if(StringUtils.isNotBlank(idNo)){ + param.setIdNo(idNo); + } + String hiredate = request.getParameter("hiredate"); + if(StringUtils.isNotBlank(hiredate)){ + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + List dates = Arrays.stream(hiredate.split(",")).map(d -> { + try { + return format.parse(d); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + }).collect(Collectors.toList()); + param.setHiredate(dates); + } + String mobile = request.getParameter("mobile"); + if(StringUtils.isNotBlank(mobile)){ + param.setMobile(mobile); + } + String otherTaxExemptDeductionId = request.getParameter("otherTaxExemptDeductionId"); + if(StringUtils.isNotBlank(otherTaxExemptDeductionId)){ + param.setOtherTaxExemptDeductionId(Long.valueOf(otherTaxExemptDeductionId)); + } + return param; + } + + @POST + @Path("/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("importParam", importParam); + return ResponseResult.run(getService(user)::preview, map); + } + + @POST + @Path("/importData") + @Produces(MediaType.APPLICATION_JSON) + public String importAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + map.put("importParam", importParam); + return ResponseResult.run(getService(user)::importData, map); + } + + + +}