|
|
@ -17,6 +17,9 @@ |
|
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.rocketmq.messages.BaseMQMsgDTO; |
|
|
import com.epmet.commons.rocketmq.messages.BaseMQMsgDTO; |
|
|
@ -24,20 +27,30 @@ 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.result.DictTreeResultDTO; |
|
|
import com.epmet.commons.tools.dto.result.DictTreeResultDTO; |
|
|
import com.epmet.commons.tools.enums.DictTypeEnum; |
|
|
import com.epmet.commons.tools.enums.DictTypeEnum; |
|
|
|
|
|
import com.epmet.commons.tools.enums.OrgTypeEnum; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
|
|
|
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
|
|
import com.epmet.commons.tools.utils.ExcelUtils; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.constant.SystemMessageType; |
|
|
import com.epmet.constant.SystemMessageType; |
|
|
import com.epmet.dao.PatrolRoutineWorkDao; |
|
|
import com.epmet.dao.PatrolRoutineWorkDao; |
|
|
import com.epmet.dto.CustomerGridDTO; |
|
|
import com.epmet.dto.CustomerGridDTO; |
|
|
import com.epmet.dto.form.CustomerGridFormDTO; |
|
|
import com.epmet.dto.form.CustomerGridFormDTO; |
|
|
import com.epmet.dto.form.PatrolRoutineWorkFormDTO; |
|
|
import com.epmet.dto.form.PatrolRoutineWorkFormDTO; |
|
|
|
|
|
import com.epmet.dto.form.PcWorkListFormDTO; |
|
|
import com.epmet.dto.form.patrol.PatrolQueryFormDTO; |
|
|
import com.epmet.dto.form.patrol.PatrolQueryFormDTO; |
|
|
|
|
|
import com.epmet.dto.result.AllGridsByUserIdResultDTO; |
|
|
import com.epmet.dto.result.PatrolRoutineWorkResult; |
|
|
import com.epmet.dto.result.PatrolRoutineWorkResult; |
|
|
|
|
|
import com.epmet.dto.result.PcWorkListResultDTO; |
|
|
import com.epmet.entity.PatrolRoutineWorkEntity; |
|
|
import com.epmet.entity.PatrolRoutineWorkEntity; |
|
|
import com.epmet.entity.PatrolRoutineWorkTypeEntity; |
|
|
import com.epmet.entity.PatrolRoutineWorkTypeEntity; |
|
|
|
|
|
import com.epmet.excel.PcWorkListExport; |
|
|
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|
|
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|
|
import com.epmet.feign.EpmetMessageOpenFeignClient; |
|
|
import com.epmet.feign.EpmetMessageOpenFeignClient; |
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
@ -46,6 +59,7 @@ import com.epmet.service.PatrolRoutineWorkService; |
|
|
import com.epmet.service.PatrolRoutineWorkTypeService; |
|
|
import com.epmet.service.PatrolRoutineWorkTypeService; |
|
|
import com.github.pagehelper.Page; |
|
|
import com.github.pagehelper.Page; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -53,10 +67,13 @@ import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import java.util.HashMap; |
|
|
import java.beans.Encoder; |
|
|
import java.util.List; |
|
|
import java.net.URLEncoder; |
|
|
import java.util.Map; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 巡查例行工作 |
|
|
* 巡查例行工作 |
|
|
@ -147,6 +164,135 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
.doSelectPage(() -> baseDao.selectList(formDTO)); |
|
|
.doSelectPage(() -> baseDao.selectList(formDTO)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description 【网格员工作统计】例行工作列表 |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
* @date 2022/1/4 2:18 下午 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public PcWorkListResultDTO pcWorkList(PcWorkListFormDTO formDTO) { |
|
|
|
|
|
PcWorkListResultDTO result = new PcWorkListResultDTO(); |
|
|
|
|
|
List<PcWorkListResultDTO.PcWorkListResult> list; |
|
|
|
|
|
if (formDTO.getIsPage()){ |
|
|
|
|
|
PageInfo<PcWorkListResultDTO.PcWorkListResult> listPageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.pcWorkList(formDTO)); |
|
|
|
|
|
result.setTotal(Integer.valueOf(String.valueOf(listPageInfo.getTotal()))); |
|
|
|
|
|
list = listPageInfo.getList(); |
|
|
|
|
|
}else { |
|
|
|
|
|
list = baseDao.pcWorkList(formDTO); |
|
|
|
|
|
result.setTotal(list.size()); |
|
|
|
|
|
} |
|
|
|
|
|
if (CollectionUtils.isEmpty(list)){ |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
Result<List<DictTreeResultDTO>> workTypeResult = adminOpenFeignClient.dictTree(DictTypeEnum.PATROL_WORK_TYPE.getCode()); |
|
|
|
|
|
if (!workTypeResult.success()){ |
|
|
|
|
|
throw new EpmetException("查询例行工作分类失败..."); |
|
|
|
|
|
} |
|
|
|
|
|
List<String> gridIds = list.stream().map(m -> m.getGridId()).distinct().collect(Collectors.toList()); |
|
|
|
|
|
Result<List<AllGridsByUserIdResultDTO>> gridNamesResult = govOrgOpenFeignClient.getGridListByGridIds(gridIds); |
|
|
|
|
|
if (!gridNamesResult.success()){ |
|
|
|
|
|
throw new EpmetException("查询网格名字失败..."); |
|
|
|
|
|
} |
|
|
|
|
|
list.forEach(l -> { |
|
|
|
|
|
l.setWorkTypeName(disposeWorkTypeCode(workTypeResult.getData(),l.getWorkTypeCode()).stream().collect(Collectors.joining(","))); |
|
|
|
|
|
gridNamesResult.getData().stream().filter(g -> l.getGridId().equals(g.getGridId())).forEach(g -> l.setGridName(g.getGridName())); |
|
|
|
|
|
}); |
|
|
|
|
|
result.setList(list); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void pcWorkListExport(PcWorkListFormDTO formDTO, HttpServletResponse response) throws Exception { |
|
|
|
|
|
String name = getFileName(formDTO); |
|
|
|
|
|
ExcelWriter excelWriter = null; |
|
|
|
|
|
try { |
|
|
|
|
|
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); |
|
|
|
|
|
response.setHeader("Content-Type", "application/vnd.ms-excel"); |
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(name, "UTF-8")); |
|
|
|
|
|
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(name,response),PcWorkListExport.class).build(); |
|
|
|
|
|
// 如果同一个sheet只要创建一次
|
|
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet(name).build(); |
|
|
|
|
|
Integer pageNo = NumConstant.ONE; |
|
|
|
|
|
Integer pageSize = 1000; |
|
|
|
|
|
Integer num = NumConstant.ZERO; |
|
|
|
|
|
do { |
|
|
|
|
|
formDTO.setPageNo(pageNo); |
|
|
|
|
|
formDTO.setPageSize(pageSize); |
|
|
|
|
|
List<PcWorkListResultDTO.PcWorkListResult> dtos = pcWorkList(formDTO).getList(); |
|
|
|
|
|
List<PcWorkListExport> data = ConvertUtils.sourceToTarget(dtos, PcWorkListExport.class); |
|
|
|
|
|
num = data.size(); |
|
|
|
|
|
excelWriter.write(data, writeSheet); |
|
|
|
|
|
pageNo++; |
|
|
|
|
|
}while (num > NumConstant.ZERO && num.compareTo(pageSize) == NumConstant.ZERO); |
|
|
|
|
|
} finally { |
|
|
|
|
|
if (excelWriter != null) { |
|
|
|
|
|
excelWriter.finish(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getFileName(PcWorkListFormDTO formDTO){ |
|
|
|
|
|
StringBuilder name = new StringBuilder(); |
|
|
|
|
|
if (formDTO.getOrgType().equals(OrgTypeEnum.GRID.getCode())){ |
|
|
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId()); |
|
|
|
|
|
if (null == gridInfo){ |
|
|
|
|
|
throw new EpmetException("查询网格信息失败..."); |
|
|
|
|
|
} |
|
|
|
|
|
name.append(gridInfo.getGridName()); |
|
|
|
|
|
}else { |
|
|
|
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(formDTO.getOrgId()); |
|
|
|
|
|
if (null == agencyInfo){ |
|
|
|
|
|
throw new EpmetException("查询组织信息失败..."); |
|
|
|
|
|
} |
|
|
|
|
|
name.append(agencyInfo.getOrganizationName()); |
|
|
|
|
|
} |
|
|
|
|
|
name.append(" 例行工作 "); |
|
|
|
|
|
if (StringUtils.isNotBlank(formDTO.getStartTime())){ |
|
|
|
|
|
name.append(getDate(formDTO.getStartTime())) |
|
|
|
|
|
.append("至").append(getDate(formDTO.getEndTime())).append("区间增长值"); |
|
|
|
|
|
}else { |
|
|
|
|
|
name.append("截止至"); |
|
|
|
|
|
name.append(getDate(formDTO.getEndTime())); |
|
|
|
|
|
name.append("累计值"); |
|
|
|
|
|
} |
|
|
|
|
|
name.append(".xlsx"); |
|
|
|
|
|
return name.toString(); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public static String getDate(String dateId){ |
|
|
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
|
|
sb.append(dateId.substring(0,4)).append(StrConstant.HYPHEN); |
|
|
|
|
|
sb.append(dateId.substring(4,6)).append(StrConstant.HYPHEN); |
|
|
|
|
|
sb.append(dateId.substring(6,8)); |
|
|
|
|
|
|
|
|
|
|
|
return sb.toString(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description 处理 workTypeName |
|
|
|
|
|
* @param workTypeList |
|
|
|
|
|
* @param code |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
* @date 2022/1/5 9:27 上午 |
|
|
|
|
|
*/ |
|
|
|
|
|
public List<String> disposeWorkTypeCode(List<DictTreeResultDTO> workTypeList,List<String> code){ |
|
|
|
|
|
if (CollectionUtils.isEmpty(code)){ |
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
} |
|
|
|
|
|
List<String> result = new ArrayList<>(); |
|
|
|
|
|
code.forEach(c -> { |
|
|
|
|
|
workTypeList.forEach(w1 -> { |
|
|
|
|
|
w1.getChildren().forEach(w2 -> { |
|
|
|
|
|
if (c.equals(w2.getId())){ |
|
|
|
|
|
result.add(w1.getName() + StrConstant.HYPHEN + w2.getName()); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* desc:递归遍历树形结构 构建pids 根节点pids 为空字符串 |
|
|
* desc:递归遍历树形结构 构建pids 根节点pids 为空字符串 |
|
|
* |
|
|
* |
|
|
@ -190,7 +336,7 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
/*public static void main(String[] args) { |
|
|
String str = "[{\"id\":\"01\",\"pid\":\"0\",\"children\":[{\"id\":\"0101\",\"pid\":\"01\",\"children\":[{\"id\":\"010101\",\"pid\":\"0101\",\"children\":[],\"name\":\"出租房屋巡查\"}],\"name\":\"出租房屋巡查\"},{\"id\":\"0102\",\"pid\":\"01\",\"children\":[],\"name\":\"重点场所巡查\"},{\"id\":\"0103\",\"pid\":\"01\",\"children\":[],\"name\":\"宗教活动\"},{\"id\":\"0199\",\"pid\":\"01\",\"children\":[],\"name\":\"其他\"}],\"name\":\"重点巡查\"},{\"id\":\"02\",\"pid\":\"0\",\"children\":[{\"id\":\"0201\",\"pid\":\"02\",\"children\":[],\"name\":\"刑满释放人员\"},{\"id\":\"0202\",\"pid\":\"02\",\"children\":[],\"name\":\"社区矫正\"},{\"id\":\"0203\",\"pid\":\"02\",\"children\":[],\"name\":\"吸毒人员\"},{\"id\":\"0204\",\"pid\":\"02\",\"children\":[],\"name\":\"信访人员\"},{\"id\":\"0205\",\"pid\":\"02\",\"children\":[],\"name\":\"重点青少年\"},{\"id\":\"0206\",\"pid\":\"02\",\"children\":[],\"name\":\"精神障碍者\"}],\"name\":\"特殊人群\"},{\"id\":\"09\",\"pid\":\"0\",\"children\":[{\"id\":\"0901\",\"pid\":\"09\",\"children\":[],\"name\":\"公共服务\"},{\"id\":\"0902\",\"pid\":\"09\",\"children\":[],\"name\":\"权益保障\"},{\"id\":\"0903\",\"pid\":\"09\",\"children\":[],\"name\":\"政策宣传\"},{\"id\":\"0904\",\"pid\":\"09\",\"children\":[],\"name\":\"便利服务\"},{\"id\":\"0999\",\"pid\":\"09\",\"children\":[],\"name\":\"其他\"}],\"name\":\"为民服务\"}]"; |
|
|
String str = "[{\"id\":\"01\",\"pid\":\"0\",\"children\":[{\"id\":\"0101\",\"pid\":\"01\",\"children\":[{\"id\":\"010101\",\"pid\":\"0101\",\"children\":[],\"name\":\"出租房屋巡查\"}],\"name\":\"出租房屋巡查\"},{\"id\":\"0102\",\"pid\":\"01\",\"children\":[],\"name\":\"重点场所巡查\"},{\"id\":\"0103\",\"pid\":\"01\",\"children\":[],\"name\":\"宗教活动\"},{\"id\":\"0199\",\"pid\":\"01\",\"children\":[],\"name\":\"其他\"}],\"name\":\"重点巡查\"},{\"id\":\"02\",\"pid\":\"0\",\"children\":[{\"id\":\"0201\",\"pid\":\"02\",\"children\":[],\"name\":\"刑满释放人员\"},{\"id\":\"0202\",\"pid\":\"02\",\"children\":[],\"name\":\"社区矫正\"},{\"id\":\"0203\",\"pid\":\"02\",\"children\":[],\"name\":\"吸毒人员\"},{\"id\":\"0204\",\"pid\":\"02\",\"children\":[],\"name\":\"信访人员\"},{\"id\":\"0205\",\"pid\":\"02\",\"children\":[],\"name\":\"重点青少年\"},{\"id\":\"0206\",\"pid\":\"02\",\"children\":[],\"name\":\"精神障碍者\"}],\"name\":\"特殊人群\"},{\"id\":\"09\",\"pid\":\"0\",\"children\":[{\"id\":\"0901\",\"pid\":\"09\",\"children\":[],\"name\":\"公共服务\"},{\"id\":\"0902\",\"pid\":\"09\",\"children\":[],\"name\":\"权益保障\"},{\"id\":\"0903\",\"pid\":\"09\",\"children\":[],\"name\":\"政策宣传\"},{\"id\":\"0904\",\"pid\":\"09\",\"children\":[],\"name\":\"便利服务\"},{\"id\":\"0999\",\"pid\":\"09\",\"children\":[],\"name\":\"其他\"}],\"name\":\"为民服务\"}]"; |
|
|
List<DictTreeResultDTO> dtos = JSON.parseArray(str, DictTreeResultDTO.class); |
|
|
List<DictTreeResultDTO> dtos = JSON.parseArray(str, DictTreeResultDTO.class); |
|
|
Map<String, StringBuilder> result = new HashMap<>(); |
|
|
Map<String, StringBuilder> result = new HashMap<>(); |
|
|
@ -199,6 +345,6 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
}); |
|
|
}); |
|
|
System.out.println(result.get("010101")); |
|
|
System.out.println(result.get("010101")); |
|
|
System.out.println(JSON.toJSONString(result)); |
|
|
System.out.println(JSON.toJSONString(result)); |
|
|
} |
|
|
}*/ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|