huliguo
3 天以前 5a7486e9893a706ed464e3197c9711286b077896
文件导入
6个文件已修改
126 ■■■■ 已修改文件
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserPointMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargeOrderController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/ChargeOrderService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ChargeOrderServiceImpl.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -39,14 +39,23 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
@@ -622,7 +631,7 @@
     * @param file
     * @return
     */
    @PostMapping("/upload")
 /*   @PostMapping("/upload")
    public R upload(MultipartFile file){
        String s = null;
        try {
@@ -631,9 +640,77 @@
            throw new RuntimeException(e);
        }
        return R.ok(s);
    }*/
    private static final String FILE_DIRECTORY = "/var/files/ldf_files"; // Linux路径
//    private static final String FILE_DIRECTORY = "E://ldf_files"; // Linux路径
    @PostMapping("/upload")
    public R handleFileUpload(@RequestParam("file") MultipartFile file) {
        if (file.isEmpty()) {
            return R.fail("请选择一个文件上传");
        }
        try {
            // 1. 构建日期目录路径(格式:/年/月/日)
            LocalDate today = LocalDate.now();
            String datePath = String.format("/%d/%02d/%02d",
                    today.getYear(), today.getMonthValue(), today.getDayOfMonth());
            // 2. 完整目标目录路径
            String fullDirPath = FILE_DIRECTORY + datePath;
            File targetDir = new File(fullDirPath);
            // 3. 自动创建目录(如果不存在)
            if (!targetDir.exists()) {
                targetDir.mkdirs(); // 递归创建所有父目录
            }
            String UUID= java.util.UUID.randomUUID().toString();
            // 4. 保存文件
            String filePath = fullDirPath + "/" +UUID+ file.getOriginalFilename();
            File targetFile = new File(filePath);
            file.transferTo(targetFile);
            // 5. 返回可访问的URL(修正路径分隔符为Web格式)
            return R.ok("http://zjrqxny.com/account/app-user/download" + datePath + "/" + UUID+file.getOriginalFilename());
        } catch (IOException e) {
            e.printStackTrace();
            return R.fail("上传文件失败");
        }
    }
    @GetMapping("/download/{year}/{month}/{day}/{fileName:.+}")
    @ResponseBody
    public ResponseEntity<org.springframework.core.io.Resource> downloadFile( @PathVariable String year,
                                                                              @PathVariable String month,
                                                                              @PathVariable String day,
                                                                              @PathVariable String fileName) {
        System.out.println("下载文件名:"+fileName);
        try {
            // 1. 解码文件名
            String decodedFileName = URLDecoder.decode(fileName, "UTF-8");
            java.nio.file.Path filePath = java.nio.file.Paths.get(FILE_DIRECTORY, year, month, day, decodedFileName).normalize();
            org.springframework.core.io.Resource resource = new org.springframework.core.io.UrlResource(filePath.toUri());
            if (resource.exists() || resource.isReadable()) {
                // 5. 设置下载头(兼容所有浏览器)
                String contentDisposition = "attachment; filename=\"" + decodedFileName + "\"; " +
                        "filename*=UTF-8''" + URLEncoder.encode(decodedFileName, "UTF-8").replace("+", "%20");
                return ResponseEntity.ok()
                        .contentType(MediaType.APPLICATION_OCTET_STREAM)
                        .header(HttpHeaders.CONTENT_DISPOSITION, contentDisposition)
                        .body(resource);
            } else {
                return ResponseEntity.notFound().build();
            }
        } catch (IOException ex) {
            ex.printStackTrace();
            return ResponseEntity.status(500).build();
        }
    }
    /**
     * 清空绑定门店的用户门店数据
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserPointMapper.xml
@@ -133,7 +133,7 @@
        tp.create_time,
        CASE
        WHEN tp.type = 17 THEN tp.extention  -- 当 type=17 时取 extention
        ELSE CAST(tp.object_id AS VARCHAR)     -- 否则取 object_id 的字符串形式
        ELSE CAST(tp.object_id AS CHAR)     -- 否则取 object_id 的字符串形式
        END AS objectIdStr
        from
        t_user_point tp
@@ -167,7 +167,7 @@
        tp.object_id,
        CASE
        WHEN tp.type = 17 THEN tp.extention  -- 当 type=17 时取 extention
        ELSE CAST(tp.object_id AS VARCHAR)     -- 否则取 object_id 的字符串形式
        ELSE CAST(tp.object_id AS CHAR)     -- 否则取 object_id 的字符串形式
        END AS objectIdStr,
        tp.create_time
        from
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargeOrderController.java
@@ -9,6 +9,7 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
@@ -23,10 +24,13 @@
     * 导入充电信息
     */
    @PostMapping("/importExpress")
    public R importExpress(@RequestBody String url) {
        JSONObject jsonObject = JSONObject.parseObject(url);
        String url2 = jsonObject.getString("url");
        chargeOrderService.importExpress(url2);
    public R importExpress(@RequestParam("file") MultipartFile file) {
       /* JSONObject jsonObject = JSONObject.parseObject(url);
        String url2 = jsonObject.getString("url");*/
        if (file.isEmpty()) {
            return R.fail("请选择要上传的文件");
        }
        chargeOrderService.importExpress(file);
        return R.ok();
    }
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/ChargeOrderService.java
@@ -5,9 +5,10 @@
import com.ruoyi.order.dto.GetImportOrderDTO;
import com.ruoyi.order.model.ChargeOrder;
import com.ruoyi.order.model.Order;
import org.springframework.web.multipart.MultipartFile;
public interface ChargeOrderService extends IService<ChargeOrder> {
    void importExpress(String url);
    void importExpress(MultipartFile file);
    PageInfo<ChargeOrder> getUserPointPageList(GetImportOrderDTO getImportOrderDTO);
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ChargeOrderServiceImpl.java
@@ -30,6 +30,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
@@ -37,6 +38,8 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.time.LocalDateTime;
import java.time.LocalTime;
@@ -65,17 +68,22 @@
    @Override
    public void importExpress(String url) {
    public void importExpress(MultipartFile file) {
 /*       System.out.println("导入订单url:"+url);
        URL url1 = null;
        try {
            url1 = new URL(url);
            String encodedUrl = new URI(url).toASCIIString();
            url1 = new URL(encodedUrl);
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }*/
        List<String> orderNumberList=new ArrayList<>();
        try (InputStream fileInputStream = url1.openStream()) {
            Workbook workbook = new XSSFWorkbook(fileInputStream);
        try (InputStream inputStream = file.getInputStream();
             Workbook workbook = new XSSFWorkbook(inputStream)) {
//            Workbook workbook = new XSSFWorkbook(fileInputStream);
            Sheet sheet = workbook.getSheetAt(0); // 获取第一个Sheet
            int lastRowNum = sheet.getLastRowNum();
            for (int i = 1; i <= lastRowNum; i++) {//第二行开始
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -1093,9 +1093,9 @@
        shopBalanceStatement.setObjectId(order.getId());
        shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatement);
        Map<String, String> payParams = new HashMap<>();
        payParams.put("payMethod","3");//给前端标识 3-不需要调微信支付
        payParams.put("orderId",order.getId().toString());
        return R.ok(JSON.toJSONString(payParams));
//        payParams.put("payMethod","3");//给前端标识 3-不需要调微信支付
//        payParams.put("orderId",order.getId().toString());
        return R.ok(order.getId().toString());
    }
    /**