Browse Source

Merge remote-tracking branch 'origin/develop' into develop

tags/v1.1.0^2
chenjiandong 1 year ago
parent
commit
494c684ffb
8 changed files with 200 additions and 12 deletions
  1. +97
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AliyunOssController.java
  2. +45
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/QuestionHandleVO.java
  3. +4
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/QuestionReportVO.java
  4. +20
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/WorkOrderQuestionVO.java
  5. +5
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/QuestionHandleMapper.java
  6. +8
    -12
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ReportServiceImpl.java
  7. +17
    -0
      tuoheng-admin/src/main/resources/mapper/QuestionHandleMapper.xml
  8. +4
    -0
      tuoheng-admin/src/main/resources/mapper/WorkOrderMapper.xml

+ 97
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AliyunOssController.java View File

@@ -0,0 +1,97 @@
package com.tuoheng.admin.controller;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import com.aliyuncs.sts.model.v20150401.AssumeRoleRequest;
import com.aliyuncs.sts.model.v20150401.AssumeRoleResponse;
import com.tuoheng.admin.config.AliyuncsVodConfig;
import com.tuoheng.common.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
* 阿里云对象存储OSS 前端控制器
*
* @author WangHaoran
* @since 2022-03-15
*/
@Slf4j
@RestController
@RequestMapping("/aliyunOss")
public class AliyunOssController {

/**
* 获取securityToken
*
* @return
*/
@GetMapping("/getSecurityToken")
public JsonResult getSecurityToken() {
// STS接入地址,例如sts.cn-shanghai.aliyuncs.com。
String endpoint = "sts.cn-shanghai.aliyuncs.com";
// 填写步骤1生成的访问密钥AccessKey ID和AccessKey Secret。
String AccessKeyId = AliyuncsVodConfig.accessKeyId;
String accessKeySecret = AliyuncsVodConfig.accessKeySecret;
// 填写步骤3获取的角色ARN。
String roleArn = AliyuncsVodConfig.roleArn;
// 自定义角色会话名称,用来区分不同的令牌,例如可填写为SessionTest。
// String roleSessionName = "<yourRoleSessionName>";
// 以下Policy用于限制仅允许使用临时访问凭证向目标存储空间examplebucket上传文件。
// 临时访问凭证最后获得的权限是步骤4设置的角色权限和该Policy设置权限的交集,即仅允许将文件上传至目标存储空间examplebucket下的exampledir目录。
String policy = "{\n" +
" \"Version\": \"1\", \n" +
" \"Statement\": [\n" +
" {\n" +
" \"Action\": [\n" +
" \"oss:PutObject\"\n" +
" ], \n" +
" \"Resource\": [\n" +
" \"acs:oss:*:*:ta-tech-image/imagedir/*\" \n" +
" ], \n" +
" \"Effect\": \"Allow\"\n" +
" }\n" +
" ]\n" +
"}";
try {
// regionId表示RAM的地域ID。以华东1(杭州)地域为例,regionID填写为cn-hangzhou。也可以保留默认值,默认值为空字符串("")。
String regionId = "";
// 添加endpoint。适用于Java SDK 3.12.0及以上版本。
DefaultProfile.addEndpoint(regionId, "Sts", endpoint);
// 添加endpoint。适用于Java SDK 3.12.0以下版本。
// DefaultProfile.addEndpoint("",regionId, "Sts", endpoint);
// 构造default profile。
IClientProfile profile = DefaultProfile.getProfile(regionId, AccessKeyId, accessKeySecret);
// 构造client。
DefaultAcsClient client = new DefaultAcsClient(profile);
final AssumeRoleRequest request = new AssumeRoleRequest();
// 适用于Java SDK 3.12.0及以上版本。
request.setSysMethod(MethodType.POST);
// 适用于Java SDK 3.12.0以下版本。
//request.setMethod(MethodType.POST);
request.setRoleArn(roleArn);
request.setRoleSessionName("SessionTest");
request.setPolicy(policy); // 如果policy为空,则用户将获得该角色下所有权限。
request.setDurationSeconds(3600L); // 设置临时访问凭证的有效时间为3600秒。
final AssumeRoleResponse response = client.getAcsResponse(request);
log.info("Expiration: " + response.getCredentials().getExpiration());
log.info("Access Key Id: " + response.getCredentials().getAccessKeyId());
log.info("Access Key Secret: " + response.getCredentials().getAccessKeySecret());
log.info("Security Token: " + response.getCredentials().getSecurityToken());
log.info("RequestId: " + response.getRequestId());
return JsonResult.success(response);
} catch (ClientException e) {
log.error("Error code: " + e.getErrCode());
log.error("Error message: " + e.getErrMsg());
log.error("RequestId: " + e.getRequestId());
}
return JsonResult.error();
}


}

+ 45
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/QuestionHandleVO.java View File

@@ -0,0 +1,45 @@
package com.tuoheng.admin.entity.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Data
public class QuestionHandleVO {

/**
* 处理人
*/
private Integer handlerUser;

/**
* 处理人
*/
private String handlerUserName;

/**
* 处理后图片(多个图片逗号“,”分隔)
*/
private String handlerImage;

/**
* 处理结果
*/
private String handlerResult;

/**
* 处理时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date handlerTime;

/**
* 处理状态:0待处理 1已处理
*/
@TableField(exist = false)
private Integer status;
}

