diff --git a/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionRequestResultDTO.java b/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionRequestResultDTO.java new file mode 100644 index 000000000..5ef39f2e0 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/AddUpDeductionRequestResultDTO.java @@ -0,0 +1,34 @@ +package com.engine.salary.entity.datacollection.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +/** + * 数据采集-累计专项附加扣除-在线获取结果 + * + * @author chengliming + * @date 2022-11-01 09:47:27 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +@ApiModel("数据采集-累计专项附加扣除-在线获取结果") +public class AddUpDeductionRequestResultDTO { + @ApiModelProperty("请求id") + private String requestId; + + @ApiModelProperty("提示语") + private String msg; + + @ApiModelProperty("处理结果") + private String result; + + @ApiModelProperty("是否结束轮询") + private Boolean finish; +} diff --git a/src/com/engine/salary/entity/datacollection/param/AddUpDeductionMonthTaxAgentParam.java b/src/com/engine/salary/entity/datacollection/param/AddUpDeductionMonthTaxAgentParam.java new file mode 100644 index 000000000..843ecd238 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AddUpDeductionMonthTaxAgentParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.datacollection.param; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * 数据采集-累计专项附加月份+扣缴主体参数 + * + * @author : chengliming + * @Date: 2022-09-29 10:38:25 + */ +@Data +@ApiModel("数据采集-累计专项附加月份+扣缴主体参数") +public class AddUpDeductionMonthTaxAgentParam { + + @ApiModelProperty("税款所属期") + private Date declareMonth; + + @ApiModelProperty("个税扣缴义务人的主键id") + private Long taxAgentId; + +} diff --git a/src/com/engine/salary/service/AddUpDeductionService.java b/src/com/engine/salary/service/AddUpDeductionService.java index 51498f653..6f7a5f372 100644 --- a/src/com/engine/salary/service/AddUpDeductionService.java +++ b/src/com/engine/salary/service/AddUpDeductionService.java @@ -3,10 +3,8 @@ package com.engine.salary.service; import com.engine.salary.entity.datacollection.AddUpDeduction; import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO; import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO; -import com.engine.salary.entity.datacollection.param.AddUpDeductionImportParam; -import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam; -import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam; -import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordParam; +import com.engine.salary.entity.datacollection.dto.AddUpDeductionRequestResultDTO; +import com.engine.salary.entity.datacollection.param.*; import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; import com.engine.salary.util.page.PageInfo; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -157,4 +155,45 @@ public interface AddUpDeductionService { * @author lfc */ String autoAddAll(Date yearMonth, Boolean isAdmin); + + /** + * 在线获取数据 + * + * @param param + * @return + */ + Map onlineRequest(AddUpDeductionMonthTaxAgentParam param); + + /** + * 在线获取结果查询 + * + * @return + */ + AddUpDeductionRequestResultDTO onlineFeedback(); + + /** + * 在线获取失败记录 + * + * @param queryParam + * @return + */ + PageInfo onlineFeedbackFail(AddUpDeductionRequestFailQueryParam queryParam); + + /** + * 获取反馈失败记录 + * + * @param requestId + * @param tenantKey + * @return + */ + List getAddUpDeductionRequestFailPOList(Long requestId); + + /** + * 导出反馈失败记录 + * + * @param map + * @param requestId + */ + void exportOnlineFeedbackFail(Map map, Long requestId); + } diff --git a/src/com/engine/salary/web/AddUpDeductionController.java b/src/com/engine/salary/web/AddUpDeductionController.java index b153fd475..ef2754c5e 100644 --- a/src/com/engine/salary/web/AddUpDeductionController.java +++ b/src/com/engine/salary/web/AddUpDeductionController.java @@ -12,11 +12,13 @@ import com.engine.salary.util.ResponseResult; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.page.PageInfo; import com.engine.salary.wrapper.AddUpDeductionWrapper; +import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.parameters.RequestBody; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.jetbrains.annotations.Nullable; +import org.springframework.web.bind.annotation.RequestParam; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; @@ -35,10 +37,7 @@ import java.net.URLEncoder; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDate; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -271,8 +270,8 @@ public class AddUpDeductionController { } /** - * @description 新建累计专项附加扣除 * @return String + * @description 新建累计专项附加扣除 * @author Harryxzy * @date 2022/10/26 14:23 */ @@ -285,8 +284,8 @@ public class AddUpDeductionController { } /** - * @description 获取累计专项附加扣除信息 * @return String + * @description 获取累计专项附加扣除信息 * @author Harryxzy * @date 2022/10/31 11:23 */ @@ -300,8 +299,8 @@ public class AddUpDeductionController { /** - * @description 编辑累计专项附加扣除 * @return String + * @description 编辑累计专项附加扣除 * @author Harryxzy * @date 2022/10/25 14:08 */ @@ -314,8 +313,8 @@ public class AddUpDeductionController { } /** - * @description 累计专项附加扣除-删除所选 * @return String + * @description 累计专项附加扣除-删除所选 * @author Harryxzy * @date 2022/10/27 14:08 */ @@ -328,8 +327,8 @@ public class AddUpDeductionController { } /** - * @description 累计专项附加扣除-一键清空 * @return String + * @description 累计专项附加扣除-一键清空 * @author Harryxzy * @date 2022/10/27 14:08 */ @@ -353,6 +352,7 @@ public class AddUpDeductionController { /** * 一键自动累计 + * * @return */ @POST @@ -374,4 +374,84 @@ public class AddUpDeductionController { User user = HrmUserVarify.getUser(request, response); return new ResponseResult(user).run(getAddUpDeductionWrapper(user)::autoAddAll, date); } + + + /** + * 在线获取 + * + * @param param 前端请求参数 + * @return WeaResult 接口返回信息 + */ + @Path("/online/request") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String onlineRequest(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody AddUpDeductionMonthTaxAgentParam param) { + Map result = addUpDeductionWrapper.onlineRequest(param, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); + if (Objects.nonNull(result.get("msg"))) { + return WeaResult.fail(result.get("msg").toString()); + } + return WeaResult.success(null); + } + + /** + * 在线获取结果查询 + * + * @return WeaResult 接口返回信息 + */ + @Path("/online/feedback") + @GET + @Produces(MediaType.APPLICATION_JSON) + public String onlineFeedback() { + return WeaResult.success(addUpDeductionWrapper.onlineFeedback(UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey())); + } + + /** + * 在线获取失败结果查询 + * + * @return WeaResult 接口返回信息 + */ + @Path("/online/feedback/fail") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String onlineFeedbackFail(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody AddUpDeductionRequestFailQueryParam queryParam) { + return WeaResult.success(addUpDeductionWrapper.onlineFeedbackFail(UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey(), queryParam)); + } + + /** + * 在线获取结果导出 + * + * @return WeaResult 接口返回信息 + */ + @Path("/online/feedback/fail/export") + @GET + @Produces(MediaType.APPLICATION_JSON) + public String exportOnlineFeedbackFail(@RequestParam Long requestId) { + return WeaResult.success(addUpDeductionWrapper.exportOnlineFeedbackFail(UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey(), requestId)); + } + + /** + * 在线获取表单 + * + * @return WeaResult 返回结果 + */ + @Path("/online/request/form") + @GET + @Produces(MediaType.APPLICATION_JSON) + public String getForm() { + return WeaResult.success(addUpDeductionWrapper.getRequestForm()); + } + + /** + * 自动计算次月 + * + * @param queryParam 查询条件 + * @return WeaResult 返回结果 + */ + @Path("/autoCalculate") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String autoCalculate(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody AddUpDeductionQueryParam queryParam) { + addUpDeductionWrapper.autoCalculate(queryParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); + return WeaResult.success(null); + } } diff --git a/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java b/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java index aa89c3c58..3ac0dfe17 100644 --- a/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java +++ b/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java @@ -179,4 +179,51 @@ public class AddUpDeductionWrapper extends Service { } return getAddUpDeductionService(user).autoAddAll(yearMonth, null); } + + public Map onlineRequest(AddUpDeductionMonthTaxAgentParam param, Long currentEmployeeId, String currentTenantKey) { + return addUpDeductionService.onlineRequest(param, currentEmployeeId, currentTenantKey); + } + + public AddUpDeductionRequestResultDTO onlineFeedback(Long currentEmployeeId, String currentTenantKey) { + return addUpDeductionService.onlineFeedback(currentEmployeeId, currentTenantKey); + } + + public WeaTable onlineFeedbackFail(Long currentEmployeeId, String currentTenantKey, AddUpDeductionRequestFailQueryParam queryParam) { + if (queryParam.getRequestId() == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 153345, "在线获取的请求ID不可为空")); + } + Page page = addUpDeductionService.onlineFeedbackFail(currentEmployeeId, currentTenantKey, queryParam); + return SalaryFormatUtil.getInstance().buildTable(AddUpDeductionRequestFailListDTO.class, page); + } + + public Map exportOnlineFeedbackFail(Long employeeId, String tenantKey, Long requestId) { + List poList = addUpDeductionService.getAddUpDeductionRequestFailPOList(requestId, tenantKey); + if (CollectionUtils.isEmpty(poList)) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 95795, "数据不存在") + "[id:%s]", requestId)); + } + // 构建异步导出参数 + Map map = salaryBatchService.buildeExportParam("exportOnlineFeedbackFail"); + map.put("sheetName", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 183778, "在线获取专项附加扣除失败数据")); + LocalRunnable localRunnable = new LocalRunnable() { + @Override + public void execute() { + try { + DSTenantKeyThreadVar.tenantKey.set(tenantKey); + addUpDeductionService.exportOnlineFeedbackFail(map, requestId, employeeId, tenantKey); + } finally { + DSTenantKeyThreadVar.tenantKey.remove(); + } + } + }; + ThreadPoolUtil.execute(localRunnable); + return map; + } + + public WeaForm getRequestForm() { + WeaForm weaForm = SalaryFormatUtil.getInstance().buildForm(AddUpDeductionRequestFormDTO.class, new AddUpDeductionRequestFormDTO()); + WeaFormSalaryItem item = new WeaFormSalaryItem(WeaFormItemType.DATEPICKER, "month", "YYYY-MM", "YYYY-MM"); + item.setRequired(true); + weaForm.getItems().put("declareMonth", item); + return weaForm; + } }