Browse Source

统计服务

develop
wangsixiang 5 months ago
parent
commit
2ab2e68130
  1. 3
      zc-business/src/main/java/com/zc/business/controller/DcPublishManageController.java
  2. 2
      zc-business/src/main/java/com/zc/business/domain/DcPublishManage.java
  3. 2
      zc-business/src/main/java/com/zc/business/mapper/DcPublishManageMapper.java
  4. 21
      zc-business/src/main/java/com/zc/business/service/IDcPublishManageService.java
  5. 95
      zc-business/src/main/java/com/zc/business/service/impl/DcPublishManageServiceImpl.java
  6. 17
      zc-business/src/main/resources/mapper/business/DcPublishManageMapper.xml

3
zc-business/src/main/java/com/zc/business/controller/DcPublishManageController.java

@ -1,5 +1,6 @@
package com.zc.business.controller;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
@ -164,7 +165,7 @@ public class DcPublishManageController extends BaseController
@PostMapping("/export")
public void export(HttpServletResponse response, DcPublishManage dcPublishManage)
{
List<DcPublishManage> list = dcPublishManageService.selectDcPublishManageStatistics(dcPublishManage);
List<DcPublishManage> list = dcPublishManageService.selectDcPublishManageExport(dcPublishManage);
ExcelUtil<DcPublishManage> util = new ExcelUtil<>(DcPublishManage.class);
util.exportExcel(response, list, "信息发布管理记录数据");
}

2
zc-business/src/main/java/com/zc/business/domain/DcPublishManage.java

@ -38,7 +38,7 @@ public class DcPublishManage extends BaseEntity
private String title;
/** 发布渠道:多选用逗号隔开1-手机短信2-微信公众号3-微博4-情报板5-服务网站6-微信小程序 */
@Excel(name = "发布渠道",readConverterExp="1=手机短信,2=微信公众号,3=微博,4=情报板,5=服务网站,6=微信小程序,7=语音广播")
@Excel(name = "发布渠道",readConverterExp="1=手机短信,2=微信公众号,3=微博,4=情报板,5=服务网站,6=微信小程序,7=语音广播,8=企业微信")
private Integer publishChannels;
/** 审核状态:0-待审核1-已审核2-未通过 */

2
zc-business/src/main/java/com/zc/business/mapper/DcPublishManageMapper.java

@ -87,4 +87,6 @@ public interface DcPublishManageMapper
public List<HashMap<String,Object>> eventTypePublishManageMonth(DcPublishManage dcPublishManage);
//公众服务统计查询
public List<DcPublishManage> selectDcPublishManageStatistics(DcPublishManage dcPublishManage);
//数据处理
public List<HashMap> selectOperLog();
}

21
zc-business/src/main/java/com/zc/business/service/IDcPublishManageService.java

@ -1,20 +1,21 @@
package com.zc.business.service;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import com.zc.business.domain.DcPublishManage;
/**
* 信息发布管理记录Service接口
*
*
* @author ruoyi
* @date 2024-04-19
*/
public interface IDcPublishManageService
public interface IDcPublishManageService
{
/**
* 查询信息发布管理记录
*
*
* @param id 信息发布管理记录主键
* @return 信息发布管理记录
*/
@ -22,7 +23,7 @@ public interface IDcPublishManageService
/**
* 查询信息发布管理记录列表
*
*
* @param dcPublishManage 信息发布管理记录
* @return 信息发布管理记录集合
*/
@ -31,7 +32,7 @@ public interface IDcPublishManageService
List<DcPublishManage> selectEventDcPublishManageList(DcPublishManage dcPublishManage);
/**
* 新增信息发布管理记录
*
*
* @param dcPublishManage 信息发布管理记录
* @return 结果
*/
@ -39,7 +40,7 @@ public interface IDcPublishManageService
/**
* 修改信息发布管理记录
*
*
* @param dcPublishManage 信息发布管理记录
* @return 结果
*/
@ -47,7 +48,7 @@ public interface IDcPublishManageService
/**
* 批量删除信息发布管理记录
*
*
* @param ids 需要删除的信息发布管理记录主键集合
* @return 结果
*/
@ -55,7 +56,7 @@ public interface IDcPublishManageService
/**
* 删除信息发布管理记录信息
*
*
* @param id 信息发布管理记录主键
* @return 结果
*/
@ -74,4 +75,8 @@ public interface IDcPublishManageService
public List<HashMap<String,Object>> eventTypePublishManageMonth(DcPublishManage dcPublishManage);
//公众服务统计查询
public List<DcPublishManage> selectDcPublishManageStatistics(DcPublishManage dcPublishManage);
//公众服务统计导出
public List<DcPublishManage> selectDcPublishManageExport(DcPublishManage dcPublishManage);
//数据处理
public List<HashMap> selectOperLog() throws ParseException;
}

95
zc-business/src/main/java/com/zc/business/service/impl/DcPublishManageServiceImpl.java

@ -1,14 +1,24 @@
package com.zc.business.service.impl;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.ruoyi.common.utils.DateUtils;
import com.zc.business.domain.DcPublishManage;
import com.zc.business.mapper.DcPublishManageMapper;
import com.zc.business.service.IDcPublishManageService;
import com.zc.business.utils.StakeMarkUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -145,4 +155,89 @@ public class DcPublishManageServiceImpl implements IDcPublishManageService
public List<DcPublishManage> selectDcPublishManageStatistics(DcPublishManage dcPublishManage) {
return dcPublishManageMapper.selectDcPublishManageStatistics(dcPublishManage);
}
@Override
public List<DcPublishManage> selectDcPublishManageExport(DcPublishManage dcPublishManage) {
List<DcPublishManage> dcPublishManagesValue = dcPublishManageMapper.selectDcPublishManageStatistics(dcPublishManage);
ArrayList<DcPublishManage> objects = new ArrayList<>();
for (DcPublishManage dcPublishManages : dcPublishManagesValue) {
Integer publishChannels = dcPublishManages.getPublishChannels();//取出发布渠道判断使用
if (publishChannels == 7 && StringUtils.isNotBlank(dcPublishManages.getContentDetails())) {//语音广播
String contentDetails = dcPublishManages.getContentDetails();
JsonParser parser = new JsonParser();
JsonArray jsonArray = parser.parse(contentDetails).getAsJsonArray();
// 假设我们只关心第一个对象(因为语音广播一个设备一次只会发一条语音)
JsonObject jsonObject = jsonArray.get(0).getAsJsonObject();
JsonArray functionsArray = jsonObject.get("functions").getAsJsonArray();
// 遍历 functions 数组以找到 text
for (JsonElement functionElement : functionsArray) {
JsonObject functionObject = functionElement.getAsJsonObject();
JsonObject paramsObject = functionObject.get("params").getAsJsonObject();
// 提取 text
String text = paramsObject.get("text").getAsString();
dcPublishManages.setContentDetails(text);
break; //退出循环
}
}
if (publishChannels == 4 && StringUtils.isNotBlank(dcPublishManages.getContentDetails())) {
String contentDetails = dcPublishManages.getContentDetails();
try {
JSONArray jsonArray = new JSONArray(contentDetails);
StringBuilder contentStringBuilder = new StringBuilder();
for (int i = 0; i < jsonArray.length(); i++) {
// 确保当前元素是JSONObject
Object element = jsonArray.get(i);
if (element instanceof JSONObject) {
JSONObject jsonObject = (JSONObject) element;
JSONArray functionsArray = jsonObject.getJSONArray("functions");
for (int j = 0; j < functionsArray.length(); j++) {
JSONObject functionObject = functionsArray.getJSONObject(j);
if ("13".equals(functionObject.getString("functionId"))) {
JSONObject paramsObject = functionObject.getJSONObject("params");
JSONArray parametersArray = paramsObject.getJSONArray("parameters");
for (int k = 0; k < parametersArray.length(); k++) {
JSONObject parameterObject = parametersArray.getJSONObject(k);
String content = parameterObject.getString("CONTENT");
if (contentStringBuilder.length() > 0) {
contentStringBuilder.append(",");
}
contentStringBuilder.append(content);
}
}
}
dcPublishManages.setContentDetails(contentStringBuilder.toString());
} else {
dcPublishManages.setContentDetails("");
}
}
} catch (Exception e) {
e.printStackTrace(); // 处理JSON解析中的异常
}
}
objects.add(dcPublishManages);
}
return objects;
}
//数据处理
@Override
public List<HashMap> selectOperLog() throws ParseException {
List<HashMap> maps = dcPublishManageMapper.selectOperLog();
for (HashMap map:maps){
DcPublishManage dcPublishManage = new DcPublishManage();
dcPublishManage.setLogId((Long) map.get("id"));
dcPublishManage.setContentDetails(map.get("operParam").toString());
dcPublishManage.setRemark(map.get("remark").toString());
dcPublishManage.setPublishStatus(1);
String operTime = map.get("operTime").toString();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = sdf.parse(operTime);
dcPublishManage.setCreateTime(date);
dcPublishManage.setPublishTime(date);
dcPublishManage.setPublisher("admin");
dcPublishManage.setPublishChannels(4);
dcPublishManageMapper.insertDcPublishManage(dcPublishManage);
}
return null;
}
}

17
zc-business/src/main/resources/mapper/business/DcPublishManageMapper.xml

@ -51,11 +51,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
manage.id, manage.event_id, manage.publish_channels_id,
manage.title, manage.publish_channels , manage.publisher,
manage.publish_status, manage.content_details, manage.remark,
CASE
WHEN manage.publish_channels = 8 THEN event.stake_mark
WHEN manage.publish_channels IN (4, 7) THEN log.dc_device_name
ELSE'未知'
END AS position,
event.create_time eventTime
from dc_publish_manage as manage
LEFT JOIN dc_event as event on event.id=manage.event_id
LEFT JOIN dc_event_traffic_control as traffic on event.id=traffic.id
LEFT JOIN dc_facility as facility ON traffic.facility_id=facility.id
left join dc_oper_log as log on log.id=manage.log_id
where manage.event_id=#{eventId}
</select>
<select id="selectDcPublishManageList" parameterType="DcPublishManage" resultMap="DcPublishManageResult">
@ -331,7 +337,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY h.eventType, pc.publish_channels;
</select>
<select id="selectDcPublishManageStatistics" resultType="com.zc.business.domain.DcPublishManage">
select manage.id,IFNULL(event.stake_mark,log.dc_device_name)position,
select manage.id, CASE
WHEN manage.publish_channels = 8 THEN event.stake_mark
WHEN manage.publish_channels IN (4, 7) THEN log.dc_device_name
ELSE'未知'
END AS position,
manage.publisher,manage.publish_channels,manage.publish_status,manage.content_details,publish_time
from dc_publish_manage as manage
left join dc_event as event on event.id=manage.event_id
@ -345,4 +355,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
ORDER BY publish_time desc
</select>
<select id="selectOperLog" resultType="java.util.HashMap">
select id,oper_param operParam,remark,
DATE_FORMAT(oper_time, '%Y-%m-%d %H:%i:%s') operTime
from dc_oper_log where dc_device_type=2
</select>
</mapper>

Loading…
Cancel
Save