feat: 阳采按钮

dev_unify
chenhc 3 months ago
parent 671789bd23
commit 63aab5a655

@ -1,15 +1,19 @@
package com.glxp.api.controller.alihealth;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.CusRedissonAnnotation;
import com.glxp.api.annotation.Log;
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.BusinessType;
import com.glxp.api.constant.RedissonCacheKey;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.alihealth.AliYljgBillDetail;
import com.glxp.api.entity.alihealth.AliYljgBillDetailDrugCode;
@ -30,7 +34,9 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.*;

@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.annotation.CusRedissonAnnotation;
import com.glxp.api.annotation.Log;
import com.glxp.api.annotation.RepeatSubmit;
import com.glxp.api.common.enums.ResultEnum;
@ -16,6 +17,7 @@ import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BusinessType;
import com.glxp.api.constant.Constant;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.constant.RedissonCacheKey;
import com.glxp.api.controller.BaseController;
import com.glxp.api.dao.basic.UdiRelevanceDao;
import com.glxp.api.dao.inout.IoOrderDetailBizDao;
@ -70,6 +72,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.math.BigDecimal;
@ -846,4 +849,14 @@ public class IoOrderDetailBizController extends BaseController {
return ResultVOUtils.success(ioOrderEntity);
}
//录入阳光采购的追溯码
@PostMapping("/udiwms/inout/order/yc/fileUpload")
@CusRedissonAnnotation(cacheName = RedissonCacheKey.XML_UPLOAD, key = {"#billNo"}, timeOutMsg = "系统正在处理,请勿重复上传")
public BaseResponse ycFileUpload(@RequestParam("billNo") String billNo, @RequestParam("file") MultipartFile file) {
alihealthBusService.ycFileUpload(billNo,file);
return ResultVOUtils.successMsg("上传成功!");
}
}

@ -0,0 +1,17 @@
package com.glxp.api.entity.alihealth;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class YcFileCodeUploadVo {
@ExcelProperty("订单编号")
private String billNo;
@ExcelProperty("交易明细编号")
private String detailNo;
@ExcelProperty("追溯码")
private String code;
}

@ -5,6 +5,7 @@ import com.glxp.api.entity.alihealth.AliYljgBillDetailDrug;
import com.glxp.api.entity.alihealth.AliYljgBillDetailDrugCode;
import com.glxp.api.entity.alihealth.AliYljgSearchbill;
import com.glxp.api.req.alihealth.AliYljgSearchbillReqeust;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@ -13,4 +14,6 @@ public interface AlihealthBusService {
List<AliYljgSearchbill> aliYljgSearchbillPage(AliYljgSearchbillReqeust aliYljgSearchbillReqeust);
AliYljgBillDetail aliYljgBillDetail(AliYljgSearchbillReqeust aliYljgSearchbillReqeust);
void ycFileUpload(String billNo,MultipartFile file);
}

