feat: 药品关联关系功能

v3
chenhc 6 months ago
parent fcc90167ad
commit c5fed5f2aa

@ -0,0 +1,15 @@
package com.glxp.udidl.admin.dao.collect;
import com.glxp.udidl.admin.dao.BaseMapperPlus;
import com.glxp.udidl.admin.entity.collect.RelCodeBatch;
import com.glxp.udidl.admin.req.collect.RelCodeBatchRequest;
import com.glxp.udidl.admin.res.collect.RelCodeBatchResponse;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface RelCodeBatchMapper extends BaseMapperPlus<RelCodeBatchMapper, RelCodeBatch,RelCodeBatch> {
List<RelCodeBatchResponse> filterList(RelCodeBatchRequest relCodeBatchRequest);
}

@ -0,0 +1,15 @@
package com.glxp.udidl.admin.dao.collect;
import com.glxp.udidl.admin.dao.BaseMapperPlus;
import com.glxp.udidl.admin.entity.collect.RelCodeDetail;
import com.glxp.udidl.admin.req.collect.RelCodeDetailRequest;
import com.glxp.udidl.admin.res.collect.RelCodeDetailResponse;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface RelCodeDetailMapper extends BaseMapperPlus<RelCodeDetailMapper,RelCodeDetail,RelCodeDetail> {
List<RelCodeDetailResponse> filterList(RelCodeDetailRequest relCodeDetailRequest);
}

@ -0,0 +1,115 @@
package com.glxp.udidl.admin.entity.collect;
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@ApiModel(value="com-glxp-api-entity-collect-RelCodeBatch")
@Data
@TableName(value = "rel_code_batch")
public class RelCodeBatch implements Serializable {
@TableId(value = "id", type = IdType.AUTO)
@ApiModelProperty(value="")
private Integer id;
/**
*
*/
@TableField(value = "productCode")
@ApiModelProperty(value="产品编码")
private String productCode;
/**
*
*/
@TableField(value = "subTypeNo")
@ApiModelProperty(value="类型编码")
private String subTypeNo;
/**
*
*/
@TableField(value = "cascadeRatio")
@ApiModelProperty(value="包装比例")
private String cascadeRatio;
/**
*
*/
@TableField(value = "packageSpec")
@ApiModelProperty(value="包装规格")
private String packageSpec;
/**
*
*/
@TableField(value = "comment")
@ApiModelProperty(value="备注")
private String comment;
/**
*
*/
@TableField(value = "batchNo")
@ApiModelProperty(value="批次号")
private String batchNo;
/**
*
*/
@TableField(value = "madeDate")
@ApiModelProperty(value="生产日期")
private String madeDate;
/**
*
*/
@TableField(value = "validateDate")
@ApiModelProperty(value="有效期至")
private String validateDate;
/**
*
*/
@TableField(value = "workShop")
@ApiModelProperty(value="生产车间")
private String workShop;
/**
* 线
*/
@TableField(value = "lineName")
@ApiModelProperty(value="生产线")
private String lineName;
/**
*
*/
@TableField(value = "lineManager")
@ApiModelProperty(value="负责人")
private String lineManager;
@TableField(value = "createTime")
@ApiModelProperty(value = "")
private Date createTime;
@TableField(value = "`createUser`")
@ApiModelProperty(value = "")
private String createUser;
@TableField(value = "updateTime")
@ApiModelProperty(value = "")
private Date updateTime;
@TableField(value = "updateUser")
@ApiModelProperty(value = "")
private String updateUser;
}

@ -0,0 +1,56 @@
package com.glxp.udidl.admin.entity.collect;
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@ApiModel(value="com-glxp-api-entity-collect-RelCodeDetail")
@Data
@TableName(value = "rel_code_detail")
public class RelCodeDetail implements Serializable {
@TableId(value = "id", type = IdType.INPUT)
@ApiModelProperty(value="")
private Integer id;
/**
*
*/
@TableField(value = "curCode")
@ApiModelProperty(value="当前条码")
private String curCode;
/**
*
*/
@TableField(value = "packLayer")
@ApiModelProperty(value="包装级别")
private Integer packLayer;
/**
*
*/
@TableField(value = "parentCode")
@ApiModelProperty(value="父级码")
private String parentCode;
/**
*
*/
@TableField(value = "flag")
@ApiModelProperty(value="状态")
private Integer flag;
/**
* ID
*/
@TableField(value = "batchIdFk")
@ApiModelProperty(value="产品批次ID外键")
private Integer batchIdFk;
}

