同步相关修改,新增mybatis plus ,,条码缺失,同步条码缺失
parent
b485a740dc
commit
39471eb342
@ -0,0 +1,117 @@
|
||||
package com.glxp.api.admin.controller.inout;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.glxp.api.admin.annotation.AuthRuleAnnotation;
|
||||
import com.glxp.api.admin.entity.inout.IoCodeLostEntity;
|
||||
import com.glxp.api.admin.entity.inout.WarehouseEntity;
|
||||
import com.glxp.api.admin.res.PageSimpleResponse;
|
||||
import com.glxp.api.admin.res.inout.IoCodeLostResponse;
|
||||
import com.glxp.api.admin.service.inout.IoCodeLostService;
|
||||
import com.glxp.api.common.enums.ResultEnum;
|
||||
import com.glxp.api.common.res.BaseResponse;
|
||||
import com.glxp.api.common.util.ResultVOUtils;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class IoCodeLostController {
|
||||
|
||||
|
||||
@Resource
|
||||
IoCodeLostService codeLostService;
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("warehouse/inout/getCodeLost")
|
||||
public BaseResponse getCodeLost(@RequestBody @Valid IoCodeLostEntity ioCodeLostEntity, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||
}
|
||||
List<IoCodeLostResponse> list = codeLostService.selectLost(ioCodeLostEntity);
|
||||
PageInfo<IoCodeLostResponse> pageInfo;
|
||||
pageInfo = new PageInfo<>(list);
|
||||
PageSimpleResponse<IoCodeLostResponse> pageSimpleResponse = new PageSimpleResponse<>();
|
||||
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
||||
pageSimpleResponse.setList(list);
|
||||
return ResultVOUtils.success(pageSimpleResponse);
|
||||
}
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("warehouse/inout/updateCodeLost")
|
||||
public BaseResponse updateCodeLost(@RequestBody @Valid IoCodeLostEntity ioCodeLostEntity, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||
}
|
||||
|
||||
|
||||
codeLostService.update(ioCodeLostEntity);
|
||||
|
||||
return ResultVOUtils.success("成功");
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("warehouse/inout/saveTabCode")
|
||||
public BaseResponse saveCode(@RequestBody WarehouseEntity codeTempEntity) {
|
||||
|
||||
if (StrUtil.isNotEmpty(codeTempEntity.getSerialNo()) && codeTempEntity.getSerialNo().length() > 20) {
|
||||
return ResultVOUtils.error(500, "无效条码!序列号超出最大范围,不予缓存");
|
||||
}
|
||||
|
||||
if (StrUtil.isNotEmpty(codeTempEntity.getBatchNo()) && codeTempEntity.getBatchNo().length() > 20) {
|
||||
return ResultVOUtils.error(500, "无效条码!批次号超出最大范围,不予缓存");
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(codeTempEntity.getSerialNo()) && StrUtil.isBlank(codeTempEntity.getBatchNo())) {
|
||||
return ResultVOUtils.error(500, "批次号不能为空!,不予缓存");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(codeTempEntity.getSerialNo())) {
|
||||
return ResultVOUtils.error(500, "有序列号不予缓存");
|
||||
}
|
||||
|
||||
IoCodeLostEntity codeLostEntity = codeLostService.findByCode(codeTempEntity.getCode());
|
||||
IoCodeLostEntity insertEntity = null;
|
||||
if (codeLostEntity == null) {
|
||||
insertEntity = new IoCodeLostEntity();
|
||||
insertEntity.setCreateTime(new Date());
|
||||
} else {
|
||||
insertEntity = codeLostEntity;
|
||||
}
|
||||
insertEntity.setCode(codeTempEntity.getCode());
|
||||
insertEntity.setBatchNo(codeTempEntity.getBatchNo());
|
||||
insertEntity.setProduceDate(codeTempEntity.getProduceDate());
|
||||
insertEntity.setExpireDate(codeTempEntity.getExpireDate());
|
||||
insertEntity.setSerialNo(codeTempEntity.getSerialNo());
|
||||
insertEntity.setSupId(codeTempEntity.getSupId());
|
||||
insertEntity.setUpdateTime(new Date());
|
||||
|
||||
if (codeLostEntity != null) {
|
||||
codeLostService.update(insertEntity);
|
||||
} else {
|
||||
codeLostService.insert(insertEntity);
|
||||
}
|
||||
return ResultVOUtils.success("修改成功!");
|
||||
}
|
||||
|
||||
|
||||
//获取验收单据业务详情
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("/warehouse/inout/getTabCode")
|
||||
public BaseResponse getTabCode(String code) {
|
||||
if (StrUtil.isBlank(code)) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||
}
|
||||
IoCodeLostEntity codeLostEntity = codeLostService.findByCode(code);
|
||||
if (codeLostEntity == null)
|
||||
return ResultVOUtils.error(500, "未缓存!");
|
||||
return ResultVOUtils.success(codeLostEntity);
|
||||
|
||||
}
|
||||
}
|
@ -1,14 +1,13 @@
|
||||
package com.glxp.api.admin.controller.info;
|
||||
package com.glxp.api.admin.controller.sync;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.glxp.api.admin.annotation.AuthRuleAnnotation;
|
||||
import com.glxp.api.admin.constant.Constant;
|
||||
import com.glxp.api.admin.entity.info.SyncDataBustypeEntity;
|
||||
import com.glxp.api.admin.entity.info.SyncDataSetEntity;
|
||||
import com.glxp.api.admin.entity.sync.SyncDataBustypeEntity;
|
||||
import com.glxp.api.admin.entity.sync.SyncDataSetEntity;
|
||||
import com.glxp.api.admin.res.info.SyncDataSetResponse;
|
||||
import com.glxp.api.admin.service.info.SyncDataBustypeService;
|
||||
import com.glxp.api.admin.service.info.SyncDataSetService;
|
||||
import com.glxp.api.admin.service.sync.SyncDataBustypeService;
|
||||
import com.glxp.api.admin.service.sync.SyncDataSetService;
|
||||
import com.glxp.api.admin.util.RedisUtil;
|
||||
import com.glxp.api.common.enums.ResultEnum;
|
||||
import com.glxp.api.common.res.BaseResponse;
|
@ -0,0 +1,17 @@
|
||||
package com.glxp.api.admin.dao.inout;
|
||||
|
||||
import com.glxp.api.admin.dao.BaseMapperPlus;
|
||||
import com.glxp.api.admin.entity.inout.IoCodeLostEntity;
|
||||
import com.glxp.api.admin.res.inout.IoCodeLostResponse;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface IoCodeLostMapper extends BaseMapperPlus<IoCodeLostMapper, IoCodeLostEntity, IoCodeLostEntity> {
|
||||
List<IoCodeLostResponse> selectLost(IoCodeLostEntity ioCodeLostEntity);
|
||||
|
||||
List<IoCodeLostEntity> filterList(IoCodeLostEntity ioCodeLostEntity);
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.glxp.api.admin.dao.info;
|
||||
package com.glxp.api.admin.dao.sync;
|
||||
|
||||
import com.glxp.api.admin.entity.info.SyncDataBustypeEntity;
|
||||
import com.glxp.api.admin.entity.sync.SyncDataBustypeEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.glxp.api.admin.dao.info;
|
||||
package com.glxp.api.admin.dao.sync;
|
||||
|
||||
import com.glxp.api.admin.entity.info.SyncDataSetEntity;
|
||||
import com.glxp.api.admin.entity.sync.SyncDataSetEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
@ -0,0 +1,112 @@
|
||||
package com.glxp.api.admin.entity.inout;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 扫码缺失字段信息补齐表
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "io_code_lost")
|
||||
public class IoCodeLostEntity {
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* UDI码
|
||||
*/
|
||||
@TableField(value = "code")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
@TableField(value = "batchNo")
|
||||
private String batchNo;
|
||||
|
||||
/**
|
||||
* 生产日期
|
||||
*/
|
||||
@TableField(value = "produceDate")
|
||||
private String produceDate;
|
||||
|
||||
/**
|
||||
* 失效日期
|
||||
*/
|
||||
@TableField(value = "expireDate")
|
||||
private String expireDate;
|
||||
|
||||
/**
|
||||
* 序列号
|
||||
*/
|
||||
@TableField(value = "serialNo")
|
||||
private String serialNo;
|
||||
|
||||
/**
|
||||
* 供应商
|
||||
*/
|
||||
@TableField(value = "supId")
|
||||
private String supId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "createTime")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "updateTime")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField(value = "remark")
|
||||
private String remark;
|
||||
|
||||
|
||||
@TableField(value = "nameCode")
|
||||
private String nameCode;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String cpmctymc;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String ggxh;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String startTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String endTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String lastUpdateTime;
|
||||
|
||||
public static final String COL_ID = "id";
|
||||
|
||||
public static final String COL_CODE = "code";
|
||||
|
||||
public static final String COL_BATCHNO = "batchNo";
|
||||
|
||||
public static final String COL_PRODUCEDATE = "produceDate";
|
||||
|
||||
public static final String COL_EXPIREDATE = "expireDate";
|
||||
|
||||
public static final String COL_SERIALNO = "serialNo";
|
||||
|
||||
public static final String COL_SUPID = "supId";
|
||||
|
||||
public static final String COL_CREATETIME = "createTime";
|
||||
|
||||
public static final String COL_UPDATETIME = "updateTime";
|
||||
|
||||
public static final String COL_REMARK = "remark";
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.glxp.api.admin.entity.info;
|
||||
package com.glxp.api.admin.entity.sync;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.glxp.api.admin.entity.info;
|
||||
package com.glxp.api.admin.entity.sync;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -0,0 +1,69 @@
|
||||
package com.glxp.api.admin.res.inout;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author : zhangsan
|
||||
* @date : 2023/3/22 11:08
|
||||
* @modyified By :
|
||||
*/
|
||||
@Data
|
||||
public class IoCodeLostResponse {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String code;
|
||||
|
||||
|
||||
private String batchNo;
|
||||
|
||||
|
||||
private String produceDate;
|
||||
|
||||
|
||||
private String expireDate;
|
||||
|
||||
|
||||
private String serialNo;
|
||||
|
||||
|
||||
private String supId;
|
||||
|
||||
|
||||
private Date createTime;
|
||||
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
private String remark;
|
||||
|
||||
//产品名称
|
||||
private String cpmctymc;
|
||||
//规格型号
|
||||
private String ggxh;
|
||||
|
||||
public static final String COL_ID = "id";
|
||||
|
||||
public static final String COL_CODE = "code";
|
||||
|
||||
public static final String COL_BATCHNO = "batchNo";
|
||||
|
||||
public static final String COL_PRODUCEDATE = "produceDate";
|
||||
|
||||
public static final String COL_EXPIREDATE = "expireDate";
|
||||
|
||||
public static final String COL_SERIALNO = "serialNo";
|
||||
|
||||
public static final String COL_SUPID = "supId";
|
||||
|
||||
public static final String COL_CREATETIME = "createTime";
|
||||
|
||||
public static final String COL_UPDATETIME = "updateTime";
|
||||
|
||||
public static final String COL_REMARK = "remark";
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.glxp.api.admin.service.inout;
|
||||
|
||||
|
||||
import com.glxp.api.admin.entity.inout.IoCodeLostEntity;
|
||||
import com.glxp.api.admin.res.inout.IoCodeLostResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IoCodeLostService {
|
||||
|
||||
List<IoCodeLostResponse> selectLost(IoCodeLostEntity ioCodeLostEntity);
|
||||
|
||||
List<IoCodeLostEntity> filterList(IoCodeLostEntity ioCodeLostEntity);
|
||||
|
||||
IoCodeLostEntity findByCode(String code);
|
||||
|
||||
int insert(IoCodeLostEntity ioCodeLostEntity);
|
||||
|
||||
boolean insertOrUpdate(IoCodeLostEntity ioCodeLostEntity);
|
||||
|
||||
int deleteByCode(String code);
|
||||
|
||||
int update(IoCodeLostEntity ioCodeLostEntity);
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.glxp.api.admin.service.inout.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.glxp.api.admin.dao.inout.IoCodeLostMapper;
|
||||
import com.glxp.api.admin.entity.inout.IoCodeLostEntity;
|
||||
import com.glxp.api.admin.res.inout.IoCodeLostResponse;
|
||||
import com.glxp.api.admin.service.inout.IoCodeLostService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class IoCodeLostServiceImpl implements IoCodeLostService {
|
||||
|
||||
@Resource
|
||||
IoCodeLostMapper codeLostEntityMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<IoCodeLostResponse> selectLost(IoCodeLostEntity ioCodeLostEntity) {
|
||||
return codeLostEntityMapper.selectLost(ioCodeLostEntity);
|
||||
}
|
||||
@Override
|
||||
public List<IoCodeLostEntity> filterList(IoCodeLostEntity ioCodeLostEntity) {
|
||||
return codeLostEntityMapper.filterList(ioCodeLostEntity);
|
||||
}
|
||||
@Override
|
||||
public IoCodeLostEntity findByCode(String code) {
|
||||
|
||||
return codeLostEntityMapper.selectOne(new QueryWrapper<IoCodeLostEntity>().eq("code", code));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(IoCodeLostEntity ioCodeLostEntity) {
|
||||
|
||||
return codeLostEntityMapper.insert(ioCodeLostEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insertOrUpdate(IoCodeLostEntity ioCodeLostEntity) {
|
||||
return codeLostEntityMapper.insertOrUpdate(ioCodeLostEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByCode(String code) {
|
||||
return codeLostEntityMapper.delete(new QueryWrapper<IoCodeLostEntity>().eq("code", code));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(IoCodeLostEntity ioCodeLostEntity) {
|
||||
return codeLostEntityMapper.updateById(ioCodeLostEntity);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.glxp.api.admin.service.info;
|
||||
package com.glxp.api.admin.service.sync;
|
||||
|
||||
import com.glxp.api.admin.entity.info.SyncDataBustypeEntity;
|
||||
import com.glxp.api.admin.entity.sync.SyncDataBustypeEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.glxp.api.admin.service.info;
|
||||
package com.glxp.api.admin.service.sync;
|
||||
|
||||
|
||||
import com.glxp.api.admin.entity.info.SyncDataSetEntity;
|
||||
import com.glxp.api.admin.entity.sync.SyncDataSetEntity;
|
||||
import com.glxp.api.admin.res.info.SyncDataSetResponse;
|
||||
|
||||
public interface SyncDataSetService {
|
@ -1,8 +1,8 @@
|
||||
package com.glxp.api.admin.service.info.impl;
|
||||
package com.glxp.api.admin.service.sync.impl;
|
||||
|
||||
import com.glxp.api.admin.dao.info.SyncDataBustypeDao;
|
||||
import com.glxp.api.admin.entity.info.SyncDataBustypeEntity;
|
||||
import com.glxp.api.admin.service.info.SyncDataBustypeService;
|
||||
import com.glxp.api.admin.dao.sync.SyncDataBustypeDao;
|
||||
import com.glxp.api.admin.entity.sync.SyncDataBustypeEntity;
|
||||
import com.glxp.api.admin.service.sync.SyncDataBustypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
@ -1,12 +1,11 @@
|
||||
package com.glxp.api.admin.service.info.impl;
|
||||
package com.glxp.api.admin.service.sync.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.glxp.api.admin.dao.info.SyncDataSetDao;
|
||||
import com.glxp.api.admin.entity.info.SyncDataBustypeEntity;
|
||||
import com.glxp.api.admin.entity.info.SyncDataSetEntity;
|
||||
import com.glxp.api.admin.dao.sync.SyncDataSetDao;
|
||||
import com.glxp.api.admin.entity.sync.SyncDataBustypeEntity;
|
||||
import com.glxp.api.admin.entity.sync.SyncDataSetEntity;
|
||||
import com.glxp.api.admin.res.info.SyncDataSetResponse;
|
||||
import com.glxp.api.admin.service.info.SyncDataBustypeService;
|
||||
import com.glxp.api.admin.service.info.SyncDataSetService;
|
||||
import com.glxp.api.admin.service.sync.SyncDataBustypeService;
|
||||
import com.glxp.api.admin.service.sync.SyncDataSetService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -0,0 +1,184 @@
|
||||
package com.glxp.api.admin.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.SimpleCache;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.cglib.beans.BeanCopier;
|
||||
import org.springframework.cglib.beans.BeanMap;
|
||||
import org.springframework.cglib.core.Converter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* bean深拷贝工具(基于 cglib 性能优异)
|
||||
* <p>
|
||||
* 重点 cglib 不支持 拷贝到链式对象
|
||||
* 例如: 源对象 拷贝到 目标(链式对象)
|
||||
* 请区分好`浅拷贝`和`深拷贝`再做使用
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class BeanCopyUtils {
|
||||
|
||||
/**
|
||||
* 单对象基于class创建拷贝
|
||||
*
|
||||
* @param source 数据来源实体
|
||||
* @param desc 描述对象 转换后的对象
|
||||
* @return desc
|
||||
*/
|
||||
public static <T, V> V copy(T source, Class<V> desc) {
|
||||
if (ObjectUtil.isNull(source)) {
|
||||
return null;
|
||||
}
|
||||
if (ObjectUtil.isNull(desc)) {
|
||||
return null;
|
||||
}
|
||||
final V target = ReflectUtil.newInstanceIfPossible(desc);
|
||||
return copy(source, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单对象基于对象创建拷贝
|
||||
*
|
||||
* @param source 数据来源实体
|
||||
* @param desc 转换后的对象
|
||||
* @return desc
|
||||
*/
|
||||
public static <T, V> V copy(T source, V desc) {
|
||||
if (ObjectUtil.isNull(source)) {
|
||||
return null;
|
||||
}
|
||||
if (ObjectUtil.isNull(desc)) {
|
||||
return null;
|
||||
}
|
||||
BeanCopier beanCopier = BeanCopierCache.INSTANCE.get(source.getClass(), desc.getClass(), null);
|
||||
beanCopier.copy(source, desc, null);
|
||||
return desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表对象基于class创建拷贝
|
||||
*
|
||||
* @param sourceList 数据来源实体列表
|
||||
* @param desc 描述对象 转换后的对象
|
||||
* @return desc
|
||||
*/
|
||||
public static <T, V> List<V> copyList(List<T> sourceList, Class<V> desc) {
|
||||
if (ObjectUtil.isNull(sourceList)) {
|
||||
return null;
|
||||
}
|
||||
if (CollUtil.isEmpty(sourceList)) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
return StreamUtils.toList(sourceList, source -> {
|
||||
V target = ReflectUtil.newInstanceIfPossible(desc);
|
||||
copy(source, target);
|
||||
return target;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* bean拷贝到map
|
||||
*
|
||||
* @param bean 数据来源实体
|
||||
* @return map对象
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Map<String, Object> copyToMap(T bean) {
|
||||
if (ObjectUtil.isNull(bean)) {
|
||||
return null;
|
||||
}
|
||||
return BeanMap.create(bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* map拷贝到bean
|
||||
*
|
||||
* @param map 数据来源
|
||||
* @param beanClass bean类
|
||||
* @return bean对象
|
||||
*/
|
||||
public static <T> T mapToBean(Map<String, Object> map, Class<T> beanClass) {
|
||||
if (MapUtil.isEmpty(map)) {
|
||||
return null;
|
||||
}
|
||||
if (ObjectUtil.isNull(beanClass)) {
|
||||
return null;
|
||||
}
|
||||
T bean = ReflectUtil.newInstanceIfPossible(beanClass);
|
||||
return mapToBean(map, bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* map拷贝到bean
|
||||
*
|
||||
* @param map 数据来源
|
||||
* @param bean bean对象
|
||||
* @return bean对象
|
||||
*/
|
||||
public static <T> T mapToBean(Map<String, Object> map, T bean) {
|
||||
if (MapUtil.isEmpty(map)) {
|
||||
return null;
|
||||
}
|
||||
if (ObjectUtil.isNull(bean)) {
|
||||
return null;
|
||||
}
|
||||
BeanMap.create(bean).putAll(map);
|
||||
return bean;
|
||||
}
|
||||
|
||||
/**
|
||||
* BeanCopier属性缓存<br>
|
||||
* 缓存用于防止多次反射造成的性能问题
|
||||
*
|
||||
* @author Looly
|
||||
* @since 5.4.1
|
||||
*/
|
||||
public enum BeanCopierCache {
|
||||
/**
|
||||
* BeanCopier属性缓存单例
|
||||
*/
|
||||
INSTANCE;
|
||||
|
||||
private final SimpleCache<String, BeanCopier> cache = new SimpleCache<>();
|
||||
|
||||
/**
|
||||
* 获得类与转换器生成的key在{@link BeanCopier}的Map中对应的元素
|
||||
*
|
||||
* @param srcClass 源Bean的类
|
||||
* @param targetClass 目标Bean的类
|
||||
* @param converter 转换器
|
||||
* @return Map中对应的BeanCopier
|
||||
*/
|
||||
public BeanCopier get(Class<?> srcClass, Class<?> targetClass, Converter converter) {
|
||||
final String key = genKey(srcClass, targetClass, converter);
|
||||
return cache.get(key, () -> BeanCopier.create(srcClass, targetClass, converter != null));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得类与转换器生成的key
|
||||
*
|
||||
* @param srcClass 源Bean的类
|
||||
* @param targetClass 目标Bean的类
|
||||
* @param converter 转换器
|
||||
* @return 属性名和Map映射的key
|
||||
*/
|
||||
private String genKey(Class<?> srcClass, Class<?> targetClass, Converter converter) {
|
||||
final StringBuilder key = StrUtil.builder()
|
||||
.append(srcClass.getName()).append('#').append(targetClass.getName());
|
||||
if(null != converter){
|
||||
key.append('#').append(converter.getClass().getName());
|
||||
}
|
||||
return key.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?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.glxp.api.admin.dao.inout.IoCodeLostMapper">
|
||||
<select id="selectLost" parameterType="com.glxp.api.admin.entity.inout.IoCodeLostEntity"
|
||||
resultType="com.glxp.api.admin.res.inout.IoCodeLostResponse">
|
||||
select io_code_lost.*, basic_products.cpmctymc, basic_products.ggxh
|
||||
from io_code_lost
|
||||
LEFT JOIN basic_products on io_code_lost.nameCode = basic_products.nameCode
|
||||
<where>
|
||||
<if test="code != '' and code != null">
|
||||
and code like concat('%', #{code}, '%')
|
||||
</if>
|
||||
<if test="cpmctymc != '' and cpmctymc != null">
|
||||
and basic_products.cpmctymc like concat('%', #{cpmctymc}, '%')
|
||||
</if>
|
||||
<if test="ggxh != '' and ggxh != null">
|
||||
and basic_products.ggxh like concat('%', #{ggxh}, '%')
|
||||
</if>
|
||||
|
||||
<if test="batchNo != '' and batchNo != null">
|
||||
and batchNo like concat('%', #{batchNo}, '%')
|
||||
</if>
|
||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||
AND date_format(io_code_lost.createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and date_format(#{endTime}, '%Y-%m-%d')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="filterList" parameterType="com.glxp.api.admin.entity.inout.IoCodeLostEntity"
|
||||
resultType="com.glxp.api.admin.entity.inout.IoCodeLostEntity">
|
||||
select io_code_lost.*
|
||||
from io_code_lost
|
||||
<where>
|
||||
<if test="lastUpdateTime != null and lastUpdateTime != ''">
|
||||
<![CDATA[
|
||||
and DATE_FORMAT(updateTime
|
||||
, '%Y-%m-%d %H:%i:%S') >= DATE_FORMAT(#{lastUpdateTime}
|
||||
, '%Y-%m-%d %H:%i:%S')
|
||||
]]>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue