From bf999d13674ec5f23a26a00991acdb8eee4dbad9 Mon Sep 17 00:00:00 2001 From: ic_excellent Date: Mon, 6 Feb 2023 11:31:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E8=A3=85=E5=8F=91=E7=A5=A8=E5=8B=BE?= =?UTF-8?q?=E9=80=89=E6=8E=A5=E5=8F=A3=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aiyh/utils/action/SafeCusBaseAction.java | 1 + .../controller/InvoiceSelectController.java | 73 +++++++++++++++++ .../dz_invoice/mapper/DzInvoiceMapper.java | 40 +++++++++ .../dz_invoice/service/DzInvoiceService.java | 29 +++++++ .../service/impl/DzInvoiceServiceImpl.java | 81 +++++++++++++++++++ .../action/InvoiceDeductionAction.java | 70 ++++++++++++++++ .../dz_invoice/mapper/WorkflowMapper.java | 26 ++++++ .../schedule/InvoiceQuerySchedule.java | 18 +++++ 8 files changed, 338 insertions(+) create mode 100644 src/main/java/com/api/bokang/xiao/dz_invoice/controller/InvoiceSelectController.java create mode 100644 src/main/java/com/api/bokang/xiao/dz_invoice/mapper/DzInvoiceMapper.java create mode 100644 src/main/java/com/api/bokang/xiao/dz_invoice/service/DzInvoiceService.java create mode 100644 src/main/java/com/api/bokang/xiao/dz_invoice/service/impl/DzInvoiceServiceImpl.java create mode 100644 src/main/java/weaver/bokang/xiao/dz_invoice/action/InvoiceDeductionAction.java create mode 100644 src/main/java/weaver/bokang/xiao/dz_invoice/mapper/WorkflowMapper.java create mode 100644 src/main/java/weaver/bokang/xiao/dz_invoice/schedule/InvoiceQuerySchedule.java diff --git a/src/main/java/aiyh/utils/action/SafeCusBaseAction.java b/src/main/java/aiyh/utils/action/SafeCusBaseAction.java index c638269..e97c6d7 100644 --- a/src/main/java/aiyh/utils/action/SafeCusBaseAction.java +++ b/src/main/java/aiyh/utils/action/SafeCusBaseAction.java @@ -12,6 +12,7 @@ import weaver.workflow.request.RequestManager; import weaver.workflow.workflow.WorkflowBillComInfo; import weaver.workflow.workflow.WorkflowComInfo; +import java.io.IOException; import java.util.*; /** diff --git a/src/main/java/com/api/bokang/xiao/dz_invoice/controller/InvoiceSelectController.java b/src/main/java/com/api/bokang/xiao/dz_invoice/controller/InvoiceSelectController.java new file mode 100644 index 0000000..d44ec32 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/dz_invoice/controller/InvoiceSelectController.java @@ -0,0 +1,73 @@ +package com.api.bokang.xiao.dz_invoice.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.api.bokang.xiao.dz_invoice.service.DzInvoiceService; +import com.api.bokang.xiao.dz_invoice.service.impl.DzInvoiceServiceImpl; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.log4j.Logger; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Map; + +/** + * @ClassName InvoiceSelectController + * @Author 肖博亢 + * @Date 2023/2/2 16:21 + * @Description

发票勾选,查询

+ **/ + +@Path("/xbk/dz_invoice") +public class InvoiceSelectController { + + private final Logger log = Util.getLogger(); + private final DzInvoiceService dzInvoiceService = new DzInvoiceServiceImpl(); + + /** + *

发票抵扣勾选处理

+ * @param request 请求体 + * @param response 响应体 + * @param param 请求参数 + * @return 请求结果 + */ + @Path("/checkInvoice") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String checkInvoice(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + try{ + log.info("into checkInvoice success params ==> "+param); + List> maps = dzInvoiceService.checkInvoice(param); + return ApiResult.success(maps); + }catch (Exception e){ + log.error("发票勾选调用异常 ==> \n"+Util.getErrString(e)); + return ApiResult.error(); + } + } + + /** + *

发票取消抵扣勾选处理

+ * @param request 请求体 + * @param response 响应体 + * @param param 请求参数 + * @return 请求结果 + */ + @Path("/unCheckInvoice") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String unCheckInvoice(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + try{ + log.info("into unCheckInvoice success params ==> "+param); + List> maps = dzInvoiceService.unCheckInvoice(param); + return ApiResult.success(maps); + }catch (Exception e){ + log.error("发票勾选调用异常 ==> \n"+Util.getErrString(e)); + return ApiResult.error(); + } + } + +} diff --git a/src/main/java/com/api/bokang/xiao/dz_invoice/mapper/DzInvoiceMapper.java b/src/main/java/com/api/bokang/xiao/dz_invoice/mapper/DzInvoiceMapper.java new file mode 100644 index 0000000..3a94c7d --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/dz_invoice/mapper/DzInvoiceMapper.java @@ -0,0 +1,40 @@ +package com.api.bokang.xiao.dz_invoice.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; +import aiyh.utils.annotation.recordset.Update; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName DzInvoiceMapper + * @Author 肖博亢 + * @Date 2023/2/2 17:03 + * @Description

