178 lines
7.3 KiB
Java
178 lines
7.3 KiB
Java
|
|
package com.engine.salary.cmd.datacollection;
|
||
|
|
|
||
|
|
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.result.WeaResultMsg;
|
||
|
|
import com.engine.common.biz.AbstractCommonCommand;
|
||
|
|
import com.engine.common.entity.BizLogContext;
|
||
|
|
import com.engine.core.interceptor.CommandContext;
|
||
|
|
import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam;
|
||
|
|
import org.apache.commons.collections4.CollectionUtils;
|
||
|
|
import org.apache.commons.lang3.StringUtils;
|
||
|
|
import weaver.general.PageIdConst;
|
||
|
|
import weaver.hrm.User;
|
||
|
|
|
||
|
|
import java.util.*;
|
||
|
|
import java.util.stream.Collectors;
|
||
|
|
|
||
|
|
public class AddUpSituationListCmd extends AbstractCommonCommand<Map<String, Object>> {
|
||
|
|
|
||
|
|
public AddUpSituationListCmd(Map<String, Object> params, User user) {
|
||
|
|
this.user = user;
|
||
|
|
this.params = params;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public BizLogContext getLogContext() {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public Map<String, Object> execute(CommandContext commandContext) {
|
||
|
|
|
||
|
|
String fileds = " t1.id," +
|
||
|
|
" t1.declare_month," +
|
||
|
|
" t1.employee_id," +
|
||
|
|
" e.lastname as username," +
|
||
|
|
" d.departmentname AS departmentName," +
|
||
|
|
" e.mobile," +
|
||
|
|
" e.workcode as job_num," +
|
||
|
|
" e.created as hiredate," +
|
||
|
|
" t2.name AS tax_agent_name," +
|
||
|
|
" t1.add_up_child_education," +
|
||
|
|
" t1.add_up_continuing_education," +
|
||
|
|
" t1.add_up_housing_loan_interest," +
|
||
|
|
" t1.add_up_housing_rent," +
|
||
|
|
" t1.add_up_support_elderly";
|
||
|
|
|
||
|
|
String fromSql = " FROM" +
|
||
|
|
" hrsa_add_up_deduction t1" +
|
||
|
|
" LEFT JOIN hrsa_tax_agent t2 ON t1.tax_agent_id = t2.id" +
|
||
|
|
" LEFT JOIN hrmresource e ON t1.employee_id = e.id" +
|
||
|
|
" LEFT JOIN hrmdepartment d ON e.departmentid = d.id";
|
||
|
|
|
||
|
|
|
||
|
|
Map<String, Object> apidatas = new HashMap<String, Object>(16);
|
||
|
|
|
||
|
|
WeaResultMsg result = new WeaResultMsg(false);
|
||
|
|
String pageID = "a4f85287-e3f9-4275-adn9-7d06e54y6rj8";
|
||
|
|
String pageUid = pageID + "_" + user.getUID();
|
||
|
|
String pageSize = PageIdConst.getPageSize(pageID, user.getUID());
|
||
|
|
|
||
|
|
|
||
|
|
WeaTable table = new WeaTable();
|
||
|
|
table.setPageUID(pageUid);
|
||
|
|
table.setPageID(pageID);
|
||
|
|
table.setPagesize(pageSize);
|
||
|
|
table.setBackfields(fileds);
|
||
|
|
table.setSqlform(fromSql);
|
||
|
|
table.setSqlwhere(makeSqlWhere());
|
||
|
|
table.setSqlorderby("t1.id DESC");
|
||
|
|
table.setSqlprimarykey("t1.id");
|
||
|
|
table.setSqlisdistinct("false");
|
||
|
|
|
||
|
|
table.getColumns().add(new WeaTableColumn("id").setDisplay(WeaBoolAttr.FALSE));
|
||
|
|
table.getColumns().add(new WeaTableColumn("10%", "姓名", "username", ""));
|
||
|
|
table.getColumns().add(new WeaTableColumn("10%", "个税扣缴义务人", "taxAgentName", ""));
|
||
|
|
table.getColumns().add(new WeaTableColumn("10%", "部门", "departmentName", ""));
|
||
|
|
table.getColumns().add(new WeaTableColumn("10%", "手机号", "mobile", ""));
|
||
|
|
table.getColumns().add(new WeaTableColumn("10%", "工号", "jobNum", ""));
|
||
|
|
table.getColumns().add(new WeaTableColumn("10%", "证件号码", "idNo", ""));
|
||
|
|
table.getColumns().add(new WeaTableColumn("10%", "入职日期", "hiredate", ""));
|
||
|
|
table.getColumns().add(new WeaTableColumn("20%", "操作", "operate", ""));
|
||
|
|
|
||
|
|
List<WeaTableOperate> operateList = new ArrayList<>();
|
||
|
|
WeaTableOperate delete = new WeaTableOperate("删除", "", "0");
|
||
|
|
operateList.add(delete);
|
||
|
|
WeaTableOperates weaTableOperates = new WeaTableOperates();
|
||
|
|
weaTableOperates.setOperate(operateList);
|
||
|
|
table.setOperates(weaTableOperates);
|
||
|
|
|
||
|
|
//设置check是否可用
|
||
|
|
table.setCheckboxList(null);
|
||
|
|
table.setCheckboxpopedom(null);
|
||
|
|
result.putAll(table.makeDataResult());
|
||
|
|
result.success();
|
||
|
|
apidatas = result.getResultMap();
|
||
|
|
return apidatas;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
private String makeSqlWhere() {
|
||
|
|
|
||
|
|
AddUpDeductionQueryParam queryParam = (AddUpDeductionQueryParam) params.get("queryParam");
|
||
|
|
//申报月份
|
||
|
|
List<String> 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<Long> 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<String> 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<Long> 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<Date> hiredate = queryParam.getHiredate();
|
||
|
|
if (CollectionUtils.isNotEmpty(hiredate) && hiredate.size() == 2) {
|
||
|
|
sqlWhere += " AND (e.created BETWEEN "+hiredate.get(0)+" AND "+hiredate.get(1)+")";
|
||
|
|
}
|
||
|
|
//手机号
|
||
|
|
String mobile = queryParam.getMobile();
|
||
|
|
if (StringUtils.isNotBlank(mobile)) {
|
||
|
|
sqlWhere += " AND e.mobile like '%" + mobile + "%'";
|
||
|
|
}
|
||
|
|
|
||
|
|
return sqlWhere;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|