czt
2026-01-06 97dfab42d2736e2e91035aad58ed01fc27ad3a7d
fzzy-igdss-web/src/main/java/com/fzzy/group/manager/GroupManager.java
@@ -1,19 +1,18 @@
package com.fzzy.group.manager;
import com.fzzy.common.manager.CommonManager;
import com.fzzy.igds.constant.Constant;
import com.fzzy.igds.constant.FoodVariety;
import com.fzzy.igds.constant.RespCodeEnum;
import com.fzzy.igds.data.*;
import com.fzzy.igds.domain.Depot;
import com.fzzy.igds.domain.Dept;
import com.fzzy.igds.domain.DicArea;
import com.fzzy.igds.domain.InoutRecord;
import com.fzzy.igds.domain.*;
import com.fzzy.igds.service.*;
import com.fzzy.igds.utils.ContextUtil;
import com.fzzy.igds.utils.DateUtil;
import com.fzzy.igds.utils.NumberUtil;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@@ -30,6 +29,8 @@
public class GroupManager {
    @Resource
    private CommonManager commonManager;
    @Resource
    private DicAreaService dicAreaService;
    @Resource
    private CoreDeptService deptService;
@@ -39,6 +40,12 @@
    private CoreCompanyService coreCompanyService;
    @Resource
    private InoutRecordService inoutRecordService;
    @Resource
    private EventInfoService eventInfoService;
    @Resource
    private SnapRecordService snapRecordService;
    @Resource
    private SecCameraService cameraService;
    /**
     * 获取省及下属市州集合
@@ -111,15 +118,97 @@
    }
    /**
     * 获取组织下所有库区信息
     * 获取用户下所有库区信息
     *
     * @return
     */
    public List<Dept> getDeptList() {
        return deptService.getDeptByUserType(null);
    }
    /**
     * 获取库区封装信息
     * @param companyId
     * @return
     */
    public List<Dept> getAllDept(String companyId) {
        return deptService.listDept(null, companyId, null);
    public List<GroupDeptData> getDeptData(String companyId) {
        List<GroupDeptData> list = new ArrayList<>();
        GroupDeptData deptData;
        List<Dept> deptList = deptService.getDeptData();
        if (null != deptList && !deptList.isEmpty()) {
            List<Depot> depotList;
            for (Dept dept : deptList) {
                deptData = new GroupDeptData();
                deptData.setDeptId(dept.getId());
                deptData.setDeptName(dept.getKqmc());
                deptData.setCode(dept.getXzqhdm());
                deptData.setCounty(dept.getXzqhmc());
                deptData.setJd(dept.getJd());
                deptData.setWd(dept.getWd());
                //统计仓库数
                depotList = depotService.getCacheDepotList(dept.getCompanyId(), dept.getId());
                if (null != depotList && !depotList.isEmpty()) {
                    for (Depot depot : depotList) {
                        deptData.setDepotNumber(deptData.getDepotNumber() + 1);
                        if(StringUtils.isNotBlank(depot.getPledgeBank())){
                            deptData.setDepotBankNumber(deptData.getDepotBankNumber() + 1);
                        }
                        if(null == depot.getStorageReal()){
                            depot.setStorageReal(0.0);
                        }
                        deptData.setStorageNum(deptData.getStorageNum() + depot.getStorageReal()/1000);
                    }
                }
                //统计出入库数量
                InoutParam inoutParam = new InoutParam();
                inoutParam.setDeptId(dept.getId());
                inoutParam.setCompanyId(companyId);
                inoutParam.setStart(DateUtil.getCurZero(new Date()));
                inoutParam.setEnd(DateUtil.getNextZero(new Date()));
                List<InoutRecord> inoutRecords = inoutRecordService.listInout(inoutParam);
                if (null != inoutRecords && !inoutRecords.isEmpty()) {
                    for (InoutRecord inoutRecord : inoutRecords) {
                        if (Constant.TYPE_IN.equals(inoutRecord.getType())) {
                            deptData.setInNum(deptData.getInNum() + 1);
                        }
                        if (Constant.TYPE_OUT.equals(inoutRecord.getType())){
                            deptData.setOutNum(deptData.getOutNum() + 1);
                        }
                    }
                }
                list.add(deptData);
            }
        }
        return list;
    }
    /**
     * 获取库区下监控信息
     * @param param
     * @return
     */
    public PageResponse<List<Camera>> cameraList(IgdsBaseParam param) {
        if(StringUtils.isBlank(param.getDeptId())){
            return new PageResponse<>(RespCodeEnum.CODE_2000, null);
        }
        if (StringUtils.isBlank(param.getCompanyId())){
            param.setCompanyId(ContextUtil.getCompanyId());
        }
        List<Camera> listCamera = cameraService.getCameraByDeptId(param.getCompanyId(), param.getDeptId());
        return new PageResponse<>(RespCodeEnum.CODE_0000, listCamera);
    }
    /**
     * 大屏首页统计信息:企业数、库区数、仓库数、质押仓数、散粮及成品粮数、分品种库存数
@@ -202,6 +291,7 @@
            List<Depot> depotList;
            for (Dept dept : deptList) {
                deptData = new GroupDeptData();
                deptData.setDeptId(dept.getId());
                deptData.setDeptName(dept.getKqmc());
                deptData.setCode(dept.getXzqhdm());
                deptData.setCounty(dept.getXzqhmc());
@@ -243,6 +333,23 @@
                        }
                    }
                }
                //统计AI事件数量
                IgdsBaseParam igdsParam = new IgdsBaseParam();
                igdsParam.setDeptId(dept.getId());
                igdsParam.setCompanyId(param.getCompanyId());
                igdsParam.setStart(DateUtil.getNewByDay(new Date(), -6));
                igdsParam.setEnd(DateUtil.getNextZero(new Date()));
                List<EventInfo> enevtList = eventInfoService.getListByParam(igdsParam);
                if (null != enevtList && !enevtList.isEmpty()) {
                    deptData.setWarnNum7(enevtList.size());
                    for (EventInfo eventInfo : enevtList) {
                        if(DateFormatUtils.format(new Date(), "yyyyMMdd").equals(DateFormatUtils.format(eventInfo.getTime(), "yyyyMMdd"))){
                            deptData.setDailyTotal(deptData.getDailyTotal() + 1);
                        }
                    }
                }
                list.add(deptData);
            }
        }
@@ -317,4 +424,25 @@
        return groupGisData;
    }
    /**
     * 大屏首页-抓拍跟踪信息
     * @param param
     * @return
     */
    public PageResponse<List<SnapRecord>> indexSnapList(IgdsBaseParam param) {
        param.setStart(DateUtil.getNewByDay(new Date(), -10));
        param.setEnd(new Date());
        List<SnapRecord> listSnap = snapRecordService.getListByParam(param);
        if (null != listSnap && !listSnap.isEmpty()) {
            //判断文件是否存在
            for (SnapRecord record : listSnap) {
                record.setImgName(commonManager.isImgExit( record.getImgName(), null));
            }
        }
        return new PageResponse<>(RespCodeEnum.CODE_0000, listSnap);
    }
}