发票信息查询

+ **/ + +@SqlMapper +public interface DzInvoiceMapper { + + /** + *

通过id查询发票信息

+ * @param ids 发票id字符串 + * @return 发票信息集合 + */ + @Select("select * from APInvoice where id in (${ids})") + List> queryInvoiceList(@ParamMapper("ids") String ids); + + /** + *

更新发票勾选状态

+ * @param checkStatus 勾选状态值 + * @param fieldId 字段名 + * @param fieldValue 字段值 + * @return 操作结果 + */ + @Update("update APInvoice set check_status = #{checkStatus} where $t{fieldId} = #{fieldValue}") + boolean updateInvoiceCheckStatus(@ParamMapper("check_status") int checkStatus, + @ParamMapper("fieldId") String fieldId, + @ParamMapper("fieldValue") Object fieldValue); +} diff --git a/src/main/java/com/api/bokang/xiao/dz_invoice/service/DzInvoiceService.java b/src/main/java/com/api/bokang/xiao/dz_invoice/service/DzInvoiceService.java new file mode 100644 index 0000000..4f269c7 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/dz_invoice/service/DzInvoiceService.java @@ -0,0 +1,29 @@ +package com.api.bokang.xiao.dz_invoice.service; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName DzInvoiceService + * @Author 肖博亢 + * @Date 2023/2/2 16:41 + * @Description

业务处理类

+ **/ +public interface DzInvoiceService { + + /** + *

将选中的发票作为参数 调用发票勾选接口 抵扣勾选

+ * @param param 参数信息 + * @return 调用结果集合 + * @throws Exception 异常 + */ + List> checkInvoice(Map param) throws Exception; + + /** + *

将选中的发票作为参数 调用发票勾选接口 取消抵扣勾选

+ * @param param 参数信息 + * @return 调用结果集合 + * @throws Exception 异常 + */ + List> unCheckInvoice(Map param) throws Exception; +} diff --git a/src/main/java/com/api/bokang/xiao/dz_invoice/service/impl/DzInvoiceServiceImpl.java b/src/main/java/com/api/bokang/xiao/dz_invoice/service/impl/DzInvoiceServiceImpl.java new file mode 100644 index 0000000..514d07e --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/dz_invoice/service/impl/DzInvoiceServiceImpl.java @@ -0,0 +1,81 @@ +package com.api.bokang.xiao.dz_invoice.service.impl; + +import aiyh.utils.Util; +import aiyh.utils.httpUtil.ResponeVo; +import aiyh.utils.httpUtil.util.HttpUtils; +import com.api.bokang.xiao.dz_invoice.mapper.DzInvoiceMapper; +import com.api.bokang.xiao.dz_invoice.service.DzInvoiceService; +import weaver.xiao.commons.config.entity.RequestMappingConfig; +import weaver.xiao.commons.config.service.DealWithMapping; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @ClassName DzInvoiceServiceImpl + * @Author 肖博亢 + * @Date 2023/2/2 16:42 + * @Description

实现类

