Merge remote-tracking branch 'origin/dev_drug' into dev_drug

dev_unify
wangwei 6 months ago
commit f4c9afc4f5

@ -73,6 +73,11 @@ public enum BasicExportTypeEnum {
PRODUCE_BUSINESS_DATA("thr_manufacturer", "生产企业数据"),
/**
*
*/
DRUG_DATA_TASK("drug_data_task", "药品关联信息任"),
;
@EnumValue
private String key;

@ -38,4 +38,6 @@ public interface RedissonCacheKey {
* web
*/
String WEB_ADD_CODE = "web_add_code";
String XML_UPLOAD="xml_upload";
}

@ -0,0 +1,114 @@
package com.glxp.api.controller.collect;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.CusRedissonAnnotation;
import com.glxp.api.annotation.RepeatSubmit;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.RedissonCacheKey;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.collect.RelCodeBatch;
import com.glxp.api.req.collect.RelCodeBatchRequest;
import com.glxp.api.req.collect.RelCodeDetailRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.collect.RelCodeBatchResponse;
import com.glxp.api.service.collect.RelCodeBatchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
@Slf4j
@RestController
public class RelCodeBatchController extends BaseController {
@Resource
private RelCodeBatchService relCodeBatchService;
/**
*
* @param uuid
* @param file
* @return
*/
@RepeatSubmit()
@CusRedissonAnnotation(cacheName = RedissonCacheKey.XML_UPLOAD, key = {"#uuid"}, timeOutMsg = "系统正在处理,请勿重复上传")
@PostMapping("/udiwms/relCode/batch/xmlUpload")
public BaseResponse xmlUpload(@RequestParam("uuid") String uuid,@RequestParam("file") MultipartFile file) {
relCodeBatchService.xmlUpload(file);
return ResultVOUtils.successMsg("上传成功!");
}
/**
*
* @param relCodeBatchRequest
* @return
*/
@RepeatSubmit()
@PostMapping("/udiwms/relCode/batch/add")
public BaseResponse add(@RequestBody @Valid RelCodeBatchRequest relCodeBatchRequest,BindingResult bindingResult) {
relCodeBatchService.add(relCodeBatchRequest);
return ResultVOUtils.successMsg("添加成功!");
}
/**
*
* @param relCodeBatchRequest
* @return
*/
@RepeatSubmit()
@PostMapping("/udiwms/relCode/batch/addRelCodeSpellBox")
public BaseResponse addRelCodeSpellBox(@RequestBody @Valid List<RelCodeBatchRequest> relCodeBatchRequest,BindingResult bindingResult) {
relCodeBatchService.addRelCodeSpellBox(relCodeBatchRequest);
return ResultVOUtils.successMsg("添加成功!");
}
@GetMapping("/udiwms/relCode/batch/filter")
public BaseResponse list(RelCodeBatchRequest relCodeBatchRequest, BindingResult bindingResult) {
List<RelCodeBatchResponse> relCodeBatchResponses = relCodeBatchService.filterList(relCodeBatchRequest);
PageInfo<RelCodeBatchResponse> pageInfo = new PageInfo<>(relCodeBatchResponses);
PageSimpleResponse<RelCodeBatchResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(relCodeBatchResponses);
return ResultVOUtils.success(pageSimpleResponse);
}
@GetMapping("/udiwms/relCode/batch/get")
public BaseResponse get(@RequestParam("id") Long id) {
RelCodeBatch relCodeBatch = relCodeBatchService.getById(id);
return ResultVOUtils.success(relCodeBatch);
}
@GetMapping("/udiwms/relCode/batch/delete")
public BaseResponse delete(@RequestParam("id") Long id) {
relCodeBatchService.delete(id);
return ResultVOUtils.success("删除成功");
}
@PostMapping("/udiwms/relCode/batch/update")
public BaseResponse update(@RequestBody @Valid RelCodeBatch relCodeBatch) {
relCodeBatchService.updateById(relCodeBatch);
return ResultVOUtils.success("修改成功!");
}
@GetMapping("/udiwms/relCode/batch/deleteDetail")
public BaseResponse deleteDetail(@RequestParam("curCode") String curCode) {
relCodeBatchService.deleteDetail(curCode);
return ResultVOUtils.success("删除成功");
}
@PostMapping("/udiwms/relCode/batch/deleteAllDetail")
public BaseResponse deleteAllDetail(@RequestBody List<RelCodeDetailRequest> detailList) {
relCodeBatchService.deleteAllDetail(detailList);
return ResultVOUtils.success("清空成功");
}
}

@ -0,0 +1,70 @@
package com.glxp.api.controller.collect;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.RepeatSubmit;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.collect.RelCodeDetail;
import com.glxp.api.req.collect.RelCodeDetailRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.collect.RelCodeDetailResponse;
import com.glxp.api.service.collect.RelCodeDetailService;
import lombok.extern.slf4j.Slf4j;
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.List;
@Slf4j
@RestController
public class RelCodeDetailController extends BaseController {
@Resource
private RelCodeDetailService relCodeDetailService;
/**
*
* @param relCodeDetailRequest
* @return
*/
@RepeatSubmit()
@PostMapping("/udiwms/relCode/detail/scanCode")
public BaseResponse scanCode(@RequestBody @Valid RelCodeDetailRequest relCodeDetailRequest, BindingResult bindingResult) {
RelCodeDetailResponse relCodeDetailResponse = relCodeDetailService.scanCode(relCodeDetailRequest);
return ResultVOUtils.success(relCodeDetailResponse);
}
@GetMapping("/udiwms/relCode/detail/filter")
public BaseResponse list(RelCodeDetailRequest relCodeDetailRequest, BindingResult bindingResult) {
List<RelCodeDetailResponse> relCodeDetailResponses = relCodeDetailService.filterList(relCodeDetailRequest);
PageInfo<RelCodeDetailResponse> pageInfo = new PageInfo<>(relCodeDetailResponses);
PageSimpleResponse<RelCodeDetailResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(relCodeDetailResponses);
return ResultVOUtils.success(pageSimpleResponse);
}
@GetMapping("/udiwms/relCode/detail/get")
public BaseResponse get(Long id) {
RelCodeDetail relCodeDetail = relCodeDetailService.getById(id);
return ResultVOUtils.success(relCodeDetail);
}
@PostMapping("/udiwms/relCode/detail/update")
public BaseResponse update(@RequestBody @Valid RelCodeDetail relCodeDetail) {
relCodeDetailService.updateById(relCodeDetail);
return ResultVOUtils.success("修改成功!");
}
}

@ -17,6 +17,8 @@ import com.glxp.api.constant.*;
import com.glxp.api.constant.Constant;
import com.glxp.api.dao.auth.*;
import com.glxp.api.dao.basic.*;
import com.glxp.api.dao.collect.RelCodeBatchMapper;
import com.glxp.api.dao.collect.RelCodeDetailMapper;
import com.glxp.api.dao.dev.*;
import com.glxp.api.dao.inout.*;
import com.glxp.api.dao.inv.*;
@ -26,6 +28,8 @@ import com.glxp.api.dao.system.*;
import com.glxp.api.dao.thrsys.*;
import com.glxp.api.entity.auth.*;
import com.glxp.api.entity.basic.*;
import com.glxp.api.entity.collect.RelCodeBatch;
import com.glxp.api.entity.collect.RelCodeDetail;
import com.glxp.api.entity.dev.*;
import com.glxp.api.entity.inout.*;
import com.glxp.api.entity.inv.DeviceInspectTaskEntity;
@ -40,6 +44,8 @@ import com.glxp.api.req.sync.SyncUpLoadRequest;
import com.glxp.api.res.sync.*;
import com.glxp.api.service.auth.InvWarehouseService;
import com.glxp.api.service.basic.IBasicBussinessTypeService;
import com.glxp.api.service.collect.RelCodeBatchService;
import com.glxp.api.service.collect.RelCodeDetailService;
import com.glxp.api.service.dev.DeviceUpkeepService;
import com.glxp.api.service.inout.IoAddInoutService;
import com.glxp.api.service.inout.IoCheckInoutService;
@ -401,6 +407,9 @@ public class SpsSyncDownloadController {
case PRODUCE_BUSINESS_DATA:
saveUploadProBusinessData(JSONUtil.toBean(obj, SpsSyncProBusinessDataResponse.class));
break;
case DRUG_DATA_TASK:
saveUploadDrugData(JSONUtil.toBean(obj, SpsSyncDrugDataTaskResponse.class));
break;
}
String taskId = obj.getStr("taskId");
BasicDownloadStatusEntity downloadStatus = BasicDownloadStatusEntity.builder()
@ -426,6 +435,26 @@ public class SpsSyncDownloadController {
}
@Resource
RelCodeDetailMapper relCodeDetailMapper;
@Resource
RelCodeBatchMapper relCodeBatchMapper;
private void saveUploadDrugData(SpsSyncDrugDataTaskResponse bean) {
if (CollectionUtil.isNotEmpty(bean.getRelCodeBatches())) {
for (RelCodeBatch entity : bean.getRelCodeBatches()) {
entity.setUpdateTime(null);
}
boolean b = relCodeBatchMapper.replaceBatchs(bean.getRelCodeBatches());
}
if (CollectionUtil.isNotEmpty(bean.getRelCodeDetails())) {
// for (RelCodeDetail entity : bean.getRelCodeDetails()) {
// entity.setUpdateTime(null);
// }
boolean b = relCodeDetailMapper.replaceBatchs(bean.getRelCodeDetails());
}
}
private String writeFile(String filePath, String fileDesc, String content) throws IOException {
filePath = String.format("%s/%s", filePath, DateUtil.getDate());

@ -0,0 +1,17 @@
package com.glxp.api.dao.collect;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.api.dao.BaseMapperPlus;
import com.glxp.api.entity.collect.RelCodeBatch;
import com.glxp.api.entity.collect.RelCodeDetail;
import com.glxp.api.req.collect.RelCodeBatchRequest;
import com.glxp.api.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,18 @@
package com.glxp.api.dao.collect;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.api.dao.BaseMapperPlus;
import com.glxp.api.dao.thrsys.ThrManufacturerMapper;
import com.glxp.api.entity.collect.RelCodeDetail;
import com.glxp.api.entity.thrsys.ThrManufacturerEntity;
import com.glxp.api.req.collect.RelCodeDetailRequest;
import com.glxp.api.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.api.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.api.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;
}

@ -0,0 +1,84 @@
package com.glxp.api.req.collect;
import com.glxp.api.util.page.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.api.req.collect;
import com.glxp.api.util.page.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.api.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.api.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,16 @@
package com.glxp.api.res.sync;
import com.glxp.api.entity.collect.RelCodeBatch;
import com.glxp.api.entity.collect.RelCodeDetail;
import lombok.Data;
import java.util.List;
@Data
public class SpsSyncDrugDataTaskResponse extends BaseSyncResponse {
public List<RelCodeBatch> relCodeBatches;
public List<RelCodeDetail> relCodeDetails;
}

@ -0,0 +1,220 @@
package com.glxp.api.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.api.dao.collect.RelCodeBatchMapper;
import com.glxp.api.entity.auth.AuthAdmin;
import com.glxp.api.entity.collect.RelCodeBatch;
import com.glxp.api.entity.collect.RelCodeDetail;
import com.glxp.api.exception.JsonException;
import com.glxp.api.req.collect.RelCodeBatchRequest;
import com.glxp.api.req.collect.RelCodeDetailRequest;
import com.glxp.api.res.collect.RelCodeBatchResponse;
import com.glxp.api.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.api.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.api.dao.basic.BasicProductsDao;
import com.glxp.api.dao.collect.RelCodeDetailMapper;
import com.glxp.api.entity.basic.BasicProductsEntity;
import com.glxp.api.entity.basic.UdiEntity;
import com.glxp.api.entity.collect.RelCodeDetail;
import com.glxp.api.exception.JsonException;
import com.glxp.api.req.collect.RelCodeDetailRequest;
import com.glxp.api.res.collect.RelCodeDetailResponse;
import com.glxp.api.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);
}
}

