qin преди 1 година
родител
ревизия
dca2aae48a

+ 4 - 19
src/main/java/com/poteviohealth/cgp/statistics/controller/OrderController.java

@@ -1,7 +1,6 @@
 package com.poteviohealth.cgp.statistics.controller;
 
 
-import com.aliyun.oss.OSSClient;
 import com.google.common.collect.Maps;
 import com.poteviohealth.cgp.common.controller.BaseWebController;
 import com.poteviohealth.cgp.common.exception.BusinessException;
@@ -28,7 +27,6 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
-import java.io.File;
 import java.util.List;
 import java.util.Map;
 
@@ -195,23 +193,10 @@ public class OrderController extends BaseWebController {
     @MethodTime
     public VaultsResponse uploadArrayFile(@RequestBody List<PriceUploadDto> list){
         log.info(list);
-        return ossUtils.uploadArrayFile(list);
-    }
-
-    public static void main(String[] args) {
-        String endpoint = "oss-cn-beijing.aliyuncs.com";
-        String accessKeyId = "LTAIKYgOt8D3W9kz";
-        String accessKeySecret = "yHszJ0sEyQXq90Ad7cxRh4Ake0qfbd";
-        String bucketName = "ptsubsidy";
-        String objectName = "yqaa/2408/S232618057175041N-39be3dc7-e478-4414-94bc-c6d4c9e03243.jpg"; // 上传到OSS的文件名
-        String filePath = "C:\\Users\\86180\\Desktop\\111.jpg"; // 本地文件路径
+        VaultsResponse<List<PriceUploadDto>> vaultsResponse = ossUtils.uploadArrayFile(list);
+        if(vaultsResponse.validate()){
 
-// 创建OSSClient实例。
-        //OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
-        OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
-        // 文件上传
-        ossClient.putObject(bucketName, objectName, new File(filePath));
-        //关闭OSSClient。
-        ossClient.shutdown();
+        }
+        return vaultsResponse;
     }
 }

+ 4 - 0
src/main/java/com/poteviohealth/cgp/statistics/mapper/OrderMapper.java

@@ -206,4 +206,8 @@ public interface OrderMapper extends BaseMapper<Order>{
     @SqlParser(filter=true)
     LinkedList<OrderCostWebOutDTO> costOrderExcel(@Param(Constants.WRAPPER) Wrapper wrapper,@Param("dbName")String dbName,@Param("operatorId")Integer operatorId,@Param("start")Integer start);
 
+    @SqlParser(filter = true)
+    int updateOrderUrl(@Param("operatorId")Integer operatorId, @Param("startUrl") String startUrl,@Param("endUrl") String endUrl,@Param("dbName") String dbName,@Param("orderId") Long orderId);
+
+
 }

+ 9 - 4
src/main/java/com/poteviohealth/cgp/statistics/service/IOrderService.java

@@ -1,11 +1,9 @@
 package com.poteviohealth.cgp.statistics.service;
 
+import com.poteviohealth.cgp.common.model.VaultsResponse;
 import com.poteviohealth.cgp.common.service.IBaseService;
 import com.poteviohealth.cgp.statistics.model.Order;
-import com.poteviohealth.cgp.statistics.model.indto.DishesOrderWebInDTO;
-import com.poteviohealth.cgp.statistics.model.indto.OrderCostWebInDTO;
-import com.poteviohealth.cgp.statistics.model.indto.OrderServiceWebInDTO;
-import com.poteviohealth.cgp.statistics.model.indto.OrderWebInDTO;
+import com.poteviohealth.cgp.statistics.model.indto.*;
 import com.poteviohealth.cgp.statistics.model.outdto.DishesOrderWebOutDTO;
 import com.poteviohealth.cgp.statistics.model.outdto.OrderCostWebOutDTO;
 import com.poteviohealth.cgp.statistics.model.outdto.OrderExcelDTO;
@@ -46,4 +44,11 @@ public interface IOrderService extends IBaseService<Order> {
      */
     List<OrderExcelDTO> excelList(OrderWebInDTO orderWebInDTO);
 
+    /**
+     * 更新图片地址
+     * @param list
+     * @return
+     */
+    VaultsResponse updateOrderUrl(List<PriceUploadDto> list);
+
 }

+ 31 - 4
src/main/java/com/poteviohealth/cgp/statistics/service/impl/OrderServiceImpl.java

