diff --git a/pom.xml b/pom.xml
index 8b68ec59..e6b63103 100644
--- a/pom.xml
+++ b/pom.xml
@@ -219,13 +219,13 @@
org.apache.httpcomponents
httpclient
- 4.3.1
+ 4.5.1
org.apache.httpcomponents
httpcore
- 4.3.1
+ 4.4.3
diff --git a/tall/src/main/java/com/ccsens/tall/bean/dto/RoleDto.java b/tall/src/main/java/com/ccsens/tall/bean/dto/RoleDto.java
index 64b7caea..57ccc427 100644
--- a/tall/src/main/java/com/ccsens/tall/bean/dto/RoleDto.java
+++ b/tall/src/main/java/com/ccsens/tall/bean/dto/RoleDto.java
@@ -105,4 +105,13 @@ public class RoleDto {
@ApiModelProperty("角色id")
private Long roleId;
}
+
+ @Data
+ @ApiModel("对谁不可见")
+ public static class RoleOfNoLook {
+ @ApiModelProperty("角色id")
+ private Long roleId;
+ @ApiModelProperty("不可见角色id(数组)")
+ private List noRoleId;
+ }
}
diff --git a/tall/src/main/java/com/ccsens/tall/bean/po/ProShow.java b/tall/src/main/java/com/ccsens/tall/bean/po/ProShow.java
index 8a8a13ba..8dacaa85 100644
--- a/tall/src/main/java/com/ccsens/tall/bean/po/ProShow.java
+++ b/tall/src/main/java/com/ccsens/tall/bean/po/ProShow.java
@@ -42,6 +42,8 @@ public class ProShow implements Serializable {
private Byte roleBelong;
+ private Byte milestoneSubtask;
+
private static final long serialVersionUID = 1L;
public Long getId() {
@@ -196,6 +198,14 @@ public class ProShow implements Serializable {
this.roleBelong = roleBelong;
}
+ public Byte getMilestoneSubtask() {
+ return milestoneSubtask;
+ }
+
+ public void setMilestoneSubtask(Byte milestoneSubtask) {
+ this.milestoneSubtask = milestoneSubtask;
+ }
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -221,6 +231,7 @@ public class ProShow implements Serializable {
sb.append(", updatedAt=").append(updatedAt);
sb.append(", recStatus=").append(recStatus);
sb.append(", roleBelong=").append(roleBelong);
+ sb.append(", milestoneSubtask=").append(milestoneSubtask);
sb.append("]");
return sb.toString();
}
diff --git a/tall/src/main/java/com/ccsens/tall/bean/po/ProShowExample.java b/tall/src/main/java/com/ccsens/tall/bean/po/ProShowExample.java
index 59f56608..7383b642 100644
--- a/tall/src/main/java/com/ccsens/tall/bean/po/ProShowExample.java
+++ b/tall/src/main/java/com/ccsens/tall/bean/po/ProShowExample.java
@@ -1274,6 +1274,66 @@ public class ProShowExample {
addCriterion("role_belong not between", value1, value2, "roleBelong");
return (Criteria) this;
}
+
+ public Criteria andMilestoneSubtaskIsNull() {
+ addCriterion("milestone_subtask is null");
+ return (Criteria) this;
+ }
+
+ public Criteria andMilestoneSubtaskIsNotNull() {
+ addCriterion("milestone_subtask is not null");
+ return (Criteria) this;
+ }
+
+ public Criteria andMilestoneSubtaskEqualTo(Byte value) {
+ addCriterion("milestone_subtask =", value, "milestoneSubtask");
+ return (Criteria) this;
+ }
+
+ public Criteria andMilestoneSubtaskNotEqualTo(Byte value) {
+ addCriterion("milestone_subtask <>", value, "milestoneSubtask");
+ return (Criteria) this;
+ }
+
+ public Criteria andMilestoneSubtaskGreaterThan(Byte value) {
+ addCriterion("milestone_subtask >", value, "milestoneSubtask");
+ return (Criteria) this;
+ }
+
+ public Criteria andMilestoneSubtaskGreaterThanOrEqualTo(Byte value) {
+ addCriterion("milestone_subtask >=", value, "milestoneSubtask");
+ return (Criteria) this;
+ }
+
+ public Criteria andMilestoneSubtaskLessThan(Byte value) {
+ addCriterion("milestone_subtask <", value, "milestoneSubtask");
+ return (Criteria) this;
+ }
+
+ public Criteria andMilestoneSubtaskLessThanOrEqualTo(Byte value) {
+ addCriterion("milestone_subtask <=", value, "milestoneSubtask");
+ return (Criteria) this;
+ }
+
+ public Criteria andMilestoneSubtaskIn(List values) {
+ addCriterion("milestone_subtask in", values, "milestoneSubtask");
+ return (Criteria) this;
+ }
+
+ public Criteria andMilestoneSubtaskNotIn(List values) {
+ addCriterion("milestone_subtask not in", values, "milestoneSubtask");
+ return (Criteria) this;
+ }
+
+ public Criteria andMilestoneSubtaskBetween(Byte value1, Byte value2) {
+ addCriterion("milestone_subtask between", value1, value2, "milestoneSubtask");
+ return (Criteria) this;
+ }
+
+ public Criteria andMilestoneSubtaskNotBetween(Byte value1, Byte value2) {
+ addCriterion("milestone_subtask not between", value1, value2, "milestoneSubtask");
+ return (Criteria) this;
+ }
}
public static class Criteria extends GeneratedCriteria {
diff --git a/tall/src/main/java/com/ccsens/tall/bean/vo/ProjectVo.java b/tall/src/main/java/com/ccsens/tall/bean/vo/ProjectVo.java
index 9882964f..59334119 100644
--- a/tall/src/main/java/com/ccsens/tall/bean/vo/ProjectVo.java
+++ b/tall/src/main/java/com/ccsens/tall/bean/vo/ProjectVo.java
@@ -187,6 +187,8 @@ public class ProjectVo {
private String relevanceProjectName;
@ApiModelProperty("成员信息")
private List members;
+ @ApiModelProperty("对谁不可见")
+ private List roleOfNoLook = new ArrayList<>();
@JsonIgnore
private Long parentId; //一级角色Id
@JsonIgnore
@@ -196,6 +198,14 @@ public class ProjectVo {
}
@ApiModel
@Data
+ public static class RolesOfNoLook{
+ @ApiModelProperty("不可见角色id")
+ private Long id;
+ @ApiModelProperty("不可见角色名称")
+ private String name;
+ }
+ @ApiModel
+ @Data
public static class ProMemberVo{
@JsonIgnore
private Long mUserId;//成员的userId
diff --git a/tall/src/main/java/com/ccsens/tall/bean/vo/UserVo.java b/tall/src/main/java/com/ccsens/tall/bean/vo/UserVo.java
index d2ed5e45..ce1f6005 100644
--- a/tall/src/main/java/com/ccsens/tall/bean/vo/UserVo.java
+++ b/tall/src/main/java/com/ccsens/tall/bean/vo/UserVo.java
@@ -144,6 +144,8 @@ public class UserVo {
private Date createdAt;
@ApiModelProperty("空间使用情况")
private Interspace interspace;
+ @ApiModelProperty("WxInfo")
+ private WxInfo wxInfo;
@ApiModelProperty("标签信息")
private List labelList;
}
diff --git a/tall/src/main/java/com/ccsens/tall/persist/dao/ProRoleDao.java b/tall/src/main/java/com/ccsens/tall/persist/dao/ProRoleDao.java
index b3fd7016..24a14f76 100644
--- a/tall/src/main/java/com/ccsens/tall/persist/dao/ProRoleDao.java
+++ b/tall/src/main/java/com/ccsens/tall/persist/dao/ProRoleDao.java
@@ -121,6 +121,13 @@ public interface ProRoleDao extends ProRoleMapper{
*/
List selectMemberOfRole(Long roleId);
+ /**
+ * 根据角色id查询不可见角色列表
+ * @param roleId 二级角色id
+ * @return 不可见角色list
+ */
+ List selectRoleOfNoLook(Long roleId);
+
diff --git a/tall/src/main/java/com/ccsens/tall/persist/dao/SysUserDao.java b/tall/src/main/java/com/ccsens/tall/persist/dao/SysUserDao.java
index 344526b9..c6b688e7 100644
--- a/tall/src/main/java/com/ccsens/tall/persist/dao/SysUserDao.java
+++ b/tall/src/main/java/com/ccsens/tall/persist/dao/SysUserDao.java
@@ -61,4 +61,11 @@ public interface SysUserDao extends SysUserMapper {
* @return
*/
UserVo.TokenBean getTokenBeanByUserId(Long userId);
+
+ /**
+ * 查找用户wxInfo中的信息
+ * @param currentUserId 当前用户id
+ * @return UserVo.WxInfo
+ */
+ UserVo.WxInfo selectWxInfo(@Param("userId") Long currentUserId);
}
diff --git a/tall/src/main/java/com/ccsens/tall/persist/dao/TaskDetailDao.java b/tall/src/main/java/com/ccsens/tall/persist/dao/TaskDetailDao.java
index b451322d..a177df26 100644
--- a/tall/src/main/java/com/ccsens/tall/persist/dao/TaskDetailDao.java
+++ b/tall/src/main/java/com/ccsens/tall/persist/dao/TaskDetailDao.java
@@ -70,7 +70,7 @@ public interface TaskDetailDao extends ProTaskDetailMapper {
* @param userId 当前用户的userId
* @return
*/
- List queryLwbsByProjectId(@Param("projectId")Long projectId, @Param("startTime")Long startTime, @Param("endTime")Long endTime, @Param("userId")Long userId);
+ List queryLwbsByProjectId(@Param("projectId")Long projectId, @Param("startTime")Long startTime, @Param("endTime")Long endTime, @Param("userId")Long userId,@Param("roleIds") List roleIds);
/**
* 通过任务详情id查询项目下的经理角色id
diff --git a/tall/src/main/java/com/ccsens/tall/service/IProRoleService.java b/tall/src/main/java/com/ccsens/tall/service/IProRoleService.java
index eb634833..a6fd520a 100644
--- a/tall/src/main/java/com/ccsens/tall/service/IProRoleService.java
+++ b/tall/src/main/java/com/ccsens/tall/service/IProRoleService.java
@@ -79,4 +79,11 @@ public interface IProRoleService {
void queryRoleIsShows(QueryDto param);
void upRoleShowsOrder(QueryDto param);
+
+ /**
+ * 角色管理:修改对谁不可见
+ * @param param 参数
+ * @param userId 当前用户id
+ */
+ void upRoleWhoNoLook(RoleDto.RoleOfNoLook param, Long userId);
}
diff --git a/tall/src/main/java/com/ccsens/tall/service/LwbsService.java b/tall/src/main/java/com/ccsens/tall/service/LwbsService.java
index bc9e5d46..8ad885c0 100644
--- a/tall/src/main/java/com/ccsens/tall/service/LwbsService.java
+++ b/tall/src/main/java/com/ccsens/tall/service/LwbsService.java
@@ -21,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
/**
* @author 逗
@@ -33,6 +34,8 @@ public class LwbsService implements ILwbsService{
private TaskDetailDao taskDetailDao;
@Resource
public SysProjectDao sysProjectDao;
+ @Resource
+ public ProMemberService proMemberService;
/**
* 查询该用户的所有项目
@@ -125,8 +128,11 @@ public class LwbsService implements ILwbsService{
private TaskVo.ProTaskInfo queryLwbsByProjectId(Long projectId, Long startTime,Long endTime, Long userId){
TaskVo.ProTaskInfo proTaskInfo = new TaskVo.ProTaskInfo();
+ //查找当前用户在项目中的角色
+ List proRoles = proMemberService.selectRolesByUserIdAndProjectId(userId, projectId, null);
+ List roleIds = proRoles.stream().map(ProRole::getId).collect(Collectors.toList());
//查询当前项目下所有任务
- List normalTaskList = taskDetailDao.queryLwbsByProjectId(projectId,startTime,endTime,userId);
+ List normalTaskList = taskDetailDao.queryLwbsByProjectId(projectId,startTime,endTime,userId,roleIds);
//分解为全局和普通
if(CollectionUtil.isNotEmpty(normalTaskList)) {
TaskUtil.Task task = TaskUtil.splitTask(normalTaskList, startTime, endTime, 0);
diff --git a/tall/src/main/java/com/ccsens/tall/service/ProRoleService.java b/tall/src/main/java/com/ccsens/tall/service/ProRoleService.java
index 1201b29d..96d660d6 100644
--- a/tall/src/main/java/com/ccsens/tall/service/ProRoleService.java
+++ b/tall/src/main/java/com/ccsens/tall/service/ProRoleService.java
@@ -251,6 +251,14 @@ public class ProRoleService implements IProRoleService {
private List getRealMemberRolesShowByProjectIdAll(Long projectId, Long currentUserId) {
List memberRoleList;
memberRoleList = proRoleDao.selectSecondRolesByProjectId(projectId);
+ //查找对谁不可见
+ for (ProjectVo.RoleInfo roleInfo : memberRoleList) {
+ List noLookList = proRoleDao.selectRoleOfNoLook(roleInfo.getId());
+ if (CollectionUtil.isNotEmpty(noLookList)){
+ roleInfo.getRoleOfNoLook().addAll(noLookList);
+ }
+ }
+
return memberRoleList;
}
@@ -773,6 +781,16 @@ public class ProRoleService implements IProRoleService {
if (ObjectUtil.isNull(project)) {
throw new BaseException(CodeEnum.NOT_PROJECT);
}
+ //查找项目配置
+ String milestone = "";
+ ProShowExample proShowExample = new ProShowExample();
+ proShowExample.createCriteria().andProjectIdEqualTo(projectId.getProjectId());
+ List proShows = proShowDao.selectByExample(proShowExample);
+ if (CollectionUtil.isNotEmpty(proShows)){
+ Byte milestoneSubtask = proShows.get(0).getMilestoneSubtask();
+ milestone = milestoneSubtask == 0 ? "里程碑":null;
+ }
+
long beginTime = projectId.getStartTime() == null ? project.getBeginTime() : projectId.getStartTime();
long endTime = projectId.getEndTime() == null ? project.getEndTime() : projectId.getEndTime();
//1、查找一级任务
@@ -783,6 +801,7 @@ public class ProRoleService implements IProRoleService {
List firstTaskDetailList = taskDetailDao.selectByExample(proTaskDetailExample);
log.info("查找到一级任务:{}", firstTaskDetailList);
if (CollectionUtil.isNotEmpty(firstTaskDetailList)) {
+ String finalMilestone = milestone;
firstTaskDetailList.forEach(firstTaskDetail -> {
int sequence = 1;
TaskVo.NormalTask normalTask = new TaskVo.NormalTask();
@@ -790,7 +809,7 @@ public class ProRoleService implements IProRoleService {
normalTask.setDetailId(firstTaskDetail.getId());
normalTask.setSequence(sequence);
- List secondTaskList = taskDetailDao.getTaskByParentId(firstTaskDetail.getId(), "里程碑",beginTime,endTime);
+ List secondTaskList = taskDetailDao.getTaskByParentId(firstTaskDetail.getId(), finalMilestone,beginTime,endTime);
List secondList = new ArrayList<>();
if (CollectionUtil.isNotEmpty(secondTaskList)) {
secondTaskList.forEach(secondTask -> {
@@ -1116,4 +1135,45 @@ public class ProRoleService implements IProRoleService {
}
return memberId;
}
+
+ /**
+ * 修改对谁不可见
+ * @param param 参数
+ * @param userId 当前用户id
+ */
+ @Override
+ public void upRoleWhoNoLook(RoleDto.RoleOfNoLook param, Long userId) {
+ ProRole proRole = proRoleDao.selectByPrimaryKey(param.getRoleId());
+ if (ObjectUtil.isNotNull(proRole)){
+ //用户在项目中的最高权限
+ int power = selectPowerByRoleName(userId, proRole.getProjectId());
+ if (2 < power){
+ //删除之前的记录
+ ProRoleExcludeExample excludeExample = new ProRoleExcludeExample();
+ excludeExample.createCriteria().andRoleIdEqualTo(param.getRoleId()).andRecStatusEqualTo((byte)0);
+ List proRoleExcludes = proRoleExcludeMapper.selectByExample(excludeExample);
+ if (CollectionUtil.isNotEmpty(proRoleExcludes)){
+ for (ProRoleExclude proRoleExclude : proRoleExcludes) {
+ ProRoleExclude oldExclude = new ProRoleExclude();
+ oldExclude.setId(proRoleExclude.getId());
+ oldExclude.setRecStatus((byte)2);
+ proRoleExcludeMapper.updateByExampleSelective(oldExclude,excludeExample);
+ }
+ }
+
+ //添加新数据
+ for (Long noRoleId : param.getNoRoleId()) {
+ ProRoleExclude roleExclude = new ProRoleExclude();
+ roleExclude.setId(snowflake.nextId());
+ roleExclude.setRoleId(param.getRoleId());
+ roleExclude.setOtherRoleId(noRoleId);
+ proRoleExcludeMapper.insertSelective(roleExclude);
+ }
+ }else{
+ throw new BaseException(CodeEnum.NOT_POWER);
+ }
+ }
+
+ }
+
}
diff --git a/tall/src/main/java/com/ccsens/tall/service/ProTaskDetailService.java b/tall/src/main/java/com/ccsens/tall/service/ProTaskDetailService.java
index 6b0e682e..266e61a9 100644
--- a/tall/src/main/java/com/ccsens/tall/service/ProTaskDetailService.java
+++ b/tall/src/main/java/com/ccsens/tall/service/ProTaskDetailService.java
@@ -437,10 +437,11 @@ public class ProTaskDetailService implements IProTaskDetailService {
if(ObjectUtil.isNotNull(executor)){
normalTask.setExecutorRoleName(executor.getName());
}
+
Long checkerRole = normalTask.getCheckerRole();
ProRole checker = proRoleDao.selectByPrimaryKey(checkerRole);
- if(ObjectUtil.isNotNull(checker)){
- normalTask.setCheckerRoleName(checker.getName());
+ if(ObjectUtil.isNotNull(checker)) {
+ normalTask.setExecutorRoleName(checker.getName());
}
diff --git a/tall/src/main/java/com/ccsens/tall/service/TaskDeliverService.java b/tall/src/main/java/com/ccsens/tall/service/TaskDeliverService.java
index 13c6de2b..fd1b7ff2 100644
--- a/tall/src/main/java/com/ccsens/tall/service/TaskDeliverService.java
+++ b/tall/src/main/java/com/ccsens/tall/service/TaskDeliverService.java
@@ -321,7 +321,7 @@ public class TaskDeliverService implements ITaskDeliverService {
data.setDeliverId(taskDeliver.getId());
data.setDeliverName(taskDeliver.getName());
data.setRoleId(roleId);
- data.setTaskId(taskDetail.getId());
+ data.setTaskId(uploadDeliver.getTaskId());
data.setUploader(currentUserId);
data.setUploadTime(now);
data.setFile(uploadDeliver.getFileInfo());
@@ -811,7 +811,7 @@ public class TaskDeliverService implements ITaskDeliverService {
} else {
checkerDtoData.setRoleId(task.getExecutorRole());
}
- checkerDtoData.setTaskId(task.getId());
+ checkerDtoData.setTaskId(checkDeliver.getTaskId());
checkerDtoData.setDeliverId(deliver.getId());
checkerDtoData.setDeliverName(deliver.getName());
if(ObjectUtil.isNotNull(checkRole)) {
diff --git a/tall/src/main/java/com/ccsens/tall/service/UserInfoService.java b/tall/src/main/java/com/ccsens/tall/service/UserInfoService.java
index 61855606..1cd54e20 100644
--- a/tall/src/main/java/com/ccsens/tall/service/UserInfoService.java
+++ b/tall/src/main/java/com/ccsens/tall/service/UserInfoService.java
@@ -195,6 +195,9 @@ public class UserInfoService implements IUserInfoService{
//获取空间使用信息
UserVo.Interspace interspace = sysUserDao.selectInterspace(currentUserId);
selectUserInfo.setInterspace(interspace);
+ //封装wxInfo
+ UserVo.WxInfo wxInfo = sysUserDao.selectWxInfo(currentUserId);
+ selectUserInfo.setWxInfo(wxInfo);
}
return selectUserInfo;
diff --git a/tall/src/main/java/com/ccsens/tall/web/RoleController.java b/tall/src/main/java/com/ccsens/tall/web/RoleController.java
index dba40607..e2b7c9ee 100644
--- a/tall/src/main/java/com/ccsens/tall/web/RoleController.java
+++ b/tall/src/main/java/com/ccsens/tall/web/RoleController.java
@@ -163,4 +163,13 @@ public class RoleController {
List roleInfoList = proRoleService.getRolesByProjectIdAndUserId(projectId, currentUserId,imitation,queryType);
return JsonResponse.newInstance().ok(roleInfoList);
}
+
+ @MustLoginTall
+ @ApiOperation(value = "角色管理:修改对谁不可见",notes = "")
+ @RequestMapping(value = "/upRoleWhoNoLook", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
+ public JsonResponse upRoleWhoNoLook(@ApiParam @Validated @RequestBody QueryDto params){
+ log.info("传入参数:{}", params);
+ proRoleService.upRoleWhoNoLook(params.getParam(),params.getUserId());
+ return JsonResponse.newInstance().ok();
+ }
}
diff --git a/tall/src/main/resources/application.yml b/tall/src/main/resources/application.yml
index b5408a3a..ebc544af 100644
--- a/tall/src/main/resources/application.yml
+++ b/tall/src/main/resources/application.yml
@@ -1,5 +1,5 @@
spring:
profiles:
- active: dev
- include: util-dev,common
+ active: test
+ include: util-test,common
diff --git a/tall/src/main/resources/mapper_dao/ProRoleDao.xml b/tall/src/main/resources/mapper_dao/ProRoleDao.xml
index 184f860a..1b2cd0ca 100644
--- a/tall/src/main/resources/mapper_dao/ProRoleDao.xml
+++ b/tall/src/main/resources/mapper_dao/ProRoleDao.xml
@@ -70,28 +70,28 @@
@@ -445,4 +445,23 @@
pmr.role_id = #{roleId}
AND pmr.rec_status = 0
+
+
\ No newline at end of file
diff --git a/tall/src/main/resources/mapper_dao/SysUserDao.xml b/tall/src/main/resources/mapper_dao/SysUserDao.xml
index d917ade3..c884fb86 100644
--- a/tall/src/main/resources/mapper_dao/SysUserDao.xml
+++ b/tall/src/main/resources/mapper_dao/SysUserDao.xml
@@ -198,4 +198,19 @@
AND
rec_status = 0
+
+
\ No newline at end of file
diff --git a/tall/src/main/resources/mapper_dao/TaskDetailDao.xml b/tall/src/main/resources/mapper_dao/TaskDetailDao.xml
index f991ca6b..bb00af62 100644
--- a/tall/src/main/resources/mapper_dao/TaskDetailDao.xml
+++ b/tall/src/main/resources/mapper_dao/TaskDetailDao.xml
@@ -721,6 +721,13 @@
AND s.end_time >= #{startTime}
AND d.Level = 2
+ AND
+
+ d.executor_role IN
+
+ #{item}
+
+
order by s.begin_time
)t
LEFT JOIN
diff --git a/tall/src/main/resources/mapper_raw/ProShowMapper.xml b/tall/src/main/resources/mapper_raw/ProShowMapper.xml
index dd83eae0..06e24aca 100644
--- a/tall/src/main/resources/mapper_raw/ProShowMapper.xml
+++ b/tall/src/main/resources/mapper_raw/ProShowMapper.xml
@@ -21,6 +21,7 @@
+
@@ -83,7 +84,7 @@
id, project_id, slide, filter, is_show_mvp, style, create_task, time_show, duration,
show_shortcuts, select_task_type, detail_path, pims_nav_type, share_change, share_change_code,
- created_at, updated_at, rec_status, role_belong
+ created_at, updated_at, rec_status, role_belong, milestone_subtask
+
+
+ com.aliyun.api.gateway
+ sdk-core-java
+ 1.1.6
+
diff --git a/util/src/main/java/com/ccsens/util/ali/AliInstanceUtil.java b/util/src/main/java/com/ccsens/util/ali/AliInstanceUtil.java
new file mode 100644
index 00000000..c1839d43
--- /dev/null
+++ b/util/src/main/java/com/ccsens/util/ali/AliInstanceUtil.java
@@ -0,0 +1,27 @@
+package com.ccsens.util.ali;
+
+import com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams;
+
+/**
+ * @description:
+ * @author: whj
+ * @time: 2021/4/25 16:53
+ */
+public class AliInstanceUtil {
+
+ private static String appKey = "203933478";
+ private static String appSecret = "KrDev8GlVu6DyMOhjGSudngDZ8RsslYE";
+
+ /**
+ *
+ * @return
+ */
+ public static HttpsApiClientlyocr_general_advanced getGeneralAdvancedHttps(){
+ HttpClientBuilderParams httpsParam = new HttpClientBuilderParams();
+ httpsParam.setAppKey(appKey);
+ httpsParam.setAppSecret(appSecret);
+ HttpsApiClientlyocr_general_advanced instance = HttpsApiClientlyocr_general_advanced.getInstance();
+ instance.init(httpsParam);
+ return instance;
+ }
+}
diff --git a/util/src/main/java/com/ccsens/util/ali/Demolyocr_general_advanced.java b/util/src/main/java/com/ccsens/util/ali/Demolyocr_general_advanced.java
new file mode 100644
index 00000000..98d141e0
--- /dev/null
+++ b/util/src/main/java/com/ccsens/util/ali/Demolyocr_general_advanced.java
@@ -0,0 +1,168 @@
+//
+// Created by fred on 2016/10/26.
+// Copyright © 2016年 Alibaba. All rights reserved.
+//
+
+package com.ccsens.util.ali;
+
+import com.alibaba.cloudapi.sdk.constant.SdkConstant;
+import com.alibaba.cloudapi.sdk.model.ApiCallback;
+import com.alibaba.cloudapi.sdk.model.ApiRequest;
+import com.alibaba.cloudapi.sdk.model.ApiResponse;
+import com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams;
+import java.io.IOException;
+
+
+
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.ssl.SSLContextBuilder;
+import org.apache.http.ssl.TrustStrategy;
+import javax.net.ssl.*;
+import java.security.KeyStore;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+public class Demolyocr_general_advanced {
+
+
+ static{
+ //HTTP Client init
+ HttpClientBuilderParams httpParam = new HttpClientBuilderParams();
+ httpParam.setAppKey("203933478");
+ httpParam.setAppSecret("KrDev8GlVu6DyMOhjGSudngDZ8RsslYE");
+ HttpApiClientlyocr_general_advanced.getInstance().init(httpParam);
+
+
+ //HTTPS Client init
+ HttpClientBuilderParams httpsParam = new HttpClientBuilderParams();
+ httpsParam.setAppKey("203933478");
+ httpsParam.setAppSecret("KrDev8GlVu6DyMOhjGSudngDZ8RsslYE");
+
+ /**
+ * HTTPS request use DO_NOT_VERIFY mode only for demo
+ * Suggest verify for security
+ */
+ //httpsParam.setRegistry(getNoVerifyRegistry());
+
+ HttpsApiClientlyocr_general_advanced.getInstance().init(httpsParam);
+
+
+ }
+
+
+ public static void ocrAdvancedHttpsTest(){
+ HttpsApiClientlyocr_general_advanced.getInstance().ocrAdvanced("default".getBytes(SdkConstant.CLOUDAPI_ENCODING) , new ApiCallback() {
+ @Override
+ public void onFailure(ApiRequest request, Exception e) {
+ e.printStackTrace();
+ }
+
+ @Override
+ public void onResponse(ApiRequest request, ApiResponse response) {
+ try {
+ System.out.println(getResultString(response));
+ }catch (Exception ex){
+ ex.printStackTrace();
+ }
+ }
+ });
+ }
+
+ public static void ocrAdvancedHttpsSyncTest(){
+ ApiResponse response = HttpsApiClientlyocr_general_advanced.getInstance().ocrAdvancedSyncMode("default".getBytes(SdkConstant.CLOUDAPI_ENCODING));
+ try {
+ System.out.println(getResultString(response));
+ }catch (Exception ex){
+ ex.printStackTrace();
+ }
+ }
+
+
+
+ private static String getResultString(ApiResponse response) throws IOException {
+ StringBuilder result = new StringBuilder();
+ result.append("Response from backend server").append(SdkConstant.CLOUDAPI_LF).append(SdkConstant.CLOUDAPI_LF);
+ result.append("ResultCode:").append(SdkConstant.CLOUDAPI_LF).append(response.getCode()).append(SdkConstant.CLOUDAPI_LF).append(SdkConstant.CLOUDAPI_LF);
+ if(response.getCode() != 200){
+ result.append("Error description:").append(response.getHeaders().get("X-Ca-Error-Message")).append(SdkConstant.CLOUDAPI_LF).append(SdkConstant.CLOUDAPI_LF);
+ }
+
+ result.append("ResultBody:").append(SdkConstant.CLOUDAPI_LF).append(new String(response.getBody() , SdkConstant.CLOUDAPI_ENCODING));
+
+ return result.toString();
+ }
+
+ private static Registry getNoVerifyRegistry() {
+ RegistryBuilder registryBuilder = RegistryBuilder.create();
+ try {
+ registryBuilder.register("http", PlainConnectionSocketFactory.INSTANCE).build();
+ registryBuilder.register(
+ "https",
+ new SSLConnectionSocketFactory(new SSLContextBuilder().loadTrustMaterial(
+ KeyStore.getInstance(KeyStore.getDefaultType()), new TrustStrategy() {
+ @Override
+ public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
+ return true;
+ }
+ }).build(),
+ new HostnameVerifier() {
+ @Override
+ public boolean verify(String paramString, SSLSession paramSSLSession) {
+ return true;
+ }
+ }));
+
+ } catch (Exception e) {
+ throw new RuntimeException("HttpClientUtil init failure !", e);
+ }
+ return registryBuilder.build();
+ }
+
+
+ private static void trustAllHttpsCertificates() throws Exception {
+ javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1];
+ javax.net.ssl.TrustManager tm = new miTM();
+ trustAllCerts[0] = tm;
+ javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext
+ .getInstance("SSL");
+ sc.init(null, trustAllCerts, null);
+ javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc
+ .getSocketFactory());
+ }
+
+ static class miTM implements javax.net.ssl.TrustManager,
+ javax.net.ssl.X509TrustManager {
+ @Override
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ public boolean isServerTrusted(
+ java.security.cert.X509Certificate[] certs) {
+ return true;
+ }
+
+ public boolean isClientTrusted(
+ java.security.cert.X509Certificate[] certs) {
+ return true;
+ }
+
+ @Override
+ public void checkServerTrusted(
+ java.security.cert.X509Certificate[] certs, String authType)
+ throws java.security.cert.CertificateException {
+ return;
+ }
+
+ @Override
+ public void checkClientTrusted(
+ java.security.cert.X509Certificate[] certs, String authType)
+ throws java.security.cert.CertificateException {
+ return;
+ }
+ }
+}
diff --git a/util/src/main/java/com/ccsens/util/ali/HttpApiClientlyocr_general_advanced.java b/util/src/main/java/com/ccsens/util/ali/HttpApiClientlyocr_general_advanced.java
new file mode 100644
index 00000000..99c5d958
--- /dev/null
+++ b/util/src/main/java/com/ccsens/util/ali/HttpApiClientlyocr_general_advanced.java
@@ -0,0 +1,34 @@
+//
+// Created by fred on 2017/1/12.
+// Copyright © 2016年 Alibaba. All rights reserved.
+//
+
+package com.ccsens.util.ali;
+import com.alibaba.cloudapi.sdk.client.ApacheHttpClient;
+import com.alibaba.cloudapi.sdk.enums.Scheme;
+import com.alibaba.cloudapi.sdk.enums.HttpMethod;
+import com.alibaba.cloudapi.sdk.model.ApiRequest;
+import com.alibaba.cloudapi.sdk.model.ApiResponse;
+import com.alibaba.cloudapi.sdk.model.ApiCallback;
+import com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams;
+import com.alibaba.cloudapi.sdk.enums.ParamPosition;
+import com.alibaba.cloudapi.sdk.enums.WebSocketApiType;
+import com.alibaba.fastjson.JSONObject;
+
+
+public class HttpApiClientlyocr_general_advanced extends ApacheHttpClient{
+ public final static String HOST = "ocrapi-advanced.taobao.com";
+ static HttpApiClientlyocr_general_advanced instance = new HttpApiClientlyocr_general_advanced();
+ public static HttpApiClientlyocr_general_advanced getInstance(){return instance;}
+
+ public void init(HttpClientBuilderParams httpClientBuilderParams){
+ httpClientBuilderParams.setScheme(Scheme.HTTP);
+ httpClientBuilderParams.setHost(HOST);
+ super.init(httpClientBuilderParams);
+ }
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/util/src/main/java/com/ccsens/util/ali/HttpsApiClientlyocr_general_advanced.java b/util/src/main/java/com/ccsens/util/ali/HttpsApiClientlyocr_general_advanced.java
new file mode 100644
index 00000000..fa99dcbc
--- /dev/null
+++ b/util/src/main/java/com/ccsens/util/ali/HttpsApiClientlyocr_general_advanced.java
@@ -0,0 +1,50 @@
+//
+// Created by fred on 2017/1/12.
+// Copyright © 2016年 Alibaba. All rights reserved.
+//
+
+package com.ccsens.util.ali;
+
+import com.alibaba.cloudapi.sdk.client.ApacheHttpClient;
+import com.alibaba.cloudapi.sdk.enums.HttpMethod;
+import com.alibaba.cloudapi.sdk.enums.ParamPosition;
+import com.alibaba.cloudapi.sdk.enums.Scheme;
+import com.alibaba.cloudapi.sdk.model.ApiCallback;
+import com.alibaba.cloudapi.sdk.model.ApiRequest;
+import com.alibaba.cloudapi.sdk.model.ApiResponse;
+import com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams;
+import com.alibaba.cloudapi.sdk.enums.WebSocketApiType;
+import com.alibaba.fastjson.JSONObject;
+
+public class HttpsApiClientlyocr_general_advanced extends ApacheHttpClient{
+ public final static String HOST = "ocrapi-advanced.taobao.com";
+ static HttpsApiClientlyocr_general_advanced instance = new HttpsApiClientlyocr_general_advanced();
+ public static HttpsApiClientlyocr_general_advanced getInstance(){return instance;}
+
+ public void init(HttpClientBuilderParams httpClientBuilderParams){
+ httpClientBuilderParams.setScheme(Scheme.HTTPS);
+ httpClientBuilderParams.setHost(HOST);
+ super.init(httpClientBuilderParams);
+ }
+
+
+
+ public void ocrAdvanced(byte[] body , ApiCallback callback) {
+ String path = "/ocrservice/advanced";
+ ApiRequest request = new ApiRequest(HttpMethod.POST_BODY , path, body);
+
+
+
+ sendAsyncRequest(request , callback);
+ }
+
+ public ApiResponse ocrAdvancedSyncMode(byte[] body) {
+ String path = "/ocrservice/advanced";
+ ApiRequest request = new ApiRequest(HttpMethod.POST_BODY , path, body);
+
+
+
+ return sendSyncRequest(request);
+ }
+
+}
\ No newline at end of file