diff --git a/src/main/java/com/glxp/api/controller/inout/IoOrderDetailBizController.java b/src/main/java/com/glxp/api/controller/inout/IoOrderDetailBizController.java index ac4df92c..81542543 100644 --- a/src/main/java/com/glxp/api/controller/inout/IoOrderDetailBizController.java +++ b/src/main/java/com/glxp/api/controller/inout/IoOrderDetailBizController.java @@ -859,4 +859,13 @@ public class IoOrderDetailBizController extends BaseController { return ResultVOUtils.successMsg("上传成功!"); } + + //录入阳光采购的采购订单明细 + @PostMapping("/udiwms/inout/order/yc/orderFileUpload") + @CusRedissonAnnotation(cacheName = RedissonCacheKey.XML_UPLOAD, key = {"#billNoJson"}, timeOutMsg = "系统正在处理,请勿重复上传") + public BaseResponse ycOrderFileUpload(@RequestParam("billNoJson") String billNoJson, @RequestParam("file") MultipartFile file) { + IoOrderEntity ioOrderEntity = alihealthBusService.ycOrderFileUpload(billNoJson,file); + return ResultVOUtils.success(ioOrderEntity); + } + } diff --git a/src/main/java/com/glxp/api/entity/alihealth/YcFileCodeUploadVo.java b/src/main/java/com/glxp/api/entity/alihealth/YcFileCodeUploadVo.java index 70756486..75172646 100644 --- a/src/main/java/com/glxp/api/entity/alihealth/YcFileCodeUploadVo.java +++ b/src/main/java/com/glxp/api/entity/alihealth/YcFileCodeUploadVo.java @@ -1,6 +1,7 @@ package com.glxp.api.entity.alihealth; import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; import io.swagger.annotations.ApiOperation; import lombok.Data; import org.springframework.web.bind.annotation.GetMapping; @@ -11,12 +12,14 @@ import javax.servlet.http.HttpServletResponse; public class YcFileCodeUploadVo { @ExcelProperty("订单编号") + @ColumnWidth(30) private String ycBillNo; @ExcelProperty("交易明细编号") + @ColumnWidth(30) private String detailNo; @ExcelProperty("追溯码") + @ColumnWidth(60) private String code; } - diff --git a/src/main/java/com/glxp/api/entity/alihealth/YcFileOrderUploadVo.java b/src/main/java/com/glxp/api/entity/alihealth/YcFileOrderUploadVo.java new file mode 100644 index 00000000..072159e1 --- /dev/null +++ b/src/main/java/com/glxp/api/entity/alihealth/YcFileOrderUploadVo.java @@ -0,0 +1,128 @@ +package com.glxp.api.entity.alihealth; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + + +@Data +public class YcFileOrderUploadVo { + + @ExcelProperty("订单编号") + @ColumnWidth(30) + private String ycBillNo; + + + @ExcelProperty("发货明细编号") + @ColumnWidth(30) + private String shipmentDetailId; + + @ExcelProperty("发货明细状态") + @ColumnWidth(30) + private String shipmentDetailStatus; + + @ExcelProperty("发货时间") + @ColumnWidth(30) + private String shipmentTime; + + @ExcelProperty("药品统一编码") + @ColumnWidth(30) + private String drugUnifiedCode; + + @ExcelProperty("产品名称") + @ColumnWidth(50) + private String productName; + + @ExcelProperty("数据来源") + @ColumnWidth(30) + private String dataSource; + + @ExcelProperty("剂型") + @ColumnWidth(30) + private String dosageForm; + + @ExcelProperty("规格") + @ColumnWidth(30) + private String specification; + + @ExcelProperty("包装") + @ColumnWidth(30) + private String packaging; + + @ExcelProperty("包装材质") + @ColumnWidth(30) + private String packagingMaterial; + + @ExcelProperty("采购价格(元)") + @ColumnWidth(20) + private String purchasePrice; + + @ExcelProperty("挂网价(元)") + @ColumnWidth(20) + private String listedPrice; + + @ExcelProperty("备案号") + @ColumnWidth(50) + private String recordNumber; + + @ExcelProperty("备案时间") + @ColumnWidth(30) + private String recordTime; + + @ExcelProperty("全国省级最低挂网价") + @ColumnWidth(20) + private String lowestListedPrice; + + @ExcelProperty("计价单位") + @ColumnWidth(30) + private String pricingUnit; + + @ExcelProperty("发货数量") + @ColumnWidth(20) + private String shipmentQuantity; + + @ExcelProperty("发货金额(元)") + @ColumnWidth(20) + private String shipmentAmount; + + @ExcelProperty("批号") + @ColumnWidth(30) + private String batchNumber; + + @ExcelProperty("发货备注") + @ColumnWidth(100) + private String shipmentRemark; + + @ExcelProperty("片区") + @ColumnWidth(30) + private String district; + + @ExcelProperty("医疗机构") + @ColumnWidth(50) + private String medicalInstitution; + + @ExcelProperty("生产企业") + @ColumnWidth(50) + private String manufacturer; + + @ExcelProperty("申报企业") + @ColumnWidth(50) + private String declaringEnterprise; + + @ExcelProperty("销售清单号(第二票)") + @ColumnWidth(50) + private String salesInvoiceNumberSecond; + + @ExcelProperty("销售发票号(第二票)") + @ColumnWidth(50) + private String salesInvoiceNumberSecondTicket; + + @ExcelProperty("销售发票号(第一票)") + @ColumnWidth(50) + private String salesInvoiceNumberFirstTicket; + + @ExcelProperty("采购备注") + @ColumnWidth(100) + private String purchaseRemark; +} + diff --git a/src/main/java/com/glxp/api/service/alihealth/AlihealthBusService.java b/src/main/java/com/glxp/api/service/alihealth/AlihealthBusService.java index bd1f1ba7..49d1a1a4 100644 --- a/src/main/java/com/glxp/api/service/alihealth/AlihealthBusService.java +++ b/src/main/java/com/glxp/api/service/alihealth/AlihealthBusService.java @@ -4,6 +4,7 @@ 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.entity.inout.IoOrderEntity; import com.glxp.api.req.alihealth.AliYljgSearchbillReqeust; import org.springframework.web.multipart.MultipartFile; @@ -16,4 +17,6 @@ public interface AlihealthBusService { AliYljgBillDetail aliYljgBillDetail(AliYljgSearchbillReqeust aliYljgSearchbillReqeust); void ycFileUpload(String billNo,MultipartFile file); + + IoOrderEntity ycOrderFileUpload(String billNoJson, MultipartFile file); } diff --git a/src/main/java/com/glxp/api/service/alihealth/impl/AlihealthBusServiceImpl.java b/src/main/java/com/glxp/api/service/alihealth/impl/AlihealthBusServiceImpl.java index a9c34933..c5cb26c3 100644 --- a/src/main/java/com/glxp/api/service/alihealth/impl/AlihealthBusServiceImpl.java +++ b/src/main/java/com/glxp/api/service/alihealth/impl/AlihealthBusServiceImpl.java @@ -7,7 +7,9 @@ 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.alibaba.fastjson.JSONObject; import com.glxp.api.common.res.BaseResponse; +import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.dao.inout.IoOrderDao; import com.glxp.api.entity.alihealth.*; import com.glxp.api.entity.basic.UdiEntity; @@ -17,8 +19,11 @@ 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.basic.FilterUdiRelRequest; +import com.glxp.api.req.inout.AddBizProductReqeust; import com.glxp.api.req.inout.AddOrderRequest; import com.glxp.api.req.inout.FilterOrderRequest; +import com.glxp.api.res.basic.UdiRelevanceResponse; import com.glxp.api.service.alihealth.AlihealthBusService; import com.glxp.api.service.inout.IoCodeLostService; import com.glxp.api.service.inout.IoOrderService; @@ -180,6 +185,94 @@ public class AlihealthBusServiceImpl implements AlihealthBusService { } } + @Override + @Transactional(rollbackFor = Exception.class) + public IoOrderEntity ycOrderFileUpload(String billNoJson, MultipartFile file) { + + AddBizProductReqeust addBizProductReqeust = JSONObject.parseObject(billNoJson, AddBizProductReqeust.class); + 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 list = getOrderList(file); + if (CollUtil.isEmpty(list)){ + throw new JsonException("文件数据为空"); + } + + IoOrderEntity ioOrderEntity = addBizProductReqeust.getOrderEntity(); + // TODO: 2024/12/25 阳采导入业务明细功能 1、参考阿里的业务导入(下方注释的代码)搜索 addAliBizProduct 参考 需要考虑 发票的问题 和 后续导出 阳采的单号 和 明细 需要先做存储 有单号追加 + return ioOrderEntity; +// +// IoOrderEntity ioOrderEntity = addBizProductReqeust.getOrderEntity(); +// addBizProductReqeust.setAliOrderBillNo(billCode); +// ioOrderEntity.setAliOrderBillNo(billCode); +// for (int i = 0; i < aliYljgBillDetailDrugList.size(); i++) { +// AliYljgBillDetailDrug aliYljgBillDetailDrug = aliYljgBillDetailDrugList.get(i); +// +// +// String code = aliYljgBillDetailDrug.getAliYljgBillDetailDrugCodeList().get(0).getCode(); +// if (StrUtil.isEmpty(code)) { +// return ResultVOUtils.error("单据码为空!"); +// } +// +// UdiEntity drugInfo = FilterUdiUtils.getDrugInfo(code); +// if (drugInfo == null) { +// return ResultVOUtils.error("单据码解析药品信息错误!"); +// } +// +// //获取药品信息 +// String nameCode = drugInfo.getUdi(); +// if (StrUtil.isEmpty(nameCode)) { +// return ResultVOUtils.error("单据码解析药品标识错误!"); +// } +// FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest(); +// filterUdiRelRequest.setNameCode(nameCode); +// List udiRelevanceResponses = udiRelevanceDao.filterUdiRelevance(filterUdiRelRequest); +// if (CollUtil.isEmpty(udiRelevanceResponses)) { +// return ResultVOUtils.error("未通过药品标识获取详情信息!"); +// } +// UdiRelevanceResponse udiRelevanceResponse = udiRelevanceResponses.get(0); +// List aliYljgBillDetailDrugCodeList1 = aliYljgBillDetailDrug.getAliYljgBillDetailDrugCodeList(); +// //1、直接模拟增加biz一行 +// addBizProductReqeust.setProductId(String.valueOf(udiRelevanceResponse.getProductId())); +// addBizProductReqeust.setRelId(udiRelevanceResponse.getRelId()); +// addBizProductReqeust.setZczbhhzbapzbh(udiRelevanceResponse.getZczbhhzbapzbh()); +// addBizProductReqeust.setSupId(udiRelevanceResponse.getSupId()); +// addBizProductReqeust.setDatas(null); +// addBizProductReqeust.setCount(aliYljgBillDetailDrugCodeList1.size() * udiCalCountUtil.getCirActCount(udiRelevanceResponse)); +// +// addBizProductReqeust.setBatchNo(aliYljgBillDetailDrug.getProduceBatchNo()); +// if (StrUtil.isNotEmpty(aliYljgBillDetailDrug.getProduceDate())) { +// addBizProductReqeust.setProductDate(aliYljgBillDetailDrug.getProduceDate().substring(2).replace(" 00:00:00", "").replace("-", "")); +// } +// if (StrUtil.isNotEmpty(aliYljgBillDetailDrug.getValidEndDate())) { +// addBizProductReqeust.setExpireDate(aliYljgBillDetailDrug.getValidEndDate().substring(2).replace(" 00:00:00", "").replace("-", "")); +// } +// if (i == 0) { +// addBizProductReqeust.setOrderEntity(ioOrderEntity); +// } +// addBizProductReqeust.setProductType(udiRelevanceResponse.getProductType()); +// BaseResponse response = orderDetailBizService.addBizProduct(addBizProductReqeust); +// if (response.getCode() != 20000) { +// return response; +// } +// if (i == 0) { +// ioOrderEntity = JSONObject.parseObject(JSONObject.toJSONString(response.getData()), IoOrderEntity.class); +// addBizProductReqeust.setOrderEntity(ioOrderEntity); +// } + + + } + public List getList(MultipartFile file) { List entities = new ArrayList<>(); @@ -207,5 +300,32 @@ public class AlihealthBusServiceImpl implements AlihealthBusService { return entities; } + public List getOrderList(MultipartFile file) { + List entities = new ArrayList<>(); + + try (InputStream inputStream = file.getInputStream()) { + EasyExcel.read(inputStream, YcFileOrderUploadVo.class, new AnalysisEventListener() { + + @Override + public void invoke(YcFileOrderUploadVo data, AnalysisContext context) { + // 每次读取到一行数据,都会调用这个方法 + entities.add(data); + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + // 所有数据解析完成后的操作,可以在这里进行后续处理 + // 比如:保存数据到数据库 + } + + // 可以选择性地覆盖其他方法,比如处理表头、异常等 + }).sheet().doRead(); + } catch (IOException e) { + e.printStackTrace(); + } + + return entities; + } + }