|
@ -27,11 +27,18 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
|
|
import com.epmet.commons.tools.dto.form.IdAndNameDTO; |
|
|
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.dataaggre.constant.DataSourceConstant; |
|
|
import com.epmet.dataaggre.constant.DataSourceConstant; |
|
|
|
|
|
import com.epmet.dataaggre.constant.TDuckConstant; |
|
|
import com.epmet.dataaggre.dao.epmettduck.PrUserProjectDao; |
|
|
import com.epmet.dataaggre.dao.epmettduck.PrUserProjectDao; |
|
|
|
|
|
import com.epmet.dataaggre.dao.epmettduck.PrUserProjectResultDao; |
|
|
import com.epmet.dataaggre.dao.epmettduck.PrVistRecordDao; |
|
|
import com.epmet.dataaggre.dao.epmettduck.PrVistRecordDao; |
|
|
import com.epmet.dataaggre.dto.epmettduck.PrPublishRangeDTO; |
|
|
import com.epmet.dataaggre.dto.epmettduck.PrPublishRangeDTO; |
|
|
import com.epmet.dataaggre.dto.epmettduck.PrUserProjectDTO; |
|
|
import com.epmet.dataaggre.dto.epmettduck.PrUserProjectDTO; |
|
@ -49,6 +56,9 @@ import com.epmet.dataaggre.service.epmettduck.PrPublishRangeService; |
|
|
import com.epmet.dataaggre.service.epmettduck.PrUserProjectService; |
|
|
import com.epmet.dataaggre.service.epmettduck.PrUserProjectService; |
|
|
import com.epmet.dataaggre.service.epmettduck.PrVistRecordService; |
|
|
import com.epmet.dataaggre.service.epmettduck.PrVistRecordService; |
|
|
import com.epmet.dataaggre.service.govorg.GovOrgService; |
|
|
import com.epmet.dataaggre.service.govorg.GovOrgService; |
|
|
|
|
|
import com.epmet.dto.CustomerGridDTO; |
|
|
|
|
|
import com.epmet.dto.form.CustomerGridFormDTO; |
|
|
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
@ -76,13 +86,15 @@ import java.util.stream.Stream; |
|
|
public class PrUserProjectServiceImpl extends BaseServiceImpl<PrUserProjectDao, PrUserProjectEntity> implements PrUserProjectService { |
|
|
public class PrUserProjectServiceImpl extends BaseServiceImpl<PrUserProjectDao, PrUserProjectEntity> implements PrUserProjectService { |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private PrVistRecordDao visitRecordDao; |
|
|
private PrUserProjectResultDao prUserProjectResultDao; |
|
|
@Resource |
|
|
@Resource |
|
|
private PrPublishRangeService prPublishRangeService; |
|
|
private PrPublishRangeService prPublishRangeService; |
|
|
@Resource |
|
|
@Resource |
|
|
private GovOrgService govOrgService; |
|
|
private GovOrgService govOrgService; |
|
|
@Resource |
|
|
@Resource |
|
|
private PrVistRecordService prVistRecordService; |
|
|
private PrVistRecordService prVistRecordService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageData<PrUserProjectDTO> page(Map<String, Object> params) { |
|
|
public PageData<PrUserProjectDTO> page(Map<String, Object> params) { |
|
@ -157,26 +169,109 @@ public class PrUserProjectServiceImpl extends BaseServiceImpl<PrUserProjectDao, |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public List<TDuckListResultDTO> queryProjectList(TDuckListFormDTO formDTO) { |
|
|
public List<TDuckListResultDTO> queryProjectList(TDuckListFormDTO formDTO) { |
|
|
List<String> projectKeys = baseDao.selectProjectKey(formDTO.getOrgIds()); |
|
|
List<String> orgIds = new ArrayList<>(); |
|
|
|
|
|
// 工作端不需要传orgId
|
|
|
|
|
|
if (formDTO.getClient().equals(TDuckConstant.CLIENT_GOV)){ |
|
|
|
|
|
// 根据 客户ID 和 人ID 从redis获取信息
|
|
|
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); |
|
|
|
|
|
String pids = staffInfo.getAgencyPIds(); |
|
|
|
|
|
String agencyId = staffInfo.getAgencyId(); |
|
|
|
|
|
// 来源于 部门
|
|
|
|
|
|
if (staffInfo.getFromOrgType().equals(TDuckConstant.ORG_TYPE_DEPT)){ |
|
|
|
|
|
List<IdAndNameDTO> deptList = staffInfo.getDeptList(); |
|
|
|
|
|
if (CollectionUtils.isEmpty(deptList)){ |
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
} |
|
|
|
|
|
orgIds = joint(pids,agencyId,deptList); |
|
|
|
|
|
// 来源于 网格
|
|
|
|
|
|
}else if (staffInfo.getFromOrgType().equals(TDuckConstant.ORG_TYPE_GRID)){ |
|
|
|
|
|
List<IdAndNameDTO> gridList = staffInfo.getGridList(); |
|
|
|
|
|
if (CollectionUtils.isEmpty(gridList)){ |
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
} |
|
|
|
|
|
orgIds = joint(pids,agencyId,gridList); |
|
|
|
|
|
}else { |
|
|
|
|
|
String selfOrg = pids + ":" + agencyId; |
|
|
|
|
|
orgIds.add(selfOrg); |
|
|
|
|
|
} |
|
|
|
|
|
}else { |
|
|
|
|
|
CustomerGridFormDTO customerGridFormDTO = new CustomerGridFormDTO(); |
|
|
|
|
|
customerGridFormDTO.setGridId(formDTO.getOrgId()); |
|
|
|
|
|
// 查询网格信息
|
|
|
|
|
|
Result<CustomerGridDTO> gridResult = govOrgOpenFeignClient.getGridBaseInfoByGridId(customerGridFormDTO); |
|
|
|
|
|
if (!gridResult.success()){ |
|
|
|
|
|
throw new RenException("查询网格信息失败了..."); |
|
|
|
|
|
} |
|
|
|
|
|
CustomerGridDTO data = gridResult.getData(); |
|
|
|
|
|
String oneOrg = data.getPids() + ":" + data.getId(); |
|
|
|
|
|
orgIds.add(oneOrg); |
|
|
|
|
|
} |
|
|
|
|
|
// 根据orgIds查询 问卷调查的key
|
|
|
|
|
|
List<String> projectKeys = baseDao.selectProjectKey(orgIds); |
|
|
if (CollectionUtils.isEmpty(projectKeys)){ |
|
|
if (CollectionUtils.isEmpty(projectKeys)){ |
|
|
return new ArrayList<>(); |
|
|
return new ArrayList<>(); |
|
|
} |
|
|
} |
|
|
PageInfo<TDuckListResultDTO> projectPageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.queryProjectList(projectKeys, formDTO.getStatus(), formDTO.getClient())); |
|
|
PageInfo<TDuckListResultDTO> projectPageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.queryProjectList(projectKeys, formDTO.getStatus(), formDTO.getClient())); |
|
|
List<TDuckListResultDTO> result = projectPageInfo.getList(); |
|
|
List<TDuckListResultDTO> result = projectPageInfo.getList(); |
|
|
List<String> records = visitRecordDao.selectVisitRecordByUserId(formDTO.getUserId()); |
|
|
// 查询此人已填写过的问卷 并赋值已填写字段
|
|
|
|
|
|
List<String> records = prUserProjectResultDao.selectFillRecordByUserId(formDTO.getUserId()); |
|
|
if (!CollectionUtils.isEmpty(records)){ |
|
|
if (!CollectionUtils.isEmpty(records)){ |
|
|
for (String r : records) { |
|
|
for (String r : records) { |
|
|
for (TDuckListResultDTO t : result) { |
|
|
for (TDuckListResultDTO t : result) { |
|
|
|
|
|
if (t.getIsEveryoneWriteOnceUid() == NumConstant.ONE && r.equals(t.getKey())){ |
|
|
|
|
|
t.setIsFillQuestion(false); |
|
|
|
|
|
} |
|
|
if (r.equals(t.getKey())){ |
|
|
if (r.equals(t.getKey())){ |
|
|
t.setFillStatus(true); |
|
|
t.setFillStatus(true); |
|
|
continue; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
//赋值 orgName
|
|
|
|
|
|
result.forEach(r -> { |
|
|
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), r.getCreatedBy()); |
|
|
|
|
|
String orgName = ""; |
|
|
|
|
|
if (null != staffInfo){ |
|
|
|
|
|
if (staffInfo.getFromOrgType().equals(TDuckConstant.ORG_TYPE_AGENCY)){ |
|
|
|
|
|
orgName = staffInfo.getAgencyName(); |
|
|
|
|
|
}else if (staffInfo.getFromOrgType().equals(TDuckConstant.ORG_TYPE_GRID)){ |
|
|
|
|
|
for (IdAndNameDTO g : staffInfo.getGridList()) { |
|
|
|
|
|
if (g.getId().equals(staffInfo.getFromOrgId())){ |
|
|
|
|
|
orgName = g.getName(); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}else if (staffInfo.getFromOrgType().equals(TDuckConstant.ORG_TYPE_DEPT)){ |
|
|
|
|
|
for (IdAndNameDTO d : staffInfo.getDeptList()) { |
|
|
|
|
|
if (d.getId().equals(staffInfo.getFromOrgId())){ |
|
|
|
|
|
orgName = d.getName(); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
r.setOrgName(orgName); |
|
|
|
|
|
}); |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description orgIds拼接 |
|
|
|
|
|
* @Param pids |
|
|
|
|
|
* @Param agencyId |
|
|
|
|
|
* @Param list |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
* @date 2021/9/23 4:48 下午 |
|
|
|
|
|
*/ |
|
|
|
|
|
public List<String> joint(String pids, String agencyId, List<IdAndNameDTO> list){ |
|
|
|
|
|
List<String> orgIds = new ArrayList<>(); |
|
|
|
|
|
list.forEach(l -> { |
|
|
|
|
|
String oneOrg = pids + ":" + agencyId + ":" + l.getId(); |
|
|
|
|
|
orgIds.add(oneOrg); |
|
|
|
|
|
}); |
|
|
|
|
|
return orgIds; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 分析报告 |
|
|
* 分析报告 |
|
|
* |
|
|
* |
|
@ -385,7 +480,8 @@ public class PrUserProjectServiceImpl extends BaseServiceImpl<PrUserProjectDao, |
|
|
int totalCount = 0; |
|
|
int totalCount = 0; |
|
|
Map<String, Integer> resMap = new HashMap<>(); |
|
|
Map<String, Integer> resMap = new HashMap<>(); |
|
|
for (PrUserProjectResultEntity res : resultList) { |
|
|
for (PrUserProjectResultEntity res : resultList) { |
|
|
JSONObject originalData = JSON.parseObject(res.getOriginalData()); |
|
|
//级联组件,用processdata特殊处理下
|
|
|
|
|
|
JSONObject originalData = JSON.parseObject(res.getProcessData()); |
|
|
if(originalData.containsKey(key)){ |
|
|
if(originalData.containsKey(key)){ |
|
|
List<CascaderDTO> dtoList = JSON.parseArray(originalData.get(key).toString(), CascaderDTO.class); |
|
|
List<CascaderDTO> dtoList = JSON.parseArray(originalData.get(key).toString(), CascaderDTO.class); |
|
|
if(CollectionUtils.isEmpty(dtoList)){ |
|
|
if(CollectionUtils.isEmpty(dtoList)){ |
|
@ -706,4 +802,11 @@ public class PrUserProjectServiceImpl extends BaseServiceImpl<PrUserProjectDao, |
|
|
} |
|
|
} |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public PrUserProjectEntity getProjectEntityBykey(String key) { |
|
|
|
|
|
LambdaQueryWrapper<PrUserProjectEntity> query = new LambdaQueryWrapper<>(); |
|
|
|
|
|
query.eq(PrUserProjectEntity::getKey, key); |
|
|
|
|
|
return baseDao.selectOne(query); |
|
|
|
|
|
} |
|
|
} |
|
|
} |