@ -1,21 +1,42 @@
package com.glxp.api.service.alihealth.impl;
import com.github.pagehelper.PageHelper;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.read.listener.ReadListener;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.entity.alihealth.AliYljgBillDetail;
import com.glxp.api.entity.alihealth.AliYljgBillDetailDrug;
import com.glxp.api.entity.alihealth.AliYljgBillDetailDrugCode;
import com.glxp.api.entity.alihealth.AliYljgSearchbill;
import com.glxp.api.dao.inout.IoOrderDao;
import com.glxp.api.entity.alihealth.*;
import com.glxp.api.entity.basic.UdiEntity;
import com.glxp.api.entity.inout.IoCodeLostEntity;
import com.glxp.api.entity.inout.IoOrderEntity;
import com.glxp.api.exception.JsonException;
import com.glxp.api.req.alihealth.AliYljgSearchbillReqeust;
import com.glxp.api.req.alihealth.AlihealthYljgListupoutDetailReqeust;
import com.glxp.api.req.alihealth.AlihealthYljgListupoutReqeust;
import com.glxp.api.req.inout.AddOrderRequest;
import com.glxp.api.req.inout.FilterOrderRequest;
import com.glxp.api.service.alihealth.AlihealthBusService;
import com.glxp.api.service.inout.IoCodeLostService;
import com.glxp.api.service.inout.IoOrderService;
import com.glxp.api.service.inout.impl.IoCodeTempService;
import com.glxp.api.util.StringUtils;
import com.glxp.api.util.alihealth.AlihealthYljgUtils;
import com.glxp.api.util.udi.FilterUdiUtils;
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 com.alibaba.excel.EasyExcel;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -25,6 +46,10 @@ public class AlihealthBusServiceImpl implements AlihealthBusService {
@Resource
private AlihealthYljgUtils alihealthYljgUtils;
@Resource
IoOrderService ioOrderService;
@Resource
IoOrderDao ioOrderDao;
@Override
public List<AliYljgSearchbill> aliYljgSearchbillPage(AliYljgSearchbillReqeust aliYljgSearchbillReqeust) {
@ -72,4 +97,115 @@ public class AlihealthBusServiceImpl implements AlihealthBusService {
}
@Resource
IoCodeLostService ioCodeLostService;
@Resource
IoCodeTempService ioCodeTempService;
@Override
@Transactional(rollbackFor = Exception.class)
public void ycFileUpload(String billNo,MultipartFile file) {
try {
String fileName = file.getOriginalFilename();
String suffix = FileUtil.getSuffix(fileName);
if (!"xlsx".equals(suffix)) {
throw new JsonException("仅支持.xlsx文件类型错误" + suffix);
}
if (file.getSize() > 5 * 1024 * 1024) {
throw new JsonException("上传文件超过5M");
}
} catch (Exception e) {
throw new JsonException("上传失败:" + e.getMessage());
}
List<YcFileCodeUploadVo> list = getList(file);
if (CollUtil.isEmpty(list)){
throw new JsonException("文件数据为空");
}
FilterOrderRequest request = new FilterOrderRequest();
request.setBillNo(billNo);
List<IoOrderEntity> ioOrderEntities = ioOrderService.filterOrderList(request);
if (CollUtil.isEmpty(ioOrderEntities)){
throw new JsonException("单据编号未找到信息");
}
IoOrderEntity ioOrderEntity = ioOrderEntities.get(0);
AddOrderRequest addOrderRequest = new AddOrderRequest();
BeanUtils.copyProperties(ioOrderEntity, addOrderRequest);
for (int j = 0; j < list.size(); j++) {
YcFileCodeUploadVo ycFileCodeUploadVo = list.get(j);
String code = ycFileCodeUploadVo.getCode();
addOrderRequest.setCode(code);
UdiEntity udiEntity = FilterUdiUtils.getUdi(code);
if (udiEntity == null){
throw new JsonException("追溯码解析错误:【"+code+"】");
}
IoCodeLostEntity codeLostEntity = ioCodeLostService.findByCode(ycFileCodeUploadVo.getCode());
if (codeLostEntity == null) {
codeLostEntity = new IoCodeLostEntity();
codeLostEntity.setId(IdUtil.getSnowflakeNextId());
codeLostEntity.setNameCode(udiEntity.getUdi());
codeLostEntity.setCode(udiEntity.getCode());
codeLostEntity.setBatchNo(udiEntity.getBatchNo());
if (StrUtil.isNotEmpty(udiEntity.getProduceDate())) {
codeLostEntity.setProduceDate(udiEntity.getProduceDate());
}
if (StrUtil.isNotEmpty(udiEntity.getExpireDate())) {
codeLostEntity.setExpireDate(udiEntity.getExpireDate());
}
} else {
codeLostEntity.setBatchNo(udiEntity.getBatchNo());
if (StrUtil.isNotEmpty(udiEntity.getProduceDate())) {
codeLostEntity.setProduceDate(udiEntity.getProduceDate());
}
if (StrUtil.isNotEmpty(udiEntity.getExpireDate())) {
codeLostEntity.setExpireDate(udiEntity.getExpireDate());
}
Long id = codeLostEntity.getId();
if (id == null) codeLostEntity.setId(IdUtil.getSnowflakeNextId());
}
ioCodeLostService.insertOrUpdate(codeLostEntity);
BaseResponse response2 = ioCodeTempService.addDrugOrderWeb(addOrderRequest);
if (response2.getCode() != 20000) {
throw new JsonException(response2.getMessage());
}
}
}
public List<YcFileCodeUploadVo> getList(MultipartFile file) {
List<YcFileCodeUploadVo> entities = new ArrayList<>();
try (InputStream inputStream = file.getInputStream()) {
EasyExcel.read(inputStream, YcFileCodeUploadVo.class, new AnalysisEventListener<YcFileCodeUploadVo>() {
@Override
public void invoke(YcFileCodeUploadVo data, AnalysisContext context) {
// 每次读取到一行数据,都会调用这个方法
entities.add(data);
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
// 所有数据解析完成后的操作,可以在这里进行后续处理
// 比如:保存数据到数据库
}
// 可以选择性地覆盖其他方法,比如处理表头、异常等
}).sheet().doRead();
} catch (IOException e) {
e.printStackTrace();
}
return entities;
}
}

Loading…
Cancel
Save