日期转换

This commit is contained in:
钱涛 2022-03-08 15:40:26 +08:00
parent c8b05f5ef1
commit 9de0f08415
13 changed files with 324 additions and 29 deletions

View File

@ -3,6 +3,7 @@ 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.AddUpDeductionListDTO;
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO;
import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam;
import com.engine.salary.mapper.datacollection.AddUpDeductionMapper;
import org.apache.commons.collections4.CollectionUtils;
@ -58,6 +59,36 @@ public class AddUpDeductionBiz extends BaseBean {
}
/**
* 根据id获取
* @param id
* @return
*/
public AddUpDeduction getById(Long id) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class);
return mapper.getById(id);
} finally {
sqlSession.close();
}
}
/**
* 详情列表
* @param param
* @return
*/
public List<AddUpDeductionRecordDTO> recordList(AddUpDeductionQueryParam param){
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class);
return mapper.recordList(param);
} finally {
sqlSession.close();
}
}
/**
* 批量插入
*

View File

@ -0,0 +1,165 @@
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.AddUpDeductionBiz;
import com.engine.salary.component.SalaryWeaTable;
import com.engine.salary.entity.datacollection.AddUpDeduction;
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO;
import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam;
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.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class AddUpDeductionGetDetailListCmd extends AbstractCommonCommand<Map<String, Object>> {
public AddUpDeductionGetDetailListCmd(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) {
AddUpDeductionBiz biz = new AddUpDeductionBiz();
AddUpDeductionQueryParam queryParam = (AddUpDeductionQueryParam)params.get("queryParam");
Long id = queryParam.getAccumulatedSpecialAdditionalDeductionId();
if (id == null) {
throw new SalaryRunTimeException("累计专项附加扣除id不能为空");
}
AddUpDeduction po = biz.getById(id);
if (po == null) {
throw new SalaryRunTimeException(String.format("累计专项附加扣除不存在[id:%s]", id));
}
// List<SimpleEmployee> employeeList = employeeService.getEmployeeByIds(Collections.singletonList(po.getEmployeeId()), tenantKey);
// if (CollectionUtils.isEmpty(employeeList)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100340, "员工信息不存在"));
// }
queryParam.setEmployeeId(po.getEmployeeId());
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";
SalaryWeaTable<AddUpDeductionRecordDTO> table = new SalaryWeaTable<AddUpDeductionRecordDTO>(user, AddUpDeductionRecordDTO.class);
table.setBackfields(fileds);
table.setSqlform(fromSql);
table.setSqlwhere(makeSqlWhere(queryParam));
table.setSqlorderby("t1.declare_month DESC");
table.setSqlprimarykey("t1.id");
table.setSqlisdistinct("false");
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
return result.getResultMap();
}
private String makeSqlWhere( AddUpDeductionQueryParam 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;
}
}

View File

@ -5,8 +5,8 @@ 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.AddUpDeductionListDTO;
import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam;
import com.engine.salary.entity.datacollection.vo.AddUpDeductionVO;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.hrm.User;
@ -53,7 +53,7 @@ public class AddUpDeductionListCmd extends AbstractCommonCommand<Map<String, Obj
" LEFT JOIN hrmresource e ON t1.employee_id = e.id" +
" LEFT JOIN hrmdepartment d ON e.departmentid = d.id";
SalaryWeaTable<AddUpDeductionVO> table = new SalaryWeaTable<>(user, AddUpDeductionVO.class);
SalaryWeaTable<AddUpDeductionListDTO> table = new SalaryWeaTable<AddUpDeductionListDTO>(user, AddUpDeductionListDTO.class);
table.setBackfields(fileds);
table.setSqlform(fromSql);
table.setSqlwhere(makeSqlWhere());

View File

@ -48,7 +48,7 @@ public class AddUpSituationGetSearchConditionCmd extends AbstractCommonCommand<M
conditionItems.add(username);
SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER,502227,"departmentName","124");
SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER,502227,"departmentName","4");
departmentName.setColSpan(2);
departmentName.setFieldcol(12);
departmentName.setLabelcol(6);

View File

@ -82,6 +82,10 @@ public class SalaryWeaTable<T> extends WeaTable {
String orderkey = columnAnn.orderkey();
boolean display = columnAnn.display();
WeaTableColumn weaTableColumn = new WeaTableColumn(width, text, column, orderkey);
String transmethod = columnAnn.transmethod();
if(StringUtils.isNotBlank(transmethod)){
weaTableColumn.setTransmethod(transmethod);
}
if (!display) {
weaTableColumn.setDisplay(WeaBoolAttr.FALSE);
}

View File

@ -1,5 +1,8 @@
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 com.engine.salary.util.excel.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
@ -22,11 +25,15 @@ import java.util.Date;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@SalaryTable(pageId = "a4f85287-e3f9-4275-adn9-7d06e54y6rj8", operates = {
@SalaryTableOperate(text = "删除")
})
public class AddUpDeductionListDTO {
/**
* 主键id
*/
@SalaryTableColumn(column = "id", display = false)
private Long id;
/**
@ -38,36 +45,42 @@ public class AddUpDeductionListDTO {
* 姓名
*/
@ExcelProperty(index = 0)
@SalaryTableColumn(text = "姓名", width = "10%", column = "username")
private String username;
/**
* 个税扣缴义务人
*/
@ExcelProperty(index = 1)
@SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName")
private String taxAgentName;
/**
* 部门
*/
@ExcelProperty(index = 2)
@SalaryTableColumn(text = "部门", width = "10%", column = "departmentName")
private String departmentName;
/**
* 手机号
*/
@ExcelProperty(index = 3)
@SalaryTableColumn(text = "手机号", width = "10%", column = "mobile")
private String mobile;
/**
* 工号
*/
@ExcelProperty(index = 4)
@SalaryTableColumn(text = "工号", width = "10%", column = "jobNum")
private String jobNum;
/**
* 证件号码
*/
@ExcelProperty(index = 5)
@SalaryTableColumn(text = "证件号码", width = "10%", column = "idNo")
private String idNo;
/**
@ -75,35 +88,44 @@ public class AddUpDeductionListDTO {
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@ExcelProperty(index = 6)
@SalaryTableColumn(text = "入职日期", width = "10%", column = "hiredate",transmethod="com.engine.salary.transmethod.TransMethod.timeToDate")
private Date hiredate;
/**
* 累计子女教育
*/
@ExcelProperty(index = 7)
@SalaryTableColumn(text = "累计子女教育", width = "10%", column = "addUpChildEducation")
private BigDecimal addUpChildEducation;
/**
* 累计继续教育
*/
@ExcelProperty(index = 8)
@SalaryTableColumn(text = "累计继续教育", width = "10%", column = "addUpContinuingEducation")
private BigDecimal addUpContinuingEducation;
/**
* 累计住房贷款利息
*/
@ExcelProperty(index = 9)
@SalaryTableColumn(text = "累计住房贷款利息", width = "10%", column = "addUpHousingLoanInterest")
private BigDecimal addUpHousingLoanInterest;
/**
* 累计住房租金
*/
@ExcelProperty(index = 10)
@SalaryTableColumn(text = "累计住房租金", width = "10%", column = "addUpHousingRent")
private BigDecimal addUpHousingRent;
/**
* 累计赡养老人
*/
@ExcelProperty(index = 11)
@SalaryTableColumn(text = "累计赡养老人", width = "10%", column = "addUpSupportElderly")
private BigDecimal addUpSupportElderly;
@SalaryTableColumn(text = "操作", width = "20%", column = "operate")
private String operate;
}

View File

@ -1,43 +1,66 @@
package com.engine.salary.entity.datacollection.vo;
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 com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 数据采集-累计专项附加扣除表
*/
import java.math.BigDecimal;
import java.util.Date;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@SalaryTable(pageId = "a4f85287-e3f9-4275-adn9-7d06e54y6rj8", operates = {
@SalaryTableOperate(text = "删除")
})
public class AddUpDeductionVO {
//数据采集-累计专项附加扣除记录
@SalaryTable(pageId = "a4f85287-3354-4275-adn9-7d06e54y6rj8")
public class AddUpDeductionRecordDTO {
//主键id
@SalaryTableColumn(column = "id", display = false)
private Long id;
@SalaryTableColumn(text = "姓名", width = "10%", column = "username")
private String username;
//员工id
private Long employeeId;
//申报月份
@JsonFormat(pattern = "yyyy-MM")
private Date declareMonth;
//个税扣缴义务人
@SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName")
private String taxAgentName;
@SalaryTableColumn(text = "姓名", width = "10%", column = "username")
private String username;
//部门
@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")
private String hiredate;
@SalaryTableColumn(text = "操作", width = "20%", column = "operate")
private String operate;
//累计子女教育
private BigDecimal addUpChildEducation;
}
//累计继续教育
private BigDecimal addUpContinuingEducation;
//累计住房贷款利息
private BigDecimal addUpHousingLoanInterest;
//累计住房租金
private BigDecimal addUpHousingRent;
//累计赡养老人
private BigDecimal addUpSupportElderly;
}

View File

@ -3,6 +3,7 @@ package com.engine.salary.mapper.datacollection;
import com.engine.salary.entity.datacollection.AddUpDeduction;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.datacollection.dto.AddUpDeductionListDTO;
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO;
import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -101,5 +102,5 @@ public interface AddUpDeductionMapper {
*/
void updateData(@Param("collection") List<AddUpDeduction> updateList);
List<AddUpDeductionRecordDTO> recordList(@Param("param") AddUpDeductionQueryParam param);
}

View File

@ -677,5 +677,19 @@
</foreach>
</update>
<select id="recordList" resultType="com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO">
SELECT
<include refid="addUpDeductionColumn"/>
FROM
hrsa_add_up_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
WHERE
t1.delete_type = 0 AND t2.delete_type = 0
<include refid="paramSql"/>
ORDER BY t1.declare_month DESC
</select>
</mapper>

View File

@ -13,4 +13,6 @@ public interface AddUpDeductionService {
Map<String, Object> getSearchCondition(Map<String, Object> params);
Map<String, Object> importAddUpDeduction(Map<String, Object> params);
Map<String, Object> getDetailList(Map<String, Object> params);
}

View File

@ -1,10 +1,7 @@
package com.engine.salary.service.impl;
import com.engine.core.impl.Service;
import com.engine.salary.cmd.datacollection.AddUpDeductionExportCmd;
import com.engine.salary.cmd.datacollection.AddUpDeductionGetSearchConditionCmd;
import com.engine.salary.cmd.datacollection.AddUpDeductionImportCmd;
import com.engine.salary.cmd.datacollection.AddUpDeductionListCmd;
import com.engine.salary.cmd.datacollection.*;
import com.engine.salary.service.AddUpDeductionService;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@ -31,4 +28,9 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
public Map<String, Object> importAddUpDeduction(Map<String, Object> params) {
return commandExecutor.execute(new AddUpDeductionImportCmd(params, user));
}
@Override
public Map<String, Object> getDetailList(Map<String, Object> params) {
return commandExecutor.execute(new AddUpDeductionGetDetailListCmd(params, user));
}
}

View File

@ -0,0 +1,21 @@
package com.engine.salary.transmethod;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class TransMethod {
public static String timeToDate(String time) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format = "";
try {
Date parse = timeFormat.parse(time);
format = dateFormat.format(parse);
} catch (ParseException e) {
e.printStackTrace();
}
return format;
}
}

View File

@ -73,7 +73,7 @@ public class AddUpDeductionController {
public Response getAll(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
//模板文件路径
String templateFilePath = GCONST.getRootPath() + "salary/addUpDeduction/addUpDeductionTemplate.xlsx";
String templateFilePath = GCONST.getRootPath() + "salary/addUpDeduction/importTemplate.xlsx";
File file = new File(templateFilePath);
@ -198,7 +198,6 @@ public class AddUpDeductionController {
return param;
}
//新建个税扣缴义务人
@POST
@Path("/importAddUpDeduction")
@Produces(MediaType.APPLICATION_JSON)
@ -209,4 +208,15 @@ public class AddUpDeductionController {
return ResponseResult.run(getService(user)::importAddUpDeduction, map);
}
@POST
@Path("/getDetailList")
@Produces(MediaType.APPLICATION_JSON)
public String getDetailList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionQueryParam queryParam) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> map = ParamUtil.request2Map(request);
map.put("queryParam", queryParam);
return ResponseResult.run(getService(user)::getDetailList, map);
}
}