sgj
2026-03-24 deb8a2c32ba0cb7a88819b54d720418cdc2f7ebb
fzzy-igdss-web/src/main/java/com/fzzy/common/manager/CommonManager.java
@@ -3,13 +3,12 @@
import com.fzzy.igds.constant.Constant;
import com.fzzy.igds.constant.DepotType;
import com.fzzy.igds.data.IgdsBaseParam;
import com.fzzy.igds.data.MainData;
import com.fzzy.igds.data.InoutParam;
import com.fzzy.igds.data.MainData;
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.work.data.OrderStatus;
import com.fzzy.work.service.WorkOrderService;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysDictData;
@@ -18,11 +17,13 @@
import com.ruoyi.system.service.ISysDeptService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
/**
 * @Description
@@ -39,7 +40,7 @@
    private DicService dicService;
    @Resource
    private CoreDeptService coreDeptService;
    @Autowired
    @Resource
    private SecCameraService secCameraService;
    @Resource
    private ISysDeptService iSysDeptService;
@@ -57,6 +58,22 @@
    private EventInfoService eventInfoService;
    @Resource
    private SnapRecordService snapRecordService;
    @Resource
    private GatewaySerService gatewaySerService;
    /**
     * 根据库区编码获取库区网关信息
     *
     * @param deptId
     * @return
     */
    public GatewaySer getGatewaySerByDeptId(String deptId) {
        if (StringUtils.isBlank(deptId)) {
            deptId = ContextUtil.subDeptId(null);
        }
        return gatewaySerService.getCacheSerByDeptId(deptId);
    }
    /**
     * 根据库区编码获取库区下所有仓库列表
@@ -112,16 +129,39 @@
     * @return
     */
    public List<Depot> listDepotByDeptId(String deptId) {
        try{
        try {
            if (StringUtils.isEmpty(deptId)) {
                deptId = ContextUtil.subDeptId(null);
            }
            return depotService.getCacheDepotList(ContextUtil.getCompanyId(), deptId);
        }catch (Exception e){
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 根据仓库类型获取库区下仓库列表
     *
     * @param deptId
     * @param depotTypes 类型多个,用逗号隔开
     * @return
     */
    public List<Depot> listAllDepot(String deptId, String depotTypes) {
        List<Depot> depots = this.listDepotByDeptId(deptId);
        if (null == depots || depots.isEmpty()) {
            return null;
        }
        List<Depot> result = new ArrayList<>();
        for (Depot depot : depots) {
            if (depotTypes.contains(depot.getDepotType())) {
                result.add(depot);
            }
        }
        return result;
    }
    /**
@@ -133,13 +173,13 @@
    /**
     * 获取分库列表
     * 根据公司ID获取公司下的分库列表
     *
     * @author sgj
     * @date 2025/12/12
     */
    public List<Dept> listDeptData() {
        return coreDeptService.getDeptData();
    public List<Dept> listDeptData(String parentId) {
        return coreDeptService.getDeptByUserType(parentId);
    }
    /**
@@ -176,8 +216,7 @@
     * @date 2025/12/17
     */
    public List<Company> listCompanyData() {
        SysUser user = ContextUtil.getLoginUser();
        return coreCompanyService.listCompany(null, null, user.getDeptId() + "");
        return coreCompanyService.getCompanyByUserType();
    }
@@ -205,7 +244,7 @@
        MainData mainData = new MainData();
        //待办工单数
        Integer orderNum = workOrderService.getNumByUser(OrderStatus.STATUS_30.getCode(), user.getLoginName());
        Integer orderNum = workOrderService.getTodoNumByUser(user);
        mainData.setOrderNum(orderNum);
        //统计出入库信息
@@ -217,15 +256,17 @@
        LinkedHashMap<String, Integer> mapMonthOutNum = new LinkedHashMap<>();
        LinkedHashMap<String, Integer> mapWeekAiNum = new LinkedHashMap<>();
        LinkedHashMap<String, Integer> mapWeekSnapNum = new LinkedHashMap<>();
        LinkedHashMap<String, Double> mapWeekMaizeNum = new LinkedHashMap<>();
        String key;
        for (int i = -29; i <= 0; i++) {
            mapMonthInNum.put(DateFormatUtils.format(DateUtil.getNewByDay(new Date(), i), "MM-dd"), 0);
            mapMonthOutNum.put(DateFormatUtils.format(DateUtil.getNewByDay(new Date(), i), "MM-dd"), 0);
            if(i >=-6){
            if (i >= -6) {
                mapWeekInNum.put(DateFormatUtils.format(DateUtil.getNewByDay(new Date(), i), "MM-dd"), 0);
                mapWeekOutNum.put(DateFormatUtils.format(DateUtil.getNewByDay(new Date(), i), "MM-dd"), 0);
                mapWeekAiNum.put(DateFormatUtils.format(DateUtil.getNewByDay(new Date(), i), "MM-dd"), 0);
                mapWeekSnapNum.put(DateFormatUtils.format(DateUtil.getNewByDay(new Date(), i), "MM-dd"), 0);
                mapWeekMaizeNum.put(DateFormatUtils.format(DateUtil.getNewByDay(new Date(), i), "MM-dd"), 0.0);
            }
        }
@@ -238,8 +279,8 @@
        if (null != listEvent && !listEvent.isEmpty()) {
            mainData.setAiNum(listEvent.size());
            for (EventInfo event : listEvent) {
                key = DateFormatUtils.format(event.getTime(),"MM-dd");
                if(null != mapWeekAiNum.get(key)){
                key = DateFormatUtils.format(event.getTime(), "MM-dd");
                if (null != mapWeekAiNum.get(key)) {
                    mapWeekAiNum.put(key, mapWeekAiNum.get(key) + 1);
                }
            }
@@ -253,8 +294,8 @@
        List<SnapRecord> listSnap = snapRecordService.getListByParam(param);
        if (null != listSnap && !listSnap.isEmpty()) {
            for (SnapRecord snap : listSnap) {
                key = DateFormatUtils.format(snap.getSnapTime(),"MM-dd");
                if(null != mapWeekSnapNum.get(key)){
                key = DateFormatUtils.format(snap.getSnapTime(), "MM-dd");
                if (null != mapWeekSnapNum.get(key)) {
                    mapWeekSnapNum.put(key, mapWeekSnapNum.get(key) + 1);
                }
            }
@@ -263,36 +304,64 @@
            mainData.getWeekSnapDateList().add(mapKey);
            mainData.getWeekSnapNumList().add(mapWeekSnapNum.get(mapKey));
        }
        //近七天玉米出库价格统计
        InoutParam inoutParamOfMaize = new InoutParam();
        inoutParamOfMaize.setDeptId(user.getDeptId() + "");
        //粮食品种玉米
        inoutParamOfMaize.setFoodVariety("1120000");
        inoutParamOfMaize.setType(Constant.TYPE_OUT);
        inoutParamOfMaize.setStart(DateUtil.getNewByDay(new Date(), -6));
        inoutParamOfMaize.setEnd(new Date());
        List<InoutRecord> inoutRecordsOfMaize = inoutRecordService.listInout(inoutParamOfMaize);
        if (null != inoutRecordsOfMaize && !inoutRecordsOfMaize.isEmpty()) {
            for (InoutRecord record : inoutRecordsOfMaize) {
                key = DateFormatUtils.format(record.getRegisterTime(), "MM-dd");
                if (null != mapWeekMaizeNum.get(key)) {
                    Double nowPrice = mapWeekMaizeNum.get(key);
                    Double newPrice = record.getPrice();
                    if (nowPrice > newPrice || nowPrice == 0) {
                        nowPrice = newPrice;
                    }
                    mapWeekMaizeNum.put(key, nowPrice);
                }
            }
        }
        for (String mapKey : mapWeekMaizeNum.keySet()) {
            mainData.getWeekMaizeDateList().add(mapKey);
            mainData.getWeekMaizeNumList().add(mapWeekMaizeNum.get(mapKey));
        }
        //查询近30天所有出入库信息
        InoutParam inoutParam = new InoutParam();
        param.setDeptId(user.getDeptId() + "");
        param.setStart(DateUtil.getNewByDay(new Date(), -29));
        param.setEnd(new Date());
        inoutParam.setDeptId(user.getDeptId() + "");
        inoutParam.setStart(DateUtil.getNewByDay(new Date(), -29));
        inoutParam.setEnd(new Date());
        List<InoutRecord> inoutRecords = inoutRecordService.listInout(inoutParam);
        if (null != inoutRecords && !inoutRecords.isEmpty()) {
            for (InoutRecord record : inoutRecords) {
                key = DateFormatUtils.format(record.getRegisterTime(),"MM-dd");
                if(Constant.TYPE_IN.equals(record.getType())){
                    if(null != mapWeekInNum.get(key)){
                key = DateFormatUtils.format(record.getRegisterTime(), "MM-dd");
                if (Constant.TYPE_IN.equals(record.getType())) {
                    if (null != mapWeekInNum.get(key)) {
                        mapWeekInNum.put(key, mapWeekInNum.get(key) + 1);
                    }
                    if(null != mapMonthInNum.get(key)){
                    if (null != mapMonthInNum.get(key)) {
                        mapMonthInNum.put(key, mapMonthInNum.get(key) + 1);
                    }
                    if(key.equals(DateFormatUtils.format(new Date(),"MM-dd"))){
                    if (key.equals(DateFormatUtils.format(new Date(), "MM-dd"))) {
                        mainData.setInNumDay(mainData.getInNumDay() + 1);
                        inSum += record.getRecordWeight();
                    }
                }
                if(Constant.TYPE_OUT.equals(record.getType())){
                    if(null != mapWeekOutNum.get(key)){
                if (Constant.TYPE_OUT.equals(record.getType())) {
                    if (null != mapWeekOutNum.get(key)) {
                        mapWeekOutNum.put(key, mapWeekOutNum.get(key) + 1);
                    }
                    if(null != mapMonthOutNum.get(key)){
                    if (null != mapMonthOutNum.get(key)) {
                        mapMonthOutNum.put(key, mapMonthOutNum.get(key) + 1);
                    }
                    if(key.equals(DateFormatUtils.format(new Date(),"MM-dd"))){
                    if (key.equals(DateFormatUtils.format(new Date(), "MM-dd"))) {
                        mainData.setOutNumDay(mainData.getOutNumDay() + 1);
                        outSum += record.getRecordWeight();
                    }