+ **/ +public class DzInvoiceServiceImpl implements DzInvoiceService { + + private final DzInvoiceMapper dzInvoiceMapper = Util.getMapper(DzInvoiceMapper.class); + + private final DealWithMapping dealWithMapping = new DealWithMapping(); + + private final HttpUtils httpUtils = new HttpUtils(); + + /** 已申请抵扣 */ + private static final Integer REQ_DEDUCTION = 2; + + /** 已申请取消抵扣 */ + private static final Integer REQ_UN_DEDUCTION = 3; + + @Override + public List> checkInvoice(Map param) throws IOException { + return handleInvoice(param,1); + } + + @Override + public List> unCheckInvoice(Map param) throws Exception { + return handleInvoice(param,2); + } + + /** + *

发票勾选具体处理逻辑

+ * @param param 请求参数 + * @param handleType 处理类型 1: 抵扣勾选处理; 2: 取消抵扣勾选处理 + * @return 处理结果集合 + * @throws IOException IO异常 + */ + private List> handleInvoice(Map param,int handleType) throws IOException { + List> results = new ArrayList<>(); + String ids = Util.null2String(param.get("ids")); + String reqUniqueCode = handleType == 1 ? Util.null2String(param.get("checkInvoiceUniqueCode")) : Util.null2String(param.get("unCheckInvoiceUniqueCode")); + List> invoiceList = dzInvoiceMapper.queryInvoiceList(ids); + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(reqUniqueCode); + for (Map invoice : invoiceList) { + Map result = new HashMap<>(); + Map requestParam = dealWithMapping.getRequestParam(invoice, requestMappingConfig); + String invoiceId = Util.null2String(invoice.get("id")); + ResponeVo responeVo = httpUtils.apiPost(requestMappingConfig.getRequestUrl(), requestParam); + if(responeVo.getCode() == 200){ + result.put("reqFlag",true); + Map entity = responeVo.getResponseEntity(Map.class); + boolean reqStatus = "E0000".equals(Util.null2String(entity.get("code"))); + String describe = Util.null2String(entity.get("describe")); + result.put("checkStatus",reqStatus); + result.put("describe",describe); + int checkStatus = handleType == 1 ? REQ_DEDUCTION : REQ_UN_DEDUCTION; + dzInvoiceMapper.updateInvoiceCheckStatus(checkStatus,"id",invoiceId); + }else { + result.put("reqFlag",false); + } + results.add(result); + } + return results; + } +} diff --git a/src/main/java/weaver/bokang/xiao/dz_invoice/action/InvoiceDeductionAction.java b/src/main/java/weaver/bokang/xiao/dz_invoice/action/InvoiceDeductionAction.java new file mode 100644 index 0000000..f9ddb2a --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/dz_invoice/action/InvoiceDeductionAction.java @@ -0,0 +1,70 @@ +package weaver.bokang.xiao.dz_invoice.action; + +import aiyh.utils.Util; +import aiyh.utils.action.SafeCusBaseAction; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.httpUtil.ResponeVo; +import aiyh.utils.httpUtil.util.HttpUtils; +import com.api.bokang.xiao.dz_invoice.mapper.DzInvoiceMapper; +import weaver.bokang.xiao.dz_invoice.mapper.WorkflowMapper; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; +import weaver.xiao.commons.config.entity.RequestMappingConfig; +import weaver.xiao.commons.config.service.DealWithMapping; + + +import java.io.IOException; +import java.util.Map; + +/** + * @ClassName InvoiceDeductionAction + * @Author 肖博亢 + * @Date 2023/2/3 9:54 + * @Description

发票抵扣action

+ **/ +@ActionDesc(value = "抵扣勾选发票接口调用",author = "bokang.xiao") +public class InvoiceDeductionAction extends SafeCusBaseAction { + + @RequiredMark("勾选发票接口唯一标识") + @PrintParamMark + private String requestUnique; + + private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class); + + private final DzInvoiceMapper dzInvoiceMapper = Util.getMapper(DzInvoiceMapper.class); + + private final DealWithMapping dealWithMapping = new DealWithMapping(); + + private final HttpUtils httpUtils = new HttpUtils(); + + /** 已申请抵扣 */ + private static final Integer REQ_DEDUCTION = 2; + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo){ + log.info(String.format("=================== {%s} begin ======================", this.getClass().getName())); + log.info(String.format("params:[requestId ==>%s],[requestUnique ==>%s]", requestId,requestUnique)); + Map workflowMessage = workflowMapper.queryWorkflowByRequestId(requestId, billTable); + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(requestUnique); + Map requestParam = dealWithMapping.getRequestParam(workflowMessage, requestMappingConfig); + try { + ResponeVo responeVo = httpUtils.apiPost(requestMappingConfig.getRequestUrl(), requestParam); + if(responeVo.getCode() == 200){ + Map result = responeVo.getResponseEntity(Map.class); + String code = Util.null2String(result.get("code")); + String describe = Util.null2String(result.get("describe")); + if(!"E0000".equals(code)){ + throw new CustomerException("请求调用失败 ==>"+describe); + } + }else { + throw new CustomerException("请求状态码不为200"); + } + }catch (IOException ioException){ + log.error("请求发送异常 ==>"+Util.getErrString(ioException)); + throw new CustomerException("请求发送异常"); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/dz_invoice/mapper/WorkflowMapper.java b/src/main/java/weaver/bokang/xiao/dz_invoice/mapper/WorkflowMapper.java new file mode 100644 index 0000000..c20fb02 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/dz_invoice/mapper/WorkflowMapper.java @@ -0,0 +1,26 @@ +package weaver.bokang.xiao.dz_invoice.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +import java.util.Map; + +/** + * @ClassName WorkflowMapper + * @Author 肖博亢 + * @Date 2023/2/3 9:57 + * @Description

流程数据操作

+ **/ +@SqlMapper +public interface WorkflowMapper { + + /** + *

通过requestId查询流程数据

+ * @param requestId requestId + * @param tableName 流程表名 + * @return 流程数据 + */ + @Select("select * from $t{tableName} where requestid = #{requestId}") + Map queryWorkflowByRequestId(@ParamMapper("requestId") String requestId,@ParamMapper("tableName") String tableName); +} diff --git a/src/main/java/weaver/bokang/xiao/dz_invoice/schedule/InvoiceQuerySchedule.java b/src/main/java/weaver/bokang/xiao/dz_invoice/schedule/InvoiceQuerySchedule.java new file mode 100644 index 0000000..49dcf19 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/dz_invoice/schedule/InvoiceQuerySchedule.java @@ -0,0 +1,18 @@ +package weaver.bokang.xiao.dz_invoice.schedule; + +import weaver.interfaces.schedule.BaseCronJob; + +/** + * @ClassName InvoiceQuerySchecule + * @Author 肖博亢 + * @Date 2023/2/3 15:31 + * @Description

通过定时任务查询发票勾选状态

+ **/ +public class InvoiceQuerySchedule extends BaseCronJob { + + @Override + public void execute() { + + } + +}