|
|
@ -26,6 +26,7 @@ import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
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.form.*; |
|
|
|
import com.epmet.dto.form.demand.ServiceQueryFormDTO; |
|
|
|
import com.epmet.dto.result.*; |
|
|
@ -46,9 +47,9 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -179,7 +180,64 @@ public class IcSocietyOrgServiceImpl extends BaseServiceImpl<IcSocietyOrgDao, Ic |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Integer> importExcel(String customerId, List<IcSocietyOrgExcel> result, String userId, List<Integer> numList) { |
|
|
|
public List<Integer> importExcel(String customerId, List<IcSocietyOrgExcel> list, String staffId, List<Integer> numList) throws ParseException { |
|
|
|
//1.数据校验 只允许导入当前组织下社会组织
|
|
|
|
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId); |
|
|
|
//组织名称不一样的数据舍弃
|
|
|
|
Iterator<IcSocietyOrgExcel> iterator = list.iterator(); |
|
|
|
while (iterator.hasNext()) { |
|
|
|
IcSocietyOrgExcel obj = iterator.next(); |
|
|
|
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) { |
|
|
|
numList.add(obj.getRowNum()); |
|
|
|
iterator.remove(); |
|
|
|
} |
|
|
|
} |
|
|
|
if(CollectionUtils.isEmpty(list)){ |
|
|
|
return numList; |
|
|
|
} |
|
|
|
|
|
|
|
//2.查询绑定的管理员信息
|
|
|
|
Set<String> staffNames = list.stream().map(item -> item.getAdminStaffName().trim()).collect(Collectors.toSet()); |
|
|
|
GetByRealNamesFormDTO dto = new GetByRealNamesFormDTO(); |
|
|
|
dto.setCustomerId(customerId); |
|
|
|
dto.setRealNames(staffNames); |
|
|
|
Result<List<CustomerStaffDTO>> staffResult = epmetUserOpenFeignClient.getByRealNames(dto); |
|
|
|
if (!staffResult.success()) { |
|
|
|
throw new RenException("获取工作人员基础信息失败......"); |
|
|
|
} |
|
|
|
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"); |
|
|
|
while (iterator1.hasNext()) { |
|
|
|
IcSocietyOrgExcel icHouseExcel = iterator1.next(); |
|
|
|
IcSocietyOrgEntity entity = new IcSocietyOrgEntity(); |
|
|
|
entity.setCustomerId(customerId); |
|
|
|
entity.setAgencyId(staffInfoCache.getAgencyId()); |
|
|
|
entity.setPids(staffInfoCache.getAgencyPIds()); |
|
|
|
entity.setSocietyName(icHouseExcel.getSocietyName()); |
|
|
|
entity.setServiceMatters(icHouseExcel.getServiceMatters()); |
|
|
|
entity.setPersonInCharge(icHouseExcel.getPersonInCharge()); |
|
|
|
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()):""); |
|
|
|
if ("".equals(entity.getAdminStaffId())) { |
|
|
|
numList.add(icHouseExcel.getRowNum()); |
|
|
|
iterator1.remove(); |
|
|
|
continue; |
|
|
|
} |
|
|
|
entity.setAddress(icHouseExcel.getAddress()); |
|
|
|
entity.setLongitude(icHouseExcel.getLongitude()); |
|
|
|
entity.setLatitude(icHouseExcel.getLatitude()); |
|
|
|
houseEntityList.add(entity); |
|
|
|
} |
|
|
|
|
|
|
|
//3.批量保存数据
|
|
|
|
insertBatch(houseEntityList); |
|
|
|
|
|
|
|
return numList; |
|
|
|
} |
|
|
|
|
|
|
|