|
|
@@ -44,12 +44,15 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -91,6 +94,12 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
@Autowired
|
|
|
private CloudHostProper cloudHostProper;
|
|
|
|
|
|
+ // 允许的文件扩展名
|
|
|
+ private static final String[] ALLOWED_EXCEL_EXTENSIONS = {".xlsx", ".xls"};
|
|
|
+
|
|
|
+ // 最大文件大小(5MB)
|
|
|
+ private static final long MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
|
|
+
|
|
|
/**
|
|
|
* 查询订单列表
|
|
|
*/
|
|
|
@@ -99,19 +108,6 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
{
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
param.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
-
|
|
|
- // 郑多燕需求
|
|
|
- if("广州郑多燕".equals(cloudHostProper.getCompanyName())){
|
|
|
- // 根据当前销售所属的数据权限过滤订单;
|
|
|
- List<CompanyUser> companyUsers = companyUserService.getDataScopeCompanyUser(loginUser.getUser().getUserId());
|
|
|
- if(!companyUsers.isEmpty()){
|
|
|
- List<Long> companyUserIds = companyUsers.stream().map(CompanyUser::getUserId).collect(Collectors.toList());
|
|
|
- param.setCompanyUserIds(companyUserIds);
|
|
|
- } else {
|
|
|
- // 表示数据权限是本人
|
|
|
- param.setCompanyUserId(loginUser.getUser().getUserId());
|
|
|
- }
|
|
|
- }
|
|
|
startPage();
|
|
|
if(!StringUtils.isEmpty(param.getCreateTimeRange())){
|
|
|
param.setCreateTimeList(param.getCreateTimeRange().split("--"));
|
|
|
@@ -127,6 +123,91 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 发货单导出接口
|
|
|
+ * **/
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:exportShippingOrder')")
|
|
|
+ @GetMapping("/exportShippingOrder")
|
|
|
+ public AjaxResult exportShippingOrder(FsStoreOrderParam param){
|
|
|
+ if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
|
|
|
+ param.setBeginTime(null);
|
|
|
+ param.setEndTime(null);
|
|
|
+ }
|
|
|
+ if(fsStoreOrderService.isEntityNull(param)){
|
|
|
+ param = new FsStoreOrderParam();
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(param.getCreateTimeRange())){
|
|
|
+ param.setCreateTimeList(param.getCreateTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(param.getPayTimeRange())){
|
|
|
+ param.setPayTimeList(param.getPayTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
|
|
|
+ param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
|
|
|
+ param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ param.setNotHealth(1);
|
|
|
+ List<FsStoreOrderDeliveryNoteExportVO> storeOrderDeliveryNoteExportVOList=fsStoreOrderService.getDeliveryNote(param);
|
|
|
+ ExcelUtil<FsStoreOrderDeliveryNoteExportVO> util = new ExcelUtil<>(FsStoreOrderDeliveryNoteExportVO.class);
|
|
|
+ //通过商品ID获取关键字
|
|
|
+ String firstKeyword = storeOrderDeliveryNoteExportVOList.stream()
|
|
|
+ .map(FsStoreOrderDeliveryNoteExportVO::getKeyword)
|
|
|
+ .findFirst()
|
|
|
+ .orElse("无订单");
|
|
|
+ String fileName="077AC"+firstKeyword+new SimpleDateFormat("yyyyMMdd").format(new Date());
|
|
|
+ return util.exportExcel(storeOrderDeliveryNoteExportVOList, fileName);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //订单发货批量导入
|
|
|
+ @Log(title = "发货同步导入", businessType = BusinessType.IMPORT)
|
|
|
+ @PostMapping("/importDeliveryNoteExpress")
|
|
|
+ public R importDeliveryNoteExpress(@RequestParam("file") MultipartFile file, @RequestParam(name = "shipmentType",required = false) Integer shipmentType) {
|
|
|
+ // 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<FsStoreOrderDeliveryNoteExportVO> util=new ExcelUtil<>(FsStoreOrderDeliveryNoteExportVO.class);
|
|
|
+ try {
|
|
|
+ List<FsStoreOrderDeliveryNoteExportVO> dtoList = util.importExcel(file.getInputStream());
|
|
|
+ if(dtoList.isEmpty()){
|
|
|
+ return R.error("操作失败,导入数据不能小于1条!");
|
|
|
+ }
|
|
|
+ if(dtoList.size() > 200){
|
|
|
+ return R.error("操作失败,导入数据不能大于200条!");
|
|
|
+ }
|
|
|
+ if(shipmentType == null){
|
|
|
+ shipmentType = 2;
|
|
|
+ }
|
|
|
+ return fsStoreOrderService.importDeliveryNoteExpress(dtoList,null,shipmentType);
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.error("发货导入异常", e);
|
|
|
+ return R.error("导入失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isValidExcelFile(String fileName) {
|
|
|
+ for (String ext : ALLOWED_EXCEL_EXTENSIONS) {
|
|
|
+ if (fileName.toLowerCase().endsWith(ext)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@GetMapping("/allList")
|
|
|
public TableDataInfo allList(FsStoreOrderParam param)
|
|
|
{
|