| | |
| | | import java.text.NumberFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.function.Consumer; |
| | | |
| | | @Service |
| | | public class UnlawfulServiceImpl implements UnlawfulService { |
| | | |
| | | private List<UnlawfulDto> res = new ArrayList<>(); |
| | | |
| | | @Resource |
| | | private UnlawfulMapper unlawfuldao; |
| | | |
| | | |
| | | /** |
| | | * 按类型 |
| | | */ |
| | | @Override |
| | | public List<UnlawfulDto> getUnlawfulByType(Integer currentPage, Integer pageSize, String startTime, String endTime) { |
| | | List<UnlawfulDto> res = new ArrayList<>(); |
| | | Double total = unlawfuldao.getTotal().doubleValue(); |
| | | List<CategoryDto> data = unlawfuldao.getDataByType(currentPage, pageSize, startTime, endTime); |
| | | data.forEach(categoryDto -> { |
| | | Double checkedRatio; //审核率 |
| | | Double registerRatio; //立案率 |
| | | StatusDto statusData = unlawfuldao.getStatusDataByType(startTime, endTime, categoryDto.getId()); |
| | | UnlawfulDto build = new UnlawfulDto().builder().name(categoryDto.getName()) //类型名称 |
| | | .count(statusData.getTotal()) //事件总数 |
| | | .ratio(changeFormat(statusData.getTotal().doubleValue() / total)) //占比 |
| | | .register(statusData.getRegister()) //立案 |
| | | .notRegister(statusData.getNotRegister()) //暂不立案 |
| | | .closing(statusData.getClosing()) //结案 |
| | | .relearn(statusData.getRelearn()) //在学习 |
| | | .checked(statusData.getChecked()) //已审核 |
| | | .checkedRatio(changeFormat(statusData.getChecked().doubleValue() / statusData.getTotal().doubleValue())) //审核率 |
| | | .registerRatio(changeFormat(statusData.getRegister().doubleValue() / statusData.getTotal().doubleValue())) //立案率 |
| | | .build(); |
| | | res.add(build); |
| | | format(res, total, categoryDto, statusData); |
| | | }); |
| | | return res; |
| | | } |
| | | @Override |
| | | public List<UnlawfulDto> getUnlawfulByTypeExport() { |
| | | Double total = unlawfuldao.getTotal().doubleValue(); |
| | | List<CategoryDto> data = unlawfuldao.getDataByTypeExp(); |
| | | data.forEach(categoryDto -> { |
| | | StatusDto statusData = unlawfuldao.getStatusDataByType(null, null, categoryDto.getId()); |
| | | format(res, total, categoryDto, statusData); |
| | | }); |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | | * 按区域 |
| | | */ |
| | | @Override |
| | | public List<UnlawfulDto> getUnlawfulByTypeExport() { |
| | | List<UnlawfulDto> res = new ArrayList<>(); |
| | | public List<UnlawfulDto> getUnlawfulByStreet(Integer currentPage, Integer pageSize, String startTime, String endTime) { |
| | | Double total = unlawfuldao.getTotal().doubleValue(); |
| | | List<CategoryDto> data = unlawfuldao.getDataByTypeExp(); |
| | | List<CategoryDto> data = unlawfuldao.getDataByStreet(currentPage, pageSize, startTime, endTime); |
| | | data.forEach(categoryDto -> { |
| | | Double checkedRatio; //审核率 |
| | | Double registerRatio; //立案率 |
| | | StatusDto statusData = unlawfuldao.getStatusDataByType(null, null, categoryDto.getId()); |
| | | UnlawfulDto build = new UnlawfulDto().builder().name(categoryDto.getName()) //类型名称 |
| | | .count(statusData.getTotal()) //事件总数 |
| | | .ratio(changeFormat(statusData.getTotal().doubleValue() / total)) //占比 |
| | | .register(statusData.getRegister()) //立案 |
| | | .notRegister(statusData.getNotRegister()) //暂不立案 |
| | | .closing(statusData.getClosing()) //结案 |
| | | .relearn(statusData.getRelearn()) //在学习 |
| | | .checked(statusData.getChecked()) //已审核 |
| | | .checkedRatio(changeFormat(statusData.getChecked().doubleValue() / statusData.getTotal().doubleValue())) //审核率 |
| | | .registerRatio(changeFormat(statusData.getRegister().doubleValue() / statusData.getTotal().doubleValue())) //立案率 |
| | | .build(); |
| | | res.add(build); |
| | | StatusDto statusData = unlawfuldao.getStatusDataByStreet(startTime, endTime, categoryDto.getId()); |
| | | format(res, total, categoryDto, statusData); |
| | | }); |
| | | return res; |
| | | } |
| | | @Override |
| | | public List<UnlawfulDto> getUnlawfulByStreetExport() { |
| | | Double total = unlawfuldao.getTotal().doubleValue(); |
| | | List<CategoryDto> data = unlawfuldao.getDataByStreetExp(); |
| | | data.forEach(categoryDto -> { |
| | | StatusDto statusData = unlawfuldao.getStatusDataByStreet(null, null, categoryDto.getId()); |
| | | format(res, total, categoryDto, statusData); |
| | | }); |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | | * 按报警点位 |
| | | */ |
| | | @Override |
| | | public List<UnlawfulDto> getUnlawfulBySite(Integer currentPage, Integer pageSize, String startTime, String endTime) { |
| | | Double total = unlawfuldao.getTotal().doubleValue(); |
| | | List<String> data = unlawfuldao.getDataBySite(currentPage, pageSize, startTime, endTime); |
| | | data.forEach(site -> { |
| | | StatusDto statusData = unlawfuldao.getStatusDataBySite(startTime, endTime, site); |
| | | format1(res, total, site, statusData); |
| | | }); |
| | | return res; |
| | | } |
| | | @Override |
| | | public List<UnlawfulDto> getUnlawfulBySiteExport() { |
| | | Double total = unlawfuldao.getTotal().doubleValue(); |
| | | List<String> data = unlawfuldao.getDataBySiteExp(); |
| | | data.forEach(site -> { |
| | | StatusDto statusData = unlawfuldao.getStatusDataBySite(null, null, site); |
| | | format1(res, total, site, statusData); |
| | | }); |
| | | return res; |
| | | } |
| | |
| | | String format = numberInstance.format(previous); |
| | | return Double.parseDouble(format); |
| | | } |
| | | |
| | | private void format(List<UnlawfulDto> res, Double total, CategoryDto categoryDto, StatusDto statusData) { |
| | | UnlawfulDto build = UnlawfulDto.builder().name(categoryDto.getName()) //类型名称 |
| | | .count(statusData.getTotal()) //事件总数 |
| | | .ratio(changeFormat(statusData.getTotal().doubleValue() / total)) //占比 |
| | | .register(statusData.getRegister()) //立案 |
| | | .notRegister(statusData.getNotRegister()) //暂不立案 |
| | | .closing(statusData.getClosing()) //结案 |
| | | .relearn(statusData.getRelearn()) //在学习 |
| | | .checked(statusData.getChecked()) //已审核 |
| | | .checkedRatio(changeFormat(statusData.getChecked().doubleValue() / statusData.getTotal().doubleValue())) //审核率 |
| | | .registerRatio(changeFormat(statusData.getRegister().doubleValue() / statusData.getTotal().doubleValue())) //立案率 |
| | | .build(); |
| | | res.add(build); |
| | | } |
| | | |
| | | private void format1(List<UnlawfulDto> res, Double total, String site, StatusDto statusData) { |
| | | UnlawfulDto build = UnlawfulDto.builder().name(site) //类型名称 |
| | | .count(statusData.getTotal()) //事件总数 |
| | | .ratio(changeFormat(statusData.getTotal().doubleValue() / total)) //占比 |
| | | .register(statusData.getRegister()) //立案 |
| | | .notRegister(statusData.getNotRegister()) //暂不立案 |
| | | .closing(statusData.getClosing()) //结案 |
| | | .relearn(statusData.getRelearn()) //在学习 |
| | | .checked(statusData.getChecked()) //已审核 |
| | | .checkedRatio(changeFormat(statusData.getChecked().doubleValue() / statusData.getTotal().doubleValue())) //审核率 |
| | | .registerRatio(changeFormat(statusData.getRegister().doubleValue() / statusData.getTotal().doubleValue())) //立案率 |
| | | .build(); |
| | | res.add(build); |
| | | } |
| | | } |