合并远程到sap开发
main
youHong.ai 2023-02-06 18:57:15 +08:00
commit 1e754843ff
8 changed files with 338 additions and 0 deletions

View File

@ -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.*;
/**

View File

@ -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 <h1></h1>
**/
@Path("/xbk/dz_invoice")
public class InvoiceSelectController {
private final Logger log = Util.getLogger();
private final DzInvoiceService dzInvoiceService = new DzInvoiceServiceImpl();
/**
* <h2></h2>
* @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<String,Object> param) {
try{
log.info("into checkInvoice success params ==> "+param);
List<Map<String, Object>> maps = dzInvoiceService.checkInvoice(param);
return ApiResult.success(maps);
}catch (Exception e){
log.error("发票勾选调用异常 ==> \n"+Util.getErrString(e));
return ApiResult.error();
}
}
/**
* <h2></h2>
* @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<String,Object> param) {
try{
log.info("into unCheckInvoice success params ==> "+param);
List<Map<String, Object>> maps = dzInvoiceService.unCheckInvoice(param);
return ApiResult.success(maps);
}catch (Exception e){
log.error("发票勾选调用异常 ==> \n"+Util.getErrString(e));
return ApiResult.error();
}
}
}

View File

@ -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 <h1></h1>
**/
@SqlMapper
public interface DzInvoiceMapper {
/**
* <h2>id</h2>
* @param ids id
* @return
*/
@Select("select * from APInvoice where id in (${ids})")
List<Map<String,Object>> queryInvoiceList(@ParamMapper("ids") String ids);
/**
* <h2></h2>
* @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);
}

View File

@ -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 <h1></h1>
**/
public interface DzInvoiceService {
/**
* <h2> </h2>
* @param param
* @return
* @throws Exception
*/
List<Map<String,Object>> checkInvoice(Map<String,Object> param) throws Exception;
/**
* <h2> </h2>
* @param param
* @return
* @throws Exception
*/
List<Map<String, Object>> unCheckInvoice(Map<String, Object> param) throws Exception;
}

View File

@ -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 <h1></h1>
**/
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<Map<String,Object>> checkInvoice(Map<String,Object> param) throws IOException {
return handleInvoice(param,1);
}
@Override
public List<Map<String, Object>> unCheckInvoice(Map<String, Object> param) throws Exception {
return handleInvoice(param,2);
}
/**
* <h2></h2>
* @param param
* @param handleType 1: ; 2:
* @return
* @throws IOException IO
*/
private List<Map<String, Object>> handleInvoice(Map<String,Object> param,int handleType) throws IOException {
List<Map<String,Object>> 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<Map<String, Object>> invoiceList = dzInvoiceMapper.queryInvoiceList(ids);
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(reqUniqueCode);
for (Map<String, Object> invoice : invoiceList) {
Map<String,Object> result = new HashMap<>();
Map<String, Object> 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;
}
}

View File

@ -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 <h1>action</h1>
**/
@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<String, Object> workflowMessage = workflowMapper.queryWorkflowByRequestId(requestId, billTable);
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(requestUnique);
Map<String, Object> 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("请求发送异常");
}
}
}

View File

@ -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 <h1></h1>
**/
@SqlMapper
public interface WorkflowMapper {
/**
* <h2>requestId</h2>
* @param requestId requestId
* @param tableName
* @return
*/
@Select("select * from $t{tableName} where requestid = #{requestId}")
Map<String,Object> queryWorkflowByRequestId(@ParamMapper("requestId") String requestId,@ParamMapper("tableName") String tableName);
}

View File

@ -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 <h1></h1>
**/
public class InvoiceQuerySchedule extends BaseCronJob {
@Override
public void execute() {
}
}