@@ -21,14 +21,12 @@ import com.poteviohealth.cgp.common.integrated.order.model.PayAccount;
 import com.poteviohealth.cgp.common.integrated.partner.model.AreaDTO;
 import com.poteviohealth.cgp.common.integrated.partner.model.EmployeeStationFace;
 import com.poteviohealth.cgp.common.integrated.partner.model.EmployeeStationJsonFace;
+import com.poteviohealth.cgp.common.model.VaultsResponse;
 import com.poteviohealth.cgp.common.service.impl.BaseServiceImpl;
 import com.poteviohealth.cgp.statistics.constant.enums.OrderConstantEnum;
 import com.poteviohealth.cgp.statistics.mapper.OrderMapper;
 import com.poteviohealth.cgp.statistics.model.Order;
-import com.poteviohealth.cgp.statistics.model.indto.DishesOrderWebInDTO;
-import com.poteviohealth.cgp.statistics.model.indto.OrderCostWebInDTO;
-import com.poteviohealth.cgp.statistics.model.indto.OrderServiceWebInDTO;
-import com.poteviohealth.cgp.statistics.model.indto.OrderWebInDTO;
+import com.poteviohealth.cgp.statistics.model.indto.*;
 import com.poteviohealth.cgp.statistics.model.outdto.*;
 import com.poteviohealth.cgp.statistics.service.IOrderService;
 import lombok.extern.log4j.Log4j2;
@@ -316,6 +314,35 @@ public class OrderServiceImpl extends BaseServiceImpl<OrderMapper, Order> implem
         }
     }
 
+    @Override
+    public VaultsResponse updateOrderUrl(List<PriceUploadDto> list) {
+        List<String> startUrl = Lists.newArrayList();
+        List<String> endUrl = Lists.newArrayList();
+        Long orderId = null;
+        for (PriceUploadDto dto : list) {
+            orderId = dto.getOrderId();
+            if(dto.getIndex() <=3 && StringUtils.isNotEmpty(dto.getUrl())){
+                startUrl.add(dto.getUrl());
+            }else if(dto.getIndex() >3 && StringUtils.isNotEmpty(dto.getUrl())){
+                endUrl.add(dto.getUrl());
+            }
+        }
+        String start = "";
+        if(!startUrl.isEmpty()){
+            start = startUrl.stream().map(String::valueOf).collect(Collectors.joining(","));
+        }
+
+        String end = "";
+        if(!endUrl.isEmpty()){
+            end = endUrl.stream().map(String::valueOf).collect(Collectors.joining(","));
+        }
+
+        if(orderId != null){
+            baseMapper.updateOrderUrl(TokenContext.cureOperatorId(),start ,end , dbName, orderId);
+        }
+        return VaultsResponse.success();
+    }
+
 
     private String getPayAccountString(String payAccount){
         StringBuilder sb = new StringBuilder();

+ 2 - 5
src/main/java/com/poteviohealth/cgp/statistics/utils/OssUtils.java

@@ -48,7 +48,7 @@ public class OssUtils {
         if (pos != -1) {
             suffix = file.getName().substring(pos);
         }
-        String fileName = dir+"/S"+key+"N-"+ CgpTool.generateUUID() +suffix;
+        String fileName = dir+"S"+key+"N-"+ CgpTool.generateUUID() +suffix;
 
         try {
             // 创建PutObject请求。
@@ -82,9 +82,6 @@ public class OssUtils {
             return VaultsResponse.failed("关键参数为空");
         }
         // 创建OSSClient实例。
-        log.info("endPoint==="+endPoint);
-        log.info("accessKeyId==="+accessKeyId);
-        log.info("secretAccessKey==="+secretAccessKey);
         OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, secretAccessKey);
         try {
             //设置文件名
@@ -97,7 +94,7 @@ public class OssUtils {
                 if (pos != -1) {
                     suffix = uploadDto.getUrl().substring(pos);
                 }
-                String fileName = dir+"/S"+orderId+"N-"+ CgpTool.generateUUID() +suffix;
+                String fileName = dir+"S"+orderId+"N-"+ CgpTool.generateUUID() +suffix;
                 // 创建PutObject请求。
                 ossClient.putObject(bucketName, fileName, base64ToInputStream(uploadDto.getBase64()));
 

+ 4 - 0
src/main/resources/mapper/statistics/OrderMapper.xml

@@ -357,4 +357,8 @@
         order by o.id
             limit 10000
     </select>
+
+    <update id="updateOrderUrl">
+        update  ${dbName}_order.o_order_detail_${operatorId} set start_url=#{startUrl},end_url=#{endUrl} where order_id = #{orderId}
+    </update>
 </mapper>