电装发票勾选接口开发
parent
9ed409364b
commit
bf999d1367
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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("请求发送异常");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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() {
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue