Browse Source

社会组织导入

dev_shibei_match
sunyuchao 4 years ago
parent
commit
ad5f07fde5
  1. 4
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java
  2. 7
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcSocietyOrgDao.java
  3. 35
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcSocietyOrgServiceImpl.java
  4. 22
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcSocietyOrgDao.xml
  5. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java

4
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java

@ -139,7 +139,7 @@ public class IcSocietyOrgController {
/**
* @Author sun
* @Description 九小场所下组织列表导入---咱不能使用 程序未开发
* @Description 九小场所下组织列表导入
**/
@PostMapping("import")
public Result importExcel(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file) throws IOException, ParseException {
@ -151,7 +151,7 @@ public class IcSocietyOrgController {
List<Integer> numList = new ArrayList<>();
if (!CollectionUtils.isEmpty(failList)) {
for (IcSocietyOrgExcel entity : failList) {
log.error("第{}行,{}", entity.getRowNum(), entity.getErrorMsg());//打印失败的行 和失败的信息
log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg());//打印失败的行 和失败的信息
numList.add(entity.getRowNum());
}
//return new Result().error(8001,failList.get(0).getErrorMsg());

7
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcSocietyOrgDao.java

@ -18,6 +18,7 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.IcSocietyOrgDTO;
import com.epmet.dto.form.GetListSocietyOrgFormDTO;
import com.epmet.dto.result.GetListSocietyOrgResultDTO;
import com.epmet.dto.result.SocietyOrgListResultDTO;
@ -53,4 +54,10 @@ public interface IcSocietyOrgDao extends BaseDao<IcSocietyOrgEntity> {
@Param("societyName")String societyName,
@Param("customerId")String customerId,
@Param("queryPurpose")String queryPurpose);
/**
* @Author sun
* @Description 查询当前组织下的社会组织数据
**/
List<IcSocietyOrgDTO> getByAgencyId(@Param("agencyId") String agencyId);
}

35
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcSocietyOrgServiceImpl.java

@ -27,6 +27,7 @@ import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcSocietyOrgDao;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.IcSocietyOrgDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.form.demand.ServiceQueryFormDTO;
import com.epmet.dto.result.*;
@ -179,20 +180,36 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl<IcSocietyOrgDao, Ic
return resultList;
}
/**
* @Author sun
* @Description 九小场所下组织列表导入
**/
@Override
public List<Integer> importExcel(String customerId, List<IcSocietyOrgExcel> list, String staffId, List<Integer> numList) throws ParseException {
//1.数据校验 只允许导入当前组织下社会组织
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId);
//查询当前组织下的社会组织数据
List<IcSocietyOrgDTO> societyOrgList = baseDao.getByAgencyId(staffInfoCache.getAgencyId());
//1.数据校验 只允许导入当前组织下社会组织且是当前组织下不存在的社会组织
//组织名称不一样的数据舍弃
Iterator<IcSocietyOrgExcel> iterator = list.iterator();
while (iterator.hasNext()) {
IcSocietyOrgExcel obj = iterator.next();
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) {
numList.add(obj.getRowNum());
log.warn(String.format("不是当前组织下可导入的数据,组织名称->%s,行号->%s", obj.getAgencyName(), obj.getRowNum()));
iterator.remove();
continue;
}
societyOrgList.forEach(org -> {
if (obj.getSocietyName().equals(org.getSocietyName())) {
numList.add(obj.getRowNum());
log.warn(String.format("当前组织下的社会组织已存在,社会组织名称->%s,行号->%s", obj.getSocietyName(), obj.getRowNum()));
iterator.remove();
}
});
}
if(CollectionUtils.isEmpty(list)){
if (CollectionUtils.isEmpty(list)) {
return numList;
}
@ -205,12 +222,21 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl<IcSocietyOrgDao, Ic
if (!staffResult.success()) {
throw new RenException("获取工作人员基础信息失败......");
}
if (null == staffResult.getData()) {
Iterator<IcSocietyOrgExcel> iter = list.iterator();
while (iter.hasNext()) {
IcSocietyOrgExcel obj = iter.next();
numList.add(obj.getRowNum());
iterator.remove();
}
return numList;
}
Map<String, String> map = staffResult.getData().stream().collect(Collectors.toMap(CustomerStaffDTO::getRealName, CustomerStaffDTO::getUserId));
//3.遍历封装有效数据
List<IcSocietyOrgEntity> houseEntityList = new ArrayList<>();
Iterator<IcSocietyOrgExcel> iterator1 = list.iterator();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
while (iterator1.hasNext()) {
IcSocietyOrgExcel icHouseExcel = iterator1.next();
IcSocietyOrgEntity entity = new IcSocietyOrgEntity();
@ -223,9 +249,10 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl<IcSocietyOrgDao, Ic
entity.setMobile(icHouseExcel.getMobile());
entity.setServiceStartTime(sdf.parse(icHouseExcel.getServiceStartTime()));
entity.setServiceEndTime(sdf.parse(icHouseExcel.getServiceEndTime()));
entity.setAdminStaffId(map.containsKey(icHouseExcel.getAdminStaffName().trim())?map.get(icHouseExcel.getAdminStaffName().trim()):"");
entity.setAdminStaffId(map.containsKey(icHouseExcel.getAdminStaffName().trim()) ? map.get(icHouseExcel.getAdminStaffName().trim()) : "");
if ("".equals(entity.getAdminStaffId())) {
numList.add(icHouseExcel.getRowNum());
log.warn(String.format("绑定的管理员不存在,管理员名称->%s,行号->%s", icHouseExcel.getAdminStaffName(), icHouseExcel.getRowNum()));
iterator1.remove();
continue;
}

22
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcSocietyOrgDao.xml

@ -65,4 +65,26 @@
</if>
</foreach>
</select>
<select id="getByAgencyId" resultType="com.epmet.dto.IcSocietyOrgDTO">
SELECT
agency_id agencyId,
id societyId,
society_name societyName,
service_matters serviceMatters,
person_in_charge personInCharge,
mobile mobile,
service_start_time serviceStartTime,
service_end_time serviceEndTime,
admin_staff_id adminStaffId,
address address,
longitude longitude,
latitude latitude
FROM
ic_society_org
WHERE
del_flag = '0'
AND agency_id = #{agencyId}
</select>
</mapper>

2
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java

@ -658,6 +658,6 @@ public interface EpmetUserOpenFeignClient {
* @Author sun
* @Description 根据工作人员姓名批量查询基础信息数据
**/
@GetMapping(value = "epmetuser/customerstaff/getbyrealnames")
@PostMapping(value = "epmetuser/customerstaff/getbyrealnames")
Result<List<CustomerStaffDTO>> getByRealNames(@RequestBody GetByRealNamesFormDTO formDTO);
}

Loading…
Cancel
Save