@ -25,4 +25,8 @@ public class JsonException extends RuntimeException {
super(message);
this.code = code;
}
public JsonException(String message) {
super(message);
this.code = 500;
}
}

@ -0,0 +1,84 @@
package com.glxp.udidl.admin.req.collect;
import com.glxp.udidl.admin.req.ListPageRequest;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class RelCodeBatchRequest extends ListPageRequest {
private Integer id;
/**
*
*/
private String productCode;
/**
*
*/
private String subTypeNo;
/**
*
*/
private String cascadeRatio;
/**
*
*/
private String packageSpec;
/**
*
*/
private String comment;
/**
*
*/
private String batchNo;
/**
*
*/
private String madeDate;
/**
*
*/
private String validateDate;
/**
*
*/
private String workShop;
/**
* 线
*/
private String lineName;
/**
*
*/
private String lineManager;
private Date createTime;
private String createUser;
private Date updateTime;
private String updateUser;
private String keyWords;
private List<RelCodeDetailRequest> detailList;
private String code;
private String startDate;
private String endDate;
}

@ -0,0 +1,103 @@
package com.glxp.udidl.admin.req.collect;
import com.glxp.udidl.admin.req.ListPageRequest;
import lombok.Data;
import java.util.Date;
@Data
public class RelCodeDetailRequest extends ListPageRequest {
private Integer id;
/**
*
*/
private String curCode;
/**
*
*/
private Integer packLayer;
/**
*
*/
private String parentCode;
/**
*
*/
private Integer flag;
/**
* ID
*/
private Integer batchIdFk;
/**
*
*/
private String productCode;
/**
*
*/
private String subTypeNo;
/**
*
*/
private String cascadeRatio;
/**
*
*/
private String packageSpec;
/**
*
*/
private String comment;
/**
*
*/
private String batchNo;
/**
*
*/
private Date madeDate;
/**
*
*/
private Date validateDate;
/**
*
*/
private String workShop;
/**
* 线
*/
private String lineName;
/**
*
*/
private String lineManager;
private Date createTime;
private String createUser;
private Date updateTime;
private String updateUser;
private String keyWords;
}

@ -0,0 +1,84 @@
package com.glxp.udidl.admin.res.collect;
import lombok.Data;
import java.util.Date;
@Data
public class RelCodeBatchResponse {
private Integer id;
/**
*
*/
private String productCode;
/**
*
*/
private String subTypeNo;
/**
*
*/
private String cascadeRatio;
/**
*
*/
private String packageSpec;
/**
*
*/
private String comment;
/**
*
*/
private String batchNo;
/**
*
*/
private Date madeDate;
/**
*
*/
private Date validateDate;
/**
*
*/
private String workShop;
/**
* 线
*/
private String lineName;
/**
*
*/
private String lineManager;
/**
*
*/
private String cpmctymc;
/**
*
*/
private Integer bhxjsl;
/**
*
*/
private String packUnit;
/**
*
*/
private Integer packLayer;
}

@ -0,0 +1,108 @@
package com.glxp.udidl.admin.res.collect;
import lombok.Data;
import java.util.Date;
@Data
public class RelCodeDetailResponse {
private Integer id;
/**
*
*/
private String curCode;
/**
*
*/
private Integer packLayer;
/**
*
*/
private String parentCode;
/**
*
*/
private Integer flag;
/**
* ID
*/
private Integer batchIdFk;
//=======================具体详情========================
/**
*
*/
private String productCode;
/**
*
*/
private String subTypeNo;
/**
*
*/
private String cascadeRatio;
/**
*
*/
private String packageSpec;
/**
*
*/
private String comment;
/**
*
*/
private String batchNo;
/**
*
*/
private Date madeDate;
/**
*
*/
private Date validateDate;
/**
*
*/
private String workShop;
/**
* 线
*/
private String lineName;
/**
*
*/
private String lineManager;
/**
*
*/
private String cpmctymc;
/**
*
*/
private Integer bhxjsl;
/**
*
*/
private String packUnit;
}

