diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java
index 9e502bd6ca..84580a3b4a 100644
--- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java
+++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java
@@ -75,4 +75,14 @@ public interface SystemMessageType {
*/
String USER_PATROL_STOP = "user_patrol_stop";
+ /**
+ * 项目变动
+ */
+ String PROJECT_ADD = "project_add";
+
+ /**
+ * 项目变动
+ */
+ String PROJECT_EDIT = "project_edit";
+
}
diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java
index 551bb9d4ec..e232f5f635 100644
--- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java
+++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java
@@ -182,4 +182,35 @@ public class SendMqMsgUtil {
}
+ /**
+ * desc: 发送项目变动事件消息
+ *
+ * @param msgContent
+ * @return boolean
+ * @author LiuJanJun
+ * @date 2021/4/23 3:01 下午
+ * @remark 失败重试1次,调用端自行判断如果失败是否要继续执行
+ */
+ public boolean sendProjectMqMsg(DisputeProcessMQMsg msgContent) {
+ try {
+ SystemMsgFormDTO systemMsgFormDTO = new SystemMsgFormDTO();
+ systemMsgFormDTO.setMessageType(msgContent.getType());
+ systemMsgFormDTO.setContent(msgContent);
+ Result sendMsgResult;
+ log.info("sendProjectMqMsg param:{}",msgContent);
+ int retryTime = 0;
+ do {
+ sendMsgResult = epmetMessageOpenFeignClient.sendSystemMsgByMQ(systemMsgFormDTO);
+ } while ((sendMsgResult == null || !sendMsgResult.success()) && retryTime++ < NumConstant.TWO);
+
+ if (sendMsgResult != null && sendMsgResult.success()) {
+ return true;
+ }
+ log.error("发送(项目变动)系统消息到message服务失败:{},msg:{}", JSON.toJSONString(sendMsgResult), JSON.toJSONString(systemMsgFormDTO));
+ } catch (Exception e) {
+ log.error("sendMqMsg exception", e);
+ }
+ return false;
+ }
+
}
diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java
index dfd6737b57..61373708df 100644
--- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java
+++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java
@@ -183,6 +183,10 @@ public class SystemMessageServiceImpl implements SystemMessageService {
case SystemMessageType.USER_PATROL_STOP:
topic = TopicConstants.PATROL;
break;
+ case SystemMessageType.PROJECT_ADD:
+ case SystemMessageType.PROJECT_EDIT:
+ topic = TopicConstants.PROJECT;
+ break;
}
return topic;
}
@@ -208,6 +212,7 @@ public class SystemMessageServiceImpl implements SystemMessageService {
case TopicConstants.PATROL:
case TopicConstants.POINT:
case TopicConstants.STAFF:
+ case TopicConstants.PROJECT:
// 耗时较短。一个小时最多发送一次告警
if (l1LastAlertTime == null || (
diff --git a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/BaseDisputeProcessDTO.java b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/BaseDisputeProcessDTO.java
index 38ab49fc12..2f377e9ac9 100644
--- a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/BaseDisputeProcessDTO.java
+++ b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/BaseDisputeProcessDTO.java
@@ -44,6 +44,10 @@ public class BaseDisputeProcessDTO implements Serializable {
*/
private String customerId;
+ private Integer detpId;
+
+ private String reporterId;
+
/**
* 网格编码
*/
diff --git a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/ExDeptDTO.java b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/ExDeptDTO.java
new file mode 100644
index 0000000000..cd092d52ba
--- /dev/null
+++ b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/ExDeptDTO.java
@@ -0,0 +1,81 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.opendata.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * 部门(网格)中间表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2021-10-19
+ */
+@Data
+public class ExDeptDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * (市平台)部门id
+ */
+ private Integer deptId;
+
+ /**
+ * (市平台)父部门id
+ */
+ private Integer parentId;
+
+ /**
+ * 祖级列表
+ */
+ private String ancestors;
+
+ /**
+ * (市平台)部门/网格名称
+ */
+ private String fullName;
+
+ /**
+ * (市平台)部门/网格简称
+ */
+ private String deptName;
+
+ /**
+ * (市平台)部门/网格编码
+ */
+ private String deptCode;
+
+ /**
+ *
+ */
+ private String gridCode;
+
+ /**
+ * (区县平台)部门id
+ */
+ private String deptIdQx;
+
+ /**
+ * (区县平台)部门/网格名称
+ */
+ private String deptNameQx;
+
+}
\ No newline at end of file
diff --git a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/GridBaseInfoFormDTO.java b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/GridBaseInfoFormDTO.java
index c1952d1bcf..0b1910a2ea 100644
--- a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/GridBaseInfoFormDTO.java
+++ b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/GridBaseInfoFormDTO.java
@@ -25,7 +25,7 @@ public class GridBaseInfoFormDTO implements Serializable {
*/
private List orgIdList;
/**
- * 操作类型【新增:add 修改删除:edit】
+ * 操作类型【新增:add 修改删除:edit 初始化所有数据:all】
*/
private String type;
diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/ExDeptDao.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/ExDeptDao.java
new file mode 100644
index 0000000000..fa088c958f
--- /dev/null
+++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/ExDeptDao.java
@@ -0,0 +1,55 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.opendata.dao;
+
+import com.epmet.commons.mybatis.dao.BaseDao;
+import com.epmet.opendata.entity.BaseGridInfoEntity;
+import com.epmet.opendata.entity.ExDeptEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 网格基础信息表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2021-10-15
+ */
+@Mapper
+public interface ExDeptDao extends BaseDao {
+
+ /**
+ * @Author sun
+ * @Description 网格基础信息批量更新部分字段
+ **/
+ int updateBatch(@Param("list") List entityList);
+
+ /**
+ * @Author sun
+ * @Description 网格基础信息批量更新部分字段
+ **/
+ int insertBatch(@Param("list") List entityList);
+
+ /**
+ * @Author sun
+ * @Description 网格基础信息批量更新部分字段
+ **/
+ int updateBatchGrid(@Param("list") List entityList);
+
+}
\ No newline at end of file
diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseDisputeProcessEntity.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseDisputeProcessEntity.java
index c7266558ed..3f458a026a 100644
--- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseDisputeProcessEntity.java
+++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseDisputeProcessEntity.java
@@ -44,6 +44,10 @@ public class BaseDisputeProcessEntity extends BaseEpmetEntity {
*/
private String customerId;
+ private Integer detpId;
+
+ private String reporterId;
+
/**
* 网格编码
*/
diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/ExDeptEntity.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/ExDeptEntity.java
new file mode 100644
index 0000000000..7a2d2e3ff8
--- /dev/null
+++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/ExDeptEntity.java
@@ -0,0 +1,82 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.opendata.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 部门(网格)中间表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2021-10-19
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("ex_dept")
+public class ExDeptEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * (市平台)部门id
+ */
+ private Integer deptId;
+
+ /**
+ * (市平台)父部门id
+ */
+ private Integer parentId;
+
+ /**
+ * 祖级列表
+ */
+ private String ancestors;
+
+ /**
+ * (市平台)部门/网格名称
+ */
+ private String fullName;
+
+ /**
+ * (市平台)部门/网格简称
+ */
+ private String deptName;
+
+ /**
+ * (市平台)部门/网格编码
+ */
+ private String deptCode;
+
+ /**
+ *
+ */
+ private String gridCode;
+
+ /**
+ * (区县平台)部门id
+ */
+ private String deptIdQx;
+
+ /**
+ * (区县平台)部门/网格名称
+ */
+ private String deptNameQx;
+
+}
diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/RocketMQConsumerRegister.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/RocketMQConsumerRegister.java
index 2ffed8c3dd..3fa339bc0b 100644
--- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/RocketMQConsumerRegister.java
+++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/RocketMQConsumerRegister.java
@@ -43,9 +43,9 @@ public class RocketMQConsumerRegister extends MQAbstractRegister {
"*",
new OpenDataPatrolChangeEventListener());
register(consumerProperties,
- ConsomerGroupConstants.PROJECT_CHANGED_COMPONENTS_GROUP,
+ ConsomerGroupConstants.OPEN_DATA_PROJECT_CHANGE_EVENT_LISTENER_GROUP,
MessageModel.CLUSTERING,
- TopicConstants.PROJECT_CHANGED,
+ TopicConstants.PROJECT,
"*",
new OpenDataProjectChangeEventListener());
diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataProjectChangeEventListener.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataProjectChangeEventListener.java
index e82e2cd8c9..c2af1cffe7 100644
--- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataProjectChangeEventListener.java
+++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataProjectChangeEventListener.java
@@ -2,11 +2,13 @@ package com.epmet.opendata.mq.listener;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.rocketmq.constants.MQUserPropertys;
+import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
+import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.SpringContextUtils;
import com.epmet.dto.basereport.form.EventInfoFormDTO;
import com.epmet.feign.EpmetMessageOpenFeignClient;
@@ -63,7 +65,8 @@ public class OpenDataProjectChangeEventListener implements MessageListenerConcur
//messageExt.propert
logger.info("【开放数据事件监听器】-项目信息变更-收到消息内容:{}, 操作:{}, pendingMsgLabel:{}", msg, tags, pendingMsgLabel);
- EventInfoFormDTO obj = JSON.parseObject(msg, EventInfoFormDTO.class);
+ DisputeProcessMQMsg obj = JSON.parseObject(msg, DisputeProcessMQMsg.class);
+ EventInfoFormDTO formDTO = ConvertUtils.sourceToTarget(obj, EventInfoFormDTO.class);
DistributedLock distributedLock = null;
RLock lock = null;
@@ -71,7 +74,7 @@ public class OpenDataProjectChangeEventListener implements MessageListenerConcur
distributedLock = SpringContextUtils.getBean(DistributedLock.class);
lock = distributedLock.getLock(String.format("lock:open_data_project:%s", obj.getProjectId()),
30L, 30L, TimeUnit.SECONDS);
- SpringContextUtils.getBean(BaseDisputeProcessService.class).getEventinfo(obj);
+ SpringContextUtils.getBean(BaseDisputeProcessService.class).getEventinfo(formDTO);
} catch (RenException e) {
// 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
logger.error("【开放数据事件监听器】-项目信息变更-上报项目信息失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/ExDeptService.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/ExDeptService.java
new file mode 100644
index 0000000000..644c06c673
--- /dev/null
+++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/ExDeptService.java
@@ -0,0 +1,97 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.opendata.service;
+
+import com.epmet.commons.mybatis.service.BaseService;
+import com.epmet.commons.tools.page.PageData;
+import com.epmet.opendata.dto.ExDeptDTO;
+import com.epmet.opendata.entity.ExDeptEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 部门(网格)中间表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2021-10-19
+ */
+public interface ExDeptService extends BaseService {
+
+ /**
+ * 默认分页
+ *
+ * @param params
+ * @return PageData
+ * @author generator
+ * @date 2021-10-19
+ */
+ PageData page(Map params);
+
+ /**
+ * 默认查询
+ *
+ * @param params
+ * @return java.util.List
+ * @author generator
+ * @date 2021-10-19
+ */
+ List list(Map params);
+
+ /**
+ * 单条查询
+ *
+ * @param id
+ * @return ExDeptDTO
+ * @author generator
+ * @date 2021-10-19
+ */
+ ExDeptDTO get(String id);
+
+ /**
+ * 默认保存
+ *
+ * @param dto
+ * @return void
+ * @author generator
+ * @date 2021-10-19
+ */
+ void save(ExDeptDTO dto);
+
+ /**
+ * 默认更新
+ *
+ * @param dto
+ * @return void
+ * @author generator
+ * @date 2021-10-19
+ */
+ void update(ExDeptDTO dto);
+
+ /**
+ * 批量删除
+ *
+ * @param ids
+ * @return void
+ * @author generator
+ * @date 2021-10-19
+ */
+ void delete(String[] ids);
+
+ Map getDeptMap();
+}
\ No newline at end of file
diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java
index 0a0d18a9f0..8068eda5cc 100644
--- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java
+++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java
@@ -18,20 +18,24 @@
package com.epmet.opendata.service.impl;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
+import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
+import com.epmet.constant.SystemMessageType;
import com.epmet.dto.basereport.form.EventInfoFormDTO;
import com.epmet.feign.DataStatisticalOpenFeignClient;
import com.epmet.opendata.dao.BaseDisputeProcessDao;
import com.epmet.opendata.dto.BaseDisputeProcessDTO;
import com.epmet.opendata.entity.BaseDisputeProcessEntity;
import com.epmet.opendata.service.BaseDisputeProcessService;
+import com.epmet.opendata.service.ExDeptService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
+import java.util.Map;
/**
* 事件信息表
@@ -43,6 +47,8 @@ import java.util.List;
public class BaseDisputeProcessServiceImpl extends BaseServiceImpl implements BaseDisputeProcessService {
@Resource
private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient;
+ @Resource
+ private ExDeptService exDeptService;
/**
* 获取上报事件
@@ -59,15 +65,37 @@ public class BaseDisputeProcessServiceImpl extends BaseServiceImpl deptMap = exDeptService.getDeptMap();
List list = result.getData();
if (CollectionUtils.isNotEmpty(list)) {
List entityList = ConvertUtils.sourceToTarget(list, BaseDisputeProcessEntity.class);
- if("add".equals(formDTO.getType())){
+ entityList.forEach(item -> {
+ item.setDetpId(deptMap.get(item.getOrgCode()));
+ });
+ if(SystemMessageType.PROJECT_ADD.equals(formDTO.getType())){
insertBatch(entityList);
}else {
updateBatchById(entityList);
}
}
+ //分批次循环
+ while (CollectionUtils.isNotEmpty(list)) {
+ formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE);
+ result = dataStatisticalOpenFeignClient.getEventInfo(formDTO);
+ list = result.getData();
+ if (CollectionUtils.isNotEmpty(list)) {
+ List entityList = ConvertUtils.sourceToTarget(list, BaseDisputeProcessEntity.class);
+ entityList.forEach(item -> {
+ item.setDetpId(deptMap.get(item.getOrgCode()));
+ });
+ if("add".equals(formDTO.getType())){
+ insertBatch(entityList);
+ }else {
+ updateBatchById(entityList);
+ }
+ }
+ }
+
}
diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridInfoServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridInfoServiceImpl.java
index 1d4f4a1e17..7802dfc707 100644
--- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridInfoServiceImpl.java
+++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridInfoServiceImpl.java
@@ -18,14 +18,17 @@
package com.epmet.opendata.service.impl;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
+import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.org.result.CustomerAgencyDTO;
import com.epmet.dto.org.result.CustomerGridDTO;
import com.epmet.feign.DataStatisticalOpenFeignClient;
import com.epmet.opendata.dao.BaseGridInfoDao;
+import com.epmet.opendata.dao.ExDeptDao;
import com.epmet.opendata.dto.form.GridBaseInfoFormDTO;
import com.epmet.opendata.entity.BaseGridInfoEntity;
+import com.epmet.opendata.entity.ExDeptEntity;
import com.epmet.opendata.service.BaseGridInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -44,6 +47,8 @@ import java.util.List;
public class BaseGridInfoServiceImpl extends BaseServiceImpl implements BaseGridInfoService {
@Autowired
private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient;
+ @Autowired
+ private ExDeptDao exDeptDao;
/**
* @Author sun
@@ -52,13 +57,16 @@ public class BaseGridInfoServiceImpl extends BaseServiceImpl> result = dataStatisticalOpenFeignClient.getAgencyBaseInfo(formDTO);
if (!result.success()) {
throw new RenException(result.getInternalMsg());
}
+ if (null == result.getData() || result.getData().size() < NumConstant.ONE) {
+ return;
+ }
//2.中间库新增/修改数据
- List entityList = new ArrayList<>();
+ /*List entityList = new ArrayList<>();
result.getData().forEach(ag->{
BaseGridInfoEntity entity = new BaseGridInfoEntity();
entity.setCustomerId(ag.getCustomerId());
@@ -76,13 +84,22 @@ public class BaseGridInfoServiceImpl extends BaseServiceImpl ExList = new ArrayList<>();
+ result.getData().forEach(ag->{
+ ExDeptEntity entity = new ExDeptEntity();
+ entity.setDeptIdQx(ag.getId());
+ entity.setDeptNameQx(ag.getOrganizationName());
+ entity.setGridCode(ag.getCode());
+ ExList.add(entity);
});
- if("add".equals(formDTO.getType())){
- insertBatch(entityList);
+ if(null!=formDTO.getType()&& "all".equals(formDTO.getType())){
+ exDeptDao.updateBatch(ExList);
}else {
- baseDao.updateBatch(entityList);
+ exDeptDao.insertBatch(ExList);
}
+
}
/**
@@ -97,8 +114,11 @@ public class BaseGridInfoServiceImpl extends BaseServiceImpl entityList = new ArrayList<>();
+ /*List entityList = new ArrayList<>();
result.getData().forEach(ag->{
BaseGridInfoEntity entity = new BaseGridInfoEntity();
entity.setCustomerId(ag.getCustomerId());
@@ -111,11 +131,19 @@ public class BaseGridInfoServiceImpl extends BaseServiceImpl ExList = new ArrayList<>();
+ result.getData().forEach(ag -> {
+ ExDeptEntity entity = new ExDeptEntity();
+ entity.setDeptIdQx(ag.getId());
+ entity.setDeptNameQx(ag.getGridName());
+ entity.setGridCode(ag.getCode());
+ ExList.add(entity);
});
- if("add".equals(formDTO.getType())){
- insertBatch(entityList);
- }else {
- baseDao.updateBatch(entityList);
+ if (null != formDTO.getType() && "all".equals(formDTO.getType())) {
+ exDeptDao.updateBatchGrid(ExList);
+ } else {
+ exDeptDao.insertBatch(ExList);
}
}
diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/ExDeptServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/ExDeptServiceImpl.java
new file mode 100644
index 0000000000..44b519e95b
--- /dev/null
+++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/ExDeptServiceImpl.java
@@ -0,0 +1,115 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.opendata.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
+import com.epmet.commons.tools.constant.FieldConstant;
+import com.epmet.commons.tools.page.PageData;
+import com.epmet.commons.tools.utils.ConvertUtils;
+import com.epmet.opendata.dao.ExDeptDao;
+import com.epmet.opendata.dto.ExDeptDTO;
+import com.epmet.opendata.entity.ExDeptEntity;
+import com.epmet.opendata.service.ExDeptService;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * 部门(网格)中间表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2021-10-19
+ */
+@Service
+public class ExDeptServiceImpl extends BaseServiceImpl implements ExDeptService {
+
+
+ @Override
+ public PageData page(Map params) {
+ IPage page = baseDao.selectPage(
+ getPage(params, FieldConstant.CREATED_TIME, false),
+ getWrapper(params)
+ );
+ return getPageData(page, ExDeptDTO.class);
+ }
+
+ @Override
+ public List list(Map params) {
+ List entityList = baseDao.selectList(getWrapper(params));
+
+ return ConvertUtils.sourceToTarget(entityList, ExDeptDTO.class);
+ }
+
+ private QueryWrapper getWrapper(Map params){
+ String id = (String)params.get(FieldConstant.ID_HUMP);
+
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
+
+ return wrapper;
+ }
+
+ @Override
+ public ExDeptDTO get(String id) {
+ ExDeptEntity entity = baseDao.selectById(id);
+ return ConvertUtils.sourceToTarget(entity, ExDeptDTO.class);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void save(ExDeptDTO dto) {
+ ExDeptEntity entity = ConvertUtils.sourceToTarget(dto, ExDeptEntity.class);
+ insert(entity);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void update(ExDeptDTO dto) {
+ ExDeptEntity entity = ConvertUtils.sourceToTarget(dto, ExDeptEntity.class);
+ updateById(entity);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void delete(String[] ids) {
+ // 逻辑删除(@TableLogic 注解)
+ baseDao.deleteBatchIds(Arrays.asList(ids));
+ }
+
+ @Override
+ public Map getDeptMap() {
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ wrapper.ne(ExDeptEntity::getGridCode, null);
+ List entityList = baseDao.selectList(wrapper);
+ if (CollectionUtils.isEmpty(entityList)) {
+ return Collections.emptyMap();
+ }
+ return entityList.stream().collect(Collectors.toMap(ExDeptEntity::getGridCode, ExDeptEntity::getDeptId, (key1, key2) -> key2));
+ }
+
+}
\ No newline at end of file
diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/ExDeptDao.xml b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/ExDeptDao.xml
new file mode 100644
index 0000000000..ba20d99170
--- /dev/null
+++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/ExDeptDao.xml
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ UPDATE ex_dept
+
+
+
+
+
+ when grid_code = #{item.gridCode} then #{item.deptIdQx}
+
+
+
+
+
+
+
+ when grid_code = #{item.gridCode} then #{item.deptNameQx}
+
+
+
+
+
+ WHERE
+ 1=1
+
+ grid_code = #{item.gridCode}
+
+
+
+
+ INSERT INTO ex_dept
+ (
+ dept_id_qx,
+ dept_name_qx,
+ grid_code
+ )
+ VALUES
+
+ (
+ #{i.deptIdQx},
+ #{i.deptNameQx},
+ #{i.gridCode}
+ )
+
+ ON DUPLICATE KEY
+ UPDATE
+ dept_id_qx = values(dept_id_qx),
+ dept_name_qx = values(dept_name_qx)
+
+
+
+ UPDATE ex_dept
+
+
+
+
+
+ when dept_name LIKE CONCAT(left(#{item.deptNameQx},2),'%',right(#{item.deptNameQx},2),if(LOCATE('第二', #{item.deptNameQx})>0,'%2','%1')) then #{item.deptIdQx}
+
+
+
+
+
+
+
+ when dept_name LIKE CONCAT(left(#{item.deptNameQx},2),'%',right(#{item.deptNameQx},2),if(LOCATE('第二', #{item.deptNameQx})>0,'%2','%1')) then #{item.deptNameQx}
+
+
+
+
+
+ WHERE
+ 1=1
+
+ dept_name LIKE CONCAT(left(#{item.deptNameQx},2),'%',right(#{item.deptNameQx},2),if(LOCATE('第二', #{item.deptNameQx})>0,'%2','%1'))
+
+
+
+
+
\ No newline at end of file