8 changed files with 578 additions and 0 deletions
@ -0,0 +1,15 @@ |
|||||
|
package com.elink.esua.epdc.constant; |
||||
|
|
||||
|
/** |
||||
|
* @Description 新新向党系统调用常用参数 |
||||
|
* @Author yzm |
||||
|
* @Date 2023/5/22 13:39 |
||||
|
*/ |
||||
|
public interface XxxdConstant { |
||||
|
String APP_KEY = "bda1e5471a864c"; |
||||
|
String APP_SECRET = "42bc9a57cabb21cd08f8d6d65d615142"; |
||||
|
|
||||
|
// 反馈调用他们的接口
|
||||
|
String XXXD_QUESTION_FEED_BACK_URL = "https://xxxd.dtdjzx.gov.cn/xxxd/api/v1/feedback/question"; |
||||
|
} |
||||
|
|
@ -0,0 +1,153 @@ |
|||||
|
package com.elink.esua.epdc.dto.events; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 新新向党随手拍的接收数据 |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2023-05-22 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class XxxdEventDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
*/ |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 问题标识,可唯一识别用户问题的id |
||||
|
*/ |
||||
|
private String questionId; |
||||
|
|
||||
|
/** |
||||
|
* 问题描述 |
||||
|
*/ |
||||
|
private String description; |
||||
|
|
||||
|
/** |
||||
|
* 上报人姓名 |
||||
|
*/ |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 上报人联系方式 |
||||
|
*/ |
||||
|
private String contact; |
||||
|
|
||||
|
/** |
||||
|
* 问题类别:1生态环境,2矛盾纠纷,3社会治安,4其他 |
||||
|
*/ |
||||
|
private String type; |
||||
|
|
||||
|
/** |
||||
|
* 发生位置 |
||||
|
*/ |
||||
|
private String location; |
||||
|
|
||||
|
/** |
||||
|
* 经度 |
||||
|
*/ |
||||
|
private String longitude; |
||||
|
|
||||
|
/** |
||||
|
* 纬度 |
||||
|
*/ |
||||
|
private String latitude; |
||||
|
|
||||
|
/** |
||||
|
* 发布时间:yyyy-MM-dd HH:mm:ss |
||||
|
*/ |
||||
|
private String pubTime; |
||||
|
|
||||
|
// /**
|
||||
|
// * 问题图片列表
|
||||
|
// */
|
||||
|
// private String pics;
|
||||
|
//
|
||||
|
// /**
|
||||
|
// * 问题语音列表
|
||||
|
// */
|
||||
|
// private String audios;
|
||||
|
/** |
||||
|
* 问题图片列表 |
||||
|
*/ |
||||
|
private String[] pics; |
||||
|
|
||||
|
/** |
||||
|
* 问题语音列表 |
||||
|
*/ |
||||
|
private String[] audios; |
||||
|
|
||||
|
/** |
||||
|
* 北上速办事件id |
||||
|
*/ |
||||
|
private String bssbEventId; |
||||
|
|
||||
|
/** |
||||
|
* 处理状态:0-未处理;1-已处理;5-不予处理 |
||||
|
*/ |
||||
|
private String status; |
||||
|
|
||||
|
/** |
||||
|
* 处理结果 |
||||
|
*/ |
||||
|
private String processResult; |
||||
|
|
||||
|
/** |
||||
|
* 处理时间:yyyy-MM-dd HH:mm:ss |
||||
|
*/ |
||||
|
private String processTime; |
||||
|
|
||||
|
/** |
||||
|
* 处理人 |
||||
|
*/ |
||||
|
private String processUser; |
||||
|
|
||||
|
/** |
||||
|
* 是否已同步,0:未同步;1,已同步 |
||||
|
*/ |
||||
|
private Integer sync; |
||||
|
|
||||
|
/** |
||||
|
* 删除标识 0:未删除,1:已删除 |
||||
|
*/ |
||||
|
private String delFlag; |
||||
|
|
||||
|
/** |
||||
|
* 乐观锁 |
||||
|
*/ |
||||
|
private Integer revision; |
||||
|
|
||||
|
/** |
||||
|
* 创建人 |
||||
|
*/ |
||||
|
private String createdBy; |
||||
|
|
||||
|
/** |
||||
|
* 创建时间 |
||||
|
*/ |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createdTime; |
||||
|
|
||||
|
/** |
||||
|
* 更新人 |
||||
|
*/ |
||||
|
private String updatedBy; |
||||
|
|
||||
|
/** |
||||
|
* 更新时间 |
||||
|
*/ |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date updatedTime; |
||||
|
|
||||
|
} |
@ -0,0 +1,127 @@ |
|||||
|
package com.elink.esua.epdc.modules.events.controller; |
||||
|
|
||||
|
import cn.hutool.core.codec.Base64Encoder; |
||||
|
import cn.hutool.crypto.SecureUtil; |
||||
|
import cn.hutool.crypto.symmetric.AES; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.constant.XxxdConstant; |
||||
|
import com.elink.esua.epdc.dto.events.XxxdEventDTO; |
||||
|
import com.elink.esua.epdc.modules.events.service.XxxdEventService; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.collections4.CollectionUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.http.*; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
import org.springframework.web.client.HttpClientErrorException; |
||||
|
import org.springframework.web.client.RestTemplate; |
||||
|
|
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.util.List; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 新新向党随手拍的接收数据 |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2023-05-22 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@RestController |
||||
|
@RequestMapping("xxxd/question") |
||||
|
public class XxxdEventController { |
||||
|
|
||||
|
@Autowired |
||||
|
private XxxdEventService xxxdEventService; |
||||
|
|
||||
|
/** |
||||
|
* 推送给咱们的数据调用此接口 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("receive") |
||||
|
public Result save(@RequestBody XxxdEventDTO dto) { |
||||
|
xxxdEventService.save(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("update") |
||||
|
public Result update(@RequestBody XxxdEventDTO dto) { |
||||
|
xxxdEventService.update(dto); |
||||
|
// 向新新向党反馈数据结果
|
||||
|
submitFeedback(dto.getQuestionId(), dto.getStatus(), dto.getProcessResult()); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "{id}", method = {RequestMethod.POST}) |
||||
|
public Result<XxxdEventDTO> get(@PathVariable("id") String id) { |
||||
|
XxxdEventDTO data = xxxdEventService.get(id); |
||||
|
return new Result<XxxdEventDTO>().ok(data); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("delete") |
||||
|
public Result delete(@RequestBody List<String> ids) { |
||||
|
if (CollectionUtils.isNotEmpty(ids)) { |
||||
|
xxxdEventService.delete(ids); |
||||
|
} |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
private ResponseEntity<String> submitFeedback(String questionId, String status, String processResult) { |
||||
|
HttpHeaders headers = new HttpHeaders(); |
||||
|
headers.setContentType(MediaType.APPLICATION_JSON); |
||||
|
headers.set("Authorization", genAuthorization()); |
||||
|
|
||||
|
LocalDateTime currentTime = LocalDateTime.now(); |
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
||||
|
String processTime = currentTime.format(formatter); |
||||
|
|
||||
|
// 构建请求体数据,这里以示例数据为准
|
||||
|
String requestBody = "{\"questionId\":\"" + questionId + "\", \"status\":\"" + status + "\", \"processResult\":\"" + processResult + "\", \"processTime\":\"" + processTime + "\"}"; |
||||
|
|
||||
|
HttpEntity<String> entity = new HttpEntity<>(requestBody, headers); |
||||
|
RestTemplate restTemplate = new RestTemplate(); |
||||
|
|
||||
|
try { |
||||
|
ResponseEntity<String> response = restTemplate.exchange(XxxdConstant.XXXD_QUESTION_FEED_BACK_URL, HttpMethod.POST, entity, String.class); |
||||
|
log.warn("新新向党反馈处理结果返参:" + response.getBody()); |
||||
|
return response; |
||||
|
} catch (HttpClientErrorException e) { |
||||
|
// 处理异常情况
|
||||
|
HttpStatus statusCode = e.getStatusCode(); |
||||
|
// 进一步处理异常...
|
||||
|
} |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成认证信息 |
||||
|
* |
||||
|
* @return |
||||
|
*/ |
||||
|
public String genAuthorization() { |
||||
|
String key = XxxdConstant.APP_KEY; |
||||
|
String secret = XxxdConstant.APP_SECRET; |
||||
|
|
||||
|
LocalDateTime currentTime = LocalDateTime.now(); |
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); |
||||
|
String time = currentTime.format(formatter); |
||||
|
|
||||
|
String version = "1.0"; |
||||
|
String beforeSignStr = key + time + version;// 拼接要加密的字符串
|
||||
|
|
||||
|
AES aes = SecureUtil.aes(secret.getBytes()); |
||||
|
String signStr = aes.encryptBase64(beforeSignStr);// 执行aes加密并转base64编码
|
||||
|
String authStr = String.format("{\"ak_key\":\"%s\",\"ak_time\":\"%s\",\"ac_version\":\"%s\",\"ac_signature\":\"%s\"}", key, time, version, signStr);// 组装认证信息
|
||||
|
|
||||
|
return Base64Encoder.encode(authStr);// 认证信息执行base64
|
||||
|
} |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.elink.esua.epdc.modules.events.dao; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
||||
|
import com.elink.esua.epdc.modules.events.entity.XxxdEventEntity; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
/** |
||||
|
* 新新向党随手拍的接收数据 |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2023-05-22 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface XxxdEventDao extends BaseDao<XxxdEventEntity> { |
||||
|
|
||||
|
} |
@ -0,0 +1,109 @@ |
|||||
|
package com.elink.esua.epdc.modules.events.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 新新向党随手拍的接收数据 |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2023-05-22 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@TableName("xxxd_event") |
||||
|
public class XxxdEventEntity extends BaseEpdcEntity { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 问题标识,可唯一识别用户问题的id |
||||
|
*/ |
||||
|
private String questionId; |
||||
|
|
||||
|
/** |
||||
|
* 问题描述 |
||||
|
*/ |
||||
|
private String description; |
||||
|
|
||||
|
/** |
||||
|
* 上报人姓名 |
||||
|
*/ |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 上报人联系方式 |
||||
|
*/ |
||||
|
private String contact; |
||||
|
|
||||
|
/** |
||||
|
* 问题类别:1生态环境,2矛盾纠纷,3社会治安,4其他 |
||||
|
*/ |
||||
|
private String type; |
||||
|
|
||||
|
/** |
||||
|
* 发生位置 |
||||
|
*/ |
||||
|
private String location; |
||||
|
|
||||
|
/** |
||||
|
* 经度 |
||||
|
*/ |
||||
|
private String longitude; |
||||
|
|
||||
|
/** |
||||
|
* 纬度 |
||||
|
*/ |
||||
|
private String latitude; |
||||
|
|
||||
|
/** |
||||
|
* 发布时间:yyyy-MM-dd HH:mm:ss |
||||
|
*/ |
||||
|
private String pubTime; |
||||
|
|
||||
|
/** |
||||
|
* 问题图片列表 |
||||
|
*/ |
||||
|
private String pics; |
||||
|
|
||||
|
/** |
||||
|
* 问题语音列表 |
||||
|
*/ |
||||
|
private String audios; |
||||
|
|
||||
|
/** |
||||
|
* 北上速办事件id |
||||
|
*/ |
||||
|
private String bssbEventId; |
||||
|
|
||||
|
/** |
||||
|
* 处理状态:0-未处理;1-已处理;5-不予处理 |
||||
|
*/ |
||||
|
private String status; |
||||
|
|
||||
|
/** |
||||
|
* 处理结果 |
||||
|
*/ |
||||
|
private String processResult; |
||||
|
|
||||
|
/** |
||||
|
* 处理时间:yyyy-MM-dd HH:mm:ss |
||||
|
*/ |
||||
|
private String processTime; |
||||
|
|
||||
|
/** |
||||
|
* 处理人 |
||||
|
*/ |
||||
|
private String processUser; |
||||
|
|
||||
|
/** |
||||
|
* 是否已同步,0:未同步;1,已同步 |
||||
|
*/ |
||||
|
private Integer sync; |
||||
|
|
||||
|
} |
@ -0,0 +1,53 @@ |
|||||
|
package com.elink.esua.epdc.modules.events.service; |
||||
|
|
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
||||
|
import com.elink.esua.epdc.dto.events.XxxdEventDTO; |
||||
|
import com.elink.esua.epdc.modules.events.entity.XxxdEventEntity; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 新新向党随手拍的接收数据 |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2023-05-22 |
||||
|
*/ |
||||
|
public interface XxxdEventService extends BaseService<XxxdEventEntity> { |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 保存 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2023-05-22 |
||||
|
*/ |
||||
|
void save(XxxdEventDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 更新 |
||||
|
* @param dto |
||||
|
*/ |
||||
|
void update(XxxdEventDTO dto); |
||||
|
/** |
||||
|
* 单条查询 |
||||
|
* |
||||
|
* @param id |
||||
|
* @return XxxdEventDTO |
||||
|
* @author generator |
||||
|
* @date 2023-05-22 |
||||
|
*/ |
||||
|
XxxdEventDTO get(String id); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除 |
||||
|
* |
||||
|
* @param ids |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2023-05-22 |
||||
|
*/ |
||||
|
void delete(List<String> ids); |
||||
|
} |
@ -0,0 +1,71 @@ |
|||||
|
package com.elink.esua.epdc.modules.events.service.impl; |
||||
|
|
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.StrConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
||||
|
import com.elink.esua.epdc.dto.events.XxxdEventDTO; |
||||
|
import com.elink.esua.epdc.modules.events.dao.XxxdEventDao; |
||||
|
import com.elink.esua.epdc.modules.events.entity.XxxdEventEntity; |
||||
|
import com.elink.esua.epdc.modules.events.service.XxxdEventService; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 新新向党随手拍的接收数据 |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2023-05-22 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class XxxdEventServiceImpl extends BaseServiceImpl<XxxdEventDao, XxxdEventEntity> implements XxxdEventService { |
||||
|
|
||||
|
/** |
||||
|
* 接收新新向党 推送的随手拍事件 |
||||
|
* |
||||
|
* @param dto |
||||
|
*/ |
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void save(XxxdEventDTO dto) { |
||||
|
XxxdEventEntity entity = ConvertUtils.sourceToTarget(dto, XxxdEventEntity.class); |
||||
|
// 将图片与声音的数组转换为字符串,中间用分号分隔
|
||||
|
String[] pics = dto.getPics(); |
||||
|
if (pics != null && pics.length > 0) { |
||||
|
entity.setPics(String.join(StrConstant.SEMICOLON, pics)); |
||||
|
} |
||||
|
String[] audios = dto.getAudios(); |
||||
|
if (audios != null && audios.length > 0) { |
||||
|
entity.setAudios(String.join(StrConstant.SEMICOLON, audios)); |
||||
|
} |
||||
|
insert(entity); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 更新 |
||||
|
* |
||||
|
* @param dto |
||||
|
*/ |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
@Override |
||||
|
public void update(XxxdEventDTO dto) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public XxxdEventDTO get(String id) { |
||||
|
XxxdEventEntity entity = baseDao.selectById(id); |
||||
|
return ConvertUtils.sourceToTarget(entity, XxxdEventDTO.class); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void delete(List<String> ids) { |
||||
|
// 逻辑删除(@TableLogic 注解)
|
||||
|
baseDao.deleteBatchIds(ids); |
||||
|
} |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
<?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.epmet.dao.XxxdEventDao"> |
||||
|
|
||||
|
<resultMap type="com.epmet.entity.XxxdEventEntity" id="xxxdEventMap"> |
||||
|
<result property="id" column="ID"/> |
||||
|
<result property="questionId" column="QUESTION_ID"/> |
||||
|
<result property="description" column="DESCRIPTION"/> |
||||
|
<result property="name" column="NAME"/> |
||||
|
<result property="contact" column="CONTACT"/> |
||||
|
<result property="type" column="TYPE"/> |
||||
|
<result property="location" column="LOCATION"/> |
||||
|
<result property="longitude" column="LONGITUDE"/> |
||||
|
<result property="latitude" column="LATITUDE"/> |
||||
|
<result property="pubTime" column="PUB_TIME"/> |
||||
|
<result property="pics" column="PICS"/> |
||||
|
<result property="audios" column="AUDIOS"/> |
||||
|
<result property="bssbEventId" column="BSSB_EVENT_ID"/> |
||||
|
<result property="status" column="STATUS"/> |
||||
|
<result property="processResult" column="PROCESS_RESULT"/> |
||||
|
<result property="processTime" column="PROCESS_TIME"/> |
||||
|
<result property="processUser" column="PROCESS_USER"/> |
||||
|
<result property="sync" column="SYNC"/> |
||||
|
<result property="delFlag" column="DEL_FLAG"/> |
||||
|
<result property="revision" column="REVISION"/> |
||||
|
<result property="createdBy" column="CREATED_BY"/> |
||||
|
<result property="createdTime" column="CREATED_TIME"/> |
||||
|
<result property="updatedBy" column="UPDATED_BY"/> |
||||
|
<result property="updatedTime" column="UPDATED_TIME"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
|
||||
|
</mapper> |
Loading…
Reference in new issue