@ -0,0 +1,220 @@
package com.glxp.udidl.admin.service.collect;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.XmlUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.glxp.udidl.admin.dao.collect.RelCodeBatchMapper;
import com.glxp.udidl.admin.entity.auth.AuthAdmin;
import com.glxp.udidl.admin.entity.collect.RelCodeBatch;
import com.glxp.udidl.admin.entity.collect.RelCodeDetail;
import com.glxp.udidl.admin.exception.JsonException;
import com.glxp.udidl.admin.req.collect.RelCodeBatchRequest;
import com.glxp.udidl.admin.req.collect.RelCodeDetailRequest;
import com.glxp.udidl.admin.res.collect.RelCodeBatchResponse;
//import com.glxp.udidl.admin.service.auth.CustomerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service
@Slf4j
public class RelCodeBatchService extends ServiceImpl<RelCodeBatchMapper, RelCodeBatch> {
@Resource
private RelCodeDetailService relCodeDetailService;
// @Resource
// private CustomerService customerService;
/**
*
* @param file
*/
@Transactional(rollbackFor = Exception.class)
public void xmlUpload(MultipartFile file) {
// try {
// String fileName = file.getOriginalFilename();
// String suffix = FileUtil.getSuffix(fileName);
// if(! "xml".equals(suffix)){
// throw new JsonException("仅支持XML文件类型错误"+suffix);
// }
// log.info(file.getSize()+"文件长度");
// if(file.getSize() > 5 * 1024 *1024){
// throw new JsonException("上传文件超过5M");
// }
// List<RelCodeDetail> relCodeDetails = new ArrayList<>();
// Document document = XmlUtil.readXML(file.getInputStream());
// //获取根
// Element rootElement = XmlUtil.getRootElement(document);
// //截取Relation
// NodeList relation = rootElement.getElementsByTagName("Relation");
// if(relation == null){
// throw new JsonException("XML文件解析错误");
// }
// Element relationE = (Element) relation.item(0);
// String productCode = relationE.getAttribute("productCode");
// String subTypeNo = relationE.getAttribute("subTypeNo");
// String cascade = relationE.getAttribute("cascade");
// String packageSpec = relationE.getAttribute("packageSpec");
// String comment = relationE.getAttribute("comment");
// //截取Batch
// NodeList batch = rootElement.getElementsByTagName("Batch");
// if(batch == null){
// throw new JsonException("XML文件解析错误");
// }
// AuthAdmin user = customerService.getUserBean();
// for (int i = 0; i < batch.getLength(); i++) {
// Node batchNode = batch.item(i);
// RelCodeBatch relCodeBatch = new RelCodeBatch();
// if (batchNode.getNodeType() == Node.ELEMENT_NODE) {
// Element batchE = (Element) batchNode;
// relCodeBatch.setProductCode(productCode);
// relCodeBatch.setSubTypeNo(subTypeNo);
// relCodeBatch.setCascadeRatio(cascade);
// relCodeBatch.setPackageSpec(packageSpec);
// relCodeBatch.setComment(comment);
// String batchNo = batchE.getAttribute("batchNo");
// relCodeBatch.setBatchNo(batchNo);
// String madeDate = batchE.getAttribute("madeDate");
// relCodeBatch.setMadeDate(madeDate);
//// relCodeBatch.setMadeDate(DateUtil.parse(madeDate,"yyyy-MM-dd"));
// String validateDate = batchE.getAttribute("validateDate");
//// relCodeBatch.setValidateDate(DateUtil.offsetDay(DateUtil.parse(validateDate,"yyyy-MM-dd"),1));
// relCodeBatch.setValidateDate(String.valueOf(DateUtil.offsetDay(DateUtil.parse(validateDate,"yyyy-MM-dd"),1)));
// String workShop = batchE.getAttribute("workShop");
// relCodeBatch.setWorkShop(workShop);
// String lineName = batchE.getAttribute("lineName");
// relCodeBatch.setLineName(lineName);
// String lineManager = batchE.getAttribute("lineManager");
// relCodeBatch.setLineManager(lineManager);
// relCodeBatch.setCreateTime(new Date());
// relCodeBatch.setCreateUser(user.getUserName());
// relCodeBatch.setUpdateTime(new Date());
// relCodeBatch.setUpdateUser(user.getUserName());
// this.save(relCodeBatch);
// }
// //batch下的节点code
// NodeList code = batchNode.getChildNodes();
// for (int j = 0; j < code.getLength(); j++) {
// Node codeNode = code.item(j);
// RelCodeDetail relCodeDetail = new RelCodeDetail();
// if (codeNode.getNodeType() == Node.ELEMENT_NODE) {
// Element codeE = (Element) codeNode;
// relCodeDetail.setBatchIdFk(relCodeBatch.getId());
// String curCode = codeE.getAttribute("curCode");
// relCodeDetail.setCurCode(curCode);
// String packLayer = codeE.getAttribute("packLayer");
// relCodeDetail.setPackLayer(Integer.valueOf(packLayer));
// String parentCode = codeE.getAttribute("parentCode");
// relCodeDetail.setParentCode(StrUtil.isNotBlank(parentCode)?parentCode:"0");
// String flag = codeE.getAttribute("flag");
// relCodeDetail.setFlag(Integer.valueOf(flag));
// relCodeDetails.add(relCodeDetail);
// }
// }
// }
// relCodeDetailService.saveBatch(relCodeDetails);
// }catch (Exception e){
// throw new JsonException("上传失败:"+e.getMessage());
// }
}
/**
*
* @param relCodeBatchRequest
*/
@Transactional(rollbackFor = Exception.class)
public void add(RelCodeBatchRequest relCodeBatchRequest) {
// List<RelCodeDetailRequest> detailList = relCodeBatchRequest.getDetailList();
// if(CollUtil.isEmpty(detailList)){
// throw new JsonException("关联明细不能为空!");
// }
// AuthAdmin user = customerService.getUserBean();
// RelCodeBatch relCodeBatch = new RelCodeBatch();
// BeanUtils.copyProperties(relCodeBatchRequest,relCodeBatch);
// relCodeBatch.setCreateTime(new Date());
// relCodeBatch.setCreateUser(user.getUserName());
// relCodeBatch.setUpdateTime(new Date());
// relCodeBatch.setUpdateUser(user.getUserName());
// this.save(relCodeBatch);
// List<RelCodeDetail> relCodeDetails = new ArrayList<>();
// for(RelCodeDetailRequest request : detailList){
// RelCodeDetail relCodeDetail = new RelCodeDetail();
// String parentCode = request.getParentCode();
// request.setParentCode(StrUtil.isNotBlank(parentCode)?parentCode:"0");
// BeanUtils.copyProperties(request,relCodeDetail);
// relCodeDetail.setBatchIdFk(relCodeBatch.getId());
// relCodeDetails.add(relCodeDetail);
// }
// relCodeDetailService.saveBatch(relCodeDetails);
}
public List<RelCodeBatchResponse> filterList(RelCodeBatchRequest relCodeBatchRequest) {
if (relCodeBatchRequest == null) {
return Collections.emptyList();
}
if (relCodeBatchRequest.getPage() != null) {
int offset = (relCodeBatchRequest.getPage() - 1) * relCodeBatchRequest.getLimit();
PageHelper.offsetPage(offset, relCodeBatchRequest.getLimit());
}
return this.baseMapper.filterList(relCodeBatchRequest);
}
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
if(id == null){
throw new JsonException("id 不能为空");
}
relCodeDetailService.remove(new LambdaQueryWrapper<RelCodeDetail>().eq(RelCodeDetail::getBatchIdFk,id));
this.removeById(id);
}
@Transactional(rollbackFor = Exception.class)
public void addRelCodeSpellBox(List<RelCodeBatchRequest> relCodeBatchRequests) {
if (CollUtil.isEmpty(relCodeBatchRequests)){
throw new JsonException("单据信息异常!");
}
relCodeBatchRequests.forEach( item -> {
this.add(item);
});
}
@Transactional(rollbackFor = Exception.class)
public void deleteDetail(String curCode) {
List<RelCodeDetail> list = relCodeDetailService.list(new LambdaQueryWrapper<RelCodeDetail>().eq(RelCodeDetail::getParentCode, curCode));
if (CollUtil.isNotEmpty(list)){
List<Integer> batchIds = list.stream().map(RelCodeDetail::getBatchIdFk).collect(Collectors.toList());
this.removeBatchByIds(batchIds);
relCodeDetailService.remove(new LambdaQueryWrapper<RelCodeDetail>().in(RelCodeDetail::getBatchIdFk,batchIds));
}
}
@Transactional(rollbackFor = Exception.class)
public void deleteAllDetail(List<RelCodeDetailRequest> detailList) {
if (CollUtil.isNotEmpty(detailList)){
detailList.forEach( item -> {
String curCode = item.getCurCode();
this.deleteDetail(curCode);
});
}
}
}

@ -0,0 +1,116 @@
package com.glxp.udidl.admin.service.collect;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
//import com.glxp.udidl.admin.dao.basic.BasicProductsDao;
import com.glxp.udidl.admin.dao.collect.RelCodeDetailMapper;
//import com.glxp.udidl.admin.entity.basic.BasicProductsEntity;
//import com.glxp.udidl.admin.entity.basic.UdiEntity;
import com.glxp.udidl.admin.entity.collect.RelCodeDetail;
import com.glxp.udidl.admin.exception.JsonException;
import com.glxp.udidl.admin.req.collect.RelCodeDetailRequest;
import com.glxp.udidl.admin.res.collect.RelCodeDetailResponse;
//import com.glxp.udidl.admin.util.udi.FilterUdiUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class RelCodeDetailService extends ServiceImpl<RelCodeDetailMapper, RelCodeDetail> {
// @Resource
// private BasicProductsDao basicProductsDao;
/**
*
* @param relCodeDetailRequest
* @return
*/
// public RelCodeDetailResponse scanCode(RelCodeDetailRequest relCodeDetailRequest) {
// String curCode = relCodeDetailRequest.getCurCode();
// String parentCode = relCodeDetailRequest.getParentCode();
// if(StrUtil.isBlank(curCode)){
// throw new JsonException("追溯码不能为空");
// }
// if (curCode.endsWith("\u001D")) {
// curCode = curCode.replace("\u001D", "");
// }
// UdiEntity curCodeUdi = FilterUdiUtils.getUdi(curCode);
// if (curCodeUdi == null){
// throw new JsonException("无效条码!");
// }
// RelCodeDetailResponse relCodeDetailResponse = new RelCodeDetailResponse();
// LambdaQueryWrapper<BasicProductsEntity> cw = new LambdaQueryWrapper<BasicProductsEntity>()
// .eq(BasicProductsEntity::getNameCode, curCodeUdi.getUdi())
// .last("limit 1");
// BasicProductsEntity cur = basicProductsDao.selectOne(cw);
// if(cur == null){
// throw new JsonException("产品信息不存在");
// }
// //是否已存在数据库中
// List<RelCodeDetail> list = this.baseMapper.selectList(new LambdaQueryWrapper<RelCodeDetail>().eq(RelCodeDetail::getCurCode, curCode));
// if (CollUtil.isNotEmpty(list)){
// throw new JsonException("当前条码关联关系已被维护!");
// }
// if(StrUtil.isNotBlank(parentCode)){
// if (parentCode.endsWith("\u001D")) {
// parentCode = parentCode.replace("\u001D", "");
// }
// if(StrUtil.equals(curCode,parentCode)){
// throw new JsonException("录入条码重复!");
// }
// UdiEntity parentCodeUdi = FilterUdiUtils.getUdi(parentCode);
// if (parentCodeUdi == null){
// throw new JsonException("无效父级条码!");
// }
// LambdaQueryWrapper<BasicProductsEntity> pw = new LambdaQueryWrapper<BasicProductsEntity>()
// .eq(BasicProductsEntity::getNameCode, parentCodeUdi.getUdi())
// .last("limit 1");
// BasicProductsEntity parent = basicProductsDao.selectOne(pw);
// if(parent == null){
// throw new JsonException("父级产品信息不存在");
// }
// if(!StrUtil.equals(parent.getUuid(),cur.getUuid())){
// throw new JsonException("当前条码不是同一产品");
// }
// if(Integer.valueOf(parent.getPackLevel()) - Integer.valueOf(cur.getPackLevel()) != 1){
// throw new JsonException("当前条码不属于子条码");
// }
// }else {
// parentCode = "0";
// }
// relCodeDetailResponse.setCurCode(curCode);
// relCodeDetailResponse.setParentCode(parentCode);
// relCodeDetailResponse.setPackLayer(Integer.valueOf(cur.getPackLevel()));
// relCodeDetailResponse.setFlag(1);
// relCodeDetailResponse.setCpmctymc(cur.getCpmctymc());
// relCodeDetailResponse.setProductCode(cur.getNameCode());
// relCodeDetailResponse.setBhxjsl(cur.getBhxjsl());
// relCodeDetailResponse.setPackageSpec(cur.getBzgg());
// relCodeDetailResponse.setCascadeRatio(cur.getPackRatio());
// relCodeDetailResponse.setPackUnit(cur.getPackUnit());
// return relCodeDetailResponse;
// }
/**
*
* @param relCodeDetailRequest
* @return
*/
public List<RelCodeDetailResponse> filterList(RelCodeDetailRequest relCodeDetailRequest) {
if (relCodeDetailRequest == null) {
return Collections.emptyList();
}
if (relCodeDetailRequest.getPage() != null) {
int offset = (relCodeDetailRequest.getPage() - 1) * relCodeDetailRequest.getLimit();
PageHelper.offsetPage(offset, relCodeDetailRequest.getLimit());
}
return this.baseMapper.filterList(relCodeDetailRequest);
}
}

