合并修改ssl绕过的方式
main
youHong.ai 2023-02-16 19:00:42 +08:00
commit e9fedf8b8f
6 changed files with 634 additions and 0 deletions

View File

@ -0,0 +1,157 @@
package com.api.bokang.xiao.porsche_review.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import aiyh.utils.zwl.common.ToolUtil;
import com.api.bokang.xiao.porsche_review.service.ReviewService;
import com.api.bokang.xiao.porsche_review.service.impl.ReviewServiceImpl;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.log4j.Logger;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Map;
/**
* @ClassName YearReviewController
* @Author
* @Date 2023/2/14 17:00
* @Description <h1></h1>
**/
@Path("/xbk/porsche_review")
public class YearReviewController {
private final Logger log = Util.getLogger();
ReviewService reviewService = new ReviewServiceImpl();
/** 需要排除的流程id */
private final String workflowIds = new ToolUtil().getSystemParamValue("workflowIds");
/** 建模表表名及字段 */
private final String modelTables = new ToolUtil().getSystemParamValue("modelTables");
/**
* <h2></h2>
* @param request
* @param response
* @param param
* @return
*/
@Path("/getCreateOrOperateCount")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String getCreateOrOperateCount(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
try{
log.info("into getCreateOrOperateCount success params ==> "+param);
User loginUser = HrmUserVarify.getUser(request, response);
String type = Util.null2String(param.get("type"));
param.put("workflowIds",workflowIds);
Map<String,Object> data = "create".equals(type) ? reviewService.getCreateCount(param,loginUser) : reviewService.getDealCount(param,loginUser);
return ApiResult.success(data);
}catch (Exception e){
log.error("获取创建或处理流程的总数异常 ==> "+Util.getErrString(e));
return ApiResult.error(e.getMessage());
}
}
/**
* <h2></h2>
* @param request
* @param response
* @param param
* @return
*/
@Path("/getTotalCount")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String getTotalCount(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
try{
log.info("into getTotalCount success params ==> "+param);
param.put("workflowIds",workflowIds);
int totalCount = reviewService.getTotalCount(param);
return ApiResult.success(totalCount);
}catch (Exception e){
log.error("获取流程总数异常 ==> "+Util.getErrString(e));
return ApiResult.error(e.getMessage());
}
}
/**
* <h2></h2>
* @param request
* @param response
* @param param
* @return
*/
@Path("/getElectronicSealCount")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String getElectronicSealCount(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
try{
param.put("modelTables",modelTables);
int count = reviewService.getElectronicSealCount(param);
return ApiResult.success(count);
}catch (Exception e){
log.error("获取电子章总数异常 ==> "+Util.getErrString(e));
return ApiResult.error(e.getMessage());
}
}
/**
* <h2></h2>
* @param request
* @param response
* @param param
* @return
*/
@Path("/getWorkflowTop5")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String getWorkflowTop5(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
try{
log.info("into getWorkflowTop5 success params ==> "+param);
User loginUser = HrmUserVarify.getUser(request, response);
param.put("workflowIds",workflowIds);
String type = Util.null2String(param.get("type"));
List<Map<String, Object>> data = "create".equals(type) ? reviewService.getCreateTop5(param, loginUser) : reviewService.getOperateTop5(param, loginUser);
return ApiResult.success(data);
}catch (Exception e){
log.error("获取创建或处理流程总数异常 ==> "+Util.getErrString(e));
return ApiResult.error(e.getMessage());
}
}
/**
* <h2></h2>
* @param request
* @param response
* @param param
* @return
*/
@Path("/getTopDate")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String getTopDate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
try{
log.info("into getTopDate success params ==> "+param);
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);
}catch (Exception e){
log.error("获取创建或处理流程总数异常 ==> "+Util.getErrString(e));
return ApiResult.error(e.getMessage());
}
}
}

View File