@ -3,7 +3,7 @@ server:
spring:
datasource:
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
jdbc-url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_spms_pt2?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
jdbc-url: jdbc:p6spy:mysql://192.168.0.44:3306/udi_spms_ct?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: 123456
hikari:

@ -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.api.dao.collect.RelCodeBatchMapper">
<resultMap id="BaseResultMap" type="com.glxp.api.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.api.req.collect.RelCodeBatchRequest" resultType="com.glxp.api.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.api.dao.collect.RelCodeDetailMapper">
<resultMap id="BaseResultMap" type="com.glxp.api.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.api.req.collect.RelCodeDetailRequest" resultType="com.glxp.api.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>

@ -870,8 +870,4 @@ END;
# call Modify_UNIQUE_index('thr_products_add_di', '`uuid`, `customerId`', 'uniqueUuid', 'BTREE');
CALL Pro_Temp_ColumnWork('basic_bussiness_type', 'vailHcType',
'tinyint NULL DEFAULT NULL COMMENT '' 校验耗材类型 0:不耗材1:高值耗材2:无普通耗材''', 1);
CALL Pro_Temp_ColumnWork('basic_udirel', 'isStack', 'tinyint', 1);

@ -975,3 +975,9 @@ CALL Pro_Temp_ColumnWork('basic_products', 'pinyinInitial', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('basic_products', 'destinyType',
' int(0) NULL DEFAULT NULL COMMENT''类型1定数包内部使用2项目、组套外部关联''',
1);
CALL Pro_Temp_ColumnWork('basic_bussiness_type', 'vailHcType',
'tinyint NULL DEFAULT NULL COMMENT '' 校验耗材类型 0:不耗材1:高值耗材2:无普通耗材''', 1);
CALL Pro_Temp_ColumnWork('basic_udirel', 'isStack', 'tinyint', 1);

Loading…
Cancel
Save