OMS执行单开发
This commit is contained in:
@@ -0,0 +1,201 @@
|
||||
package com.mhd.oms.util;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.mhd.common.core.domain.entity.R;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
import com.mhd.system.api.SystemServiceFeign;
|
||||
import com.mhd.system.api.domain.SysDictData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 普通字典查询
|
||||
*/
|
||||
@Component
|
||||
public class DictDataUtils {
|
||||
|
||||
@Autowired
|
||||
private SystemServiceFeign systemServiceFeign;
|
||||
|
||||
/**
|
||||
* 获取全部通用字典
|
||||
* @return
|
||||
*/
|
||||
public List<SysDictData> getDictDataList(){
|
||||
List<SysDictData> list = new ArrayList<>();
|
||||
//通过feign调用获取通用数据字典
|
||||
SysDictData sysDictData = new SysDictData();
|
||||
sysDictData.setTopOrganizationId(0L);
|
||||
R<List<SysDictData>> result = systemServiceFeign.getDictDataList(sysDictData);
|
||||
if (result.getCode() == 200){
|
||||
list = result.getData();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过字典类别获取list
|
||||
* @param dictTypeCode
|
||||
* @return
|
||||
*/
|
||||
public List<SysDictData> getDictDataList(String dictTypeCode){
|
||||
List<SysDictData> list = new ArrayList<>();
|
||||
//通过feign调用获取通用数据字典
|
||||
SysDictData sysDictData = new SysDictData();
|
||||
sysDictData.setTopOrganizationId(0L);
|
||||
sysDictData.setDictType(dictTypeCode);
|
||||
R<List<SysDictData>> result = systemServiceFeign.getDictDataList(sysDictData);
|
||||
if (result.getCode() == 200){
|
||||
list = result.getData();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过字典类别和编码获取字典
|
||||
* @param dictType
|
||||
* @return
|
||||
*/
|
||||
public SysDictData getDictDataByValue(String dictType, String dictValue){
|
||||
if (StringUtils.isBlank(dictType) || StringUtils.isBlank(dictValue)){
|
||||
return null;
|
||||
}
|
||||
List<SysDictData> list = new ArrayList<>();
|
||||
//通过feign调用获取通用数据字典
|
||||
SysDictData sysDictData = new SysDictData();
|
||||
sysDictData.setTopOrganizationId(0L);
|
||||
sysDictData.setDictType(dictType);
|
||||
sysDictData.setDictValue(dictValue);
|
||||
R<List<SysDictData>> result = systemServiceFeign.getDictDataList(sysDictData);
|
||||
if (result.getCode() == 200){
|
||||
list = result.getData();
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(list) && ! list.isEmpty()){
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过字典类别和名称获取字典
|
||||
* @param dictType
|
||||
* @return
|
||||
*/
|
||||
public SysDictData getDictDataByLable(String dictType, String dictLable){
|
||||
if (StringUtils.isBlank(dictType) || StringUtils.isBlank(dictLable)){
|
||||
return null;
|
||||
}
|
||||
List<SysDictData> list = new ArrayList<>();
|
||||
//通过feign调用获取通用数据字典
|
||||
SysDictData sysDictData = new SysDictData();
|
||||
sysDictData.setTopOrganizationId(0L);
|
||||
sysDictData.setDictType(dictType);
|
||||
sysDictData.setDictLabel(dictLable);
|
||||
R<List<SysDictData>> result = systemServiceFeign.getDictDataList(sysDictData);
|
||||
if (result.getCode() == 200){
|
||||
list = result.getData();
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(list) && list.size() > 0){
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过给定的值和字段类型,获取数据字典
|
||||
* @param list
|
||||
* @param dictValue
|
||||
* @return
|
||||
*/
|
||||
public SysDictData getDictData(List<SysDictData> list, String dictValue){
|
||||
if (CollectionUtil.isNotEmpty(list)){
|
||||
Map<String, SysDictData> menuMap = list.stream().collect(Collectors.toMap(SysDictData::getDictValue, Function.identity(), (key1, key2) -> key2));
|
||||
SysDictData sysDictData = menuMap.get(dictValue);
|
||||
return sysDictData;
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 通过给定的值和字段类型,获取数据字典
|
||||
* @param list
|
||||
* @param dictLable
|
||||
* @return
|
||||
*/
|
||||
public SysDictData getDictDataForLable(List<SysDictData> list, String dictLable){
|
||||
if (CollectionUtil.isNotEmpty(list)){
|
||||
Map<String, SysDictData> menuMap = list.stream().collect(Collectors.toMap(SysDictData::getDictLabel, Function.identity(), (key1, key2) -> key2));
|
||||
SysDictData sysDictData = menuMap.get(dictLable);
|
||||
return sysDictData;
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过给定的值和字段类型,获取数据字典
|
||||
* @param list
|
||||
* @param dictValue
|
||||
* @return
|
||||
*/
|
||||
public SysDictData getDictDataByTypeAndValue(List<SysDictData> list, String dictType, String dictValue){
|
||||
if (CollectionUtil.isNotEmpty(list)){
|
||||
Map<String, List<SysDictData>> collect = list.stream().collect(Collectors.groupingBy(SysDictData::getDictType));
|
||||
List<SysDictData> dictDataList = collect.get(dictType);
|
||||
if (CollectionUtil.isNotEmpty(dictDataList)){
|
||||
Map<String, SysDictData> menuMap = dictDataList.stream().collect(Collectors.toMap(SysDictData::getDictValue, Function.identity(), (key1, key2) -> key2));
|
||||
SysDictData sysDictData = menuMap.get(dictValue);
|
||||
return sysDictData;
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 通过给定的值和字段值,获取数据字典
|
||||
* @param list
|
||||
* @param dictLable
|
||||
* @return
|
||||
*/
|
||||
public SysDictData getDictDataByTypeAndLable(List<SysDictData> list, String dictType, String dictLable){
|
||||
if (CollectionUtil.isNotEmpty(list)){
|
||||
Map<String, List<SysDictData>> collect = list.stream().collect(Collectors.groupingBy(SysDictData::getDictType));
|
||||
List<SysDictData> dictDataList = collect.get(dictType);
|
||||
if (CollectionUtil.isNotEmpty(dictDataList)){
|
||||
Map<String, SysDictData> menuMap = dictDataList.stream().collect(Collectors.toMap(SysDictData::getDictLabel, Function.identity(), (key1, key2) -> key2));
|
||||
SysDictData sysDictData = menuMap.get(dictLable);
|
||||
return sysDictData;
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过类别和编码获取字典名称
|
||||
* @param type
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public String getSysDictItemValue(String type, String code) {
|
||||
SysDictData dictDataList = this.getDictDataByValue(type, code);
|
||||
if (dictDataList == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return dictDataList.getDictValue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.mhd.oms.util;
|
||||
|
||||
public enum DictTypeEnum {
|
||||
VEHICLE_TYPE("vehicle_type", "车型"),
|
||||
VEHICLE_ENERGY_TYPE("vehicle_energy_type", "车辆能源类型"),
|
||||
LINCESE_COLOR("license_color", "车牌颜色"),
|
||||
ZHENGJIANLEIXING("zhengjianleixing", "证件类型"),
|
||||
ZHUNJIACHEXING("zhunjiachexing", "准驾车型"),
|
||||
MARKER_STATE("marker_state", "标记状态"),
|
||||
ZAIZHONG("zaizhong", "载重"),
|
||||
VEHICLE_LENGTH("vehicle_length", "车长"),
|
||||
AXLENUM("axlenum", "车轴数"),
|
||||
GROSS_MASS("gross_mass", "总质量"),
|
||||
VEHICLE_VOLUME("vehicle_volume", "容积"),
|
||||
BANK("bank", "银行名称"),
|
||||
SHIP_TYPE("ship_type", "船舶类型"),
|
||||
PACK_TYPE("pack_type", "包装方式"),
|
||||
TIMETYPE("time_type", "装卸货时间"),
|
||||
GOODS_TYPE("goods_type", "商品类型"),
|
||||
GOODSUNIT("goods_unit", "货物数量单位(吨、方、件)"),
|
||||
WAYBILL_TYPE("waybill_type", "货单类型"),
|
||||
SERVICE_REQUIREMENT("service_request", "服务要求(发货页面)"),
|
||||
SPECIAL_CHARGES("special_charges", "特殊费用-费用类型"),
|
||||
BUDGET_STATE("budget_state", "特殊费用-收支类型"),
|
||||
SHIPPER_CANCEL_RESON("shipper_cancel_reson", "货主取消运单理由"),
|
||||
UNNATURAL_REASON("abnormal_cause", "异常原因"),
|
||||
PINGAN_FILE_TYPE("pingan_file_type", "平安银行文件类型"),
|
||||
;
|
||||
|
||||
private String typeCode;
|
||||
private String typeValue;
|
||||
|
||||
DictTypeEnum(String typeCode, String typeValue) {
|
||||
this.typeCode = typeCode;
|
||||
this.typeValue = typeValue;
|
||||
}
|
||||
|
||||
public String getTypeCode() {
|
||||
return typeCode;
|
||||
}
|
||||
|
||||
public void setTypeCode(String typeCode) {
|
||||
this.typeCode = typeCode;
|
||||
}
|
||||
|
||||
public String getTypeValue() {
|
||||
return typeValue;
|
||||
}
|
||||
|
||||
public void setVehicleType(String typeValue) {
|
||||
this.typeValue = typeValue;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user