From f407d833546214ef750706e46d9b177a48fc9362 Mon Sep 17 00:00:00 2001 From: ic_excellent Date: Mon, 20 Feb 2023 16:15:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E8=A3=85=E7=9B=B8=E5=85=B3=E5=BC=80?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bokang.xiao/dz_invoice/invoiceReq.js | 65 +++++++++++++++++++ .../dz_invoice/mapper/DzInvoiceMapper.java | 21 ++++++ .../controller/YearReviewController.java | 8 +-- .../porsche_review/mapper/ReviewMapper.java | 10 +-- .../porsche_review/service/ReviewService.java | 4 +- .../service/impl/ReviewServiceImpl.java | 4 +- .../action/InvoiceDeductionAction.java | 22 +++++++ .../dz_invoice/mapper/WorkflowMapper.java | 11 ++++ .../schedule/InvoiceQuerySchedule.java | 59 ++++++++++++++++- .../xiao/commons/utils/RequestUtil.java | 1 + src/test/java/bokang/xiao/NormalTest.java | 16 +++-- 11 files changed, 201 insertions(+), 20 deletions(-) create mode 100644 javascript/bokang.xiao/dz_invoice/invoiceReq.js diff --git a/javascript/bokang.xiao/dz_invoice/invoiceReq.js b/javascript/bokang.xiao/dz_invoice/invoiceReq.js new file mode 100644 index 0000000..f09414f --- /dev/null +++ b/javascript/bokang.xiao/dz_invoice/invoiceReq.js @@ -0,0 +1,65 @@ +/** + * 发票勾选 + */ +function checkInvoice(){ + let ids = ModeList.getCheckedID(); + if(!ids || ids === ""){ + ModeList.showConfirm("请勾选发票!"); + return; + } + let requestParam = { + ids:ids, + checkInvoiceUniqueCode:"" + }; + console.log("请求参数 ==>",requestParam) + ModeList.showLoading(true,'large','发票勾选中...'); + $.ajax({ + url:"/api/xbk/dz_invoice/checkInvoice", + type:"POST", + headers:{'Content-Type':'application/json'}, + data:JSON.stringify(requestParam), + success:function(res){ + console.log("result==>",res); + ModeList.showLoading(false); + ModeList.showMessage("操作成功", 3, 2); //提示信息,2s后消失 + ModeList.reloadTable(); + }, + error:function(err){ + console.log(err); + ModeList.showLoading(false); + } + }) +} + +/** + * 取消勾选 + */ +function unCheckInvoice(){ + let ids = ModeList.getCheckedID(); + if(!ids || ids === ""){ + ModeList.showConfirm("请勾选发票!"); + return; + } + let requestParam = { + ids:ids, + checkInvoiceUniqueCode:"" + }; + console.log("请求参数 ==>",requestParam) + ModeList.showLoading(true,'large','发票取消勾选中...'); + $.ajax({ + url:"/api/xbk/dz_invoice/unCheckInvoice", + type:"POST", + headers:{'Content-Type':'application/json'}, + data:JSON.stringify(requestParam), + success:function(res){ + console.log("result==>",res); + ModeList.showLoading(false); + ModeList.showMessage("操作成功", 3, 2); //提示信息,2s后消失 + ModeList.reloadTable(); + }, + error:function(err){ + console.log(err); + ModeList.showLoading(false); + } + }) +} 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 index 3a94c7d..e85d4b4 100644 --- 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 @@ -37,4 +37,25 @@ public interface DzInvoiceMapper { boolean updateInvoiceCheckStatus(@ParamMapper("check_status") int checkStatus, @ParamMapper("fieldId") String fieldId, @ParamMapper("fieldValue") Object fieldValue); + + /** + *

更新发票勾选状态

+ * @param checkStatus 勾选状态值 + * @param fieldId 字段名 + * @param fieldValue 字段值 + * @return 操作结果 + */ + @Update("update APInvoice set check_status = #{checkStatus} where $t{fieldId} in ${fieldValue}") + boolean batchUpdateInvoiceCheckStatus(@ParamMapper("check_status") int checkStatus, + @ParamMapper("fieldId") String fieldId, + @ParamMapper("fieldValue") Object fieldValue); + + + /** + *

查询已经勾选过的发票信息

+ * @return 发票信息集合 + */ + @Select("select * from APInvoice where check_status = 2 or check_status = 3") + List> queryOnChooseInvoices(); + } diff --git a/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java b/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java index 7c1a9a8..d8d61f6 100644 --- a/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java +++ b/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java @@ -49,7 +49,7 @@ public class YearReviewController { @Path("/getCreateOrOperateCount") @POST @Produces(MediaType.APPLICATION_JSON) - public String getCreateOrOperateCount(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + public String getCreateOrOperateCount(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { try{ log.info("into getCreateOrOperateCount success params ==> "+param); User loginUser = HrmUserVarify.getUser(request, response); @@ -107,7 +107,7 @@ public class YearReviewController { } /** - *

获取创建或处理流程的总数

+ *

获取创建或处理流程的top5

* @param request 请求体 * @param response 响应体 * @param param 请求参数 @@ -146,8 +146,8 @@ public class YearReviewController { User loginUser = HrmUserVarify.getUser(request, response); param.put("workflowIds",workflowIds); String type = Util.null2String(param.get("type")); - String date = "create".equals(type) ? reviewService.getCreateTopDate(param, loginUser) : reviewService.getOperateTopDate(param, loginUser); - return ApiResult.success(date); + Map dateMap = "create".equals(type) ? reviewService.getCreateTopDate(param, loginUser) : reviewService.getOperateTopDate(param, loginUser); + return ApiResult.success(dateMap); }catch (Exception e){ log.error("获取创建或处理流程总数异常 ==> "+Util.getErrString(e)); return ApiResult.error(e.getMessage()); diff --git a/src/main/java/com/api/bokang/xiao/porsche_review/mapper/ReviewMapper.java b/src/main/java/com/api/bokang/xiao/porsche_review/mapper/ReviewMapper.java index 6f66253..98cc66e 100644 --- a/src/main/java/com/api/bokang/xiao/porsche_review/mapper/ReviewMapper.java +++ b/src/main/java/com/api/bokang/xiao/porsche_review/mapper/ReviewMapper.java @@ -111,7 +111,7 @@ public interface ReviewMapper { "where wr.creater = #{uid} and (createdate between #{param.startDate} and #{param.endDate}) " + " and workflowid not in (${param.workflowIds})" + "group by workflowid " + - "ORDER BY wcount " + + "ORDER BY wcount desc" + "limit 5") List> queryCreateTop5(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); @@ -141,13 +141,13 @@ public interface ReviewMapper { * @param uid 用户id * @return 日期 */ - @Select("select createdate from workflow_requestbase " + + @Select("select createdate,count(*) tcount from workflow_requestbase " + " where creater = #{uid} and (createdate between #{param.startDate} and #{param.endDate}) " + " and workflowid not in (${param.workflowIds}) " + " group by createdate " + " order by count(*) desc " + " limit 1") - String queryCreateTopDate(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); + Map queryCreateTopDate(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); /** *

查询操作流程最多的一天

@@ -155,7 +155,7 @@ public interface ReviewMapper { * @param uid 用户id * @return 日期 */ - @Select("select operatedate " + + @Select("select operatedate,count(*) tcount " + "from workflow_requestoperatelog wfo " + "inner join workflow_requestbase wrb on wfo.requestid = wrb.requestid " + "inner join workflow_base wb on wrb.workflowid = wb.id " + @@ -166,7 +166,7 @@ public interface ReviewMapper { "group by operatedate " + "order by count(*) desc " + "limit 1") - String queryOperateTopDate(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); + Map queryOperateTopDate(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); /** *

通过条件查询数量

diff --git a/src/main/java/com/api/bokang/xiao/porsche_review/service/ReviewService.java b/src/main/java/com/api/bokang/xiao/porsche_review/service/ReviewService.java index af785fa..10131ae 100644 --- a/src/main/java/com/api/bokang/xiao/porsche_review/service/ReviewService.java +++ b/src/main/java/com/api/bokang/xiao/porsche_review/service/ReviewService.java @@ -51,7 +51,7 @@ public interface ReviewService { * @param loginUser 用户信息 * @return 日期 */ - String getCreateTopDate(Map param, User loginUser); + Map getCreateTopDate(Map param, User loginUser); /** *

获取操作流程最多的一天

@@ -59,7 +59,7 @@ public interface ReviewService { * @param loginUser 用户信息 * @return 日期 */ - String getOperateTopDate(Map param, User loginUser); + Map getOperateTopDate(Map param, User loginUser); /** *

获取流程的总数

diff --git a/src/main/java/com/api/bokang/xiao/porsche_review/service/impl/ReviewServiceImpl.java b/src/main/java/com/api/bokang/xiao/porsche_review/service/impl/ReviewServiceImpl.java index 2237aac..76b18cf 100644 --- a/src/main/java/com/api/bokang/xiao/porsche_review/service/impl/ReviewServiceImpl.java +++ b/src/main/java/com/api/bokang/xiao/porsche_review/service/impl/ReviewServiceImpl.java @@ -58,12 +58,12 @@ public class ReviewServiceImpl implements ReviewService { } @Override - public String getCreateTopDate(Map param, User loginUser) { + public Map getCreateTopDate(Map param, User loginUser) { return reviewMapper.queryCreateTopDate(param,loginUser.getUID()); } @Override - public String getOperateTopDate(Map param, User loginUser) { + public Map getOperateTopDate(Map param, User loginUser) { return reviewMapper.queryOperateTopDate(param,loginUser.getUID()); } 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 index f9ddb2a..576b6be 100644 --- a/src/main/java/weaver/bokang/xiao/dz_invoice/action/InvoiceDeductionAction.java +++ b/src/main/java/weaver/bokang/xiao/dz_invoice/action/InvoiceDeductionAction.java @@ -9,6 +9,7 @@ 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 lombok.Setter; import weaver.bokang.xiao.dz_invoice.mapper.WorkflowMapper; import weaver.hrm.User; import weaver.soa.workflow.request.RequestInfo; @@ -17,7 +18,9 @@ import weaver.xiao.commons.config.service.DealWithMapping; import java.io.IOException; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * @ClassName InvoiceDeductionAction @@ -25,6 +28,8 @@ import java.util.Map; * @Date 2023/2/3 9:54 * @Description

发票抵扣action

**/ + +@Setter @ActionDesc(value = "抵扣勾选发票接口调用",author = "bokang.xiao") public class InvoiceDeductionAction extends SafeCusBaseAction { @@ -32,6 +37,14 @@ public class InvoiceDeductionAction extends SafeCusBaseAction { @PrintParamMark private String requestUnique; + @RequiredMark("发票信息所属明细") + @PrintParamMark + private String invoiceDetailId; + + @RequiredMark("发票字段名") + @PrintParamMark + private String invoiceField; + private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class); private final DzInvoiceMapper dzInvoiceMapper = Util.getMapper(DzInvoiceMapper.class); @@ -45,11 +58,13 @@ public class InvoiceDeductionAction extends SafeCusBaseAction { @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); + dealWithMapping.setMainTable(billTable); try { ResponeVo responeVo = httpUtils.apiPost(requestMappingConfig.getRequestUrl(), requestParam); if(responeVo.getCode() == 200){ @@ -58,6 +73,13 @@ public class InvoiceDeductionAction extends SafeCusBaseAction { String describe = Util.null2String(result.get("describe")); if(!"E0000".equals(code)){ throw new CustomerException("请求调用失败 ==>"+describe); + }else { + String detailTable = billTable + "_dt"+invoiceDetailId; + List> invoiceList = workflowMapper.queryDetailByMainId(Util.null2String(workflowMessage.get("id")), detailTable); + String invoices = invoiceList.stream() + .map(item -> Util.null2String(item.get(invoiceField))) + .collect(Collectors.joining(",")); + dzInvoiceMapper.batchUpdateInvoiceCheckStatus(REQ_DEDUCTION,"id",invoices); } }else { throw new CustomerException("请求状态码不为200"); 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 index c20fb02..9459711 100644 --- a/src/main/java/weaver/bokang/xiao/dz_invoice/mapper/WorkflowMapper.java +++ b/src/main/java/weaver/bokang/xiao/dz_invoice/mapper/WorkflowMapper.java @@ -4,6 +4,7 @@ import aiyh.utils.annotation.recordset.ParamMapper; import aiyh.utils.annotation.recordset.Select; import aiyh.utils.annotation.recordset.SqlMapper; +import java.util.List; import java.util.Map; /** @@ -23,4 +24,14 @@ public interface WorkflowMapper { */ @Select("select * from $t{tableName} where requestid = #{requestId}") Map queryWorkflowByRequestId(@ParamMapper("requestId") String requestId,@ParamMapper("tableName") String tableName); + + /** + *

通过mainId查询流程明细表数据

+ * @param mainId mainId + * @param tableName 流程表名 + * @return 流程数据 + */ + @Select("select * from $t{tableName} where mainid = #{mainId}") + List> queryDetailByMainId(@ParamMapper("mainId") String mainId, @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 index 49dcf19..a96888e 100644 --- a/src/main/java/weaver/bokang/xiao/dz_invoice/schedule/InvoiceQuerySchedule.java +++ b/src/main/java/weaver/bokang/xiao/dz_invoice/schedule/InvoiceQuerySchedule.java @@ -1,18 +1,75 @@ package weaver.bokang.xiao.dz_invoice.schedule; +import aiyh.utils.Util; +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 org.apache.log4j.Logger; import weaver.interfaces.schedule.BaseCronJob; +import weaver.xiao.commons.config.entity.RequestMappingConfig; +import weaver.xiao.commons.config.service.DealWithMapping; + +import java.util.List; +import java.util.Map; /** - * @ClassName InvoiceQuerySchecule + * @ClassName InvoiceQuerySchedule * @Author 肖博亢 * @Date 2023/2/3 15:31 * @Description

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

**/ + +@ActionDesc(value = "定时查询发票勾选状态", author = "bokang.xiao") public class InvoiceQuerySchedule extends BaseCronJob { + @RequiredMark("发票查询接口唯一标识") + @PrintParamMark + private String requestUnique; + + private final DealWithMapping dealWithMapping = new DealWithMapping(); + private final DzInvoiceMapper dzInvoiceMapper = Util.getMapper(DzInvoiceMapper.class); + + private final HttpUtils httpUtils = new HttpUtils(); + + private final Logger logger = Util.getLogger(); + @Override public void execute() { + try{ + logger.info(String.format("================== {%s} 定时任务开始执行 ================",this.getClass().getName())); + logger.info(String.format("param: requestUnique ==>[%s]",requestUnique)); + Util.verifyRequiredField(this); + List> invoiceList = dzInvoiceMapper.queryOnChooseInvoices(); + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(requestUnique); + if(!invoiceList.isEmpty()){ + for (Map invoice : invoiceList) { + Map requestParam = dealWithMapping.getRequestParam(invoice,requestMappingConfig); + ResponeVo responeVo = httpUtils.apiPost(requestMappingConfig.getRequestUrl(), requestParam); + if(responeVo.getCode() == 200){ + Map result = responeVo.getResponseEntity(Map.class); + String code = Util.null2String(result.get("code")); + if("E0000".equals(code)){ + List> invoices = (List>) result.get("data"); + if(!invoices.isEmpty()){ + for (Map map : invoices) { + String checkStatus = Util.null2String(map.get("checkStatus")); + dzInvoiceMapper.updateInvoiceCheckStatus(Util.getIntValue(checkStatus),"id",invoice.get("id")); + } + } + } + }else { + throw new CustomerException("请求状态码不为 200"); + } + } + } + }catch (Exception e){ + logger.info("同步发生异常 ==>"+Util.getErrString(e)); + } } } diff --git a/src/main/java/weaver/xiao/commons/utils/RequestUtil.java b/src/main/java/weaver/xiao/commons/utils/RequestUtil.java index 8fc8a73..c31a037 100644 --- a/src/main/java/weaver/xiao/commons/utils/RequestUtil.java +++ b/src/main/java/weaver/xiao/commons/utils/RequestUtil.java @@ -53,6 +53,7 @@ public class RequestUtil { headers.forEach(httpPut::setHeader); httpPut.setEntity(new StringEntity(JSON.toJSONString(requestInfo.getParams()),"UTF-8")); result = apiSend(httpPut,tClass);}break; + default:break; } return result; diff --git a/src/test/java/bokang/xiao/NormalTest.java b/src/test/java/bokang/xiao/NormalTest.java index 9200826..f19aa19 100644 --- a/src/test/java/bokang/xiao/NormalTest.java +++ b/src/test/java/bokang/xiao/NormalTest.java @@ -1,5 +1,6 @@ package bokang.xiao; +import aiyh.utils.GenerateFileUtil; import aiyh.utils.Util; import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtils; @@ -9,11 +10,12 @@ import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper; import com.api.bokang.xiao.porsche_review.service.impl.ReviewServiceImpl; import org.apache.log4j.Logger; import org.junit.Test; +import weaver.bokang.xiao.dz_invoice.action.InvoiceDeductionAction; +import weaver.bokang.xiao.dz_invoice.schedule.InvoiceQuerySchedule; import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; /** * @ClassName NormalTest @@ -25,7 +27,8 @@ public class NormalTest extends BaseTest { @Test public void testWord(){ - + GenerateFileUtil.createActionDocument(InvoiceDeductionAction.class); + GenerateFileUtil.createCronJobDocument(InvoiceQuerySchedule.class); } @Test @@ -42,8 +45,9 @@ public class NormalTest extends BaseTest { param.put("startDate","2022-01-09"); param.put("endDate","2023-04-09"); param.put("workflowIds","0"); - String s1 = reviewMapper.queryCreateTopDate(param, 1); - System.out.println(s1); + //String s1 = reviewMapper.queryCreateTopDate(param, 1); + //System.out.println(s1); + } @Test