@ -0,0 +1,182 @@
package com.api.bokang.xiao.porsche_review.mapper;
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;
/**
* @ClassName ReviewMapper
* @Author
* @Date 2023/2/14 17:02
* @Description <h1></h1>
**/
@SqlMapper
public interface ReviewMapper {
/**
* <h2></h2>
* @param uid id
* @param param
* @return
*/
@Select("select count(*) from workflow_requestbase where creater = #{uid} " +
"and (createdate between #{param.startDate} and #{param.endDate}) and workflowid not in (${param.workflowIds})")
int queryCreateCount(@ParamMapper("param") Map<String,Object> param,@ParamMapper("uid") int uid);
/**
* <h2></h2>
* @param param
* @return
*/
@Select("select count(*) from workflow_requestbase " +
"where (createdate between #{startDate} and #{endDate}) and workflowid not in (${workflowIds})")
int queryTotalCount(Map<String,Object> param);
/**
* <h2></h2>
* @param param
* @return
*/
@Select("select count(*) from hrmresource")
int queryResourceCount(Map<String,Object> param);
/**
* <h2></h2>
* @param uid id
* @param param
* @return
*/
@Select("select @row := @row + 1 as rowindex " +
"from ( " +
" select " +
" creater,count(*) wcount " +
" from workflow_requestbase wrb " +
" where createdate between #{param.startDate} and #{param.endDate} " +
" and workflowid not in (${param.workflowIds})" +
" group by creater " +
" order by wcount desc " +
") w,(SELECT @row := 0) t " +
"where creater = #{uid}")
int queryRankingMsg(@ParamMapper("param") Map<String,Object> param,@ParamMapper("uid") int uid);
/**
* <h2></h2>
* @param param
* @param uid id
* @return
*/
@Select("select @row := @row + 1 as rowindex " +
"from " +
"( " +
" select " +
" wfo.operatorid,count(*) wcount " +
" from workflow_requestoperatelog wfo " +
" inner join workflow_requestbase wrb on wfo.requestid = wrb.requestid " +
" inner join workflow_base wb on wrb.workflowid = wb.id " +
" inner join workflow_nodebase wnb on wfo.nodeid = wnb.id " +
" where (wfo.operatorid <> wrb.creater || (wfo.operatorid = wrb.creater && wnb.isstart <> 1)) " +
" and (wfo.operatedate between #{param.startDate} and #{param.endDate}) and workflowid not in (${param.workflowIds})" +
" group by operatorid " +
" order by wcount desc " +
")w,(SELECT @row := 0) t where w.operatorid = #{uid}")
int queryOperateRankingMsg(@ParamMapper("param") Map<String,Object> param,@ParamMapper("uid") int uid);
/**
* <h2></h2>
* @param uid id
* @param param
* @return
*/
@Select("select " +
"count(*) " +
"from workflow_requestoperatelog wfo " +
"inner join workflow_requestbase wrb on wfo.requestid = wrb.requestid " +
"inner join workflow_nodebase wnb on wfo.nodeid = wnb.id " +
"where (wfo.operatorid <> wrb.creater || (wfo.operatorid = wrb.creater && wnb.isstart <> 1)) " +
" and (wfo.operatedate between #{param.startDate} and #{param.endDate}) and wfo.operatorid = #{uid} and workflowid not in (${param.workflowIds})")
int queryDealCount(@ParamMapper("param") Map<String,Object> param,@ParamMapper("uid") int uid);
/**
* <h2>top5</h2>
* @param uid id
* @param param
* @return
*/
@Select("select distinct workflowid workflowId,workflowname workflowName,count(*) wcount " +
"from workflow_requestbase wr " +
"inner join workflow_base wb on wr.workflowid = wb.id " +
"where wr.creater = #{uid} and (createdate between #{param.startDate} and #{param.endDate}) " +
" and workflowid not in (${param.workflowIds})" +
"group by workflowid " +
"ORDER BY wcount " +
"limit 5")
List<Map<String, Object>> queryCreateTop5(@ParamMapper("param") Map<String,Object> param,@ParamMapper("uid") int uid);
/**
* <h2>top5</h2>
* @param param
* @param uid id
* @return
*/
@Select("select " +
" wrb.workflowid,wb.workflowname,count(*) wcount " +
"from workflow_requestoperatelog wfo " +
"inner join workflow_requestbase wrb on wfo.requestid = wrb.requestid " +
"inner join workflow_base wb on wrb.workflowid = wb.id " +
"inner join workflow_nodebase wnb on wfo.nodeid = wnb.id " +
"where (wfo.operatorid <> wrb.creater || (wfo.operatorid = wrb.creater && wnb.isstart <> 1)) " +
" and (wfo.operatedate between #{param.startDate} and #{param.endDate}) " +
" and operatorid = #{uid} and workflowid not in (${param.workflowIds}) " +
"group by workflowid " +
"order by wcount desc " +
"limit 5")
List<Map<String, Object>> queryOperateTop5(@ParamMapper("param") Map<String, Object> param,@ParamMapper("uid") int uid);
/**
* <h2></h2>
* @param param
* @param uid id
* @return
*/
@Select("select createdate 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<String, Object> param,@ParamMapper("uid") int uid);
/**
* <h2></h2>
* @param param
* @param uid id
* @return
*/
@Select("select operatedate " +
"from workflow_requestoperatelog wfo " +
"inner join workflow_requestbase wrb on wfo.requestid = wrb.requestid " +
"inner join workflow_base wb on wrb.workflowid = wb.id " +
"inner join workflow_nodebase wnb on wfo.nodeid = wnb.id " +
"where (wfo.operatorid <> wrb.creater || (wfo.operatorid = wrb.creater && wnb.isstart <> 1)) " +
" and (wfo.operatedate between #{param.startDate} and #{param.endDate}) " +
" and operatorid = #{uid} and workflowid not in (${param.workflowIds}) " +
"group by operatedate " +
"order by count(*) desc " +
"limit 1")
String queryOperateTopDate(@ParamMapper("param") Map<String, Object> param,@ParamMapper("uid") int uid);
/**
* <h2></h2>
* @param tableName
* @param fieldName
* @param fieldValue
* @return
*/
@Select("select count(*) from $t{tableName} where $t{fieldName} = #{fieldValue}")
int queryCountByParam(@ParamMapper("tableName") String tableName,
@ParamMapper("fieldName") String fieldName,
@ParamMapper("fieldValue") String fieldValue);
}

View File

@ -0,0 +1,77 @@
package com.api.bokang.xiao.porsche_review.service;
import weaver.hrm.User;
import java.util.List;
import java.util.Map;
/**
* @ClassName ReviewService
* @Author
* @Date 2023/2/14 17:01
* @Description <h1></h1>
**/
public interface ReviewService {
/**
* <h2></h2>
* @param param
* @param user
* @return
*/
Map<String, Object> getCreateCount(Map<String,Object> param, User user);
/**
* <h2></h2>
* @param param
* @param user
* @return
*/
Map<String, Object> getDealCount(Map<String,Object> param, User user);
/**
* <h2>top5</h2>
* @param param
* @param user
* @return
*/
List<Map<String,Object>> getCreateTop5(Map<String,Object> param, User user);
/**
* <h2>top5</h2>
* @param param
* @param user
* @return
*/
List<Map<String,Object>> getOperateTop5(Map<String,Object> param, User user);
/**
* <h2></h2>
* @param param
* @param loginUser
* @return
*/
String getCreateTopDate(Map<String, Object> param, User loginUser);
/**
* <h2></h2>
* @param param
* @param loginUser
* @return
*/
String getOperateTopDate(Map<String, Object> param, User loginUser);
/**
* <h2></h2>
* @param param
* @return
*/
int getTotalCount(Map<String, Object> param);
/**
* <h2></h2>
* @param param
* @return
*/
int getElectronicSealCount(Map<String, Object> param);
}

View File

@ -0,0 +1,113 @@
package com.api.bokang.xiao.porsche_review.service.impl;
import aiyh.utils.Util;
import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper;
import com.api.bokang.xiao.porsche_review.service.ReviewService;
import weaver.hrm.User;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @ClassName ReviewServiceImpl
* @Author
* @Date 2023/2/14 17:02
* @Description <h1></h1>
**/
public class ReviewServiceImpl implements ReviewService {
private final ReviewMapper reviewMapper = Util.getMapper(ReviewMapper.class);
private Integer resourceCount = 0;
@Override
public Map<String, Object> getCreateCount(Map<String,Object> param, User user) {
Map<String, Object> res = new HashMap<>();
int createCount = reviewMapper.queryCreateCount(param,user.getUID());
int ranking = reviewMapper.queryRankingMsg(param,user.getUID());
resourceCount = resourceCount > 0 ? resourceCount : reviewMapper.queryResourceCount(new HashMap<>());
double exceed = 1 - (1.00*ranking/resourceCount);
res.put("totalCount",createCount);
res.put("exceed",exceed);
return res;
}
@Override
public Map<String, Object> getDealCount(Map<String,Object> param, User user) {
Map<String, Object> res = new HashMap<>();
int operateCount = reviewMapper.queryDealCount(param, user.getUID());
resourceCount = resourceCount > 0 ? resourceCount : reviewMapper.queryResourceCount(new HashMap<>());
int rankingMsg = reviewMapper.queryOperateRankingMsg(param, user.getUID());
double exceed = 1 - (1.00*rankingMsg/resourceCount);
res.put("totalCount",operateCount);
res.put("exceed",exceed);
return res;
}
@Override
public List<Map<String, Object>> getCreateTop5(Map<String, Object> param, User user) {
return reviewMapper.queryCreateTop5(param,user.getUID());
}
@Override
public List<Map<String, Object>> getOperateTop5(Map<String, Object> param, User user) {
return reviewMapper.queryOperateTop5(param,user.getUID());
}
@Override
public String getCreateTopDate(Map<String, Object> param, User loginUser) {
return reviewMapper.queryCreateTopDate(param,loginUser.getUID());
}
@Override
public String getOperateTopDate(Map<String, Object> param, User loginUser) {
return reviewMapper.queryOperateTopDate(param,loginUser.getUID());
}
@Override
public int getTotalCount(Map<String, Object> param) {
return reviewMapper.queryTotalCount(param);
}
@Override
public int getElectronicSealCount(Map<String, Object> param) {
String modelTables = Util.null2String(param.get("modelTables"));
int totalCount = 0;
Map<String, Map<String, Object>> modelTableMap = getModelTables(modelTables);
for (Map.Entry<String, Map<String, Object>> entry : modelTableMap.entrySet()) {
String tableName = entry.getKey();
Map<String, Object> fieldMap = entry.getValue();
String fieldName = Util.null2String(fieldMap.get("fieldName"));
String fieldValue = Util.null2String(fieldMap.get("fieldValue"));
int count = reviewMapper.queryCountByParam(tableName, fieldName, fieldValue);
totalCount += count;
}
return totalCount;
}
/**
* <h2></h2>
* @param sourceStr
* @return
*/
public Map<String,Map<String,Object>> getModelTables(String sourceStr){
Map<String,Map<String,Object>> modelTableMap = new HashMap<>();
String regx = "\\{(?<tableName>\\S+):(?<fieldName>\\S+):(?<fieldValue>\\S+)}";
Pattern compile = Pattern.compile(regx);
Matcher matcher = compile.matcher(sourceStr);
while (matcher.find()){
String tableName = matcher.group("tableName");
String fieldName = matcher.group("fieldName");
String fieldValue = matcher.group("fieldValue");
Map<String,Object> fieldMap = new HashMap<>();
fieldMap.put("fieldName",fieldName);
fieldMap.put("fieldValue",fieldValue);
modelTableMap.put(tableName,fieldMap);
}
return modelTableMap;
}
}

View File

@ -0,0 +1,77 @@
package bokang.xiao;
import aiyh.utils.Util;
import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils;
import basetest.BaseTest;
import bokang.xiao.mapper.TestMapper;
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 java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @ClassName NormalTest
* @Author
* @Date 2023/2/13 13:48
* @Description <h1></h1>
**/
public class NormalTest extends BaseTest {
@Test
public void testWord(){
}
@Test
public void testQuery(){
TestMapper mapper = Util.getMapper(TestMapper.class);
List<Map<String, Object>> query = mapper.query();
System.out.println(query);
}
@Test
public void testWorkflowQuery(){
ReviewMapper reviewMapper = Util.getMapper(ReviewMapper.class);
Map<String,Object> param = new HashMap<>();
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);
}
@Test
public void testRequest() throws IOException {
HttpUtils httpUtils = new HttpUtils();
Map<String,Object> param = new HashMap<>();
param.put("grant_type","client_credentials");
param.put("client_id","95c7211b-31dd-4fe9-87d2-35ad5ab6c76c");
param.put("client_secret","Nri.W_2-bGP6H1FmorFi~3T7_-e91FSrYR");
param.put("scope","api://95c7211b-31dd-4fe9-87d2-35ad5ab6c76c/.default");
ResponeVo responeVo = httpUtils.apiPost("https://login.partner.microsoftonline.cn/875412dd-d33b-4ee0-a8a0-7133237e3c98/oauth2/v2.0/token", param);
Map entity = responeVo.getResponseEntity(Map.class);
System.out.println(entity);
Object access_token = entity.get("access_token");
Map<String,Object> requestParam = new HashMap<>();
requestParam.put("queryType","AC");
requestParam.put("startDateTime","2022-11-01");
//requestParam.put("endDateTime","2022-11-21");
requestParam.put("page",1);
requestParam.put("limit",200);
Map<String,String> heareds = new HashMap<>();
heareds.put("Authorization",Util.null2String(access_token));
ResponeVo responeVo1 = httpUtils.apiPost("https://chinaapi-uat.elcompanies.cn/api/in/out/masterdata/product/v1/list", requestParam, heareds);
Map responseEntity = responeVo1.getResponseEntity(Map.class);
System.out.println(responseEntity);
}
}

View File

@ -0,0 +1,28 @@
package bokang.xiao.mapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import java.util.List;
import java.util.Map;
/**
* @ClassName TestMapper
* @Author
* @Date 2023/2/14 16:24
* @Description <h1></h1>
**/
@SqlMapper
public interface TestMapper {
@Select("select w.*,@row := @row + 1 as rowindex\n" +
"from (\n" +
"select \n" +
" \tcreater,count(*) wcount\n" +
"from workflow_requestbase wrb\n" +
"group by creater\n" +
"order by wcount desc\n" +
") w,(SELECT @row := 0) t")
List<Map<String,Object>> query();
}