Browse Source

网格员数据同步

master
sunyuchao 3 years ago
parent
commit
4d90a611b2
  1. 117
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/ScreenPyGridStaffDTO.java
  2. 4
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java
  3. 6
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java
  4. 36
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenPyGridStaffController.java
  5. 36
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/ScreenPyGridStaffDao.java
  6. 84
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcoll/ScreenPyGridStaffEntity.java
  7. 15
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/ScreenPyGridStaffService.java
  8. 53
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/ScreenPyGridStaffServiceImpl.java
  9. 18
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/ScreenPyGridStaffDao.xml
  10. 19
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridstaffInfoPingyinServiceImpl.java

117
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/ScreenPyGridStaffDTO.java

@ -0,0 +1,117 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.indexcollect;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 平阴区网格员基础信息
*
* @author generator generator@elink-cn.com
*/
@Data
public class ScreenPyGridStaffDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID 主键
*/
private String id;
/**
* 客户Id
*/
private String customerId;
/**
* 网格Id
*/
private String gridId;
/**
* 网格编码
*/
private String gridCode;
/**
* 网格名称
*/
private String gridName;
/**
* 网格名称
*/
private String pids;
/**
* 工作人员Id
*/
private String staffId;
/**
* 网格员姓名
*/
private String staffName;
/**
* 手机号
*/
private String mobile;
/**
* 是否离职格式为YN
*/
private String isLeave;
/**
* 删除标识 0未删除1已删除
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

4
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java

@ -8,6 +8,7 @@ import com.epmet.dto.basereport.result.EventInfoResultDTO;
import com.epmet.dto.extract.form.*;
import com.epmet.dto.group.form.GroupStatsFormDTO;
import com.epmet.dto.group.form.GroupTotalFormDTO;
import com.epmet.dto.indexcollect.ScreenPyGridStaffDTO;
import com.epmet.dto.org.form.GridBaseInfoFormDTO;
import com.epmet.dto.org.result.CustomerAgencyDTO;
import com.epmet.dto.org.result.CustomerGridDTO;
@ -383,4 +384,7 @@ public interface DataStatisticalOpenFeignClient {
@PostMapping("/data/stats/datareporting/saveData")
Result saveData(@RequestBody SavePyEventDataFormDTO formDTO);
@PostMapping("/data/stats/screenPyStaffData/savelist")
Result saveList(@RequestBody List<ScreenPyGridStaffDTO> dtoList);
}

6
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java

@ -9,6 +9,7 @@ import com.epmet.dto.basereport.result.EventInfoResultDTO;
import com.epmet.dto.extract.form.*;
import com.epmet.dto.group.form.GroupStatsFormDTO;
import com.epmet.dto.group.form.GroupTotalFormDTO;
import com.epmet.dto.indexcollect.ScreenPyGridStaffDTO;
import com.epmet.dto.org.form.GridBaseInfoFormDTO;
import com.epmet.dto.org.result.CustomerAgencyDTO;
import com.epmet.dto.org.result.CustomerGridDTO;
@ -378,4 +379,9 @@ public class DataStatisticalOpenFeignClientFallBack implements DataStatisticalOp
public Result saveData(SavePyEventDataFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "SavePyEventDataFormDTO", formDTO);
}
@Override
public Result saveList(List<ScreenPyGridStaffDTO> dtoList) {
return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "saveList", dtoList);
}
}

36
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenPyGridStaffController.java

@ -0,0 +1,36 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.indexcollect.ScreenPyGridStaffDTO;
import com.epmet.service.evaluationindex.indexcoll.ScreenPyGridStaffService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 平阴区网格员基础信息
*
* @author generator generator@elink-cn.com
*/
@Slf4j
@RestController
@RequestMapping("screenPyGridStaff")
public class ScreenPyGridStaffController {
@Autowired
private ScreenPyGridStaffService screenPyStaffDataService;
@PostMapping("savelist")
public Result saveList(@RequestBody List<ScreenPyGridStaffDTO> dtoList) {
screenPyStaffDataService.saveList(dtoList);
return new Result();
}
}

36
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/ScreenPyGridStaffDao.java

@ -0,0 +1,36 @@
package com.epmet.dao.evaluationindex.indexcoll; /**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.evaluationindex.indexcoll.ScreenPyGridStaffEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 平阴区网格员基础信息
*
* @author generator generator@elink-cn.com
*/
@Mapper
public interface ScreenPyGridStaffDao extends BaseDao<ScreenPyGridStaffEntity> {
ScreenPyGridStaffEntity selectStaff(@Param("gridId") String gridId, @Param("staffId") String staffId);
}

84
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcoll/ScreenPyGridStaffEntity.java

@ -0,0 +1,84 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity.evaluationindex.indexcoll;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 平阴区网格员基础信息
*
* @author generator generator@elink-cn.com
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("screen_py_grid_staff")
public class ScreenPyGridStaffEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户Id
*/
private String customerId;
/**
* 网格Id
*/
private String gridId;
/**
* 网格编码
*/
private String gridCode;
/**
* 网格名称
*/
private String gridName;
/**
* 网格名称
*/
private String pids;
/**
* 工作人员Id
*/
private String staffId;
/**
* 网格员姓名
*/
private String staffName;
/**
* 手机号
*/
private String mobile;
/**
* 是否离职格式为YN
*/
private String isLeave;
}

