| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description |
| | |
| | | private SnapRecordService snapRecordService; |
| | | @Resource |
| | | private SecCameraService cameraService; |
| | | @Resource |
| | | private BankService bankService; |
| | | @Resource |
| | | private PledgeContractService pledgeContractService; |
| | | @Resource |
| | | private PledgeContractDepotService pledgeContractDepotService; |
| | | @Resource |
| | | private GatewaySerService gatewaySerService; |
| | | |
| | | /** |
| | | * 获取省及下属市州集合 |
| | |
| | | area.setChildren(children); |
| | | } |
| | | |
| | | } |
| | | list.add(area); |
| | | return list; |
| | | } |
| | | |
| | | |
| | | public List<DicArea> getBankAndChildDept(String areaCode) { |
| | | |
| | | DicArea area = dicAreaService.listDicAreaByCode(areaCode); |
| | | if (null == area) { |
| | | return null; |
| | | } |
| | | List<DicArea> areaChildren = new ArrayList<>(); |
| | | |
| | | List<DicArea> list = new ArrayList<>(); |
| | | if (Constant.AREA_TYPE_1.equals(area.getType())) { |
| | | //查询所有的质押合同 |
| | | List<PledgeContract> pledgeContractList = pledgeContractService.listAll(null); |
| | | //查询所有的库区 |
| | | List<Dept> depotList = deptService.listDept(null, ContextUtil.getCompanyId(), null); |
| | | //查询所有的银行 |
| | | List<Bank> bankList = bankService.listAll(null); |
| | | DicArea defaultBank = new DicArea(); |
| | | defaultBank.setCode("-1"); |
| | | defaultBank.setName("无质押银行"); |
| | | defaultBank.setChildren(new ArrayList<>()); |
| | | |
| | | for (Dept dept : depotList) { |
| | | Boolean isPledge = false; |
| | | for (PledgeContract pledgeContract : pledgeContractList) { |
| | | IgdsBaseParam param = new IgdsBaseParam(); |
| | | param.setParentId(pledgeContract.getId()); |
| | | List<PledgeContractDepot> pledgeContractDepots = pledgeContractDepotService.listAll(param); |
| | | if (null == pledgeContractDepots || pledgeContractDepots.isEmpty()) { |
| | | continue; |
| | | } |
| | | //找到pledgeContractDepots中的deptId集合,并去重 |
| | | List<String> deptIdList = pledgeContractDepots.stream().map(PledgeContractDepot::getPledgeDept).distinct().collect(Collectors.toList()); |
| | | if (deptIdList.contains(dept.getId())) { |
| | | //从list中找到当前质押银行的数据 |
| | | DicArea pledgeBank = null; |
| | | int indexBank = -1; |
| | | for (DicArea item : areaChildren) { |
| | | if (pledgeContract.getPledgeBank().equals(item.getCode())) { |
| | | pledgeBank = item; |
| | | indexBank = areaChildren.indexOf(pledgeBank); |
| | | break; |
| | | } |
| | | } |
| | | if (null == pledgeBank) { |
| | | //未找到质押银行数据则新建 |
| | | pledgeBank = new DicArea(); |
| | | pledgeBank.setCode(pledgeContract.getPledgeBank()); |
| | | pledgeBank.setName("质押银行_" + pledgeContract.getPledgeBank()); |
| | | //从银行数据中找到质押银行的信息 |
| | | for (Bank bank : bankList) { |
| | | if (pledgeContract.getPledgeBank().equals(bank.getId())) { |
| | | pledgeBank.setName(bank.getName()); |
| | | } |
| | | } |
| | | //添加质押银行下的库区数据 |
| | | DicArea deptDic = new DicArea(); |
| | | deptDic.setCode(dept.getId()); |
| | | deptDic.setName(dept.getKqmc()); |
| | | |
| | | List<DicArea> children = pledgeBank.getChildren(); |
| | | if (null == children) { |
| | | pledgeBank.setChildren(new ArrayList<>()); |
| | | } |
| | | pledgeBank.getChildren().add(deptDic); |
| | | //新增质押银行数据到list中 |
| | | areaChildren.add(pledgeBank); |
| | | isPledge = true; |
| | | break; |
| | | } else { |
| | | //添加质押银行下的库区数据 |
| | | DicArea deptDic = new DicArea(); |
| | | deptDic.setCode(dept.getId()); |
| | | deptDic.setName(dept.getKqmc()); |
| | | |
| | | List<DicArea> children = pledgeBank.getChildren(); |
| | | if (null == children) { |
| | | pledgeBank.setChildren(new ArrayList<>()); |
| | | } |
| | | pledgeBank.getChildren().add(deptDic); |
| | | //更新list中的质押银行数据 |
| | | areaChildren.set(indexBank, pledgeBank); |
| | | isPledge = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | if (!isPledge) { |
| | | DicArea deptDic = new DicArea(); |
| | | deptDic.setCode(dept.getId()); |
| | | deptDic.setName(dept.getKqmc()); |
| | | |
| | | List<DicArea> children = defaultBank.getChildren(); |
| | | if (null == children) { |
| | | defaultBank.setChildren(new ArrayList<>()); |
| | | } |
| | | defaultBank.getChildren().add(deptDic); |
| | | } |
| | | } |
| | | List<DicArea> defaultBankChildren = defaultBank.getChildren(); |
| | | if (defaultBankChildren.size() > 0) { |
| | | areaChildren.add(defaultBank); |
| | | } |
| | | area.setChildren(areaChildren); |
| | | } |
| | | list.add(area); |
| | | return list; |
| | |
| | | } |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取库区封装信息 |
| | | * |
| | | * @param companyId |
| | | * @return |
| | | */ |
| | | public List<GroupDepotData> getDepotData(String companyId) { |
| | | |
| | | List<GroupDepotData> list = new ArrayList<>(); |
| | | GroupDepotData depotData; |
| | | List<Dept> deptList = deptService.getDeptByUserType(null); |
| | | if (null != deptList && !deptList.isEmpty()) { |
| | | List<Depot> depotList; |
| | | for (Dept dept : deptList) { |
| | | //统计仓库数 |
| | | depotList = depotService.getCacheDepotList(dept.getCompanyId(), dept.getId()); |
| | | if (null != depotList && !depotList.isEmpty()) { |
| | | for (Depot depot : depotList) { |
| | | depotData = new GroupDepotData(); |
| | | depotData.setDeptId(dept.getId()); |
| | | depotData.setDeptName(dept.getKqmc()); |
| | | depotData.setCode(dept.getXzqhdm()); |
| | | depotData.setCounty(dept.getXzqhmc()); |
| | | depotData.setDepotId(depot.getId()); |
| | | depotData.setDepotName(depot.getName()); |
| | | if (null == depot.getStorageReal()) { |
| | | depot.setStorageReal(0.0); |
| | | } |
| | | depotData.setStorageNum(depot.getStorageReal() / 1000); |
| | | list.add(depotData); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | //判断网关是否在线 |
| | | GatewaySer cacheSerByDeptId = gatewaySerService.getCacheSerByDeptId(dept.getId()); |
| | | if (null == cacheSerByDeptId || (null != cacheSerByDeptId && StringUtils.isNotBlank(cacheSerByDeptId.getStatus()) && cacheSerByDeptId.getStatus().equals(Constant.YN_N))) { |
| | | deptData.setDailyTotal(-1); |
| | | } |
| | | list.add(deptData); |
| | | } |
| | | } |
| | |
| | | return groupGisData; |
| | | } |
| | | |
| | | |
| | | public GroupGisData getGisDataByCompanyId() { |
| | | |
| | | GroupGisData groupGisData = new GroupGisData(); |
| | | |
| | | //查询伊犁下属区县 |
| | | //区县 |
| | | List<DicArea> dicAreaList = dicAreaService.listData("654000", null, null); |
| | | |
| | | //统计区县下库区数 |
| | | LinkedHashMap<String, Integer> valuePieChart = new LinkedHashMap<>(); |
| | | LinkedHashMap<String, String> namePieChart = new LinkedHashMap<>(); |
| | | if (null != dicAreaList && !dicAreaList.isEmpty()) { |
| | | for (DicArea dicArea : dicAreaList) { |
| | | valuePieChart.put(dicArea.getCode(), 0); |
| | | namePieChart.put(dicArea.getCode(), dicArea.getName()); |
| | | } |
| | | } |
| | | List<Dept> deptList = deptService.getDeptByUserType(null); |
| | | if (null != deptList && !deptList.isEmpty()) { |
| | | //库区总数 |
| | | groupGisData.setDeptNum(deptList.size()); |
| | | for (Dept dept : deptList) { |
| | | if (StringUtils.isBlank(dept.getXzqhdm()) || null == valuePieChart.get(dept.getXzqhdm())) { |
| | | if (null == valuePieChart.get("999999")) { |
| | | valuePieChart.put("999999", 0); |
| | | namePieChart.put("999999", "其他区县"); |
| | | } |
| | | dept.setXzqhdm("999999"); |
| | | } |
| | | valuePieChart.put(dept.getXzqhdm(), valuePieChart.get(dept.getXzqhdm()) + 1); |
| | | } |
| | | } |
| | | |
| | | if (groupGisData.getDeptNum() > 0) { |
| | | for (String mapKey : valuePieChart.keySet()) { |
| | | groupGisData.getDeptList().add(new ChartPie(valuePieChart.get(mapKey) + "", namePieChart.get(mapKey), new DecimalFormat("0.0").format((double) valuePieChart.get(mapKey) / groupGisData.getDeptNum() * 100))); |
| | | } |
| | | } |
| | | |
| | | //统计重量 |
| | | List<Depot> depotList = depotService.getCacheDepotList(ContextUtil.getCompanyId()); |
| | | if (null != depotList && !depotList.isEmpty()) { |
| | | for (Depot depot : depotList) { |
| | | if (null == depot.getStorageReal()) { |
| | | depot.setStorageReal(0.0); |
| | | } |
| | | groupGisData.setSum(groupGisData.getSum() + depot.getStorageReal()); |
| | | if (StringUtils.isNotBlank(depot.getPledgeBank())) { |
| | | groupGisData.setBankSum(groupGisData.getBankSum() + depot.getStorageReal()); |
| | | } else { |
| | | groupGisData.setNormalSum(groupGisData.getNormalSum() + depot.getStorageReal()); |
| | | } |
| | | } |
| | | } |
| | | if (groupGisData.getSum() > 0) { |
| | | groupGisData.setSumPer(new DecimalFormat("0.00").format(groupGisData.getSum() / groupGisData.getSum() * 100L)); |
| | | groupGisData.setBankSumPer(new DecimalFormat("0.00").format(groupGisData.getBankSum() / groupGisData.getSum() * 100L)); |
| | | groupGisData.setNormalSumPer(new DecimalFormat("0.00").format(groupGisData.getNormalSum() / groupGisData.getSum() * 100L)); |
| | | } |
| | | |
| | | return groupGisData; |
| | | } |
| | | |
| | | /** |
| | | * 大屏首页-抓拍跟踪信息 |
| | | * |
| | |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, resultListSnap); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 大屏首页-抓拍跟踪信息-展示AI时间图片 |
| | | * 展示图片的业务逻辑:每个库区展示一张,图片为当天十点以后最新的一张 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public PageResponse<List<EventInfo>> indexEventInfoList(IgdsBaseParam param) { |
| | | // Date start =DateUtils.setHours(DateUtil.getNewByDay(new Date(), -3), 10); |
| | | //param.setStart(start); |
| | | // param.setEnd(DateUtil.getNewByDay(new Date(), -3)); |
| | | Date start =DateUtil.getNewByDay(new Date(), -10); |
| | | param.setStart(start); |
| | | param.setEnd(new Date()); |
| | | |
| | | //获取当日的抓拍信息 |
| | | List<EventInfo> listByParam = eventInfoService.getListByParam(param); |
| | | if (null == listByParam || listByParam.isEmpty()) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, new ArrayList<>()); |
| | | } |
| | | |
| | | //获取所有的库区信息 |
| | | List<Dept> deptList = deptService.getDeptByUserType(null); |
| | | //根据库区从listByParam来获取每一个库区下,最新的一张抓拍图片 |
| | | List<EventInfo> resultList = new ArrayList<>(); |
| | | |
| | | for (Dept dept : deptList) { |
| | | EventInfo latestEvent = null; |
| | | //从listByParam中筛选出与当前id匹配的数据 |
| | | List<EventInfo> collect = listByParam.stream().filter(info -> info.getDeptId().equals(dept.getId())).sorted(Comparator.comparing(EventInfo::getTime).reversed()).collect(Collectors.toList()); |
| | | //每个库区获取最新的3张图片 |
| | | int i = 0; |
| | | for (EventInfo info : collect) { |
| | | if (i > 2) break; |
| | | resultList.add(info); |
| | | i++; |
| | | } |
| | | } |
| | | if (null != resultList && !resultList.isEmpty()) { |
| | | //判断文件是否存在 |
| | | for (EventInfo record : resultList) { |
| | | record.setImgName(commonManager.isImgExit(record.getImgName(), null)); |
| | | } |
| | | } |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, resultList); |
| | | } |
| | | } |