package com.fzzy.igds.service;
|
|
import com.fzzy.igds.constant.*;
|
import com.fzzy.igds.utils.ContextUtil;
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
import com.ruoyi.common.utils.DictUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.system.mapper.SysDictDataMapper;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* @Description 字典service层
|
* @Author CZT
|
* @Date 2025/11/25 15:15
|
*/
|
@Service
|
public class DicService {
|
|
@Autowired
|
private SysDictDataMapper dictDataMapper;
|
|
/**
|
* 初始化常用品种、性质、出入库流程到内存
|
*
|
* @param companyId
|
*/
|
public void initDicMap(String companyId) {
|
if (StringUtils.isEmpty(companyId)) {
|
companyId = ContextUtil.getCompanyId();
|
}
|
//初始化粮食品种字典
|
List<SysDictData> dicList = DictUtils.getDictCache(Constant.TRIGGER_PARENT_FOOD_VARIETY, companyId);
|
if (null != dicList) {
|
for (SysDictData sysDictData : dicList) {
|
FoodVariety.mapFoodVariety.put(sysDictData.getDictValue(), sysDictData.getDictLabel());
|
}
|
}
|
//初始化粮食性质字典
|
dicList = DictUtils.getDictCache(Constant.TRIGGER_PARENT_FOOD_TYPE, companyId);
|
if (null != dicList) {
|
for (SysDictData sysDictData : dicList) {
|
FoodType.mapFoodType.put(sysDictData.getDictValue(), sysDictData.getDictLabel());
|
}
|
}
|
//初始化出入库流程字典
|
dicList = DictUtils.getDictCache(Constant.TRIGGER_PARENT_PROCESS_STATUS, companyId);
|
if (null != dicList) {
|
for (SysDictData sysDictData : dicList) {
|
InoutProgress.mapProgressName.put(sysDictData.getDictValue(), sysDictData.getDictLabel());
|
}
|
}
|
}
|
|
/**
|
* 根据type和组织编码获取字典,先从缓存获取,缓存没有则查询数据库
|
*
|
* @param dictType
|
* @param companyId
|
* @return
|
*/
|
public List<SysDictData> getDictDataByType(String dictType, String companyId) {
|
|
if (StringUtils.isEmpty(dictType)) {
|
return null;
|
}
|
if (StringUtils.isEmpty(companyId)) {
|
companyId = ContextUtil.getCompanyId();
|
}
|
List<SysDictData> list = DictUtils.getDictCache(dictType, companyId);
|
if (null == list || list.isEmpty()) {
|
list = dictDataMapper.selectDictDataByType(dictType, companyId);
|
DictUtils.setDictCache(dictType, list, companyId);
|
}
|
return list;
|
}
|
|
/**
|
* 仓房类型-非国标定义
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerDepotType() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
for (DepotType w : DepotType.values()) {
|
list.add(new SysDictData(w.getMsg(), w.getCode()));
|
}
|
return list;
|
}
|
|
/**
|
* 仓房状态
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerDepotStatus() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
for (DepotStatus w : DepotStatus.values()) {
|
list.add(new SysDictData(w.getMsg(), w.getCode()));
|
}
|
return list;
|
}
|
|
/**
|
* 粮食等级
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerFoodLevel() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
for (FoodLevel w : FoodLevel.values()) {
|
list.add(new SysDictData(w.getMsg(), w.getCode()));
|
}
|
return list;
|
}
|
|
/**
|
* 储粮方式
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerStoreType() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
list.add(new SysDictData("散装储粮", "1"));
|
list.add(new SysDictData("包装储粮", "2"));
|
list.add(new SysDictData("围包存", "3"));
|
list.add(new SysDictData("其他", "9"));
|
return list;
|
}
|
|
/**
|
* 管理方式
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerManagerType() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
list.add(new SysDictData("直储", "01"));
|
list.add(new SysDictData("代储", "02"));
|
list.add(new SysDictData("租仓", "03"));
|
list.add(new SysDictData("委托", "04"));
|
return list;
|
}
|
|
/**
|
* 是否
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerYN() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
list.add(new SysDictData("是", Constant.YN_Y));
|
list.add(new SysDictData("否", Constant.YN_N));
|
return list;
|
}
|
|
/**
|
* 通讯状态
|
*
|
* @return
|
* @throws Exception
|
*/
|
public List<SysDictData> conStatus() {
|
List<SysDictData> list = new ArrayList<>();
|
list.add(new SysDictData("正常", Constant.YN_Y));
|
list.add(new SysDictData("断开", Constant.YN_N));
|
return list;
|
}
|
|
/**
|
* 播放方式
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerPlayType() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
for (PlayType w : PlayType.values()) {
|
list.add(new SysDictData(w.getName(), w.getCode()));
|
}
|
return list;
|
}
|
|
/**
|
* 抓拍方式
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerSnapType() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
for (SnapType w : SnapType.values()) {
|
list.add(new SysDictData(w.getMsg(), w.getCode()));
|
}
|
return list;
|
}
|
|
/**
|
* 检验类别
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerCheckType() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
for (CheckType w : CheckType.values()) {
|
list.add(new SysDictData(w.getMsg(), w.getCode()));
|
}
|
return list;
|
}
|
|
/**
|
* 指标类别
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerStandard() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
|
list.add(new SysDictData("国标", "1"));
|
list.add(new SysDictData("其他", "0"));
|
|
return list;
|
}
|
|
/**
|
* 检验依据
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerMetrics() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
|
list.add(new SysDictData("质量指标检验", "1"));
|
list.add(new SysDictData("储存品质检验", "2"));
|
list.add(new SysDictData("食品安全检验", "3"));
|
|
return list;
|
}
|
|
/**
|
* 审核状态
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerStatusType() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
for (AuditStatus w : AuditStatus.values()) {
|
list.add(new SysDictData(w.getMsg(), w.getCode()));
|
}
|
|
return list;
|
}
|
|
/**
|
* 警告类型
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerWarnType() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
for (WarnType w : WarnType.values()) {
|
list.add(new SysDictData(w.getMsg(), w.getCode()));
|
}
|
return list;
|
}
|
|
/**
|
* 警告等级
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerWarnLevel() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
for (WarnLevel w : WarnLevel.values()) {
|
list.add(new SysDictData(w.getMsg(), w.getCode()));
|
}
|
|
return list;
|
}
|
|
/**
|
* 警告状态
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerWarnStatus() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
for (WarnStatus w : WarnStatus.values()) {
|
list.add(new SysDictData(w.getName(), w.getCode()));
|
}
|
|
return list;
|
}
|
|
/**
|
* 警告通知方式
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerNoticeType() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
for (NoticeType w : NoticeType.values()) {
|
list.add(new SysDictData(w.getName(), w.getCode()));
|
}
|
|
return list;
|
}
|
|
/**
|
* 电缆起始方位
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerStartOrientation() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
list.add(new SysDictData("右边", Constant.GRAIN_START_ORIENTATION_RIGHT));
|
list.add(new SysDictData("右上", Constant.GRAIN_START_ORIENTATION_RIGHT_UP));
|
list.add(new SysDictData("左边", Constant.GRAIN_START_ORIENTATION_LEFT));
|
list.add(new SysDictData("左上", Constant.GRAIN_START_ORIENTATION_LEFT_UP));
|
return list;
|
}
|
|
/**
|
* 电缆布线方向
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerStartDirection() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
list.add(new SysDictData("纵向", Constant.GRAIN_START_DIRECTION_PORTRAIT));
|
list.add(new SysDictData("横向", Constant.GRAIN_START_DIRECTION_TRANSVERSE));
|
return list;
|
}
|
|
/**
|
* 电缆起始点位
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerStartPoint() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
list.add(new SysDictData("顶部", Constant.GRAIN_START_POINT_TOP));
|
list.add(new SysDictData("底部", Constant.GRAIN_START_POINT_BELOW));
|
|
return list;
|
}
|
|
/**
|
* 层行转换
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerStartConvert() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
list.add(new SysDictData("默认", Constant.GRAIN_CONVERT_DEFAULT));
|
list.add(new SysDictData("顺时针", Constant.GRAIN_CONVERT_CLOCKWISE));
|
list.add(new SysDictData("逆时针", Constant.GRAIN_CONVERT_ANTICLOCKWISE));
|
return list;
|
}
|
|
/**
|
* 筒仓锥形
|
*
|
* @return
|
*/
|
public List<SysDictData> triggerCableCone() {
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
list.add(new SysDictData("无锥形", Constant.CABLE_CONE_0));
|
list.add(new SysDictData("上锥形", Constant.CABLE_CONE_1));
|
list.add(new SysDictData("下锥形", Constant.CABLE_CONE_2));
|
return list;
|
}
|
|
/**
|
*
|
* @return
|
*/
|
public List<SysDictData> getInoutType() {
|
|
List<SysDictData> list = new ArrayList<SysDictData>();
|
list.add(new SysDictData("入库", Constant.TYPE_IN));
|
list.add(new SysDictData("出库", Constant.TYPE_OUT));
|
return list;
|
}
|
}
|