@ -0,0 +1,76 @@
<?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.udidl.admin.dao.collect.RelCodeBatchMapper">
<resultMap id="BaseResultMap" type="com.glxp.udidl.admin.entity.collect.RelCodeBatch">
<!--@mbg.generated-->
<!--@Table udi_wms_ywj.rel_code_batch-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="productCode" jdbcType="VARCHAR" property="productCode" />
<result column="subTypeNo" jdbcType="VARCHAR" property="subTypeNo" />
<result column="cascadeRatio" jdbcType="VARCHAR" property="cascadeRatio" />
<result column="packageSpec" jdbcType="VARCHAR" property="packageSpec" />
<result column="comment" jdbcType="VARCHAR" property="comment" />
<result column="batchNo" jdbcType="VARCHAR" property="batchNo" />
<result column="madeDate" jdbcType="TIMESTAMP" property="madeDate" />
<result column="validateDate" jdbcType="TIMESTAMP" property="validateDate" />
<result column="workShop" jdbcType="VARCHAR" property="workShop" />
<result column="lineName" jdbcType="VARCHAR" property="lineName" />
<result column="lineManager" jdbcType="VARCHAR" property="lineManager" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, productCode, subTypeNo, `cascadeRatio`, packageSpec, `comment`, batchNo, madeDate,
validateDate, workShop, lineName, lineManager
</sql>
<select id="filterList" parameterType="com.glxp.udidl.admin.req.collect.RelCodeBatchRequest" resultType="com.glxp.udidl.admin.res.collect.RelCodeBatchResponse">
select
a.id,
a.productCode,
a.subTypeNo,
a.cascadeRatio,
a.packageSpec,
a.comment,
a.batchNo,
a.madeDate,
a.validateDate,
a.workShop,
a.lineName,
a.lineManager,
bp.cpmctymc,
bp.bhxjsl,
bp.packLevel AS packLayer,
bp.packUnit
from rel_code_batch a
LEFT JOIN basic_products bp ON bp.nameCode = a.productCode
<where>
<if test="productCode != '' and productCode != null">
AND a.productCode LIKE concat('%', #{productCode}, '%')
</if>
<if test="batchNo != null and batchNo != ''">
AND a.batchNo = #{batchNo}
</if>
<if test="keyWords != '' and keyWords != null">
and (
a.productCode LIKE concat('%', #{keyWords}, '%')
or a.subTypeNo LIKE concat('%', #{keyWords}, '%')
or a.packageSpec LIKE concat('%', #{keyWords}, '%'))
</if>
<if test="lineName != '' and lineName != null">
AND a.lineName LIKE concat('%', #{lineName}, '%')
</if>
<if test="lineManager != '' and lineManager != null">
AND a.lineManager LIKE concat('%', #{lineManager}, '%')
</if>
<if test="code != '' and code != null">
and exists(select 1 from rel_code_detail b where a.id = b.batchIdFk and b.curCode = #{code})
</if>
<if test="startDate != null and startDate != ''">
<![CDATA[ and a.validateDate >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S') ]]>
</if>
<if test="endDate != null and endDate != ''">
<![CDATA[ and a.validateDate <= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S') ]]>
</if>
</where>
</select>
</mapper>

@ -0,0 +1,65 @@
<?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.udidl.admin.dao.collect.RelCodeDetailMapper">
<resultMap id="BaseResultMap" type="com.glxp.udidl.admin.entity.collect.RelCodeDetail">
<!--@mbg.generated-->
<!--@Table udi_wms_ywj.rel_code_detail-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="curCode" jdbcType="VARCHAR" property="curCode" />
<result column="packLayer" jdbcType="TINYINT" property="packLayer" />
<result column="parentCode" jdbcType="VARCHAR" property="parentCode" />
<result column="flag" jdbcType="TINYINT" property="flag" />
<result column="batchIdFk" jdbcType="INTEGER" property="batchIdFk" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, curCode, packLayer, parentCode, flag, batchIdFk
</sql>
<select id="filterList" parameterType="com.glxp.udidl.admin.req.collect.RelCodeDetailRequest" resultType="com.glxp.udidl.admin.res.collect.RelCodeDetailResponse">
select
rcd.id,
rcd.curCode,
rcd.packLayer,
rcd.parentCode,
rcd.flag,
rcd.batchIdFk,
rcb.productCode,
rcb.subTypeNo,
rcb.cascadeRatio,
rcb.packageSpec,
rcb.comment,
rcb.batchNo,
rcb.madeDate,
rcb.validateDate,
rcb.workShop,
rcb.lineName,
rcb.lineManager,
rcb.createTime,
rcb.createUser,
rcb.updateTime,
rcb.updateUser
from rel_code_detail rcd
left join rel_code_batch rcb on rcb.id = rcd.batchIdFk
<where>
<if test="productCode != '' and productCode != null">
AND rcb.productCode LIKE concat('%', #{productCode}, '%')
</if>
<if test="batchNo != null and batchNo != ''">
AND rcb.batchNo = #{batchNo}
</if>
<if test="keyWords != '' and keyWords != null">
and (
rcb.productCode LIKE concat('%', #{keyWords}, '%')
or rcb.subTypeNo LIKE concat('%', #{keyWords}, '%')
or rcb.packageSpec LIKE concat('%', #{keyWords}, '%'))
</if>
<if test="lineName != '' and lineName != null">
AND rcb.lineName LIKE concat('%', #{lineName}, '%')
</if>
<if test="lineManager != '' and lineManager != null">
AND rcb.lineManager LIKE concat('%', #{lineManager}, '%')
</if>
</where>
</select>
</mapper>
Loading…
Cancel
Save