master
parent
234d780e92
commit
0a782e2d45
|
|
@ -78,5 +78,7 @@ public interface Dict<T> extends IEnum {
|
|||
*/
|
||||
String getTxt();
|
||||
|
||||
|
||||
default boolean equals(String val) {
|
||||
return this.getVal().equals(val);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,5 +11,7 @@ import static java.lang.annotation.ElementType.PARAMETER;
|
|||
@Target({FIELD, PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface DictKey {
|
||||
String value();
|
||||
String value() default "";
|
||||
|
||||
Class<?> ienum() default DictNone.class;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.njzscloud.common.core.ienum;
|
||||
|
||||
public enum DictNone implements Dict<Object> {
|
||||
NOME;
|
||||
|
||||
|
||||
@Override
|
||||
public Object getVal() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTxt() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.njzscloud.common.core.jackson.serializer;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonStreamContext;
|
||||
import com.fasterxml.jackson.databind.BeanProperty;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
|
||||
import com.njzscloud.common.core.ienum.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
@Slf4j
|
||||
public class DictItemSerializer extends JsonSerializer<String> implements ContextualSerializer {
|
||||
|
||||
private String key;
|
||||
private Class<?> ienum;
|
||||
|
||||
@Override
|
||||
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
if (StrUtil.isBlank(value)) {
|
||||
gen.writeNull();
|
||||
} else {
|
||||
JsonStreamContext ctx = gen.getOutputContext();
|
||||
gen.writeObject(value);
|
||||
String currentName = ctx.getCurrentName();
|
||||
Dict<?> dictItem;
|
||||
if (StrUtil.isBlank(key)) {
|
||||
Object[] enumConstants = ienum.getEnumConstants();
|
||||
Optional<Object> first = Arrays.stream(enumConstants).filter(it -> ((Dict<?>) it).getVal().equals(value)).findFirst();
|
||||
dictItem = (Dict<?>) first.orElse(DictNone.NOME);
|
||||
} else {
|
||||
dictItem = SpringUtil.getBean(DictManager.class).get(key, value);
|
||||
}
|
||||
gen.writeStringField(currentName + "Txt", dictItem.getTxt());
|
||||
gen.writeStringField(currentName + "Key", dictItem.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException {
|
||||
DictKey dictKey = property.getAnnotation(DictKey.class);
|
||||
if (dictKey == null) {
|
||||
return prov.findValueSerializer(String.class, property);
|
||||
}
|
||||
String value = dictKey.value();
|
||||
Class<?> ienum = dictKey.ienum();
|
||||
if (StrUtil.isBlank(value) && (ienum == DictNone.class || Arrays.stream(ienum.getInterfaces()).anyMatch(it -> it != DictStr.class && it != DictInt.class))) {
|
||||
return prov.findValueSerializer(String.class, property);
|
||||
}
|
||||
DictItemSerializer dictItemSerializer = new DictItemSerializer();
|
||||
dictItemSerializer.key = value;
|
||||
dictItemSerializer.ienum = ienum;
|
||||
return dictItemSerializer;
|
||||
}
|
||||
}
|
||||
|
|
@ -23,4 +23,6 @@ public enum SettlementWay implements DictStr {
|
|||
private final String val;
|
||||
|
||||
private final String txt;
|
||||
|
||||
private final String key = "settlement_way";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.njzscloud.common.mp.support.PageResult;
|
|||
import com.njzscloud.dispose.finance.pojo.entity.ExpenseItemEntity;
|
||||
import com.njzscloud.dispose.finance.pojo.param.AddExpenseItemParam;
|
||||
import com.njzscloud.dispose.finance.pojo.param.ModifyExpenseItemParam;
|
||||
import com.njzscloud.dispose.finance.pojo.result.SearchExpenseItemResult;
|
||||
import com.njzscloud.dispose.finance.service.ExpenseItemService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -15,6 +16,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 收费项目
|
||||
*
|
||||
* @author ljw
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
@ -64,7 +66,7 @@ public class ExpenseItemController {
|
|||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/paging")
|
||||
public R<PageResult<ExpenseItemEntity>> paging(PageParam pageParam, ExpenseItemEntity expenseItemEntity) {
|
||||
public R<PageResult<SearchExpenseItemResult>> paging(PageParam pageParam, ExpenseItemEntity expenseItemEntity) {
|
||||
return R.success(expenseItemService.paging(pageParam, expenseItemEntity));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
package com.njzscloud.dispose.finance.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njzscloud.dispose.finance.pojo.entity.ExpenseItemEntity;
|
||||
import com.njzscloud.dispose.finance.pojo.result.SearchExpenseItemResult;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 收费项目
|
||||
|
|
@ -10,5 +15,6 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
*/
|
||||
@Mapper
|
||||
public interface ExpenseItemMapper extends BaseMapper<ExpenseItemEntity> {
|
||||
IPage<SearchExpenseItemResult> paging(Page<Object> page, @Param("ew") QueryWrapper<Object> ew);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ public class SearchExpenseItemResult {
|
|||
private String memo;
|
||||
|
||||
private Long goodsId;
|
||||
private String goodsName;
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.njzscloud.dispose.finance.mapper.ExpenseItemMapper;
|
|||
import com.njzscloud.dispose.finance.pojo.entity.ExpenseItemEntity;
|
||||
import com.njzscloud.dispose.finance.pojo.param.AddExpenseItemParam;
|
||||
import com.njzscloud.dispose.finance.pojo.param.ModifyExpenseItemParam;
|
||||
import com.njzscloud.dispose.finance.pojo.result.SearchExpenseItemResult;
|
||||
import com.njzscloud.dispose.sys.auth.pojo.result.IdentityInfo;
|
||||
import com.njzscloud.dispose.sys.auth.pojo.result.MyResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
|
@ -67,7 +68,7 @@ public class ExpenseItemService extends ServiceImpl<ExpenseItemMapper, ExpenseIt
|
|||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageResult<ExpenseItemEntity> paging(PageParam pageParam, ExpenseItemEntity expenseItemEntity) {
|
||||
public PageResult<SearchExpenseItemResult> paging(PageParam pageParam, ExpenseItemEntity expenseItemEntity) {
|
||||
String expenseItemName = expenseItemEntity.getExpenseItemName();
|
||||
MyResult userDetail = SecurityUtil.loginUser();
|
||||
List<IdentityInfo> identities = userDetail.getIdentities();
|
||||
|
|
@ -75,9 +76,9 @@ public class ExpenseItemService extends ServiceImpl<ExpenseItemMapper, ExpenseIt
|
|||
if (CollUtil.isNotEmpty(identities)) {
|
||||
orgIds = identities.stream().map(IdentityInfo::getOrgId).toList();
|
||||
}
|
||||
return PageResult.of(this.page(pageParam.toPage(), Wrappers.<ExpenseItemEntity>lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(expenseItemName), ExpenseItemEntity::getExpenseItemName, expenseItemName)
|
||||
.in(CollUtil.isNotEmpty(orgIds), ExpenseItemEntity::getOrgId, orgIds)
|
||||
return PageResult.of(baseMapper.paging(pageParam.toPage(), Wrappers.query()
|
||||
.like(StrUtil.isNotBlank(expenseItemName), "a.expense_item_name", expenseItemName)
|
||||
.in(CollUtil.isNotEmpty(orgIds), "a.org_id", orgIds)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,4 +67,9 @@ public class WarehouseController {
|
|||
public R<PageResult<WarehouseResult>> paging(PageParam pageParam, WarehouseEntity warehouseEntity) {
|
||||
return R.success(warehouseService.paging(pageParam, warehouseEntity));
|
||||
}
|
||||
|
||||
@GetMapping("/a")
|
||||
public R<?> a() {
|
||||
return R.success(new WarehouseEntity());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package com.njzscloud.dispose.wh.pojo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.njzscloud.common.core.ienum.DictItem;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.njzscloud.common.core.ienum.DictKey;
|
||||
import com.njzscloud.common.mp.support.handler.j.DictItemTypeHandler;
|
||||
import com.njzscloud.common.core.jackson.serializer.DictItemSerializer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
|
@ -37,8 +37,8 @@ public class WarehouseEntity {
|
|||
* 仓库类型;raw_material-原料库,finished_product-成品库
|
||||
*/
|
||||
@DictKey("warehouse_type")
|
||||
@TableField(typeHandler = DictItemTypeHandler.class)
|
||||
private DictItem type;
|
||||
@JsonSerialize(using = DictItemSerializer.class)
|
||||
private String type = "raw_material";
|
||||
|
||||
/**
|
||||
* 所属站点 Id
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
package com.njzscloud.dispose.wh.pojo.result;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.njzscloud.common.core.ienum.DictItem;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.njzscloud.common.core.ienum.DictKey;
|
||||
import com.njzscloud.common.mp.support.handler.j.DictItemTypeHandler;
|
||||
import com.njzscloud.common.core.jackson.serializer.DictItemSerializer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
|
@ -14,6 +13,7 @@ import java.time.LocalDateTime;
|
|||
|
||||
/**
|
||||
* 仓库信息-结果类
|
||||
*
|
||||
* @author ljw
|
||||
*/
|
||||
@Getter
|
||||
|
|
@ -36,8 +36,8 @@ public class WarehouseResult {
|
|||
* 仓库类型;raw_material-原料库,finished_product-成品库
|
||||
*/
|
||||
@DictKey("warehouse_type")
|
||||
@TableField(typeHandler = DictItemTypeHandler.class)
|
||||
private DictItem type;
|
||||
@JsonSerialize(using = DictItemSerializer.class)
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 所属站点 Id
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njzscloud.common.core.ienum.DictItem;
|
||||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
import com.njzscloud.dispose.wh.mapper.WarehouseMapper;
|
||||
|
|
@ -67,12 +66,12 @@ public class WarehouseService extends ServiceImpl<WarehouseMapper, WarehouseEnti
|
|||
public PageResult<WarehouseResult> paging(PageParam pageParam, WarehouseEntity warehouseEntity) {
|
||||
String warehouseName = warehouseEntity.getWarehouseName();
|
||||
Long stationId = warehouseEntity.getStationId();
|
||||
DictItem type = warehouseEntity.getType();
|
||||
String type = warehouseEntity.getType();
|
||||
QueryWrapper<?> ew = Wrappers.query()
|
||||
.eq("ww.deleted", 0)
|
||||
.like(StrUtil.isNotBlank(warehouseName), "ww.warehouse_name", warehouseName)
|
||||
.eq(stationId != null, "ww.station_id", stationId)
|
||||
.eq(type != null, "ww.type", type);
|
||||
.eq(StrUtil.isNotBlank(type), "ww.type", type);
|
||||
|
||||
IPage<WarehouseResult> page = baseMapper.paging(pageParam.toPage(), ew);
|
||||
return PageResult.of(page);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njzscloud.dispose.finance.mapper.ExpenseItemMapper">
|
||||
|
||||
<select id="paging" resultType="com.njzscloud.dispose.finance.pojo.result.SearchExpenseItemResult">
|
||||
SELECT
|
||||
a.id,
|
||||
a.user_id,
|
||||
a.customer_id,
|
||||
a.org_id,
|
||||
a.station_id,
|
||||
a.goods_id,
|
||||
a.expense_item_category,
|
||||
a.expense_item_name,
|
||||
a.expense_strategy,
|
||||
a.unit,
|
||||
a.tax_rate,
|
||||
a.unit_price,
|
||||
a.initial_price,
|
||||
a.initial_quantity,
|
||||
a.every_quantity,
|
||||
a.canuse,
|
||||
a.memo,
|
||||
a.creator_id,
|
||||
a.modifier_id,
|
||||
a.create_time,
|
||||
a.modify_time,
|
||||
a.deleted,
|
||||
b.goods_name
|
||||
FROM fin_expense_item a
|
||||
LEFT JOIN gds_goods b ON b.id = a.goods_id
|
||||
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue