|
@@ -6,11 +6,13 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fs.common.annotation.Log;
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
|
+import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
import com.fs.company.service.ICompanyMoneyLogsService;
|
|
|
+import com.fs.course.dto.FsOrderDeliveryNoteDTO;
|
|
|
import com.fs.erp.service.IErpOrderService;
|
|
|
import com.fs.his.service.IFsUserService;
|
|
|
import com.fs.hisStore.dto.StoreOrderProductDTO;
|
|
@@ -21,9 +23,8 @@ import com.fs.hisStore.vo.FsStoreOrderItemExportVO;
|
|
|
import com.fs.hisStore.vo.FsStoreOrderVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
@@ -51,6 +52,12 @@ public class FsStoreHealthOrderScrmController extends BaseController {
|
|
|
@Autowired
|
|
|
private ICompanyMoneyLogsService moneyLogsService;
|
|
|
|
|
|
+ // 允许的文件扩展名
|
|
|
+ private static final String[] ALLOWED_EXCEL_EXTENSIONS = {".xlsx", ".xls"};
|
|
|
+
|
|
|
+ // 最大文件大小(5MB)
|
|
|
+ private static final long MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
|
|
+
|
|
|
/**
|
|
|
* 查询健康商城订单列表
|
|
|
*/
|
|
@@ -173,4 +180,52 @@ public class FsStoreHealthOrderScrmController extends BaseController {
|
|
|
ExcelUtil<FsStoreOrderItemExportVO> util = new ExcelUtil<FsStoreOrderItemExportVO>(FsStoreOrderItemExportVO.class);
|
|
|
return util.exportExcel(list, "订单明细数据");
|
|
|
}
|
|
|
+
|
|
|
+ //订单发货批量导入
|
|
|
+ @Log(title = "发货同步导入", businessType = BusinessType.IMPORT)
|
|
|
+ @PostMapping("/importDeliveryNoteExpress")
|
|
|
+ public R importDeliveryNoteExpress(@RequestParam("file") MultipartFile file, @RequestParam("miniAppId") String miniAppId) {
|
|
|
+ // 1. 检查文件是否为空
|
|
|
+ if (file.isEmpty()) {
|
|
|
+ return R.error("上传的文件不能为空");
|
|
|
+ }
|
|
|
+ // 2. 检查文件大小
|
|
|
+ if (file.getSize() > MAX_FILE_SIZE) {
|
|
|
+ return R.error("文件大小不能超过5MB");
|
|
|
+ }
|
|
|
+ // 3. 检查文件扩展名
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ if (fileName == null || !isValidExcelFile(fileName)) {
|
|
|
+ return R.error("请上传Excel文件(.xlsx或.xls格式)");
|
|
|
+ }
|
|
|
+
|
|
|
+ ExcelUtil<FsOrderDeliveryNoteDTO> util=new ExcelUtil<>(FsOrderDeliveryNoteDTO.class);
|
|
|
+ try {
|
|
|
+ List<FsOrderDeliveryNoteDTO> dtoList = util.importExcel(file.getInputStream());
|
|
|
+ if(!dtoList.isEmpty()){
|
|
|
+ fsStoreOrderService.importDeliveryNoteExpress(dtoList,miniAppId);
|
|
|
+ }else {
|
|
|
+ R.error("操作失败,导入数据不能小于1条!");
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.getStackTrace();
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/importDeliveryNoteExpressTemplate")
|
|
|
+ public AjaxResult importTemplate() {
|
|
|
+ ExcelUtil<FsOrderDeliveryNoteDTO> util = new ExcelUtil<>(FsOrderDeliveryNoteDTO.class);
|
|
|
+ return util.importTemplateExcel("订单发货导入模板");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查文件是否为有效的Excel文件
|
|
|
+ private boolean isValidExcelFile(String fileName) {
|
|
|
+ for (String ext : ALLOWED_EXCEL_EXTENSIONS) {
|
|
|
+ if (fileName.toLowerCase().endsWith(ext)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|