10 changed files with 501 additions and 2 deletions
@ -0,0 +1,22 @@ |
|||
-- cim-查询执法人员视图 |
|||
create view view_area_legal_officer AS |
|||
select |
|||
T1.code , |
|||
t1.area_code , |
|||
t1.name, |
|||
t2.CD_TIME, |
|||
count(t2.Y201000) as zfrys |
|||
from dashboard_area_info t1 |
|||
inner join ( |
|||
SELECT t1.* |
|||
FROM s_gdsztk_y2020_jb2 t1 |
|||
INNER JOIN ( |
|||
SELECT Y202000, MAX(CD_TIME) AS max_cd_time |
|||
FROM s_gdsztk_y2020_jb2 |
|||
WHERE y202006 = '01' |
|||
GROUP BY Y202000 |
|||
) t2 ON t1.Y202000 = t2.Y202000 AND t1.CD_TIME = t2.max_cd_time |
|||
WHERE t1.y202006 = '01' |
|||
ORDER BY t1.Y202000 |
|||
) t2 on t1.area_code = t2.OPT_AREA_CODE COLLATE utf8mb4_0900_ai_ci and t1.`level` ='3' |
|||
group by T1.code ,t1.area_code ,t1.name,t2.CD_TIME; |
|||
@ -0,0 +1,20 @@ |
|||
-- 龙岗主动发送消息日志表-建表SQL |
|||
CREATE TABLE `lg_send_message_log` ( |
|||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', |
|||
`touser` varchar(512) NOT NULL COMMENT '用户ID列表', |
|||
`content` text DEFAULT NULL COMMENT '发送消息内容', |
|||
`errcode` char(1) DEFAULT NULL COMMENT '返回消息状态:0:成功 1:失败', |
|||
`errmsg` varchar(512) DEFAULT NULL COMMENT '返回消息内容', |
|||
`invaliduser` varchar(512) DEFAULT NULL COMMENT '无效用户', |
|||
`invalidparty` varchar(512) DEFAULT NULL COMMENT '无效部门', |
|||
`jobid` varchar(128) DEFAULT NULL COMMENT '消息进度ID', |
|||
status char(1) DEFAULT NULL COMMENT '状态:0:成功 1:失败 2:异常' , |
|||
exception_msg text DEFAULT NULL COMMENT '异常信息内容', |
|||
create_dept varchar(50) DEFAULT NULL COMMENT '创建部门', |
|||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人ID', |
|||
`create_time` datetime DEFAULT NULL COMMENT '创建时间', |
|||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人ID', |
|||
`update_time` datetime DEFAULT NULL COMMENT '更新时间', |
|||
`is_delete` char(1) DEFAULT '0' COMMENT '逻辑删除:0-否 1-是', |
|||
PRIMARY KEY (`id`) |
|||
) ENGINE=InnoDB AUTO_INCREMENT=2108377624276574220 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='龙岗发送消息日志表'; |
|||
@ -0,0 +1,81 @@ |
|||
package com.zdxt.enforcementcode.domain; |
|||
|
|||
import org.dromara.common.mybatis.core.domain.BaseEntity; |
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.io.Serial; |
|||
|
|||
/** |
|||
* 龙岗发送消息日志对象 lg_send_message_log |
|||
* |
|||
* @author Lion Li |
|||
* @date 2026-11-23 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@TableName("lg_send_message_log") |
|||
public class LgSendMessageLog extends BaseEntity { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
@TableId(value = "id") |
|||
private Long id; |
|||
|
|||
/** |
|||
* 用户ID列表 |
|||
*/ |
|||
private String touser; |
|||
|
|||
/** |
|||
* 发送消息内容 |
|||
*/ |
|||
private String content; |
|||
|
|||
/** |
|||
* 返回消息状态:0:成功 1:失败 |
|||
*/ |
|||
private String errcode; |
|||
|
|||
/** |
|||
* 返回消息内容 |
|||
*/ |
|||
private String errmsg; |
|||
|
|||
/** |
|||
* 无效用户 |
|||
*/ |
|||
private String invaliduser; |
|||
|
|||
/** |
|||
* 无效部门 |
|||
*/ |
|||
private String invalidparty; |
|||
|
|||
/** |
|||
* 异常信息 |
|||
*/ |
|||
private String exceptionMsg; |
|||
|
|||
/** |
|||
* 消息进度ID |
|||
*/ |
|||
private String jobid; |
|||
|
|||
/** |
|||
* 状态:0:成功 1:失败 2:异常 |
|||
*/ |
|||
private String status; |
|||
|
|||
/** |
|||
* 逻辑删除:0-否 1-是 |
|||
*/ |
|||
private String isDelete; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
package com.zdxt.enforcementcode.domain.bo; |
|||
|
|||
import com.zdxt.enforcementcode.domain.LgSendMessageLog; |
|||
import org.dromara.common.mybatis.core.domain.BaseEntity; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import jakarta.validation.constraints.*; |
|||
|
|||
/** |
|||
* 龙岗发送消息日志业务对象 lg_send_message_log |
|||
* |
|||
* @author Lion Li |
|||
* @date 2026-11-23 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@AutoMapper(target = LgSendMessageLog.class, reverseConvertGenerate = false) |
|||
public class LgSendMessageLogBo extends BaseEntity { |
|||
|
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
@NotNull(message = "主键ID不能为空", groups = { EditGroup.class }) |
|||
private Long id; |
|||
|
|||
/** |
|||
* 用户ID列表 |
|||
*/ |
|||
@NotBlank(message = "用户ID列表不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String touser; |
|||
|
|||
/** |
|||
* 发送消息内容 |
|||
*/ |
|||
private String content; |
|||
|
|||
/** |
|||
* 返回消息状态:0:成功 1:失败 |
|||
*/ |
|||
private String errcode; |
|||
|
|||
/** |
|||
* 返回消息内容 |
|||
*/ |
|||
private String errmsg; |
|||
|
|||
/** |
|||
* 无效用户 |
|||
*/ |
|||
private String invaliduser; |
|||
|
|||
/** |
|||
* 无效部门 |
|||
*/ |
|||
private String invalidparty; |
|||
|
|||
/** |
|||
* 消息进度ID |
|||
*/ |
|||
private String jobid; |
|||
|
|||
/** |
|||
* 状态:0:成功 1:失败 2:异常 |
|||
*/ |
|||
private String status; |
|||
|
|||
/** |
|||
* 逻辑删除:0-否 1-是 |
|||
*/ |
|||
private String isDelete; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
|
|||
package com.zdxt.enforcementcode.domain.bo.externalInterface; |
|||
|
|||
import jakarta.validation.constraints.NotEmpty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Data |
|||
public class LongGangSendMessageBo { |
|||
|
|||
@NotEmpty(message = "用户名称") |
|||
private List<String> touser; |
|||
|
|||
@NotEmpty(message = "消息内容") |
|||
private String content; |
|||
} |
|||
@ -0,0 +1,93 @@ |
|||
package com.zdxt.enforcementcode.domain.vo; |
|||
|
|||
import com.zdxt.enforcementcode.domain.LgSendMessageLog; |
|||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated; |
|||
import cn.idev.excel.annotation.ExcelProperty; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
|
|||
|
|||
/** |
|||
* 龙岗发送消息日志视图对象 lg_send_message_log |
|||
* |
|||
* @author Lion Li |
|||
* @date 2026-11-23 |
|||
*/ |
|||
@Data |
|||
@ExcelIgnoreUnannotated |
|||
@AutoMapper(target = LgSendMessageLog.class) |
|||
public class LgSendMessageLogVo implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
@ExcelProperty(value = "主键ID") |
|||
private Long id; |
|||
|
|||
/** |
|||
* 用户ID列表 |
|||
*/ |
|||
@ExcelProperty(value = "用户ID列表") |
|||
private String touser; |
|||
|
|||
/** |
|||
* 发送消息内容 |
|||
*/ |
|||
@ExcelProperty(value = "发送消息内容") |
|||
private String content; |
|||
|
|||
/** |
|||
* 返回消息状态:0:成功 1:失败 |
|||
*/ |
|||
@ExcelProperty(value = "返回消息状态:0:成功 1:失败") |
|||
private String errcode; |
|||
|
|||
/** |
|||
* 返回消息内容 |
|||
*/ |
|||
@ExcelProperty(value = "返回消息内容") |
|||
private String errmsg; |
|||
|
|||
/** |
|||
* 无效用户 |
|||
*/ |
|||
@ExcelProperty(value = "无效用户") |
|||
private String invaliduser; |
|||
|
|||
/** |
|||
* 无效部门 |
|||
*/ |
|||
@ExcelProperty(value = "无效部门") |
|||
private String invalidparty; |
|||
|
|||
/** |
|||
* 消息进度ID |
|||
*/ |
|||
@ExcelProperty(value = "消息进度ID") |
|||
private String jobid; |
|||
|
|||
/** |
|||
* 状态:0:成功 1:失败 2:异常 |
|||
*/ |
|||
@ExcelProperty(value = "状态:0:成功 1:失败 2:异常") |
|||
private String status; |
|||
|
|||
/** |
|||
* 逻辑删除:0-否 1-是 |
|||
*/ |
|||
@ExcelProperty(value = "逻辑删除:0-否 1-是") |
|||
private String isDelete; |
|||
|
|||
/** |
|||
* 异常信息 |
|||
*/ |
|||
private String exceptionMsg; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package com.zdxt.enforcementcode.service.thirdparty; |
|||
|
|||
|
|||
import com.zdxt.enforcementcode.domain.bo.externalInterface.LongGangSendMessageBo; |
|||
import com.zdxt.enforcementcode.domain.vo.LgSendMessageLogVo; |
|||
|
|||
/** |
|||
* 深政易Service接口 |
|||
* |
|||
* @author Lion Li |
|||
* @date 2026-04-17 |
|||
*/ |
|||
public interface ISzyService { |
|||
|
|||
|
|||
/** |
|||
* 批量发送短信 |
|||
* |
|||
* @param paramBo |
|||
* @return |
|||
*/ |
|||
LgSendMessageLogVo sendMessage(LongGangSendMessageBo paramBo); |
|||
} |
|||
@ -0,0 +1,151 @@ |
|||
package com.zdxt.enforcementcode.service.thirdparty.impl; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.zdxt.enforcementcode.controller.app.utils.HttpUtil; |
|||
import com.zdxt.enforcementcode.domain.LgSendMessageLog; |
|||
import com.zdxt.enforcementcode.domain.bo.externalInterface.LongGangSendMessageBo; |
|||
import com.zdxt.enforcementcode.domain.vo.LgSendMessageLogVo; |
|||
import com.zdxt.enforcementcode.mapper.LgSendMessageLogMapper; |
|||
import com.zdxt.enforcementcode.service.thirdparty.ISzyService; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Optional; |
|||
|
|||
|
|||
/** |
|||
* 深政易Service实现类 |
|||
*/ |
|||
@Slf4j |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
public class SzyServiceImpl implements ISzyService { |
|||
|
|||
|
|||
private final LgSendMessageLogMapper lgSendMessageLogMapper; |
|||
|
|||
|
|||
@Value("${szypt.corpid}") |
|||
private String szyptCorpid; |
|||
@Value("${szypt.agentid}") |
|||
private String szyptAgentid; |
|||
@Value("${szypt.corpsecret}") |
|||
private String szyptCorpsecret; |
|||
@Value("${szypt.url}") |
|||
private String szyptUrl; |
|||
|
|||
/** |
|||
* 批量发送短信 |
|||
* |
|||
* @param paramBo |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public LgSendMessageLogVo sendMessage(LongGangSendMessageBo paramBo) { |
|||
|
|||
try { |
|||
// 1.获取 access_token
|
|||
String accessTokenJson = HttpUtil.HttpSendGet(szyptUrl + "/cgi-bin/gettoken?corpid="+szyptCorpid+"&corpsecret="+szyptCorpsecret, null); |
|||
JSONObject tokenObj = JSONObject.parseObject(accessTokenJson); |
|||
String token = tokenObj.getString("access_token"); |
|||
log.info("深政易主动发送消息:access_token:{}", token); |
|||
|
|||
// 2.拼接消息内容
|
|||
JSONObject params = new JSONObject(); |
|||
params.put("touser", paramBo.getTouser() == null ? "" : String.join("|", paramBo.getTouser())); |
|||
params.put("agentid", szyptAgentid); |
|||
params.put("msgtype", "text"); |
|||
JSONObject text = new JSONObject(); |
|||
text.put("content", paramBo.getContent() == null ? "" : paramBo.getContent()); |
|||
params.put("text", text); |
|||
log.info("深政易主动发送消息:params:{}", params); |
|||
// 3.调用发送消息接口
|
|||
String data = com.zdxt.enforcementcode.common.util.HttpUtil.httpSendPost(szyptUrl + "cgi-bin/message/send?access_token="+token, JSONObject.toJSONString(params), new HashMap<>()); |
|||
|
|||
JSONObject jsonObject = JSONObject.parseObject(data); |
|||
log.info("深政易主动发送消息:data:{}", jsonObject); |
|||
|
|||
// 4.判断返回成功并保存信息
|
|||
String errcode = jsonObject == null ? null : jsonObject.getString("errcode"); |
|||
LgSendMessageLogVo sendMessageVo; |
|||
if ("0".equals(errcode)) { |
|||
sendMessageVo = messageInfo(jsonObject, paramBo, "0", null); |
|||
log.info("深政易主动发送消息:发送成功"); |
|||
}else { |
|||
// 5.返回失败并保存错误信息
|
|||
sendMessageVo = messageInfo(jsonObject, paramBo, "1", null); |
|||
log.error("深政易主动发送消息:发送失败"); |
|||
} |
|||
getSendMessageLogInfo(sendMessageVo); |
|||
return sendMessageVo; |
|||
|
|||
}catch (Exception e){ |
|||
// 6.处理异常并保存异常信息
|
|||
LgSendMessageLogVo sendMessageVo= messageInfo(null, paramBo, "2", e.getMessage()); |
|||
log.error("深政易主动发送消息:处理异常"); |
|||
getSendMessageLogInfo(sendMessageVo); |
|||
return sendMessageVo; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 保存发送信息 |
|||
* @param logVo |
|||
*/ |
|||
public void getSendMessageLogInfo(LgSendMessageLogVo logVo){ |
|||
|
|||
LgSendMessageLog log = new LgSendMessageLog(); |
|||
|
|||
Optional.ofNullable(logVo).ifPresent(vo -> { |
|||
log.setTouser(vo.getTouser()); |
|||
log.setContent(vo.getContent()); |
|||
log.setErrcode(vo.getErrcode()); |
|||
log.setErrmsg(vo.getErrmsg()); |
|||
log.setInvaliduser(vo.getInvaliduser()); |
|||
log.setInvalidparty(vo.getInvalidparty()); |
|||
log.setJobid(vo.getJobid()); |
|||
log.setStatus(vo.getStatus()); |
|||
log.setExceptionMsg(vo.getExceptionMsg()); |
|||
}); |
|||
|
|||
lgSendMessageLogMapper.insert(log); |
|||
} |
|||
|
|||
/** |
|||
* 封装发送信息 |
|||
* |
|||
* @param jsonObject 第三方接口返回,可能为 null(异常分支) |
|||
* @param paramBo 发送参数,用于记录收件人和消息内容 |
|||
* @param status 状态:0-成功 1-失败 2-异常 |
|||
* @param exceptionMsg 异常信息 |
|||
*/ |
|||
public LgSendMessageLogVo messageInfo(JSONObject jsonObject, LongGangSendMessageBo paramBo, String status, String exceptionMsg){ |
|||
LgSendMessageLogVo sendMessageVo = new LgSendMessageLogVo(); |
|||
|
|||
sendMessageVo.setTouser(paramBo == null || paramBo.getTouser() == null ? "" : String.join("|", paramBo.getTouser())); |
|||
sendMessageVo.setContent(paramBo.getContent() == null ? "" : paramBo.getContent()); |
|||
sendMessageVo.setErrcode(getJsonString(jsonObject, "errcode")); |
|||
sendMessageVo.setErrmsg(getJsonString(jsonObject, "errmsg")); |
|||
sendMessageVo.setInvaliduser(getJsonString(jsonObject, "invaliduser")); |
|||
sendMessageVo.setInvalidparty(getJsonString(jsonObject, "invalidparty")); |
|||
sendMessageVo.setJobid(getJsonString(jsonObject, "jobid")); |
|||
sendMessageVo.setStatus(status == null ? "" : status); |
|||
sendMessageVo.setExceptionMsg(exceptionMsg == null ? "" : exceptionMsg); |
|||
|
|||
return sendMessageVo; |
|||
} |
|||
|
|||
/** |
|||
* 安全获取 JSON 字符串值:json 为 null 或字段不存在时返回空串,避免 NPE |
|||
*/ |
|||
private String getJsonString(JSONObject jsonObject, String key) { |
|||
if (jsonObject == null) { |
|||
return ""; |
|||
} |
|||
Object value = jsonObject.get(key); |
|||
return value == null ? "" : value.toString(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue