吴远 3 months ago
parent
commit
0db63adfcd
  1. 8
      dk-api/api-business/src/main/java/org/dromara/business/api/RemoteBusinessAlertService.java
  2. 2
      dk-modules/business/src/main/java/org/dromara/business/domain/vo/BusinessAlertVo.java
  3. 17
      dk-modules/business/src/main/java/org/dromara/business/dubbo/RemoteBusinessAlertServiceImpl.java
  4. 3
      dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java
  5. 1
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertService.java
  6. 67
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java
  7. 2
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java
  8. 19
      dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml
  9. 11
      dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/impl/AiCompareServiceImpl.java
  10. 10
      dk-modules/system/src/main/java/org/dromara/system/controller/system/SysDeptController.java
  11. 4
      dk-modules/system/src/main/java/org/dromara/system/dubbo/RemoteLabelPostServicelmpl.java
  12. 3
      dk-modules/system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java
  13. 2
      dk-modules/system/src/main/java/org/dromara/system/service/ISysDeptService.java
  14. 5
      dk-modules/system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java
  15. 19
      dk-modules/system/src/main/resources/mapper/system/SysDeptMapper.xml
  16. 5
      dk-modules/system/src/main/resources/mapper/system/SysPostMapper.xml

8
dk-api/api-business/src/main/java/org/dromara/business/api/RemoteBusinessAlertService.java

@ -5,6 +5,7 @@ import org.dromara.business.api.domain.bo.RemoteBusinessAlertBo;
import org.dromara.business.api.domain.vo.RemoteBusinessAlertVo;
import java.util.List;
import java.util.Map;
/**
* 预警服务
@ -37,4 +38,11 @@ public interface RemoteBusinessAlertService {
* @return
*/
Boolean deleteAlert(List<Long> alertIdList);
/**
* 更新部门信息
* @param alertList
*/
void batchUpdateDept(List<Map<String, Object>> alertList);
}

2
dk-modules/business/src/main/java/org/dromara/business/domain/vo/BusinessAlertVo.java

@ -208,4 +208,6 @@ public class BusinessAlertVo implements Serializable {
* 指派人员名称
*/
private String assignUserName;
private Date createTime;
}

17
dk-modules/business/src/main/java/org/dromara/business/dubbo/RemoteBusinessAlertServiceImpl.java

@ -1,22 +1,20 @@
package org.dromara.business.dubbo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.business.api.RemoteBusinessAlertService;
import org.dromara.business.api.domain.bo.RemoteBusinessAlertBo;
import org.dromara.business.api.domain.vo.RemoteBusinessAlertVo;
import org.dromara.business.domain.vo.BusinessAlertVo;
import org.dromara.business.service.IBusinessAlertService;
import org.dromara.business.utils.MinioUntil;
import org.dromara.business.utils.constants.MinIOConstants;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -74,4 +72,17 @@ public class RemoteBusinessAlertServiceImpl implements RemoteBusinessAlertServic
public Boolean deleteAlert(List<Long> alertIdList) {
return businessAlertService.deleteAlert(alertIdList);
}
@Override
public void batchUpdateDept(List<Map<String, Object>> alertList) {
List<BusinessAlertVo> alertVoList = alertList.stream().map(alert -> {
BusinessAlertVo businessAlertVo = new BusinessAlertVo();
businessAlertVo.setDeptId(alert.get("deptId").toString());
businessAlertVo.setDeptName(alert.get("deptName").toString());
businessAlertVo.setId(Long.valueOf(alert.get("id").toString()));
return businessAlertVo;
}).toList();
businessAlertService.batchUpdateDept(alertVoList);
}
}

3
dk-modules/business/src/main/java/org/dromara/business/mapper/BusinessAlertMapper.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.dromara.business.domain.BusinessAlert;
import org.dromara.business.domain.bo.BusinessAlertBo;
import org.dromara.business.domain.vo.BusinessAlertVo;
@ -94,4 +95,6 @@ public interface BusinessAlertMapper extends BaseMapperPlus<BusinessAlert, Busin
Map<String, Object> streetTopAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("deptIdList") List<Long> deptIdList);
List<Map<String, Object>> countLabelRateAlert(@Param("param") BusinessAlertBo businessAlertBo,@Param("startTime") String startTime,@Param("endTime") String endTime);
void batchUpdateDept(@Param("list") List<BusinessAlertVo> alertVoList);
}

1
dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertService.java

@ -79,4 +79,5 @@ public interface IBusinessAlertService {
Boolean deleteAlert(List<Long> alertIdList);
void batchUpdateDept(List<BusinessAlertVo> alertVoList);
}

67
dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java

@ -16,6 +16,8 @@ import org.dromara.business.domain.bo.BusinessAlertBo;
import org.dromara.business.domain.vo.BusinessAlertVo;
import org.dromara.business.mapper.BusinessAlertMapper;
import org.dromara.business.service.IBusinessAlertService;
import org.dromara.business.utils.MinioUntil;
import org.dromara.business.utils.constants.MinIOConstants;
import org.dromara.common.core.enums.BusinessStatusEnum;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils;
@ -31,6 +33,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.lang.reflect.Method;
import java.net.URL;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
@ -146,7 +149,9 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
wrapper.set(BusinessAlert::getAssignDate, new Date());
}
wrapper.set(BusinessAlert::getCompleteDate,new Date());
if (BusinessStatusEnum.FINISH.getStatus().equalsIgnoreCase(flowStatus) || BusinessStatusEnum.CANCEL.getStatus().equalsIgnoreCase(flowStatus)){
wrapper.set(BusinessAlert::getCompleteDate,new Date());
}
wrapper.eq(BusinessAlert::getId, businessId);
@ -170,6 +175,13 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlert(pageQuery.build(), wrapper);
page.getRecords().forEach(businessAlertVo->{
businessAlertVo.setImages(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getImages(), 3600).toString());
businessAlertVo.setMaxImages(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getMaxImages(), 3600).toString());
businessAlertVo.setMaxMateSourceImgUrl(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getMaxMateSourceImgUrl(), 3600).toString());
businessAlertVo.setMateSourceImgUrl(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getMateSourceImgUrl(), 3600).toString());
});
return TableDataInfo.build(page);
}
@ -192,6 +204,13 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlertCancel(pageQuery.build(), wrapper);
page.getRecords().forEach(businessAlertVo->{
businessAlertVo.setImages(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getImages(), 3600).toString());
businessAlertVo.setMaxImages(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getMaxImages(), 3600).toString());
businessAlertVo.setMaxMateSourceImgUrl(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getMaxMateSourceImgUrl(), 3600).toString());
businessAlertVo.setMateSourceImgUrl(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getMateSourceImgUrl(), 3600).toString());
});
return TableDataInfo.build(page);
}
@ -216,6 +235,13 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
Page<BusinessAlert> page = this.baseMapper.pageAlertFinish(pageQuery.build(), wrapper);
page.getRecords().forEach(businessAlertVo->{
businessAlertVo.setImages(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getImages(), 3600).toString());
businessAlertVo.setMaxImages(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getMaxImages(), 3600).toString());
businessAlertVo.setMaxMateSourceImgUrl(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getMaxMateSourceImgUrl(), 3600).toString());
businessAlertVo.setMateSourceImgUrl(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getMateSourceImgUrl(), 3600).toString());
});
return TableDataInfo.build(page);
}
@ -253,6 +279,13 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
});
}
page.getRecords().forEach(businessAlertVo->{
businessAlertVo.setImages(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getImages(), 3600).toString());
businessAlertVo.setMaxImages(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getMaxImages(), 3600).toString());
businessAlertVo.setMaxMateSourceImgUrl(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getMaxMateSourceImgUrl(), 3600).toString());
businessAlertVo.setMateSourceImgUrl(MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getMateSourceImgUrl(), 3600).toString());
});
return TableDataInfo.build(page);
}
@ -339,7 +372,15 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
//查看的是总览的预警信息
if (ObjectUtil.isEmpty(businessAlertBo.getPostCode())) {
result.put("list",this.baseMapper.listAlert(businessAlertBo,startTime,endTime));
List<BusinessAlert> businessAlerts = this.baseMapper.listAlert(businessAlertBo, startTime, endTime);
businessAlerts.forEach(businessAlertVo->{
URL url = MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getImages(), 3600);
businessAlertVo.setImages(url.toString());
});
result.put("list",businessAlerts);
return result;
}
@ -351,6 +392,11 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
List<BusinessAlert> alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime);
alertList.forEach(businessAlertVo->{
URL url = MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getImages(), 3600);
businessAlertVo.setImages(url.toString());
});
handlerMap.put("total",alertList.size());
handlerMap.put("finishCount",ObjectUtil.isEmpty(alertList)?0:alertList.stream().filter(p-> p.getHandleType().equalsIgnoreCase(BusinessStatusEnum.FINISH.getStatus())).count());
handlerMap.put("todoCount",ObjectUtil.isEmpty(alertList)?0:alertList.stream().filter(p-> p.getHandleType().equalsIgnoreCase(BusinessStatusEnum.WAITING.getStatus())).count());
@ -397,12 +443,24 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
List<BusinessAlert> alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime);
alertList.forEach(businessAlertVo->{
URL url = MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_ALERT, businessAlertVo.getImages(), 3600);
businessAlertVo.setImages(url.toString());
});
Map<String, Integer> labelCnMap = alertList.stream()
.collect(Collectors.groupingBy(
BusinessAlert::getLabelEn,
Collectors.summingInt(e -> 1)
));
businessAlertBo.getAiLabelEnList().forEach(labelEn -> {
if (ObjectUtil.isEmpty(labelCnMap.get(labelEn))) {
labelCnMap.put(labelEn,0);
}
});
infoMap.put("panel",labelCnMap);
infoMap.put("list",alertList);
@ -432,6 +490,11 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
return this.baseMapper.delete(wrapper) > 0;
}
@Override
public void batchUpdateDept(List<BusinessAlertVo> alertVoList) {
this.baseMapper.batchUpdateDept(alertVoList);
}
public static List<String> getLastSixDays() {
List<String> days = new ArrayList<>(7);

2
dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java

@ -495,7 +495,7 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
Long deptId = LoginHelper.getDeptId();
//获取街道信息
List<RemoteDeptVo> streetList = remoteDeptService.selectListByParentId(String.valueOf(deptId));
List<Long> deptIdList = streetList.stream().map(RemoteDeptVo::getDeptId).filter(id -> !id.equals(deptId)).distinct().toList();
List<Long> deptIdList = streetList.stream().filter(p-> p.getParentId().equals(deptId)).map(RemoteDeptVo::getDeptId).distinct().toList();
List<Map<String,Object>> top5Map = this.baseMapper.countStreetAlert(businessAlertBo,startTime,endTime,deptIdList);

19
dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml

@ -475,8 +475,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM
warning_summary ws
LEFT JOIN business_alert ba ON ws.label_en = ba.label_en
WHERE
1=1
and ba.handle_type != 'verify'
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m-%d') >= #{startTime} ]]>
and <![CDATA[ DATE_FORMAT(ba.create_time, '%Y-%m-%d') <= #{endTime} ]]>
@ -736,5 +734,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<update id="batchUpdateDept">
UPDATE business_alert
SET
dept_id =
<foreach collection="list" item="item" separator=" " open="CASE id" close="END">
WHEN #{item.id} THEN #{item.deptId}
</foreach>,
dept_name =
<foreach collection="list" item="item" separator=" " open="CASE id" close="END">
WHEN #{item.id} THEN #{item.deptName}
</foreach>
WHERE id IN
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
</update>
</mapper>

11
dk-modules/sample/src/main/java/org/dromara/sample/wayline/service/impl/AiCompareServiceImpl.java

@ -17,6 +17,7 @@ import org.dromara.business.api.domain.vo.RemoteBusinessAlertVo;
import org.dromara.common.core.constant.AiCompareStatusConstants;
import org.dromara.common.core.constant.BusinessConstants;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
@ -70,7 +71,7 @@ public class AiCompareServiceImpl implements IAiCompareService {
@DubboReference
private final RemoteBusinessAlertService businessAlertService;
@DubboReference
@DubboReference(timeout = 30000)
private RemoteWorkflowService remoteWorkflowService;
@Override
@ -244,8 +245,13 @@ public class AiCompareServiceImpl implements IAiCompareService {
return businessAlertService.deleteAlert(ids);
}
@Transactional(rollbackFor = Exception.class)
@Override
public Boolean commitAlert(List<Map<String, Object>> alertList) {
if (ObjectUtil.isEmpty(alertList)) {
throw new ServiceException("预警信息为空!");
}
List<RemoteStartProcess> startProcessList = alertList.stream().map(map -> {
String flowCode = remoteWorkflowService.getFlowCode(map.get("labelEn").toString());
RemoteStartProcess remoteStartProcess = new RemoteStartProcess();
@ -254,6 +260,9 @@ public class AiCompareServiceImpl implements IAiCompareService {
return remoteStartProcess;
}).toList();
//更新部门信息
businessAlertService.batchUpdateDept(alertList);
return remoteWorkflowService.startWorkFlowBatch(startProcessList);
}

10
dk-modules/system/src/main/java/org/dromara/system/controller/system/SysDeptController.java

@ -42,6 +42,16 @@ public class SysDeptController extends BaseController {
return R.ok(depts);
}
/**
* 获取部门列表
*/
@SaCheckPermission("system:dept:list")
@GetMapping("/list/tree/{deptId}")
public R<List<SysDeptVo>> listTreeDept(@PathVariable Long deptId) {
List<SysDeptVo> depts = deptService.listTreeDept(deptId);
return R.ok(depts);
}
/**
* 查询部门列表排除节点
*

4
dk-modules/system/src/main/java/org/dromara/system/dubbo/RemoteLabelPostServicelmpl.java

@ -4,6 +4,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StreamUtils;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.system.api.RemoteLabelPostService;
import org.dromara.system.api.domain.vo.RemoteAiLabelPostVo;
import org.dromara.system.domain.AiLabel;
@ -34,6 +35,9 @@ public class RemoteLabelPostServicelmpl implements RemoteLabelPostService {
@Override
public List<RemoteAiLabelPostVo> selectLabelByList(String postCode, Long deptId) {
if (LoginHelper.isSuperAdmin()){
deptId = null;
}
//获取岗位只能Id
SysPostVo sysPostVo = sysPostService.selectLableByList(postCode, deptId);
if(sysPostVo != null){

3
dk-modules/system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java

@ -55,7 +55,7 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
*/
default List<SysDept> selectListByParentId(Long parentId) {
return this.selectList(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptId,SysDept::getDeptName)
.select(SysDept::getDeptId,SysDept::getDeptName,SysDept::getParentId)
.apply(DataBaseHelper.findInSet(parentId, "ancestors")));
}
@ -72,4 +72,5 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
List<Map<String,Object>> getNamePathList();
List<SysDeptVo> listTreeDept(@Param("deptId") Long deptId);
}

2
dk-modules/system/src/main/java/org/dromara/system/service/ISysDeptService.java

@ -155,4 +155,6 @@ public interface ISysDeptService {
SysDeptVo getByParentId(String deptId);
List<SysDeptVo> listTreeDept(Long deptId);
}

5
dk-modules/system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java

@ -381,4 +381,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
return BeanUtil.copyProperties(sysDept, SysDeptVo.class);
}
@Override
public List<SysDeptVo> listTreeDept(Long deptId) {
return baseMapper.listTreeDept(deptId);
}
}

19
dk-modules/system/src/main/resources/mapper/system/SysDeptMapper.xml

@ -84,4 +84,23 @@
deptId
</select>
<select id="listTreeDept" resultType="org.dromara.system.domain.vo.SysDeptVo">
WITH RECURSIVE warning_summary AS (
SELECT
sd1.*
FROM
dk_cloud.sys_dept sd1
WHERE
dept_id = #{deptId}
UNION ALL
SELECT
d.*
FROM
dk_cloud.sys_dept d
JOIN warning_summary dt ON d.parent_id = dt.dept_id
WHERE
d.del_flag = '0'
)select * from warning_summary
</select>
</mapper>

5
dk-modules/system/src/main/resources/mapper/system/SysPostMapper.xml

@ -27,7 +27,10 @@
</select>
<select id="selectLableByList" resultType="org.dromara.system.domain.vo.SysPostVo">
select p.post_id, p.dept_id, p.post_name, p.post_code, p.post_category from sys_post p
where p.post_code=#{postCode} and p.dept_id=#{deptId}
where p.post_code=#{postCode}
<if test="deptId != null and deptId != ''">
and p.dept_id=#{deptId}
</if>
</select>
<select id="getPostCode" resultType="java.lang.String">

Loading…
Cancel
Save