15
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/ScreenPyGridStaffService.java

@ -0,0 +1,15 @@
package com.epmet.service.evaluationindex.indexcoll;
import com.epmet.dto.indexcollect.ScreenPyGridStaffDTO;
import java.util.List;
/**
* 平阴区网格员基础信息
*
* @author generator generator@elink-cn.com
*/
public interface ScreenPyGridStaffService {
void saveList(List<ScreenPyGridStaffDTO> dtoList);
}

53
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/ScreenPyGridStaffServiceImpl.java

@ -0,0 +1,53 @@
package com.epmet.service.evaluationindex.indexcoll.impl;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.evaluationindex.indexcoll.ScreenPyGridStaffDao;
import com.epmet.dto.indexcollect.ScreenPyGridStaffDTO;
import com.epmet.entity.evaluationindex.indexcoll.ScreenPyGridStaffEntity;
import com.epmet.service.evaluationindex.indexcoll.ScreenPyGridStaffService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 平阴区网格员基础信息
*
* @author generator generator@elink-cn.com
*/
@Slf4j
@Service
@DataSource(DataSourceConstant.EVALUATION_INDEX)
public class ScreenPyGridStaffServiceImpl extends BaseServiceImpl<ScreenPyGridStaffDao, ScreenPyGridStaffEntity> implements ScreenPyGridStaffService {
@Override
public void saveList(List<ScreenPyGridStaffDTO> dtoList) {
dtoList.forEach(d -> {
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(StrConstant.PY_CUSTOMER, d.getStaffId());
if (null == staffInfo) {
throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", d.getStaffId()));
}
ScreenPyGridStaffEntity entity = baseDao.selectStaff(d.getGridId(), d.getStaffId());
//存在就更新 不存在就新增
if (null != entity) {
ScreenPyGridStaffEntity entity1 = ConvertUtils.sourceToTarget(d, ScreenPyGridStaffEntity.class);
entity1.setId(entity.getId());
entity1.setPids(("".equals(staffInfo.getAgencyPIds()) ? staffInfo.getAgencyId() : staffInfo.getAgencyPIds() + ":") + staffInfo.getAgencyId());
baseDao.updateById(entity1);
} else {
ScreenPyGridStaffEntity saveEntity = ConvertUtils.sourceToTarget(d, ScreenPyGridStaffEntity.class);
saveEntity.setId(IdWorker.getIdStr());
saveEntity.setPids(("".equals(staffInfo.getAgencyPIds()) ? staffInfo.getAgencyId() : staffInfo.getAgencyPIds() + ":") + staffInfo.getAgencyId());
insert(saveEntity);
}
});
}
}

18
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/ScreenPyGridStaffDao.xml

@ -0,0 +1,18 @@
<?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.evaluationindex.indexcoll.ScreenPyGridStaffDao">
<select id="selectStaff" resultType="com.epmet.entity.evaluationindex.indexcoll.ScreenPyGridStaffEntity">
SELECT
*
FROM
screen_py_grid_staff
WHERE
del_flag = '0'
AND staff_id = #{staffId}
AND grid_id = #{gridId}
LIMIT 1
</select>
</mapper>

19
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridstaffInfoPingyinServiceImpl.java

@ -7,6 +7,7 @@ import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.CustomerGridStaffListFormDTO;
import com.epmet.dto.form.GridStaffUploadtFormDTO;
import com.epmet.dto.indexcollect.ScreenPyGridStaffDTO;
import com.epmet.dto.result.CustomerGridStaffListResultDTO;
import com.epmet.dto.result.GridStaffUploadResultDTO;
import com.epmet.dto.user.result.GridUserInfoDTO;
@ -119,6 +120,7 @@ public class GridstaffInfoPingyinServiceImpl extends BaseServiceImpl<GridstaffIn
}
//2.中间库新增/修改数据【基本一个人一条数据,程序按批量处理】
List<ScreenPyGridStaffDTO> staffList = new ArrayList<>();
result.getData().forEach(r -> {
GridstaffInfoPingyinEntity entity = ConvertUtils.sourceToTarget(r, GridstaffInfoPingyinEntity.class);
entity.setQxBm("370124");
@ -142,7 +144,24 @@ public class GridstaffInfoPingyinServiceImpl extends BaseServiceImpl<GridstaffIn
} else {
insert(entity);
}
ScreenPyGridStaffDTO dto = ConvertUtils.sourceToTarget(entity, ScreenPyGridStaffDTO.class);
dto.setCustomerId(r.getCustomerId());
dto.setGridId(r.getGridId());
dto.setGridCode(r.getCode());
dto.setGridName(r.getGridName());
dto.setStaffId(r.getStaffId());
dto.setStaffName(r.getNickName());
dto.setMobile(r.getPhonenumber());
dto.setIsLeave(r.getIsLeave());
staffList.add(dto);
});
if(CollectionUtils.isNotEmpty(staffList)){
try{
dataStatisticalOpenFeignClient.saveList(staffList);
} catch (Exception e) {
log.error("method exception", e);
}
}
}

Loading…
Cancel
Save