字典序列化
parent
0a648d7b24
commit
c6851f1a4a
|
|
@ -2,6 +2,7 @@ package com.njzscloud.common.core.fastjson.serializer;
|
|||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson2.JSONReader;
|
||||
import com.alibaba.fastjson2.reader.ObjectReader;
|
||||
import com.alibaba.fastjson2.util.TypeUtils;
|
||||
|
|
@ -55,7 +56,7 @@ public class DictObjectDeserializer implements ObjectReader<Dict> {
|
|||
} else {
|
||||
if (StrUtil.isBlank(val)) return null;
|
||||
String keyField = (String) map.get(Dict.ENUM_KEY);
|
||||
return DictItem.get(keyField, val);
|
||||
return SpringUtil.getBean(DictManager.class).get(keyField, val);
|
||||
}
|
||||
} else if (DictInt.class.isAssignableFrom(clazz)) {
|
||||
DictInt[] constants = (DictInt[]) clazz.getEnumConstants();
|
||||
|
|
@ -89,7 +90,7 @@ public class DictObjectDeserializer implements ObjectReader<Dict> {
|
|||
DictKey annotation = clazz.getAnnotation(DictKey.class);
|
||||
if (annotation == null) return null;
|
||||
String value = annotation.value();
|
||||
return DictItem.get(value, val);
|
||||
return SpringUtil.getBean(DictManager.class).get(value, val);
|
||||
}
|
||||
} else if (DictInt.class.isAssignableFrom(clazz)) {
|
||||
DictInt[] constants = (DictInt[]) clazz.getEnumConstants();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.njzscloud.common.core.ienum;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson2.annotation.JSONType;
|
||||
import com.njzscloud.common.core.fastjson.serializer.DictObjectDeserializer;
|
||||
import lombok.Getter;
|
||||
|
|
@ -8,79 +7,13 @@ import lombok.Setter;
|
|||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
@JSONType(deserializer = DictObjectDeserializer.class)
|
||||
public class DictItem implements DictStr {
|
||||
private static final Map<String, List<DictItem>> cache = new ConcurrentHashMap<>();
|
||||
|
||||
private String key;
|
||||
private String val;
|
||||
private String txt;
|
||||
private static DictItemLoader loader;
|
||||
|
||||
public static void setLoader(DictItemLoader loader) {
|
||||
DictItem.loader = loader;
|
||||
}
|
||||
|
||||
public static void put(String key, DictItem dictItem) {
|
||||
cache.compute(key, (k, v) -> {
|
||||
if (v == null) v = new LinkedList<>();
|
||||
v.add(dictItem);
|
||||
return v;
|
||||
});
|
||||
}
|
||||
|
||||
public static void put(String key, List<DictItem> list) {
|
||||
cache.put(key, new LinkedList<>(list));
|
||||
}
|
||||
|
||||
public static DictItem get(String key, String val) {
|
||||
DictItem dictItem = new DictItem();
|
||||
cache.compute(key, (k, v) -> {
|
||||
Optional<DictItem> data = Optional.empty();
|
||||
if (CollUtil.isEmpty(v)) {
|
||||
if (loader != null) {
|
||||
List<DictItem> list = loader.load(k);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
if (v == null) v = new LinkedList<>();
|
||||
v.addAll(list);
|
||||
data = v.stream().filter(it -> Objects.equals(it.val, val)).findFirst();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
data = v.stream().filter(it -> Objects.equals(it.val, val)).findFirst();
|
||||
}
|
||||
|
||||
if (data.isPresent()) {
|
||||
DictItem item = data.get();
|
||||
dictItem.key = item.key;
|
||||
dictItem.val = item.val;
|
||||
dictItem.txt = item.txt;
|
||||
}
|
||||
return v;
|
||||
});
|
||||
if (dictItem.key == null) return null;
|
||||
return dictItem;
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
public static void remove(String key, String val) {
|
||||
cache.compute(key, (k, v) -> {
|
||||
if (CollUtil.isNotEmpty(v)) v.removeIf(it -> Objects.equals(it.val, val));
|
||||
return v;
|
||||
});
|
||||
}
|
||||
|
||||
public static void remove(String key) {
|
||||
cache.remove(key);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
package com.njzscloud.common.core.ienum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DictItemLoader {
|
||||
List<DictItem> load(String key);
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.njzscloud.common.core.ienum;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.njzscloud.common.core.thread.SyncUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class DictManager {
|
||||
Map<String, List<DictItem>> cache = new HashMap<>();
|
||||
|
||||
public abstract List<DictItem> load(String key);
|
||||
|
||||
public DictItem get(String key, String val) {
|
||||
return SyncUtil.syncR("com.njzscloud.common.core.ienum.DictManager", () -> {
|
||||
Optional<DictItem> dictItemOpt = SyncUtil.syncR(key, () -> {
|
||||
List<DictItem> dictItems = cache.get(key);
|
||||
if (CollUtil.isEmpty(dictItems)) return Optional.empty();
|
||||
return dictItems.stream().filter(it -> Objects.equals(it.getVal(), val)).findFirst();
|
||||
});
|
||||
|
||||
if (dictItemOpt.isPresent()) {
|
||||
return dictItemOpt.get();
|
||||
}
|
||||
|
||||
dictItemOpt = SyncUtil.syncW(key, () -> {
|
||||
List<DictItem> dictItems = cache.get(key);
|
||||
if (CollUtil.isEmpty(dictItems)) {
|
||||
List<DictItem> itemList = load(key);
|
||||
if (CollUtil.isNotEmpty(itemList)) {
|
||||
cache.put(key, itemList);
|
||||
return itemList.stream().filter(it -> Objects.equals(it.getVal(), val)).findFirst();
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
return dictItems.stream().filter(it -> Objects.equals(it.getVal(), val)).findFirst();
|
||||
});
|
||||
|
||||
return dictItemOpt.orElse(null);
|
||||
});
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
SyncUtil.syncW("com.njzscloud.common.core.ienum.DictManager", () -> cache.clear());
|
||||
}
|
||||
|
||||
public void remove(String key) {
|
||||
SyncUtil.syncW("com.njzscloud.common.core.ienum.DictManager", () -> cache.remove(key));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.njzscloud.common.core.jackson.serializer;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonStreamContext;
|
||||
import com.fasterxml.jackson.core.JsonToken;
|
||||
|
|
@ -112,7 +113,7 @@ public class DictDeserializer extends JsonDeserializer<Dict> {
|
|||
DictKey annotation = field.getAnnotation(DictKey.class);
|
||||
if (annotation == null) return null;
|
||||
String value = annotation.value();
|
||||
return DictItem.get(value, val);
|
||||
return SpringUtil.getBean(DictManager.class).get(value, val);
|
||||
}
|
||||
} else if (DictInt.class.isAssignableFrom(clazz)) {
|
||||
int val = p.getValueAsInt();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
package com.njzscloud.common.mp.support.handler.j;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njzscloud.common.core.fastjson.Fastjson;
|
||||
import com.njzscloud.common.core.ienum.DictItem;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
import org.apache.ibatis.type.TypeHandler;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Json 类型处理器
|
||||
*/
|
||||
@Slf4j
|
||||
@MappedTypes({DictItem.class})
|
||||
@MappedJdbcTypes({JdbcType.VARCHAR})
|
||||
public class DictItemTypeHandler implements TypeHandler<DictItem> {
|
||||
|
||||
private static DictItem getResult(String result) {
|
||||
if (StrUtil.isBlank(result)) return null;
|
||||
try {
|
||||
return Fastjson.toBean(result, DictItem.class);
|
||||
} catch (Exception e) {
|
||||
log.error("JSON 格式数据映射失败", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(PreparedStatement ps, int i, DictItem parameter, JdbcType jdbcType) throws SQLException {
|
||||
if (parameter == null) ps.setNull(i, jdbcType.TYPE_CODE);
|
||||
else ps.setString(i, Fastjson.toJsonStr(parameter));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictItem getResult(ResultSet rs, String columnName) throws SQLException {
|
||||
String result = rs.getString(columnName);
|
||||
return getResult(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictItem getResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
String result = rs.getString(columnIndex);
|
||||
return getResult(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictItem getResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
String result = cs.getString(columnIndex);
|
||||
return getResult(result);
|
||||
}
|
||||
}
|
||||
|
|
@ -26,6 +26,7 @@ public class JsonTypeHandler implements TypeHandler<Object> {
|
|||
try {
|
||||
return Fastjson.toBean(result, Object.class);
|
||||
} catch (Exception e) {
|
||||
log.error("JSON 格式数据映射失败", e);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.njzscloud.common.mvc.support;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.njzscloud.common.core.ienum.*;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
|
|
@ -65,7 +66,7 @@ public class DictHandlerMethodArgumentResolver implements HandlerMethodArgumentR
|
|||
DictKey annotation = parameter.getParameterAnnotation(DictKey.class);
|
||||
if (annotation == null) return null;
|
||||
String value = annotation.value();
|
||||
return DictItem.get(value, param);
|
||||
return SpringUtil.getBean(DictManager.class).get(value, param);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -18,23 +18,22 @@ import org.mybatis.spring.annotation.MapperScan;
|
|||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.context.event.EventListener;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@ConditionalOnBean(DataSource.class)
|
||||
@DependsOn("dataSource")
|
||||
@MapperScan("com.njzscloud.common.sichen.mapper")
|
||||
@ConditionalOnBooleanProperty(prefix = "sichen.task", name = "enable")
|
||||
@EnableConfigurationProperties(TaskProperties.class)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
package com.njzscloud.dispose.config;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.njzscloud.common.core.ienum.DictItem;
|
||||
import com.njzscloud.common.core.ienum.DictManager;
|
||||
import com.njzscloud.dispose.sys.dict.pojo.entity.DictItemEntity;
|
||||
import com.njzscloud.dispose.sys.dict.service.DictItemService;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Configuration
|
||||
public class DictConfiguration {
|
||||
|
||||
@Bean
|
||||
public DictManager dictManager(DictItemService dictItemService) {
|
||||
return new DictManager() {
|
||||
@Override
|
||||
public List<DictItem> load(String key) {
|
||||
try {
|
||||
return dictItemService.list(Wrappers.<DictItemEntity>lambdaQuery().eq(DictItemEntity::getDictKey, key)
|
||||
.orderByAsc(DictItemEntity::getSort, DictItemEntity::getVal, DictItemEntity::getId)
|
||||
)
|
||||
.stream().map(it -> new DictItem().setKey(key).setVal(it.getVal()).setTxt(it.getTxt()))
|
||||
.collect(Collectors.toList());
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
package com.njzscloud.dispose.config;
|
||||
|
||||
import com.njzscloud.common.core.ienum.DictItem;
|
||||
import com.njzscloud.common.security.util.SecurityUtil;
|
||||
import com.njzscloud.dispose.sys.dict.service.DictService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.event.EventListener;
|
||||
|
|
@ -15,11 +13,9 @@ import static com.njzscloud.dispose.event.SysMittEvent.COERCE_LOGOUT;
|
|||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class SpringReady {
|
||||
private final DictService dictService;
|
||||
|
||||
@EventListener(ApplicationReadyEvent.class)
|
||||
public void onApplicationReady() {
|
||||
COERCE_LOGOUT.on((List<Long> ids) -> ids.forEach(SecurityUtil::removeToken));
|
||||
DictItem.setLoader(dictService);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import lombok.Setter;
|
|||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 司机
|
||||
|
|
@ -62,12 +62,12 @@ public class DriverEntity extends BaseEntity {
|
|||
/**
|
||||
* 驾驶证有效期开始
|
||||
*/
|
||||
private LocalDateTime licenceStartTime;
|
||||
private LocalDate licenceStartTime;
|
||||
|
||||
/**
|
||||
* 驾驶证有效期结束
|
||||
*/
|
||||
private LocalDateTime licenceEndTime;
|
||||
private LocalDate licenceEndTime;
|
||||
|
||||
/**
|
||||
* 忙碌中
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package com.njzscloud.dispose.cst.driver.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
|
|
@ -49,8 +47,6 @@ public class DriverServiceImpl extends ServiceImpl<DriverMapper, DriverEntity> i
|
|||
|
||||
@Override
|
||||
public PageResult<DriverEntity> paging(PageParam pageParam, DriverEntity driverEntity) {
|
||||
Page<DriverEntity> page = pageParam.toPage();
|
||||
page.addOrder(OrderItem.desc("cd.create_time"));
|
||||
return PageResult.of(baseMapper.paging(pageParam.toPage(), Wrappers.query(driverEntity)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,22 @@
|
|||
package com.njzscloud.dispose.cst.org.service;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njzscloud.common.core.ex.Exceptions;
|
||||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
import com.njzscloud.common.security.util.SecurityUtil;
|
||||
import com.njzscloud.dispose.cst.customer.constant.IdentityCategory;
|
||||
import com.njzscloud.dispose.cst.org.constant.ApplyStatus;
|
||||
import com.njzscloud.dispose.cst.org.mapper.OrgApplyMapper;
|
||||
import com.njzscloud.dispose.cst.org.pojo.entity.OrgApplyEntity;
|
||||
import com.njzscloud.dispose.cst.org.pojo.param.SearchOrgApplyParam;
|
||||
import com.njzscloud.dispose.cst.org.pojo.result.SearchOrgApplyResult;
|
||||
import com.njzscloud.dispose.sys.auth.pojo.result.IdentityInfo;
|
||||
import com.njzscloud.dispose.sys.auth.pojo.result.MyResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -67,7 +72,17 @@ public class OrgApplyService extends ServiceImpl<OrgApplyMapper, OrgApplyEntity>
|
|||
String customerName = searchOrgApplyParam.getCustomerName();
|
||||
String customerPhone = searchOrgApplyParam.getCustomerPhone();
|
||||
IdentityCategory identityCategory = searchOrgApplyParam.getIdentityCategory();
|
||||
MyResult myResult = SecurityUtil.loginUser();
|
||||
Long orgId = null;
|
||||
if (!SecurityUtil.isAdmin()) {
|
||||
IdentityInfo identityInfo = myResult.currentIdentity();
|
||||
Assert.notNull(identityInfo, () -> Exceptions.error("仅企业管理员可访问"));
|
||||
Assert.isTrue(identityInfo.getManager(), () -> Exceptions.error("仅企业管理员可访问"));
|
||||
orgId = identityInfo.getOrgId();
|
||||
}
|
||||
|
||||
return PageResult.of(baseMapper.paging(pageParam.toPage(), Wrappers.query()
|
||||
.ge(orgId != null, "a.org_id", orgId)
|
||||
.ge(applyStartTime != null, "a.apply_time", applyStartTime)
|
||||
.le(applyStartTime != null, "a.apply_time", applyEndTime)
|
||||
.eq(applyStatus != null, "a.apply_status", applyStatus)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
package com.njzscloud.dispose.cst.truck.pojo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njzscloud.common.core.ienum.DictItem;
|
||||
import com.njzscloud.common.core.ienum.DictKey;
|
||||
import com.njzscloud.common.mp.support.handler.j.DictItemTypeHandler;
|
||||
import com.njzscloud.common.mp.support.handler.j.JsonTypeHandler;
|
||||
import com.njzscloud.dispose.common.pojo.entity.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
|
@ -8,16 +13,18 @@ import lombok.ToString;
|
|||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆信息
|
||||
*
|
||||
* @author ljw
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
@TableName("cst_truck")
|
||||
@TableName(value = "cst_truck", autoResultMap = true)
|
||||
public class TruckEntity extends BaseEntity {
|
||||
|
||||
/**
|
||||
|
|
@ -38,7 +45,8 @@ public class TruckEntity extends BaseEntity {
|
|||
/**
|
||||
* 行驶证图片
|
||||
*/
|
||||
private String truckLicense;
|
||||
@TableField(typeHandler = JsonTypeHandler.class)
|
||||
private List<String> truckLicense;
|
||||
|
||||
/**
|
||||
* 车架号
|
||||
|
|
@ -48,7 +56,8 @@ public class TruckEntity extends BaseEntity {
|
|||
/**
|
||||
* 合格证图片
|
||||
*/
|
||||
private String qualification;
|
||||
@TableField(typeHandler = JsonTypeHandler.class)
|
||||
private List<String> qualification;
|
||||
|
||||
/**
|
||||
* 最大载重;单位:千克
|
||||
|
|
@ -83,7 +92,9 @@ public class TruckEntity extends BaseEntity {
|
|||
/**
|
||||
* 车辆类型
|
||||
*/
|
||||
private String truckCategory;
|
||||
@DictKey("truck_category")
|
||||
@TableField(typeHandler = DictItemTypeHandler.class)
|
||||
private DictItem truckCategory;
|
||||
|
||||
/**
|
||||
* 车辆图片
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.njzscloud.common.security.util.SecurityUtil;
|
|||
import com.njzscloud.dispose.cst.truck.mapper.TruckMapper;
|
||||
import com.njzscloud.dispose.cst.truck.pojo.entity.TruckEntity;
|
||||
import com.njzscloud.dispose.cst.truck.service.TruckService;
|
||||
import com.njzscloud.dispose.sys.auth.pojo.result.IdentityInfo;
|
||||
import com.njzscloud.dispose.sys.auth.pojo.result.MyResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -28,6 +29,14 @@ public class TruckServiceImpl extends ServiceImpl<TruckMapper, TruckEntity> impl
|
|||
|
||||
@Override
|
||||
public void add(TruckEntity truckEntity) {
|
||||
MyResult userDetail = SecurityUtil.loginUser();
|
||||
Long customerId = userDetail.getCurrentCustomerId();
|
||||
truckEntity.setCustomerId(customerId);
|
||||
IdentityInfo identityInfo = userDetail.currentIdentity();
|
||||
if (identityInfo.getManager()) {
|
||||
truckEntity.setOrgId(identityInfo.getOrgId());
|
||||
}
|
||||
truckEntity.setTareWeight(0);
|
||||
this.save(truckEntity);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.njzscloud.dispose.sys.dict.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.njzscloud.common.core.ienum.DictItem;
|
||||
import com.njzscloud.common.core.ienum.DictManager;
|
||||
import com.njzscloud.common.core.utils.R;
|
||||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
public class DictController {
|
||||
|
||||
private final DictService dictService;
|
||||
private final DictManager dictManager;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
|
|
@ -31,7 +32,7 @@ public class DictController {
|
|||
@PostMapping("/add")
|
||||
public R<?> add(@RequestBody DictEntity dictEntity) {
|
||||
dictService.add(dictEntity);
|
||||
DictItem.remove(dictEntity.getDictKey());
|
||||
dictManager.remove(dictEntity.getDictKey());
|
||||
return R.success();
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +42,7 @@ public class DictController {
|
|||
@PostMapping("/modify")
|
||||
public R<?> modify(@RequestBody DictEntity dictEntity) {
|
||||
dictService.modify(dictEntity);
|
||||
DictItem.remove(dictEntity.getDictKey());
|
||||
dictManager.remove(dictEntity.getDictKey());
|
||||
return R.success();
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +54,7 @@ public class DictController {
|
|||
List<String> keys = dictService.del(ids);
|
||||
if (CollUtil.isNotEmpty(keys)) {
|
||||
for (String key : keys) {
|
||||
DictItem.remove(key);
|
||||
dictManager.remove(key);
|
||||
}
|
||||
}
|
||||
return R.success();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.njzscloud.dispose.sys.dict.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.njzscloud.common.core.ienum.DictManager;
|
||||
import com.njzscloud.common.core.utils.R;
|
||||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
|
|
@ -21,6 +23,7 @@ import java.util.List;
|
|||
public class SysDictItemController {
|
||||
|
||||
private final DictItemService dictItemService;
|
||||
private final DictManager dictManager;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
|
|
@ -28,6 +31,7 @@ public class SysDictItemController {
|
|||
@PostMapping("/add")
|
||||
public R<?> add(@RequestBody DictItemEntity dictItemEntity) {
|
||||
dictItemService.add(dictItemEntity);
|
||||
dictManager.remove(dictItemEntity.getDictKey());
|
||||
return R.success();
|
||||
}
|
||||
|
||||
|
|
@ -37,6 +41,7 @@ public class SysDictItemController {
|
|||
@PostMapping("/modify")
|
||||
public R<?> modify(@RequestBody DictItemEntity dictItemEntity) {
|
||||
dictItemService.modify(dictItemEntity);
|
||||
dictManager.remove(dictItemEntity.getDictKey());
|
||||
return R.success();
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +50,12 @@ public class SysDictItemController {
|
|||
*/
|
||||
@PostMapping("/del")
|
||||
public R<?> del(@RequestBody List<Long> ids) {
|
||||
dictItemService.del(ids);
|
||||
List<String> keys = dictItemService.del(ids);
|
||||
if (CollUtil.isNotEmpty(keys)) {
|
||||
for (String key : keys) {
|
||||
dictManager.remove(key);
|
||||
}
|
||||
}
|
||||
return R.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,8 +81,11 @@ public class DictItemService extends ServiceImpl<DictItemMapper, DictItemEntity>
|
|||
* 删除
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void del(List<Long> ids) {
|
||||
public List<String> del(List<Long> ids) {
|
||||
List<DictItemEntity> dictItemEntities = listByIds(ids);
|
||||
List<String> list = dictItemEntities.stream().map(DictItemEntity::getDictKey).distinct().toList();
|
||||
this.removeBatchByIds(ids);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njzscloud.common.core.ex.Exceptions;
|
||||
import com.njzscloud.common.core.ienum.DictItem;
|
||||
import com.njzscloud.common.core.ienum.DictItemLoader;
|
||||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
import com.njzscloud.dispose.sys.dict.mapper.DictMapper;
|
||||
|
|
@ -29,7 +27,7 @@ import java.util.stream.Collectors;
|
|||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DictService extends ServiceImpl<DictMapper, DictEntity> implements DictItemLoader, IService<DictEntity> {
|
||||
public class DictService extends ServiceImpl<DictMapper, DictEntity> implements IService<DictEntity> {
|
||||
private final DictItemService dictItemService;
|
||||
|
||||
/**
|
||||
|
|
@ -94,17 +92,4 @@ public class DictService extends ServiceImpl<DictMapper, DictEntity> implements
|
|||
.stream().map(it -> BeanUtil.copyProperties(it, ObtainDictDataResult.class))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictItem> load(String key) {
|
||||
try {
|
||||
return dictItemService.list(Wrappers.<DictItemEntity>lambdaQuery().eq(DictItemEntity::getDictKey, key)
|
||||
.orderByAsc(DictItemEntity::getSort, DictItemEntity::getVal, DictItemEntity::getId)
|
||||
)
|
||||
.stream().map(it -> new DictItem().setKey(key).setVal(it.getVal()).setTxt(it.getTxt()))
|
||||
.collect(Collectors.toList());
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,21 +2,21 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njzscloud.dispose.cst.truck.mapper.TruckMapper">
|
||||
|
||||
<resultMap id="TruckResultMap" type="com.njzscloud.dispose.cst.truck.pojo.entity.TruckEntity">
|
||||
<resultMap id="TruckResultMap" autoMapping="true" type="com.njzscloud.dispose.cst.truck.pojo.entity.TruckEntity">
|
||||
<id column="id" property="id"/>
|
||||
<result column="customer_id" property="customerId"/>
|
||||
<result column="org_id" property="orgId"/>
|
||||
<result column="license_plate" property="licensePlate"/>
|
||||
<result column="truck_license" property="truckLicense"/>
|
||||
<result column="truck_license" property="truckLicense" typeHandler="com.njzscloud.common.mp.support.handler.j.JsonTypeHandler"/>
|
||||
<result column="vn_code" property="vnCode"/>
|
||||
<result column="qualification" property="qualification"/>
|
||||
<result column="qualification" property="qualification" typeHandler="com.njzscloud.common.mp.support.handler.j.JsonTypeHandler"/>
|
||||
<result column="carrying_capacity" property="carryingCapacity"/>
|
||||
<result column="tare_weight" property="tareWeight"/>
|
||||
<result column="license_start_date" property="licenseStartDate"/>
|
||||
<result column="license_end_date" property="licenseEndDate"/>
|
||||
<result column="qualification_start_date" property="qualificationStartDate"/>
|
||||
<result column="qualification_end_date" property="qualificationEndDate"/>
|
||||
<result column="truck_category" property="truckCategory"/>
|
||||
<result column="truck_category" property="truckCategory" typeHandler="com.njzscloud.common.mp.support.handler.j.DictItemTypeHandler"/>
|
||||
<result column="picture" property="picture"/>
|
||||
<result column="busy" property="busy"/>
|
||||
<result column="creator_id" property="creatorId"/>
|
||||
|
|
|
|||
|
|
@ -20386,6 +20386,52 @@
|
|||
"attr20": "",
|
||||
"origin": "PASTE"
|
||||
},
|
||||
{
|
||||
"id": "DF43F70D-82A3-4F25-94E5-46F13E6B94E6",
|
||||
"defKey": "goods_id",
|
||||
"defName": "产品 Id",
|
||||
"intro": "仅当项目类型为“产品”时有值",
|
||||
"baseDataType": "BIGINT",
|
||||
"bizDomainType": "",
|
||||
"dbDataType": "BIGINT",
|
||||
"dataLen": "",
|
||||
"numScale": "",
|
||||
"primaryKey": 0,
|
||||
"notNull": 0,
|
||||
"autoIncrement": 0,
|
||||
"defaultValue": "",
|
||||
"stndDictId": "",
|
||||
"stndFieldId": "",
|
||||
"stndDictKey": "",
|
||||
"stndFieldKey": "",
|
||||
"stndComplianceLevel": "",
|
||||
"stndComplianceType": "",
|
||||
"dictFrom": "",
|
||||
"dictItems": null,
|
||||
"fieldTier": "",
|
||||
"mark": null,
|
||||
"attr1": "",
|
||||
"attr2": "",
|
||||
"attr3": "",
|
||||
"attr4": "",
|
||||
"attr5": "",
|
||||
"attr6": "",
|
||||
"attr7": "",
|
||||
"attr8": "",
|
||||
"attr9": "",
|
||||
"attr10": "",
|
||||
"attr11": "",
|
||||
"attr12": "",
|
||||
"attr13": "",
|
||||
"attr14": "",
|
||||
"attr15": "",
|
||||
"attr16": "",
|
||||
"attr17": "",
|
||||
"attr18": "",
|
||||
"attr19": "",
|
||||
"attr20": "",
|
||||
"origin": "UI"
|
||||
},
|
||||
{
|
||||
"id": "489F7BA3-FC15-4C50-8EE6-F0A529DD2349",
|
||||
"defKey": "expense_item_category",
|
||||
|
|
@ -25388,7 +25434,7 @@
|
|||
"baseDataType": "VARCHAR",
|
||||
"bizDomainType": "",
|
||||
"dbDataType": "VARCHAR",
|
||||
"dataLen": 64,
|
||||
"dataLen": 255,
|
||||
"numScale": null,
|
||||
"primaryKey": 0,
|
||||
"notNull": 1,
|
||||
|
|
@ -30448,9 +30494,9 @@
|
|||
"defName": "驾驶证有效期",
|
||||
"intro": null,
|
||||
"orderValue": null,
|
||||
"baseDataType": "DATETIME",
|
||||
"baseDataType": "DATE",
|
||||
"bizDomainType": "",
|
||||
"dbDataType": "DATETIME",
|
||||
"dbDataType": "DATE",
|
||||
"dataLen": null,
|
||||
"numScale": null,
|
||||
"primaryKey": null,
|
||||
|
|
@ -30494,9 +30540,9 @@
|
|||
"defName": "驾驶证有效期",
|
||||
"intro": null,
|
||||
"orderValue": null,
|
||||
"baseDataType": "DATETIME",
|
||||
"baseDataType": "DATE",
|
||||
"bizDomainType": "",
|
||||
"dbDataType": "DATETIME",
|
||||
"dbDataType": "DATE",
|
||||
"dataLen": null,
|
||||
"numScale": null,
|
||||
"primaryKey": null,
|
||||
|
|
@ -43033,7 +43079,7 @@
|
|||
"readonly": false,
|
||||
"allowWs": false
|
||||
},
|
||||
"updateTime": 1765434816305,
|
||||
"signature": "f39d1018f0ed556230f3489a43a16da7",
|
||||
"updateTime": 1766024936008,
|
||||
"signature": "9ada1d6a19aaacec204aacf6405d4882",
|
||||
"branchId": "1111"
|
||||
}
|
||||
Loading…
Reference in New Issue