+ 4
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/QuestionReportVO.java View File

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class QuestionReportVO implements Serializable {
@@ -24,4 +25,7 @@ public class QuestionReportVO implements Serializable {

@ApiModelProperty(value = "经度")
private String lng;

@ApiModelProperty(value = "问题处理清单")
private List<QuestionHandleVO> questionHandleList;
}

+ 20
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/WorkOrderQuestionVO.java View File

@@ -9,6 +9,14 @@ import java.util.Date;
@Data
public class WorkOrderQuestionVO {

/**
* 问题ID
*/
private Integer questionId;

/**
* 问题类型
*/
private String type;

/**
@@ -53,6 +61,18 @@ public class WorkOrderQuestionVO {
*/
private String handlerImage;

/**
* 处理后图片(多个图片逗号“,”分隔)
*/
private String handlerResult;

/**
* 处理完成时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date handlerTime;

/**
* 处理人员名称
*/

+ 5
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/QuestionHandleMapper.java View File

@@ -2,6 +2,11 @@ package com.tuoheng.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.admin.entity.domain.QuestionHandle;
import com.tuoheng.admin.entity.vo.QuestionHandleVO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface QuestionHandleMapper extends BaseMapper<QuestionHandle> {
List<QuestionHandleVO> getList(@Param("questionId") Integer questionId);
}

+ 8
- 12
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ReportServiceImpl.java View File

@@ -8,30 +8,25 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lowagie.text.*;
import com.tuoheng.admin.common.ServiceExceptionEnum;
import com.tuoheng.admin.entity.domain.Question;
import com.tuoheng.admin.entity.domain.QuestionHandle;
import com.tuoheng.admin.entity.domain.Report;
import com.tuoheng.admin.entity.domain.ThMission;
import com.tuoheng.admin.entity.request.ReportRequest;
import com.tuoheng.admin.entity.vo.*;
import com.tuoheng.admin.enums.*;
import com.tuoheng.admin.mapper.ReportMapper;
import com.tuoheng.admin.mapper.ThInspectionMapper;
import com.tuoheng.admin.mapper.ThMissionMapper;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.service.IQuestionService;
import com.tuoheng.admin.service.IReportService;
import com.tuoheng.admin.service.IThInspectionService;
import com.tuoheng.admin.utils.ImgTypeConvert;
import com.tuoheng.admin.utils.WeatherUtil;
import com.tuoheng.admin.utils.WordUtilsOld;
import com.tuoheng.common.common.BaseServiceImpl;
import com.tuoheng.common.config.CommonConfig;
import com.tuoheng.common.config.UploadFileConfig;
import com.tuoheng.common.exception.ServiceException;
import com.tuoheng.common.utils.DateUtils;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.common.utils.StringUtils;
import com.tuoheng.system.service.impl.UserServiceImpl;
import com.tuoheng.system.utils.ShiroUtils;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,12 +36,7 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
@@ -79,6 +69,9 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
@Autowired
private UserServiceImpl userService;

@Autowired
private QuestionHandleMapper questionHandleMapper;


@Override
public JsonResult generateReport(Integer missionId) {
@@ -218,6 +211,9 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
for (Question question : questionList) {
QuestionReportVO questionReportVO=new QuestionReportVO();
BeanUtils.copyProperties(question,questionReportVO);
List<QuestionHandleVO> questionHandleList = questionHandleMapper.getList(question.getId());
questionReportVO.setQuestionHandleList(questionHandleList);

questionReportVOList.add(questionReportVO);
}
//问题列表

+ 17
- 0
tuoheng-admin/src/main/resources/mapper/QuestionHandleMapper.xml View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.admin.mapper.QuestionHandleMapper">

<select id="getList" resultType="com.tuoheng.admin.entity.vo.QuestionHandleVO">
SELECT
qh.handler_user AS handlerUser,
qh.handler_image AS handlerImage,
qh.handler_result AS handlerResult,
qh.handler_time AS handlerTime,
u.realname AS handlerUserName
FROM th_question_handle qh
LEFT JOIN sys_user u ON qh.handler_user = u.id
WHERE qh.question_id = #{questionId}
</select>

</mapper>

+ 4
- 0
tuoheng-admin/src/main/resources/mapper/WorkOrderMapper.xml View File

@@ -5,7 +5,9 @@
<select id="questionPage" resultType="com.tuoheng.admin.entity.vo.WorkOrderQuestionVO">
SELECT
q.type,
q.id AS questionId,
q.question_name AS questionName,
q.question_desc AS questionDesc,
q.file_original_url AS fileOriginalUrl,
q.file_marker_url AS fileMarkerUrl,
q.lng AS lng,
@@ -14,6 +16,8 @@
q.create_time AS createTime,
qh.handler_user AS handlerUser,
qh.handler_image AS handlerImage,
qh.handler_result AS handlerResult,
qh.handler_time AS handlerTime,
u.realname AS handlerUserName
FROM th_work_order wo
LEFT JOIN th_work_order_question woq on wo.id = woq.work_order_id

Loading…
Cancel
Save