Commit af60da62 authored by suhuiguang's avatar suhuiguang

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

parents e18391f8 491630bf
package com.yeejoin.amos.boot.biz.common.utils;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.security.GeneralSecurityException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class HttpUtils {
private static PoolingHttpClientConnectionManager connMgr;
private static RequestConfig requestConfig;
private static final int MAX_TIMEOUT = 50000;
private static final Logger logger = LoggerFactory.getLogger(HttpUtils.class);
static {
// 设置连接池
connMgr = new PoolingHttpClientConnectionManager();
// 设置连接池大小
connMgr.setMaxTotal(100);
connMgr.setDefaultMaxPerRoute(connMgr.getMaxTotal());
// Validate connections after 1 sec of inactivity
connMgr.setValidateAfterInactivity(5000);
RequestConfig.Builder configBuilder = RequestConfig.custom();
// 设置连接超时
configBuilder.setConnectTimeout(MAX_TIMEOUT);
// 设置读取超时
configBuilder.setSocketTimeout(MAX_TIMEOUT);
// 设置从连接池获取连接实例的超时
configBuilder.setConnectionRequestTimeout(MAX_TIMEOUT);
requestConfig = configBuilder.build();
}
/**
* 发送 GET 请求(HTTP),不带输入数据
*
* @param url
* @return
*/
public static String doGet(String url) {
return doGet(url, new HashMap<String, Object>());
}
/**
* 发送 GET 请求(HTTP),K-V形式
*
* @param url
* @param params
* @return
*/
public static String doGet(String url, Map<String, Object> params) {
String apiUrl = url;
StringBuffer param = new StringBuffer();
int i = 0;
for (String key : params.keySet()) {
if (i == 0)
param.append("?");
else
param.append("&");
param.append(key).append("=").append(params.get(key));
i++;
}
apiUrl += param;
String result = null;
HttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory())
.setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
try {
HttpGet httpGet = new HttpGet(apiUrl);
HttpResponse response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
result = IOUtils.toString(instream, "UTF-8");
}
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
/**
* 发送 POST 请求(HTTP),不带输入数据
*
* @param apiUrl
* @return
*/
public static String doPost(String apiUrl) {
return doPost(apiUrl, new HashMap<String, Object>());
}
/**
* 发送 POST 请求,K-V形式
*
* @param apiUrl
* API接口URL
* @param params
* 参数map
* @return
*/
public static String doPost(String apiUrl, Map<String, Object> params) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory())
.setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
String httpStr = null;
HttpPost httpPost = new HttpPost(apiUrl);
CloseableHttpResponse response = null;
try {
httpPost.setConfig(requestConfig);
List<NameValuePair> pairList = new ArrayList<>(params.size());
for (Map.Entry<String, Object> entry : params.entrySet()) {
NameValuePair pair = new BasicNameValuePair(entry.getKey(), entry.getValue()!=null?entry.getValue().toString():"");
pairList.add(pair);
}
httpPost.setEntity(new UrlEncodedFormEntity(pairList, Charset.forName("UTF-8")));
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
}
return httpStr;
}
/**
* 发送 POST 请求,JSON形式,接收端需要支持json形式,否则取不到数据
*
* @param apiUrl
* @param json
* json对象
* @return
*/
public static String doPost(String apiUrl, String json) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()).setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
String httpStr = null;
HttpPost httpPost = new HttpPost(apiUrl);
CloseableHttpResponse response = null;
try {
httpPost.setConfig(requestConfig);
StringEntity stringEntity = new StringEntity(json, "UTF-8");// 解决中文乱码问题
stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
}
return httpStr;
}
/**
* 创建SSL安全连接
*
* @return
*/
private static SSLConnectionSocketFactory createSSLConnSocketFactory() {
SSLConnectionSocketFactory sslsf = null;
try {
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
}).build();
sslsf = new SSLConnectionSocketFactory(sslContext, new HostnameVerifier() {
@Override
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
});
} catch (GeneralSecurityException e) {
e.printStackTrace();
}
return sslsf;
}
}
......@@ -28,6 +28,8 @@ public class RedisKey {
public static final String ALERTCALLED_ID="alertcalled_id_";
/**特种设备根据警情id查询警情详情记录*/
public static final String TZS_ALERTCALLED_ID="tzs_alertcalled_id_";
/**联通CTI token */
public static final String CTI_TOKEN = "cti_token";
/** 驼峰转下划线(简单写法,效率低于{@link #humpToLine2(String)}) */
public static String humpToLine(String str) {
......
......@@ -32,7 +32,7 @@ public class FirefightersThought extends BaseEntity {
@ApiModelProperty(value = "消防救援人员")
private Long firefightersId;
@DateTimeFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "谈话时间")
private Date talkingTime;
......
......@@ -23,14 +23,13 @@ public interface FailureDetailsMapper extends BaseMapper<FailureDetails> {
/**
* 查询全部 分页
*
* @param page
* @param current 当前页
* @return
*/
// IPage<FailureDetails> selectAllPage(Page page);
IPage<FailureDetails> selectAllPage(Page<FailureDetails> page, Long currentStatus,
List<FailureDetails> selectAllPage(Long current,Long size, Long currentStatus,
String startTime,String endTime, Integer submissionPid);
/*IPage<FailureDetails> selectAllPage(int current,int size, Long currentStatus,
String startTime,String endTime, Integer submissionPid);*/
/**
* 查询我发起的 分页
* current 当前页
......@@ -38,31 +37,94 @@ public interface FailureDetailsMapper extends BaseMapper<FailureDetails> {
*
* @return
*/
IPage<FailureDetails> selectISubPage(Page page, String submissionPid);
List<FailureDetails> selectISubPage(Long current,Long size, Long currentStatus,
String startTime,String endTime, Integer submissionPid);
/**
* 查询待处理 分页
*
* @param page
* @param
* @return
*/
IPage<FailureDetails> selectInProcessing(Page page);
IPage<FailureDetails> selectStatusWaitTj(Page page);
IPage<FailureDetails> selectStatusWaitWx();
List<FailureDetails> selectInProcessing(Long current,Long size,Long currentStatus,
String startTime,String endTime, Integer submissionPid);
/**
* 查询待处理 应急指挥科人员分页
*
* @param
* @return
*/
List<FailureDetails> selectStatusWaitTj(Long current,Long size,Long currentStatus,
String startTime,String endTime, Integer submissionPid);
/**
* 查询待处理 维修人员分页
*
* @param
* @return
*/
List<FailureDetails> selectStatusWaitWx(Long current,Long size,Long currentStatus,
String startTime,String endTime, Integer submissionPid);
List<StatusDto> selectStatusCount();
/**
* 统计 全部
*
* @param currentStatus 状态
* @param startTime 起始时间
* @param endTime 结束时间
* @param submissionPid 报送人
*
* @return
*/
List<StatusDto> selectStatusCount(Long currentStatus,String startTime,String endTime, Integer submissionPid);
List<StatusDto> selectStatusWx();
List<StatusDto> selectStatusFq();
/**
* 统计 维修人员
*
* @param currentStatus 状态
* @param startTime 起始时间
* @param endTime 结束时间
* @param submissionPid 报送人
*
* @return
*/
List<StatusDto> selectStatusWx(Long currentStatus,String startTime,String endTime, Integer submissionPid);
/**
* 统计 应急指挥科人员
*
* @param currentStatus 状态
* @param startTime 起始时间
* @param endTime 结束时间
* @param submissionPid 报送人
*
* @return
*/
List<StatusDto> selectStatusFq(Long currentStatus,String startTime,String endTime, Integer submissionPid);
/**
* 统计 我发起
*
* @param currentStatus 状态
* @param startTime 起始时间
* @param endTime 结束时间
* @param submissionPid 报送人
*
* @return
*/
List<StatusDto> selectStatusFqp(Long currentStatus,String startTime,String endTime, Integer submissionPid);
/**
* 统计 领导
*
* @param currentStatus 状态
* @param startTime 起始时间
* @param endTime 结束时间
* @param submissionPid 报送人
*
* @return
*/
List<StatusDto> selectStatusLeader(Long currentStatus,String startTime,String endTime, Integer submissionPid);
List<StatusDto> selectStatusFqp(Integer submissionPid);
List<StatusDto> selectStatusLeader();
}
......@@ -58,7 +58,7 @@ public interface LinkageUnitMapper extends BaseMapper<LinkageUnit> {
* @return
*/
Page<List<LinkageUnitDto>> getEmergencyLinkageUnitList(IPage<LinkageUnitDto> page,String unitName,
String linkageUnitTypeCode, String emergencyLinkageUnitCode);
String linkageUnitType, String emergencyLinkageUnitCode);
List<LinkageUnitDto> exportToExcel();
......
......@@ -18,7 +18,6 @@
FROM
cb_failure_details
<where>
<if test="currentStatus!= null ">
and current_status = #{currentStatus}
</if>
......@@ -29,7 +28,7 @@
and submission_pid = #{submissionPid}
</if>
</where>
order by submission_time DESC
order by submission_time DESC limit #{current},#{size}
</select>
......@@ -47,11 +46,22 @@
submission_branch,
submission_branch_id
FROM cb_failure_details
WHERE submission_pid = #{submissionPid}
<where>
<if test="currentStatus!= null ">
and current_status = #{currentStatus}
</if>
<if test="startTime!= null and endTime != null">
and submission_time between #{startTime} and #{endTime}
</if>
<if test="submissionPid!= null ">
and submission_pid = #{submissionPid}
</if>
</where>
order by submission_time DESC
limit #{current},#{size}
</select>
<select id="selectInProcessing" resultType="com.yeejoin.amos.boot.module.common.api.entity.FailureDetails">
SELECT sequence_nbr,
current_status,
......@@ -66,9 +76,22 @@
submission_branch,
submission_branch_id
FROM cb_failure_details
WHERE cb_failure_details.current_status = 3
OR cb_failure_details.current_status = 0
<where>
<if test="currentStatus == null ">
and current_status in (0,3)
</if>
<if test="currentStatus != null ">
current_status = #{currentStatus}
</if>
<if test="startTime!= null and endTime != null">
and submission_time between #{startTime} and #{endTime}
</if>
<if test="submissionPid!= null ">
and submission_pid = #{submissionPid}
</if>
</where>
order by submission_time DESC
limit #{current},#{size}
</select>
<select id="selectStatusWaitTj" resultType="com.yeejoin.amos.boot.module.common.api.entity.FailureDetails">
......@@ -85,9 +108,19 @@
submission_branch,
submission_branch_id
FROM cb_failure_details
WHERE cb_failure_details.current_status = 1
<where>
<if test="currentStatus != null ">
and current_status = #{currentStatus}
</if>
<if test="startTime!= null and endTime != null">
and submission_time between #{startTime} and #{endTime}
</if>
<if test="submissionPid!= null ">
and submission_pid = #{submissionPid}
</if>
</where>
order by submission_time DESC
limit #{current},#{size}
</select>
<select id="selectStatusWaitWx" resultType="com.yeejoin.amos.boot.module.common.api.entity.FailureDetails">
......@@ -104,10 +137,22 @@
submission_branch,
submission_branch_id
FROM cb_failure_details
WHERE cb_failure_details.current_status = 6
OR cb_failure_details.current_status = 2
<where>
<if test="currentStatus == null ">
current_status IN (2,6)
</if>
<if test="currentStatus != null ">
current_status = #{currentStatus}
</if>
<if test="startTime!= null and endTime != null">
and submission_time between #{startTime} and #{endTime}
</if>
<if test="submissionPid!= null ">
and submission_pid = #{submissionPid}
</if>
</where>
order by submission_time DESC
limit #{current},#{size}
</select>
<select id="selectStatusCount" resultType="com.yeejoin.amos.boot.module.common.api.dto.StatusDto">
......@@ -115,6 +160,17 @@
count(cb_failure_details.current_status)
AS currentStatusCount
FROM cb_failure_details
<where>
<if test="currentStatus!= null ">
and current_status = #{currentStatus}
</if>
<if test="startTime!= null and endTime != null">
and submission_time between #{startTime} and #{endTime}
</if>
<if test="submissionPid!= null ">
and submission_pid = #{submissionPid}
</if>
</where>
GROUP BY cb_failure_details.current_status
</select>
......@@ -123,8 +179,20 @@
count(cb_failure_details.current_status)
AS currentStatusCount
FROM cb_failure_details
WHERE cb_failure_details.current_status = 6
OR cb_failure_details.current_status = 2
<where>
<if test="currentStatus == null ">
and current_status in (2,6)
</if>
<if test="currentStatus != null ">
and current_status #{currentStatus}
</if>
<if test="startTime!= null and endTime != null">
and submission_time between #{startTime} and #{endTime}
</if>
<if test="submissionPid!= null ">
and submission_pid = #{submissionPid}
</if>
</where>
GROUP BY cb_failure_details.current_status
</select>
......@@ -133,7 +201,17 @@
count(cb_failure_details.current_status)
AS currentStatusCount
FROM cb_failure_details
WHERE cb_failure_details.current_status = 1
<where>
<if test="currentStatus == null ">
and current_status = 1
</if>
<if test="startTime!= null and endTime != null">
and submission_time between #{startTime} and #{endTime}
</if>
<if test="submissionPid!= null ">
and submission_pid = #{submissionPid}
</if>
</where>
GROUP BY cb_failure_details.current_status
</select>
......@@ -143,8 +221,17 @@
count(cb_failure_details.current_status)
AS currentStatusCount
FROM cb_failure_details
WHERE cb_failure_details.current_status = 0
or cb_failure_details.current_status = 3
<where>
<if test="currentStatus == null ">
and current_status in (0,3)
</if>
<if test="startTime!= null and endTime != null">
and submission_time between #{startTime} and #{endTime}
</if>
<if test="submissionPid!= null ">
and submission_pid = #{submissionPid}
</if>
</where>
GROUP BY cb_failure_details.current_status
</select>
......@@ -154,7 +241,17 @@
count(cb_failure_details.current_status)
AS currentStatusCount
FROM cb_failure_details
WHERE submission_pid = #{submissionPid}
<where>
<if test="currentStatus!= null ">
and current_status = #{currentStatus}
</if>
<if test="startTime!= null and endTime != null">
and submission_time between #{startTime} and #{endTime}
</if>
<if test="submissionPid!= null ">
and submission_pid = #{submissionPid}
</if>
</where>
GROUP BY cb_failure_details.current_status
</select>
......
......@@ -14,10 +14,12 @@ public enum OrderByEnum {
*/
TIME_DESC("时间倒序", "1", "beginTime desc"),
TIME_ASC("时间正序", "2", "beginTime asc"),
PLAN_TASK_NUM_ASC("计划维保设施数正序", "3", "taskPlanNum asc"),
PLAN_TASK_NUM_DESC("计划维保设施数倒序", "4", "taskPlanNum desc"),
PLAN_TASK_NUM_ASC("检查设施数正序", "3", "taskPlanNum asc"),
PLAN_TASK_NUM_DESC("检查设施数倒序", "4", "taskPlanNum desc"),
FINISH_NUM_DESC("完成数倒序", "5", "finishNum desc"),
FINISH_NUM_ASC("完成数正序", "6", "finishNum asc");
FINISH_NUM_ASC("完成数正序", "6", "finishNum asc"),
PLAN_TASK_ITEM_NUM_ASC("检查项正序", "7", "itemNum asc"),
PLAN_TASK_ITEM_NUM_DESC("检查项正序", "8", "itemNum desc");
/**
* 名字
......
......@@ -4,9 +4,10 @@ import java.util.ArrayList;
import java.util.List;
public enum PlanTaskDetailIsFinishEnum {
UNFINISHED("未完成",0),
FINISHED("已完成",1),
OVERTIME("超时漏检",2);
UNFINISHED("未开始",0),
EXECUTION("执行中",1),
FINISHED("已完成",2),
OVERTIME("超时漏检",3);
/**
* 名称
......
......@@ -7,7 +7,7 @@ import java.util.Map;
public enum PlanTaskFinishStatusEnum {
NOTSTARTED("未开始",0),
UNDERWAY("处理中",1),
UNDERWAY("待执行",1),
FINISHED("已结束",2),
OVERTIME("已超时",3);
......
package com.yeejoin.amos.supervision.common.enums;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author DELL
*
*/
public enum TaskCheckTypeEnum {
/**
* 维保任务排序
*/
RCJC("日常检查", "1"),
ZXJC("专项检查", "2");
/**
* 名字
*/
private String name;
/**
* 编号
*/
private String code;
TaskCheckTypeEnum(String name, String code) {
this.code = code;
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public static List<Map<String, Object>> getEnumList() {
return Arrays.stream(TaskCheckTypeEnum.values()).map(e -> {
Map<String, Object> map = new HashMap<>();
map.put(e.getCode(), e.getName());
return map;
}).collect(Collectors.toList());
}
public static TaskCheckTypeEnum getEumByCode(String code) throws Exception {
Optional<TaskCheckTypeEnum> op = Arrays.stream(TaskCheckTypeEnum.values()).filter(e->e.getCode().equals(code)).findFirst();
return op.orElseThrow(()->new Exception("非法的条件"));
}
}
package com.yeejoin.amos.boot.module.tzs.api.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Map;
/**
* 联通回调方法传入参数
* @author fengwang
* @date 2021-08-06.
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "CtiDto", description = "CtiDto")
public class CtiDto {
@ApiModelProperty(value = "企业ID")
private Integer cid;
@ApiModelProperty(value = "呼叫类型(1:呼入;2:呼出)")
private String call_type;
@ApiModelProperty(value = "外呼主叫(呼入时为呼入的热线号码)")
private String sysphone;
@ApiModelProperty(value = "客户号码")
private String telephone;
@ApiModelProperty(value = "客户ID")
private String cusid;
@ApiModelProperty(value = "呼叫时间")
private String call_time;
@ApiModelProperty(value = "服务工号")
private String empcode;
@ApiModelProperty(value = "挂机时间")
private String hangup_time;
@ApiModelProperty(value = "挂机方(1:坐席挂机;2:客户挂机)")
private String hangup_flag;
@ApiModelProperty(value = "按键值(按键的数值,如果多个按键用-连接,如1-2)")
private String press_key;
@ApiModelProperty(value = "按键值名称(press_key中按键的含义,多个按键用-连接,如:转组-转人工)")
private String press_key_name;
@ApiModelProperty(value = "客户呼叫流水号")
private String connection_id;
@ApiModelProperty(value = "坐席呼叫流水号")
private String service_connection_id;
}
......@@ -51,4 +51,7 @@ public class VoiceRecordFileDto extends BaseDto {
@ApiModelProperty(value = "通话时长")
private String telTime;
@ApiModelProperty(value = "通话记录id")
private String connectId;
}
package com.yeejoin.amos.boot.module.tzs.api.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
/**
* 联通cti 服务类
*
* @author system_generator
* @date 2021-08-03
*/
public interface ICtiService {
/**
* 获取token
* @return
*/
String getAccessToken();
/**
* 获取登陆人坐席信息
* @return
*/
JSONObject getLoginInfo();
/**
* 根据话单id 查询话单详细信息
* @param connectionid
* @return
*/
JSONArray getCallInfo(String connectionid);
/**
* 根据connectionid 下载录音 key 为录音地址 value 为录音名称
* @return
*/
Map<String, String> downLoadRecordFile(String connectionid);
}
package com.yeejoin.amos.boot.module.common.biz.controller;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService;
import com.yeejoin.amos.boot.module.common.api.dto.CurrentStatusDto;
import com.yeejoin.amos.boot.module.common.api.enums.FailureStatuEnum;
import feign.Response;
import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -33,20 +20,24 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService;
import com.yeejoin.amos.boot.module.common.api.dto.CurrentStatusDto;
import com.yeejoin.amos.boot.module.common.api.dto.FailureDetailsDto;
import com.yeejoin.amos.boot.module.common.api.dto.FailureStatusCountDto;
import com.yeejoin.amos.boot.module.common.api.entity.FailureDetails;
import com.yeejoin.amos.boot.module.common.api.enums.FailureStatuEnum;
import com.yeejoin.amos.boot.module.common.biz.constats.Constants;
import com.yeejoin.amos.boot.module.common.biz.service.impl.FailureDetailsServiceImpl;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import feign.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -59,7 +50,6 @@ import io.swagger.annotations.ApiOperation;
@RequestMapping(value = "/common/failure-details")
public class FailureDetailsController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(FailureDetailsServiceImpl.class);
@Autowired
FailureDetailsServiceImpl failureDetailsServiceImpl;
......@@ -120,24 +110,28 @@ public class FailureDetailsController extends BaseController {
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @param size 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET", value = "分页查询", notes = "分页查询")
public ResponseModel<IPage<FailureDetailsDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam
(value = "size") int size, @RequestParam Integer type, Long currentStatus,
Integer submissionPid,
public ResponseModel<IPage<FailureDetailsDto>> queryForPage(@RequestParam(value = "current") Long current, @RequestParam
(value = "size") Long size, @RequestParam Integer type, Long currentStatus,
Integer userId,
String startTime, String endTime) {
Page<FailureDetails> page = new Page<FailureDetails>();
if (current > 0) {
page.setCurrent((current - 1) * size);
} else {
page.setCurrent(current);
}
page.setSize(size);
ReginParams userInfo = getSelectedOrgInfo();
IPage<FailureDetailsDto> failureDetailDTOsIPage = new Page<>();
//IPage<FailureDetails> failureDetailsIPage = failureDetailsServiceImpl.queryForFailureDetailsPage((current - 1) * size,size,userInfo,currentStatus, startTime,endTime,submissionPid,type);
IPage<FailureDetails> failureDetailsIPage = failureDetailsServiceImpl.queryForFailureDetailsPage(page, userInfo, currentStatus, startTime, endTime, submissionPid, type);
IPage<FailureDetails> failureDetailsIPage = failureDetailsServiceImpl.queryForFailureDetailsPage(page, userInfo, currentStatus, startTime, endTime, userId, type);
BeanUtils.copyProperties(failureDetailsIPage, FailureDetailsDto.class);
List<FailureDetails> records = failureDetailsIPage.getRecords();
......@@ -155,17 +149,6 @@ public class FailureDetailsController extends BaseController {
return ResponseHelper.buildResponse(failureDetailDTOsIPage);
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "列表全部数据查询", notes = "列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<FailureDetailsDto>> selectForList() {
return ResponseHelper.buildResponse(failureDetailsServiceImpl.queryForFailureDetailsList());
}
/**
* 根据状态查询当前下全部数据
......@@ -188,15 +171,15 @@ public class FailureDetailsController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "查询当前状态任务数量", notes = "查询当前状态任务数量")
@GetMapping(value = "/list/count")
public ResponseModel<List<CurrentStatusDto>> selectStatusCount(Integer type) {
return ResponseHelper.buildResponse(failureDetailsServiceImpl.queryStatusCount(getSelectedOrgInfo(), type));
public ResponseModel<List<CurrentStatusDto>> selectStatusCount(Integer type, Long currentStatus, String startTime, String endTime, Integer userId) {
return ResponseHelper.buildResponse(failureDetailsServiceImpl.queryStatusCount(getSelectedOrgInfo(), type, currentStatus, startTime, endTime, userId));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "流程信息", notes = "流程信息")
@GetMapping(value = "/processHistory")
public ResponseModel<Object> selectHistoryt(@RequestParam Long sequenceNbr) {
@GetMapping(value = "/processHistory/{sequenceNbr}")
public ResponseModel<Object> selectHistoryt(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(failureDetailsServiceImpl.getCurrentProcessHistoryTask(sequenceNbr));
}
......@@ -213,7 +196,6 @@ public class FailureDetailsController extends BaseController {
@GetMapping(value = "/getCurrentTask/{sequenceNbr}")
public ResponseModel<Object> getCurrentTask(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(failureDetailsServiceImpl.getCurrentTask(sequenceNbr));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
......@@ -223,13 +205,6 @@ public class FailureDetailsController extends BaseController {
return ResponseHelper.buildResponse(workflowFeignService.thighLine(instanceId));
}
// @TycloudOperation(ApiLevel = UserType.AGENCY)
//
// @GetMapping(value = "/activityHistory/gettingLineImg/{sequenceNbr}")
// public ResponseModel<Object> gothLineImg(@PathVariable Long sequenceNbr, HttpServletResponse resp) {
// String processId = failureDetailsServiceImpl.queryBySeq(sequenceNbr).getProcessId();
// return ResponseHelper.buildResponse(workflowFeignService.thighLineImg(processId, resp));
// }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "查询状态枚举", notes = "查询状态枚举")
......@@ -239,33 +214,31 @@ public class FailureDetailsController extends BaseController {
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping (value = "/downloadFile/{sequenceNbr}")
@GetMapping(value = "/downloadFile/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "流程图高亮图片", notes = "流程图高亮图片")
public void downloadFile(@PathVariable Long sequenceNbr, HttpServletRequest request, HttpServletResponse response) throws Exception {
public ResponseEntity<String> downloadFile(@PathVariable Long sequenceNbr, HttpServletRequest request, HttpServletResponse response) throws Exception {
String processId = failureDetailsServiceImpl.queryBySeq(sequenceNbr).getProcessId();
Response feignResponse = workflowFeignService.thighLineImg(processId);
OutputStream out = null;
try {
out = response.getOutputStream();
Response.Body body = feignResponse.body();
HttpHeaders heads = new HttpHeaders();
heads.setContentType(MediaType.valueOf(MediaType.IMAGE_JPEG_VALUE));
byte[] b = new byte[1024];
int len;
while ((len = body.asInputStream().read(b, 0, 1024)) != -1) {
out.write(b, 0, len);
}
out.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
// response.setContentType("application/octet-stream");//
// response.setHeader("content-type", "application/octet-stream");
// response.setContentType("text/xml");//
// response.setHeader("content-type", "text/xml");
// response.setCharacterEncoding("utf-8");
// response.setHeader("Content-Disposition", "attachment;fileName=workflow.svg");
// response.reset();
// byte[] b = new byte[1024];
// int len;
// while ((len = body.asInputStream().read(b, 0, 1024)) != -1) {
// out.write(b, 0, len);
// }
// out.flush();
return new ResponseEntity<String>(IOUtils.toString(body.asInputStream()), HttpStatus.OK);
//.toByteArray(body.asInputStream()), responseHeaders, HttpStatus.OK);
} catch (Exception e) {
e.printStackTrace();
}
throw new BaseException("Error exporting diagram", "500", processId);
}
}
}
......@@ -73,77 +73,62 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
public static Integer SELECY_ISUBMIT = 8;
public String[] roleName = {"maintenance_department_maintenance_personnel", "emergency_command_staff"};
/**
* 分页查询
* 分页查询接口
* @param type 查询类型
* @param currentStatus 状态
* @param startTime 起始时间
* @param startTime 结束时间
* @param userId 用户id
*/
public IPage<FailureDetails> queryAllPage(long size, long current) {
Page pages = new Page<>(current, size);
LambdaQueryWrapper<FailureDetails> lambdaQueryWrapper = new LambdaQueryWrapper();
lambdaQueryWrapper.orderByDesc(FailureDetails::getSubmissionTime);
return page(pages, lambdaQueryWrapper);
}
public IPage<FailureDetails> queryForFailureDetailsPage(Page<FailureDetails> page, ReginParams userInfo,Long currentStatus,
String startTime,String endTime,Integer submissionPid,Integer type) {
public IPage<FailureDetails> queryForFailureDetailsPage(Page<FailureDetails> page, ReginParams userInfo, Long currentStatus,
String startTime, String endTime, Integer userId, Integer type) {
//当传递类型参数为全部查询时
if (type.equals(SELECY_ALL)) {
return this.baseMapper.selectAllPage(page,currentStatus,startTime ,endTime,submissionPid);
List<FailureDetails> list = this.baseMapper.selectAllPage(page.getCurrent(), page.getSize(), currentStatus, startTime, endTime, userId);
IPage<FailureDetails> iPage = new Page<>();
iPage.setRecords(list);
return iPage;
}
//当传递类型参数为我提交时
if (type.equals(SELECY_ISUBMIT)) {
return baseMapper.selectISubPage(page, userInfo.getUserModel().getUserId());
List<FailureDetails> list = baseMapper.selectISubPage(page.getCurrent(), page.getSize(), currentStatus, startTime, endTime, Integer.parseInt(userInfo.getUserModel().getUserId()));
IPage<FailureDetails> iPage = new Page<>();
iPage.setRecords(list);
return iPage;
}
return this.queryForWaitManage(page, userInfo);
//否则就查询待处理
return this.queryForWaitManage(page, userInfo, currentStatus, startTime, endTime, userId);
}
/* public IPage<FailureDetails> queryForFailureDetailsPage(int current,int size, ReginParams userInfo,Long currentStatus,
String startTime,String endTime,Integer submissionPid,Integer type) {
if (type.equals(SELECY_ALL)) {
return this.baseMapper.selectAllPage(current,size,currentStatus,startTime ,endTime,submissionPid);
}
*//* if (type.equals(SELECY_ISUBMIT)) {
return baseMapper.selectISubPage(page, userInfo.getUserModel().getUserId());
}
return this.queryForWaitManage(page, userInfo);*//*
return null;
}*/
/**
* 我发起分页查询
*/
public IPage<FailureDetails> queryForPage(Page<FailureDetails> page, String submissionPid) {
if (submissionPid == null) {
return null;
}
Page pages = new Page<>(page.getCurrent(), page.getSize());
LambdaQueryWrapper<FailureDetails> lambdaQueryWrapper = new LambdaQueryWrapper();
lambdaQueryWrapper.eq(FailureDetails::getSubmissionPid, submissionPid);
lambdaQueryWrapper.orderByDesc(FailureDetails::getSubmissionTime);
return page(pages, lambdaQueryWrapper);
}
/**
* 待处理分页查询
*/
public IPage<FailureDetails> queryForWaitManage(Page<FailureDetails> page, ReginParams userInfo) {
public IPage<FailureDetails> queryForWaitManage(Page<FailureDetails> page, ReginParams userInfo, Long currentStatus,
String startTime, String endTime, Integer userId) {
if (userInfo.getRole().getRoleName().equals(roleName[0])) {
return baseMapper.selectStatusWaitWx();
IPage<FailureDetails> wxIpage = new Page<>();
List<FailureDetails> list = baseMapper.selectStatusWaitWx(page.getCurrent(), page.getSize(),currentStatus, startTime, endTime, userId);
wxIpage.setRecords(list);
return wxIpage;
} else if (userInfo.getRole().getRoleName().equals(roleName[1])) {
return baseMapper.selectStatusWaitTj(page);
currentStatus = FailureStatuEnum.WAITING_SUBMIT.getCode().longValue();
List<FailureDetails> list = baseMapper.selectStatusWaitTj(page.getCurrent(), page.getSize(), currentStatus, startTime, endTime, userId);
IPage<FailureDetails> iPage = new Page<>();
iPage.setRecords(list);
return iPage;
}
return baseMapper.selectInProcessing(page);
List<FailureDetails> list = baseMapper.selectInProcessing(page.getCurrent(), page.getSize(), currentStatus, startTime, endTime, userId);
IPage<FailureDetails> iPage = new Page<>();
iPage.setRecords(list);
return iPage;
}
/**
* 列表查询 示例
*/
public List<FailureDetailsDto> queryForFailureDetailsList() {
return this.queryForList("", false);
}
/**
* 根据状态查询
*/
......@@ -181,18 +166,18 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
/**
* 查询任务状态数量
*/
public List<CurrentStatusDto> queryStatusCount(ReginParams userInfo, Integer type) {
public List<CurrentStatusDto> queryStatusCount(ReginParams userInfo, Integer type, Long currentStatus, String startTime, String endTime, Integer userId) {
List<StatusDto> statusDtos = null;
if (type.equals(SELECY_STATUS) &&userInfo.getRole().getRoleName().equals(roleName[0])) {
statusDtos = baseMapper.selectStatusWx();
if (type.equals(SELECY_STATUS) && userInfo.getRole().getRoleName().equals(roleName[0])) {
statusDtos = baseMapper.selectStatusWx(currentStatus, startTime, endTime, userId);
} else if (type.equals(SELECY_STATUS) && userInfo.getRole().getRoleName().equals(roleName[1])) {
statusDtos = baseMapper.selectStatusFq();
statusDtos = baseMapper.selectStatusFq(currentStatus, startTime, endTime, userId);
} else if (type.equals(SELECY_ISUBMIT)) {
statusDtos = baseMapper.selectStatusFqp(Integer.parseInt(userInfo.getUserModel().getUserId()));
} else if (type.equals(SELECY_ALL)){
statusDtos = baseMapper.selectStatusCount();
}else {
statusDtos = baseMapper.selectStatusLeader();
statusDtos = baseMapper.selectStatusFqp(currentStatus, startTime, endTime, Integer.parseInt(userInfo.getUserModel().getUserId()));
} else if (type.equals(SELECY_ALL)) {
statusDtos = baseMapper.selectStatusCount(currentStatus, startTime, endTime, userId);
} else {
statusDtos = baseMapper.selectStatusLeader(currentStatus, startTime, endTime, userId);
}
List<CurrentStatusDto> currentStatusDtoList = new ArrayList<>();
statusDtos.forEach(e -> {
......@@ -527,16 +512,6 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
}
list.add(detail);
}
// datArray.stream().forEach(i -> {
// JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(i));
// if (detail.containsKey("operator") && !detail.getString("name").equals("维修中")) {
// // 从流程记录表中拿到处理人的名称
// FailureRepairlog failureRepairlog = failureRepairlogService
// .findByprocessAuditor(detail.getString("operator"));
// detail.replace("operator", failureRepairlog.getProcessAuditorName());
// list.add(detail);
// }
// });
}
return list;
}
......@@ -629,7 +604,5 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
}
}
return list;
}
}
\ No newline at end of file
......@@ -73,9 +73,9 @@ public class LinkageUnitServiceImpl extends BaseService<LinkageUnitDto, LinkageU
@Override
public Page<LinkageUnitDto> queryForLinkageUnitPage(IPage<LinkageUnitDto> page,
@Condition(Operator.eq) Boolean isDelete, @Condition(Operator.like) String unitName,
@Condition(Operator.eq) String linkageUnitTypeCode, @Condition(Operator.eq) String emergencyLinkageUnitCode,
@Condition(Operator.eq) String linkageUnitType, @Condition(Operator.eq) String emergencyLinkageUnitCode,
String inAgreement) {
Page<List<LinkageUnitDto>> linkageUnitList = linkageUnitMapper.getEmergencyLinkageUnitList(page,unitName, linkageUnitTypeCode, emergencyLinkageUnitCode);
Page<List<LinkageUnitDto>> linkageUnitList = linkageUnitMapper.getEmergencyLinkageUnitList(page,unitName, linkageUnitType, emergencyLinkageUnitCode);
List<Map> linkageUnitListMap =JSONArray.parseArray(JSONArray.toJSONString(linkageUnitList.getRecords()), Map.class);
List<Map<String, Object>> pageList = dynamicFormInstanceService.listAll(getGroupCode());
......
......@@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletResponse;
import com.yeejoin.amos.supervision.business.vo.CodeOrderVo;
import com.yeejoin.amos.supervision.business.vo.PlanTaskVo;
import com.yeejoin.amos.supervision.business.vo.PointInputItemVo;
import com.yeejoin.amos.supervision.common.enums.*;
import com.yeejoin.amos.supervision.exception.YeeException;
import com.yeejoin.amos.supervision.feign.RemoteSecurityService;
import org.slf4j.Logger;
......@@ -43,10 +44,6 @@ import com.yeejoin.amos.supervision.business.util.CommonResponseUtil;
import com.yeejoin.amos.supervision.business.util.FileHelper;
import com.yeejoin.amos.supervision.business.util.PlanTaskPageParamUtil;
import com.yeejoin.amos.supervision.business.util.Toke;
import com.yeejoin.amos.supervision.common.enums.OrderByEnum;
import com.yeejoin.amos.supervision.common.enums.PlanTaskDetailStatusEnum;
import com.yeejoin.amos.supervision.common.enums.PlanTaskFinishStatusEnum;
import com.yeejoin.amos.supervision.common.enums.TaskIsOrderEnum;
import com.yeejoin.amos.supervision.core.common.request.CommonPageable;
import com.yeejoin.amos.supervision.core.common.request.CommonRequest;
import com.yeejoin.amos.supervision.core.common.response.AppPointCheckRespone;
......@@ -56,6 +53,8 @@ import com.yeejoin.amos.supervision.dao.entity.PointClassify;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
@RestController
@RequestMapping(value = "/api/planTask")
......@@ -489,43 +488,71 @@ public class PlanTaskController extends AbstractBaseController {
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "维保任务查询-mobile", notes = "根据用户条件查询所有计划任务")
@ApiOperation(value = "消防监督任务查询-mobile", notes = "根据用户条件查询所有计划任务")
@RequestMapping(value = "/queryPlanTask", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse qryLoginUserPlanTask(
public ResponseModel qryLoginUserPlanTask(
@ApiParam(value = "人员") @RequestParam(value = "userId", required = false) Long userId,
@ApiParam(value = "开始日期") @RequestParam(value = "startTime") String startTime,
@ApiParam(value = "结束日期") @RequestParam(value = "endTime") String endTime,
@ApiParam(value = "维保状态") @RequestParam(value = "finishStatus", required = false) Integer finishStatus,
@ApiParam(value = "检查状态") @RequestParam(value = "finishStatus", required = false) Integer finishStatus,
@ApiParam(value = "排序条件") @RequestParam(value = "orderBy") String orderBy,
@ApiParam(value = "业主单位") @RequestParam(value = "companyId", required = false) String companyId,
@ApiParam(value = "被检查单位") @RequestParam(value = "companyId", required = false) String companyId,
@ApiParam(value = "检查人员") @RequestParam(value = "executorId", required = false) Long executorId,
@ApiParam(value = "任务类型") @RequestParam(value = "taskType", required = false) String taskType,
@ApiParam(value = "当前页") @RequestParam(value = "pageNumber") int pageNumber,
@ApiParam(value = "页大小") @RequestParam(value = "pageSize") int pageSize) throws Exception {
HashMap<String, Object> params = new HashMap<String, Object>();
ReginParams reginParams = getSelectedOrgInfo();
String loginOrgCode = getOrgCode(reginParams);
Map<String, Object> authMap = Bean.BeantoMap(reginParams.getPersonIdentity());
params.putAll(authMap);
// ReginParams reginParams = getSelectedOrgInfo();
// String loginOrgCode = getOrgCode(reginParams);
// Map<String, Object> authMap = Bean.BeantoMap(reginParams.getPersonIdentity());
// params.putAll(authMap);
params.put("userId", userId);
params.put("companyId", companyId);
params.put("orgCode", loginOrgCode);
params.put("userId", userId);
params.put("taskType", taskType);
params.put("startTime", startTime);
params.put("endTime", endTime);
params.put("executorId", executorId);
params.put("finishStatus", finishStatus);
params.put("taskType", TaskCheckTypeEnum.getEumByCode(taskType).getName());
params.put("orderBy", OrderByEnum.getEumByCode(orderBy).getOderBy());
CommonPageable pageable = new CommonPageable(pageNumber, pageSize);
return ResponseHelper.buildResponse(planTaskService.getPlanTasks(params, pageable));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据检查任务ID查询计划任务详情和任务点(<font color='blue'>手机app</font>)", notes = "根据检查任务ID查询计划任务详情和任务点(<font color='blue'>手机app</font>)")
@RequestMapping(value = "/detail", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public ResponseModel qryPlanTaskDetailById(
@ApiParam(value = "检查计划任务ID", required = true) @RequestParam Long planTaskId) {
ResponseModel result = null;
try {
return CommonResponseUtil.success(planTaskService.getPlanTasks(params, pageable));
Map<String, Object> response = new HashMap<String, Object>();
Map task = planTaskService.queryPlanTaskById(planTaskId);
if (ObjectUtils.isEmpty(task) || ObjectUtils.isEmpty(task.get("planTaskId"))) {
result = ResponseHelper.buildResponse("该计划已刷新,请重新选择!!!");
} else {
List points = planTaskService.getPlanTaskPoints(planTaskId);
String[] userIds = task.get("userId").toString().split(",");
for (String userId : userIds) {
task.put("userId", userId);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
task.put("checkDate", sdf.format(task.get("checkDate") != null ? sdf.parse(task.get("checkDate").toString()) : new Date()));
response.put("planTask", task);
response.put("points", points);
result = ResponseHelper.buildResponse(response);
}
} catch (Exception e) {
return CommonResponseUtil.failure(e.getMessage());
e.printStackTrace();
}
return result;
}
public static Object nvl(Object param) {
return param != null ? param : null;
}
/**
* 查询任务列表
*/
......
......@@ -61,6 +61,8 @@ import com.yeejoin.amos.supervision.dao.entity.PointClassify;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
@RestController
@RequestMapping(value = "/api/point")
......@@ -804,4 +806,11 @@ public class PointController extends AbstractBaseController {
return CommonResponseUtil.success(iPointService.getRegionTress());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询巡检点详情<font color='blue'>手机app</font>)", notes = "查询巡检点详情<font color='blue'>手机app</font>)")
@GetMapping(value = "/detail/item", produces = "application/json;charset=UTF-8")
public ResponseModel queryItemDetailByPointId(@ApiParam(value = "巡检点id", required = true) @RequestParam(name = "pointId") Long id) {
return ResponseHelper.buildResponse(iPointService.queryItemDetailByPointId(id));
}
}
......@@ -156,4 +156,6 @@ public interface PointMapper extends BaseMapper {
* 根据路线id查询所有点
*/
List<Long> getPointoriginalidbyrouteid(@Param(value = "routeId") Long routeId);
List<Map<String, Object>> queryItemsByPointId(@Param(value = "pointId") Long pointId);
}
......@@ -30,6 +30,7 @@ import com.yeejoin.amos.supervision.business.vo.CalDateVo;
import com.yeejoin.amos.supervision.business.vo.CodeOrderVo;
import com.yeejoin.amos.supervision.business.vo.LeavePlanTaskVo;
import com.yeejoin.amos.supervision.business.vo.PlanTaskVo;
import com.yeejoin.amos.supervision.common.enums.PlanTaskFinishStatusEnum;
import com.yeejoin.amos.supervision.core.common.request.CommonPageable;
import com.yeejoin.amos.supervision.core.common.response.AppCheckInputRespone;
import com.yeejoin.amos.supervision.core.common.response.AppPointCheckRespone;
......@@ -577,13 +578,27 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
if (total == 0) {
return new PageImpl<>(content, pageParam, total);
}
params.put("offset", pageParam.getOffset());
params.put("pageSize", pageParam.getPageSize());
content = planTaskMapper.getPlanTasks(params);
content.forEach(c -> {
if (c.containsKey("finishStatus")) {
String finishStatusDesc = PlanTaskFinishStatusEnum.getName(Integer.parseInt(c.get("finishStatus").toString()));
c.put("finishStatusDesc", finishStatusDesc);
}
});
return new PageImpl<>(content, pageParam, total);
}
@Override
public Map queryPlanTaskById(Long planTaskId) {
return planTaskMapper.queryPlanTaskById(planTaskId);
Map map = new HashMap();
map = planTaskMapper.queryPlanTaskById(planTaskId);
if (map.containsKey("finishStatus")) {
String finishStatusDesc = PlanTaskFinishStatusEnum.getName(Integer.parseInt(map.get("finishStatus").toString()));
map.put("finishStatusDesc", finishStatusDesc);
}
return map;
}
@Override
......
......@@ -131,6 +131,9 @@ public class PointServiceImpl implements IPointService {
@Autowired
Sequence sequence;
@Value("${file.url}")
private String fileUrl;
@Override
@Transactional
public Point addPoint(PointParam pointParam) {
......@@ -1205,4 +1208,17 @@ public class PointServiceImpl implements IPointService {
iPointDao.delPointByPointNo(id);
}
@Override
public List<Map<String, Object>> queryItemDetailByPointId(Long id) {
List<Map<String, Object>> list = pointMapper.queryItemsByPointId(id);
if (0 < list.size()) {
for (Map<String, Object> map : list) {
if (map.containsKey("picJson") && !ObjectUtils.isEmpty(map.get("picJson"))) {
map.put("remark", fileUrl + map.get("remark"));
}
}
}
return list;
}
}
......@@ -327,4 +327,6 @@ public interface IPointService {
*/
void delPointByPointNo(Long id);
List<Map<String, Object>> queryItemDetailByPointId(Long id);
}
package com.yeejoin.amos.boot.module.tzs.biz.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.CtiDto;
import com.yeejoin.amos.boot.module.tzs.api.service.ICtiService;
import com.yeejoin.amos.boot.module.tzs.biz.utils.HttpUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.security.MessageDigest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 联通API controller
*
* @author kongfm
* @date 2021-08-25
*/
@RestController
@Api(tags = "联通CTIApi")
@RequestMapping(value = "/cti")
public class CtiController extends BaseController {
@Autowired
private ICtiService ctiService;
/**
* 获取坐席登陆信息
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getCtiInfo")
@ApiOperation(httpMethod = "GET", value = "获取坐席登陆信息", notes = "获取坐席登陆信息")
public ResponseModel<JSONObject> getCtiInfo() {
JSONObject loginData = ctiService.getLoginInfo();
return ResponseHelper.buildResponse(loginData);
}
/**
* 获取坐席登陆信息
* 暴露公网
* @return
*/
@TycloudOperation(ApiLevel = UserType.ANONYMOUS , needAuth = false)
@PostMapping(value = "/ctiBack")
@ApiOperation(httpMethod = "POST", value = "获取电话结束后回调信息", notes = "获取电话结束后回调信息")
public JSONObject ctiBack(@RequestBody CtiDto ctiDto) {
System.out.println("====================================");
System.out.println(ctiDto);
JSONObject result = new JSONObject();
result.put("code","0");
result.put("message","调用成功");
return result;
}
/**
* 获取坐席登陆信息
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/info/{connectId}")
@ApiOperation(httpMethod = "GET", value = "获取通话话单详情", notes = "获取通话话单详情")
public ResponseModel<JSONObject> getCallInfo(@PathVariable String connectId) {
JSONArray recordInfos = ctiService.getCallInfo(connectId);
JSONObject recordInfo = recordInfos.getJSONObject(0);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
return ResponseHelper.buildResponse(recordInfo);
}
}
package com.yeejoin.amos.boot.module.tzs.biz.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledFormDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.VoiceRecordFileDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.VoiceRecordFile;
import com.yeejoin.amos.boot.module.tzs.api.service.ICtiService;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.AlertCalledServiceImpl;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.VoiceRecordFileServiceImpl;
import io.swagger.annotations.Api;
......@@ -25,9 +28,13 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
......@@ -47,6 +54,9 @@ public class VoiceRecordFileController extends BaseController {
@Autowired
AlertCalledServiceImpl iAlertCalledService;
@Autowired
ICtiService ctiService;
/**
* 新增通话记录附件
*
......@@ -103,4 +113,61 @@ public class VoiceRecordFileController extends BaseController {
});
return ResponseHelper.buildResponse(dtoList);
}
/**
* 新增通话记录
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/saveRecord")
@ApiOperation(httpMethod = "POST", value = "新增通话记录附件", notes = "新增通话记录附件")
public ResponseModel<VoiceRecordFileDto> saveRecord(@RequestBody VoiceRecordFileDto model) {
if (ValidationUtil.isEmpty(model.getAlertId())
|| ValidationUtil.isEmpty(model.getConnectId())){
throw new BadRequest("参数校验失败.");
}
// 获取通话人信息
JSONArray recordInfos = ctiService.getCallInfo(model.getConnectId());
if(recordInfos == null || recordInfos.size() == 0) {
throw new BadRequest("未找到通话详单信息");
}
JSONObject recordInfo = recordInfos.getJSONObject(0);
model.setTel(recordInfo.getString("telephone"));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
Date telStartTime = null;
Date telEndTime = null;
try {
telStartTime = sdf.parse(recordInfo.getString("connectTime"));
telEndTime = sdf.parse(recordInfo.getString("hangupTime"));
} catch (ParseException e) {
throw new BadRequest("日期转换错误");
}
model.setTelStartTime(telStartTime);
model.setTelEndTime(telEndTime);
if(1 == recordInfo.getInteger("callType")) {
model.setFileType("客户呼入");
} else if(2 == recordInfo.getInteger("callType")) {
model.setFileType("坐席呼出");
}
// 获取附件
Map<String, String> downloadFile = ctiService.downLoadRecordFile(model.getConnectId());
if(downloadFile.isEmpty()) {
throw new BadRequest("未找到附件文件");
}
for(Map.Entry<String,String> file : downloadFile.entrySet()) {
model.setFilePath(file.getKey());
}
AlertCalledFormDto alertDto = iAlertCalledService.selectAlertCalledByIdNoCache(model.getAlertId());
if(alertDto == null || alertDto.getAlertCalledDto() == null) {
throw new BadRequest("未找到相关警情");
}
model.setAlertStage(alertDto.getAlertCalledDto().getAlertStage());
model.setAlertStageCode(alertDto.getAlertCalledDto().getAlertStageCode());
model.setSourceId(-1l);
model = voiceRecordFileServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
}
package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledFormDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledObjsDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledQueryDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.FormValue;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.tzs.api.entity.Elevator;
import com.yeejoin.amos.boot.module.tzs.api.enums.AlertStageEnums;
import com.yeejoin.amos.boot.module.tzs.api.enums.DispatchPaperEnums;
import com.yeejoin.amos.boot.module.tzs.api.mapper.AlertCalledMapper;
import com.yeejoin.amos.boot.module.tzs.api.service.IAlertCalledService;
import com.yeejoin.amos.boot.module.tzs.api.service.ICtiService;
import com.yeejoin.amos.boot.module.tzs.biz.utils.BeanDtoVoUtils;
import com.yeejoin.amos.boot.module.tzs.biz.utils.HttpUtils;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.FileInfoModel;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 联通cti 服务实现类
*
* @author kongfm
* @date 2021-08-25
*/
@Service
public class CtiServiceImpl implements ICtiService {
@Autowired
RedisUtils redisUtils;
/**
* token 过期时间, cti 系统为7200 ,tzs 系统小于7200 防止获取到无效token
*/
private long time = 6000l;
private final String APP_KEY = "4e805006-3fef-ae43-3915-a153731007c4";
private final String SECRET_KEY = "7bd29115-99ee-4f7d-1fb1-7c4719d5f43a";
private String ctiUrl = "http://36.46.151.113:8000";
@Override
public String getAccessToken() {
if(redisUtils.hasKey(RedisKey.CTI_TOKEN)){
Object obj= redisUtils.get(RedisKey.CTI_TOKEN);
return obj.toString();
} else {
String tokenAccessUrl = ctiUrl+ "/openauth/getAccessToken";
Map<String,Object> params = new HashMap<>();
params.put("appKey",APP_KEY);
String randomStr = System.currentTimeMillis() + "";
params.put("randomStr",randomStr);
String signStr = APP_KEY+randomStr+SECRET_KEY;
String sign = encrypt32(signStr).toLowerCase();
params.put("sign",sign);
String responseStr = HttpUtils.doPost(tokenAccessUrl,params);
JSONObject response = null;
try {
response = JSONObject.parseObject(responseStr);
} catch (Exception e) {
throw new BadRequest("获取token 出错:" + e.getMessage());
}
if(response.getInteger("code") == 0) { // 获取token 成功
try {
String token = response.getJSONObject("data").getString("accessToken");
redisUtils.set(RedisKey.CTI_TOKEN, token,time);
return token;
} catch (Exception e) {
throw new BadRequest("获取token 出错:" + e.getMessage());
}
} else {
throw new BadRequest("获取token 出错:" + response.getString("msg"));
}
}
}
@Override
public JSONObject getLoginInfo() {
String token = this.getAccessToken();
// gid code extphone 目前写死 后面根据用户获取
String gid = "61,默认,0";
String code = "1001";
String extphone = "10001001";
String loginUrl = ctiUrl + "/cti/login" + "?accessToken=" + token;
Map<String,Object> params = new HashMap<>();
params.put("accessToken",token);
params.put("gid",gid);
params.put("code",code);
params.put("extphone",extphone);
String responseStr = HttpUtils.doPost(loginUrl,params);
JSONObject response = null;
try {
response = JSONObject.parseObject(responseStr);
} catch (Exception e) {
throw new BadRequest("登陆出错:" + e.getMessage());
}
if(response.getInteger("code") == 0) { // 登陆成功
try {
JSONObject loginData = response.getJSONObject("loginData");
return loginData;
} catch (Exception e) {
throw new BadRequest("获取loginData 出错:" + e.getMessage());
}
} else { //登陆失败
throw new BadRequest("登陆失败出错:" + response.getString("message"));
}
}
@Override
public JSONArray getCallInfo(String connectionid) {
String token = this.getAccessToken();
String url = ctiUrl + "/onOpenAuth/cti/openApi/querycalllist1";
JSONObject params = new JSONObject();
params.put("connectionid",connectionid);
Map<String,String> header = new HashMap<>();
header.put("accessToken",token);
String responseStr = HttpUtils.doPostWithHeader(url,params.toJSONString(),header);
JSONObject response = null;
try {
response = JSONObject.parseObject(responseStr);
} catch (Exception e) {
throw new BadRequest("获取话单出错:" + e.getMessage());
}
if(response.getInteger("code") == 0) { // 登陆成功
try {
JSONArray loginData = response.getJSONArray("data");
return loginData;
} catch (Exception e) {
throw new BadRequest("获取loginData 出错:" + e.getMessage());
}
} else { //登陆失败
throw new BadRequest("获取话单出错:" + response.getString("msg"));
}
}
@Override
public Map<String, String> downLoadRecordFile(String connectionid) {
String token = this.getAccessToken();
String url = ctiUrl + "/onOpenAuth/cti/openApi/downloadvoice";
JSONObject params = new JSONObject();
params.put("connectionid",connectionid);
Map<String,String> header = new HashMap<>();
header.put("accessToken",token);
byte[] bytes = HttpUtils.doPostWithHeaderDownload(url,params.toJSONString(),header);
if(bytes == null || bytes.length == 0) {
throw new BadRequest("获取录音失败");
} else {
MultipartFile file = new MockMultipartFile("录音.MP3","录音.MP3","application/octet-stream" ,bytes);
FeignClientResult<Map<String, String>> result = Systemctl.fileStorageClient.updateCommonFile(file);
Map<String, String> map = result.getResult();
return map;
}
}
/**
* 获取MD加密串
* @param encryptStr
* @return
*/
private String encrypt32(String encryptStr) {
MessageDigest md5;
try {
md5 = MessageDigest.getInstance("MD5");
byte[] md5Bytes = md5.digest(encryptStr.getBytes());
StringBuffer hexValue = new StringBuffer();
for (int i = 0; i < md5Bytes.length; i++) {
int val = ((int) md5Bytes[i]) & 0xff;
if (val < 16)
hexValue.append("0");
hexValue.append(Integer.toHexString(val));
}
encryptStr = hexValue.toString();
} catch (Exception e) {
throw new RuntimeException(e);
}
return encryptStr;
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.tzs.biz.utils;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.security.GeneralSecurityException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class HttpUtils {
private static PoolingHttpClientConnectionManager connMgr;
private static RequestConfig requestConfig;
private static final int MAX_TIMEOUT = 50000;
private static final Logger logger = LoggerFactory.getLogger(HttpUtils.class);
static {
// 设置连接池
connMgr = new PoolingHttpClientConnectionManager();
// 设置连接池大小
connMgr.setMaxTotal(100);
connMgr.setDefaultMaxPerRoute(connMgr.getMaxTotal());
// Validate connections after 1 sec of inactivity
connMgr.setValidateAfterInactivity(5000);
RequestConfig.Builder configBuilder = RequestConfig.custom();
// 设置连接超时
configBuilder.setConnectTimeout(MAX_TIMEOUT);
// 设置读取超时
configBuilder.setSocketTimeout(MAX_TIMEOUT);
// 设置从连接池获取连接实例的超时
configBuilder.setConnectionRequestTimeout(MAX_TIMEOUT);
requestConfig = configBuilder.build();
}
/**
* 发送 GET 请求(HTTP),不带输入数据
*
* @param url
* @return
*/
public static String doGet(String url) {
return doGet(url, new HashMap<String, Object>());
}
/**
* 发送 GET 请求(HTTP),K-V形式
*
* @param url
* @param params
* @return
*/
public static String doGet(String url, Map<String, Object> params) {
String apiUrl = url;
StringBuffer param = new StringBuffer();
int i = 0;
for (String key : params.keySet()) {
if (i == 0)
param.append("?");
else
param.append("&");
param.append(key).append("=").append(params.get(key));
i++;
}
apiUrl += param;
String result = null;
HttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory())
.setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
try {
HttpGet httpGet = new HttpGet(apiUrl);
HttpResponse response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
result = IOUtils.toString(instream, "UTF-8");
}
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
/**
* 发送 POST 请求(HTTP),不带输入数据
*
* @param apiUrl
* @return
*/
public static String doPost(String apiUrl) {
return doPost(apiUrl, new HashMap<String, Object>());
}
/**
* 发送 POST 请求,K-V形式
*
* @param apiUrl
* API接口URL
* @param params
* 参数map
* @return
*/
public static String doPost(String apiUrl, Map<String, Object> params) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory())
.setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
String httpStr = null;
HttpPost httpPost = new HttpPost(apiUrl);
CloseableHttpResponse response = null;
try {
httpPost.setConfig(requestConfig);
List<NameValuePair> pairList = new ArrayList<>(params.size());
for (Map.Entry<String, Object> entry : params.entrySet()) {
NameValuePair pair = new BasicNameValuePair(entry.getKey(), entry.getValue()!=null?entry.getValue().toString():"");
pairList.add(pair);
}
httpPost.setEntity(new UrlEncodedFormEntity(pairList, Charset.forName("UTF-8")));
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
}
return httpStr;
}
/**
* 发送 POST 请求,K-V形式
*
* @param apiUrl
* API接口URL
* @param params
* 参数map
* @return
*/
public static String doPostWithHeader(String apiUrl, Map<String, Object> params, Map<String, String> headerMap) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory())
.setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
String httpStr = null;
HttpPost httpPost = new HttpPost(apiUrl);
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
httpPost.setHeader(entry.getKey(), entry.getValue());
}
CloseableHttpResponse response = null;
try {
httpPost.setConfig(requestConfig);
List<NameValuePair> pairList = new ArrayList<>(params.size());
for (Map.Entry<String, Object> entry : params.entrySet()) {
NameValuePair pair = new BasicNameValuePair(entry.getKey(), entry.getValue()!=null?entry.getValue().toString():"");
pairList.add(pair);
}
httpPost.setEntity(new UrlEncodedFormEntity(pairList, Charset.forName("UTF-8")));
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
}
return httpStr;
}
/**
* 发送 POST 请求,JSON形式,接收端需要支持json形式,否则取不到数据
*
* @param apiUrl
* @param json
* json对象
* @return
*/
public static String doPost(String apiUrl, String json) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()).setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
String httpStr = null;
HttpPost httpPost = new HttpPost(apiUrl);
CloseableHttpResponse response = null;
try {
httpPost.setConfig(requestConfig);
StringEntity stringEntity = new StringEntity(json, "UTF-8");// 解决中文乱码问题
stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
}
return httpStr;
}
/**
* 发送 POST 请求,JSON形式,接收端需要支持json形式,否则取不到数据
*
* @param apiUrl
* @param json
* json对象
* @return
*/
public static String doPostWithHeader(String apiUrl, String json, Map<String, String> headerMap) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()).setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
String httpStr = null;
HttpPost httpPost = new HttpPost(apiUrl);
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
httpPost.setHeader(entry.getKey(), entry.getValue());
}
CloseableHttpResponse response = null;
try {
httpPost.setConfig(requestConfig);
StringEntity stringEntity = new StringEntity(json, "UTF-8");// 解决中文乱码问题
stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
}
return httpStr;
}
/**
* 发送post 请求并且获取下载字节流
* @param apiUrl
* @param json
* @param headerMap
* @return
*/
public static byte[] doPostWithHeaderDownload(String apiUrl, String json, Map<String, String> headerMap) {
InputStream inputStream = null;
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()).setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
String httpStr = null;
HttpPost httpPost = new HttpPost(apiUrl);
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
httpPost.setHeader(entry.getKey(), entry.getValue());
}
CloseableHttpResponse response = null;
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
try {
httpPost.setConfig(requestConfig);
StringEntity stringEntity = new StringEntity(json, "UTF-8");// 解决中文乱码问题
stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
inputStream = entity.getContent();
byte[] buff = new byte[1024];
int rc = 0;
while ((rc = inputStream.read(buff, 0, buff.length)) > 0) {
swapStream.write(buff, 0, rc);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
}
return swapStream.toByteArray();
}
/**
* 创建SSL安全连接
*
* @return
*/
private static SSLConnectionSocketFactory createSSLConnSocketFactory() {
SSLConnectionSocketFactory sslsf = null;
try {
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
}).build();
sslsf = new SSLConnectionSocketFactory(sslContext, new HostnameVerifier() {
@Override
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
});
} catch (GeneralSecurityException e) {
e.printStackTrace();
}
return sslsf;
}
}
......@@ -28,6 +28,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<version>2.0.8</version>
</dependency>
</dependencies>
<modules>
......
......@@ -158,4 +158,14 @@
ALTER TABLE `p_plan_task_detail` ADD COLUMN `major_danger_num` int(11) DEFAULT 0 COMMENT '重大隐患个数' AFTER `safety_danger_num`;
</sql>
</changeSet>
<changeSet author="keyong" id="1629863569-1">
<preConditions onFail="MARK_RAN">
<columnExists tableName="p_plan_task_detail" columnName="is_finish"/>
</preConditions>
<comment>p_plan_task_detail modify column is_finish</comment>
<sql>
alter table `p_plan_task_detail` modify column `is_finish` int(11) COMMENT '0-未开始,1-执行中,2-已完成,3-超时漏检(有一个检查项漏检则为漏检)' after `create_date`;
</sql>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
......@@ -178,6 +178,7 @@
pt.id planTaskId,
pt.org_code orgCode,
p.name taskName,
p.check_type_name checkTypeName,
pt.status,
pt.user_id userId,
date_format(
......@@ -200,11 +201,14 @@
pt.route_id,
pt.user_name userName,
r.owner_id,
R.owner_name as ownerName
R.owner_name as ownerName,
ptd.item_num AS itemNum,
ptd.executor_id AS executorId
FROM
p_plan_task pt
INNER JOIN p_plan p ON pt.plan_id = p.id
INNER JOIN p_route r on r.id = pt.route_id
INNER JOIN p_plan_task_detail ptd ON ptd.task_no = pt.id
) a
<include refid="mobile-plan-task-where" />
limit #{offset},#{pageSize}
......@@ -212,6 +216,9 @@
<sql id="mobile-plan-task-where">
<where>
<if test="userId != null and userId > 0 "> and find_in_set(#{userId},a.userId)>0</if>
<if test="executorId != null and executorId > 0 "> and find_in_set(#{executorId},a.executorId)>0</if>
<if test="companyId != null"> and a.owner_id = #{companyId}</if>
<if test="taskType != null"> and a.checkTypeName = #{taskType}</if>
<if test="finishStatus != null"> and a.finishStatus = #{finishStatus}</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != '' ">
AND (
......@@ -233,15 +240,15 @@
)
)
</if>
<choose>
<when test="identityType==1">
And (a.orgCode LIKE CONCAT( #{orgCode}, '-%' ) or a.orgCode= #{orgCode} )
<if test="companyId != null"> and a.owner_id = #{companyId}</if>
</when>
<when test="identityType==2">
And a.owner_id = #{companyId}
</when>
</choose>
<!-- <choose>-->
<!-- <when test="identityType==1">-->
<!-- And (a.orgCode LIKE CONCAT( #{orgCode}, '-%' ) or a.orgCode= #{orgCode} )-->
<!-- <if test="companyId != null"> and a.owner_id = #{companyId}</if>-->
<!-- </when>-->
<!-- <when test="identityType==2">-->
<!-- And a.owner_id = #{companyId}-->
<!-- </when>-->
<!-- </choose>-->
</where>
<if test="orderBy != null and orderBy != ''"> order by ${orderBy} </if>
</sql>
......@@ -258,11 +265,13 @@
pt.org_code as orgCode,
pt.begin_time as beginTime,
pt.end_time as endTime,
r.owner_id
r.owner_id,
ptd.item_num AS itemNum
FROM
p_plan_task pt
INNER JOIN p_plan p ON pt.plan_id = p.id
INNER JOIN p_route r on r.id = pt.route_id
INNER JOIN p_plan_task_detail ptd ON ptd.task_no = pt.id
) a
<include refid="mobile-plan-task-where" />
</select>
......@@ -282,6 +291,10 @@
count(a.finish) taskPlanNum,
a.finishStatus,
a.batchNo,
a.itemNum,
a.remain,
a.safetyNum,
a.majorNum,
a.inOrder
FROM
(
......@@ -304,6 +317,10 @@
pt.finish_num finishNum,
pt.finish_status finishStatus,
pt.batch_no batchNo,
ptd.item_num itemNum,
(ptd.item_num - ptd.executed_num) remain,
ptd.safety_danger_num safetyNum,
ptd.major_danger_num majorNum,
CASE ptd.`status`
WHEN 1 THEN
1
......@@ -527,7 +544,6 @@
<if test="endTime != null and endTime != '' "> and pt.begin_time <![CDATA[<=]]> #{endTime} </if>
</where>
) a
</select>
<select id="getPointPlanTaskInfo" resultType="com.yeejoin.amos.supervision.business.entity.mybatis.PointCheckDetailBo" parameterType="long">
......
......@@ -1139,4 +1139,28 @@
WHERE
prp.route_id = #{routeId}
</select>
<select id="queryItemsByPointId" resultType="map">
SELECT
ppi.id,
ppi.input_item_id itemId,
ppi.point_id pointId,
pii.name itemName,
pii.item_type itemTyp,
pii.data_json dataJson,
pii.remark remark,
pii.picture_json picJson,
CASE pii.`input_type`
WHEN 0 THEN
'手动录入'
ELSE
'同步'
END inputType
FROM
p_point_inputitem ppi
LEFT JOIN p_input_item pii ON pii.id = ppi.input_item_id
WHERE
ppi.point_id = #{pointId} AND pii.is_delete = 0
ORDER BY pii.order_no
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment