Эх сурвалжийг харах

B2B商务excel批量导入物料(直接整个文件传过来处理)

dongbw 7 жил өмнө
parent
commit
98abbba35a

+ 51 - 8
src/main/java/com/uas/ps/product/controller/ProductController.java

@@ -6,9 +6,14 @@ import com.uas.ps.core.util.CollectionUtils;
 import com.uas.ps.entity.Product;
 import com.uas.ps.entity.Status;
 import com.uas.ps.product.entity.Constant;
+import com.uas.ps.product.entity.FileUpload;
 import com.uas.ps.product.entity.Prod;
 import com.uas.ps.product.entity.ProductSaler;
+import com.uas.ps.product.exception.IllegalOperatorException;
 import com.uas.ps.product.service.ProductService;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
@@ -17,6 +22,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.ArrayList;
@@ -72,7 +79,7 @@ public class ProductController {
     }
 
     /**
-     * 新增、更新物料信息
+     * 更新物料信息(子应用做验证,这里只负责存)
      *
      * @param data 物料信息
      * @return
@@ -103,14 +110,15 @@ public class ProductController {
     /**
      * 一键匹配
      *
-     * @param enUU
-     * @param userUU
+     * @param enUU 企业UU
+     * @param userUU 用户UU
+     * @param type 匹配类型(在B2B中为all(全部)、sale(销售)、purc(采购))
      * @return
      */
-    @RequestMapping("/match")
+    @RequestMapping(value = "/match", method = RequestMethod.POST)
     @ResponseBody
-    public ModelMap match(@RequestParam Long enUU, @RequestParam Long userUU) {
-        return productService.match(enUU, userUU);
+    public ModelMap match(@RequestParam Long enUU, @RequestParam Long userUU, @RequestParam String type) {
+        return productService.match(enUU, userUU, type);
     }
 
     /**
@@ -151,7 +159,7 @@ public class ProductController {
     /**
      * 更新下载成功的状态
      *
-     * @param data
+     * @param data 下载成功的物料id
      * @throws UnsupportedEncodingException
      */
     @RequestMapping(value = "/refreshDownloadStatus", method = RequestMethod.POST)
@@ -164,7 +172,7 @@ public class ProductController {
      * UAS端禁用物料时调用此接口禁用此物料
      * 通过物料编码(code)
      *
-     * @param data
+     * @param data 包含enUU、code的map
      */
     @RequestMapping(value = "/updateEnabled", method = RequestMethod.POST)
     @ResponseBody
@@ -208,4 +216,39 @@ public class ProductController {
         productService.quitProdSaler(productSalers);
 //        logger.log("物料资料", "ERP取消个人物料同步到公共物料库", productSalers.size());
     }
+
+    /**
+     * 通过excel批量导入物料
+     *
+     * @param data excel文件及企业uu与用户uu(uploadItem, enUU, userUU)
+     * @return
+     */
+    @RequestMapping(value = "/import/excel", method = RequestMethod.POST)
+    public ModelMap releaseByExcel(@RequestParam("data") String data) throws UnsupportedEncodingException {
+        String json = URLDecoder.decode(data, "utf-8");
+        JSONObject jsonObject = JSONObject.parseObject(json, JSONObject.class);
+        FileUpload uploadItem = JSON.parseObject(String.valueOf(jsonObject.get("uploadItem")), FileUpload.class);
+        Long enUU = (Long) jsonObject.get("enUU");
+        Long userUU = (Long) jsonObject.get("userUU");
+        ModelMap map = new ModelMap();
+        String fileName = uploadItem.getFile().getOriginalFilename();
+        String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
+        InputStream is = null;
+        Workbook workbook = null;
+        try {
+            is = uploadItem.getFile().getInputStream();
+            if ("xls".equals(suffix)) {
+                workbook = new HSSFWorkbook(is);
+            } else if ("xlsx".equals(suffix)) {
+                workbook = new XSSFWorkbook(is);
+            } else {
+                throw new IllegalOperatorException("文件格不正确,请上传.xls或.xlsx的文件");
+            }
+            map = productService.releaseByWorkbook(workbook, enUU, userUU);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+//        logger.log("商品批次", "[" + userUU + "]通过excel导入了物料,数量为" + map.size());
+        return map;
+    }
 }

+ 8 - 4
src/main/java/com/uas/ps/product/controller/ProductUsersController.java

@@ -5,13 +5,17 @@ import com.alibaba.fastjson.JSONObject;
 import com.uas.ps.entity.Product;
 import com.uas.ps.entity.ProductUsers;
 import com.uas.ps.product.entity.FileUpload;
+import com.uas.ps.product.exception.IllegalOperatorException;
 import com.uas.ps.product.service.ProductUsersService;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.ui.ModelMap;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -48,7 +52,7 @@ public class ProductUsersController {
     }
 
     /**
-     * 通过excel批量导入物料
+     * 通过excel批量导入个人物料
      *
      * @param data excel文件及企业uu与用户uu(uploadItem, enUU, userUU)
      * @return
@@ -72,7 +76,7 @@ public class ProductUsersController {
             } else if ("xlsx".equals(suffix)) {
                 workbook = new XSSFWorkbook(is);
             } else {
-                throw new RuntimeException("文件格不正确,请上传.xls或.xlsx的文件");
+                throw new IllegalOperatorException("文件格不正确,请上传.xls或.xlsx的文件");
             }
             map = productUsersService.releaseByWorkbook(workbook, enUU, userUU);
         } catch (IOException e) {
@@ -83,7 +87,7 @@ public class ProductUsersController {
     }
 
     /**
-     * 新增物料
+     * 新增个人物料
      *
      * @param data  物料信息
      * @return

+ 22 - 0
src/main/java/com/uas/ps/product/exception/Error.java

@@ -0,0 +1,22 @@
+package com.uas.ps.product.exception;
+
+public class Error {
+
+	private int code;
+
+	private String msg;
+
+	public int code() {
+		return code;
+	}
+
+	public String msg() {
+		return msg;
+	}
+
+	public Error(int code, String msg) {
+		this.code = code;
+		this.msg = msg;
+	}
+
+}

+ 32 - 0
src/main/java/com/uas/ps/product/exception/IllegalOperatorException.java

@@ -0,0 +1,32 @@
+package com.uas.ps.product.exception;
+
+/**
+ * 非法操作
+ * 
+ * @author yingp
+ * 
+ */
+public class IllegalOperatorException extends RuntimeException {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 3958657497510022539L;
+
+	public IllegalOperatorException() {
+		super("非法操作");
+	}
+
+	public IllegalOperatorException(String paramString) {
+		super(paramString);
+	}
+
+	public IllegalOperatorException(String paramString, Throwable paramThrowable) {
+		super(paramString, paramThrowable);
+	}
+
+	public IllegalOperatorException(Throwable paramThrowable) {
+		super(paramThrowable);
+	}
+
+}

+ 61 - 0
src/main/java/com/uas/ps/product/exception/IllegalStatusException.java

@@ -0,0 +1,61 @@
+package com.uas.ps.product.exception;
+
+
+import com.uas.ps.entity.Status;
+
+/**
+ * 某些操作可能要求单据的状态必须是在录入或已审核等<br>
+ * 操作之前先检测单据状态,如果错误则抛出异常
+ * 
+ * @author yingp
+ * 
+ */
+public class IllegalStatusException extends RuntimeException {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 3958657497510022539L;
+
+	public IllegalStatusException() {
+	}
+
+	public IllegalStatusException(String paramString) {
+		super(paramString);
+	}
+
+	/**
+	 * 
+	 * 封装成格式为{%s 的状态为 %s}的异常信息并抛出
+	 * 
+	 * @param paramString
+	 *            描述
+	 * @param status
+	 *            状态
+	 */
+	public IllegalStatusException(String paramString, Status status) {
+		this(String.format("状态错误.%s 的状态为 %s", new Object[] { paramString, status.getPhrase() }));
+	}
+
+	/**
+	 * 
+	 * 封装成格式为{%s 的状态为 %s}的异常信息并抛出
+	 * 
+	 * @param param
+	 *            实体
+	 * @param status
+	 *            状态
+	 */
+	public IllegalStatusException(Object param, Status status) {
+		this(param.toString(), status);
+	}
+
+	public IllegalStatusException(String paramString, Throwable paramThrowable) {
+		super(paramString, paramThrowable);
+	}
+
+	public IllegalStatusException(Throwable paramThrowable) {
+		super(paramThrowable);
+	}
+
+}

+ 38 - 0
src/main/java/com/uas/ps/product/exception/NotFoundException.java

@@ -0,0 +1,38 @@
+package com.uas.ps.product.exception;
+
+/**
+ * 没有找到实体
+ * 
+ * @author yingp
+ *
+ */
+public class NotFoundException  extends RuntimeException{
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -2123298750254663463L;
+
+	public NotFoundException() {
+	}
+
+	/**
+	 * 
+	 * 封装成格式为{没有找到 %s}的异常信息并抛出
+	 * 
+	 * @param paramString
+	 *            描述
+	 */
+	public NotFoundException(String paramString) {
+		super(String.format("没有找到 %s", new Object[] { paramString}));
+	}
+
+	public NotFoundException(String paramString, Throwable paramThrowable) {
+		super(paramString, paramThrowable);
+	}
+
+	public NotFoundException(Throwable paramThrowable) {
+		super(paramThrowable);
+	}
+	
+}

+ 20 - 0
src/main/java/com/uas/ps/product/exception/SystemError.java

@@ -0,0 +1,20 @@
+package com.uas.ps.product.exception;
+
+public class SystemError extends RuntimeException {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1798462189805947475L;
+
+	private Error error;
+
+	public SystemError(Error error) {
+		this.error = error;
+	}
+
+	public Error getError() {
+		return error;
+	}
+
+}

+ 23 - 0
src/main/java/com/uas/ps/product/exception/SystemException.java

@@ -0,0 +1,23 @@
+package com.uas.ps.product.exception;
+
+/**
+ * 已捕获的异常
+ * 
+ * @author yingp
+ *
+ */
+public class SystemException extends RuntimeException {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -5786185080244656655L;
+
+	public SystemException() {
+	}
+
+	public SystemException(String paramString) {
+		super(paramString);
+	}
+
+}

+ 27 - 0
src/main/java/com/uas/ps/product/repository/ProductDao.java

@@ -68,4 +68,31 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
      * @return
      */
     List<Product> findByTitleAndPCmpCodeAndPBrandAndEnUU(String title, String cmpcode, String brand, Long enUU);
+
+//    /**
+//     * 通过uu查询非标准器件进行存储
+//     *
+//     * @param enuu
+//     * @return
+//     */
+//    @Procedure(procedureName = "PRODUCT$MATCHES")
+//    String updateResultByEnuu(Long enuu);
+//
+//    /**
+//     * 通过uu查询非标准器件进行存储
+//     *
+//     * @param enuu
+//     * @return
+//     */
+//    @Procedure(procedureName = "PRODUCT$MATCHES_SALE")
+//    String updateResultByEnuuForSale(Long enuu);
+//
+//    /**
+//     * 通过uu查询非标准器件进行存储
+//     *
+//     * @param enuu
+//     * @return
+//     */
+//    @Procedure(procedureName = "PRODUCT$MATCHES_PURC")
+//    String updateResultByEnuuForPurc(Long enuu);
 }

+ 21 - 0
src/main/java/com/uas/ps/product/repository/ProductStoreStatusDao.java

@@ -0,0 +1,21 @@
+package com.uas.ps.product.repository;
+
+import com.uas.ps.entity.ProductStoreStatus;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Created by dongbw
+ * 18/01/16 8:50.
+ */
+@Repository
+public interface ProductStoreStatusDao extends JpaSpecificationExecutor<ProductStoreStatus>, JpaRepository<ProductStoreStatus, Long> {
+
+    /**
+     * 根据企业UU查询物料存储状态
+     * @param enUU 企业UU
+     * @return
+     */
+    ProductStoreStatus findByEnuu(Long enUU);
+}

+ 15 - 3
src/main/java/com/uas/ps/product/service/ProductService.java

@@ -3,6 +3,7 @@ package com.uas.ps.product.service;
 import com.uas.ps.entity.Product;
 import com.uas.ps.product.entity.Prod;
 import com.uas.ps.product.entity.ProductSaler;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.ui.ModelMap;
 
 import java.util.List;
@@ -41,11 +42,12 @@ public interface ProductService {
     /**
      * 通过 enUU 查询非标准器件进行存储
      *
-     * @param enUU
-     * @param userUU
+     * @param enUU 企业UU
+     * @param userUU 用户UU
+     * @param type 匹配类型
      * @return
      */
-    ModelMap match(Long enUU, Long userUU);
+    ModelMap match(Long enUU, Long userUU, String type);
 
     /**
      * 分配个人物料
@@ -99,4 +101,14 @@ public interface ProductService {
      * @param productSalers
      */
     void quitProdSaler(List<ProductSaler> productSalers);
+
+    /**
+     * 批量导入物料信息
+     *
+     * @param workbook excel解析的物料信息
+     * @param enUU 企业UU
+     * @param userUU 用户UU
+     * @return
+     */
+    ModelMap releaseByWorkbook(Workbook workbook, Long enUU, Long userUU);
 }

+ 1 - 1
src/main/java/com/uas/ps/product/service/ProductUsersService.java

@@ -36,7 +36,7 @@ public interface ProductUsersService {
     void deleteById(Long id);
 
     /**
-     * 批量导入物料信息
+     * 批量导入个人物料信息
      *
      * @param workbook excel解析的物料信息
      * @param enUU 企业UU

+ 193 - 2
src/main/java/com/uas/ps/product/service/impl/ProductServiceImpl.java

@@ -3,17 +3,24 @@ package com.uas.ps.product.service.impl;
 import com.uas.ps.entity.Product;
 import com.uas.ps.entity.ProductUsers;
 import com.uas.ps.entity.Status;
+import com.uas.ps.product.entity.Constant;
 import com.uas.ps.product.entity.Prod;
 import com.uas.ps.product.entity.ProductSaler;
 import com.uas.ps.product.repository.ProductDao;
 import com.uas.ps.product.repository.ProductMatchResultDao;
+import com.uas.ps.product.repository.ProductStoreStatusDao;
 import com.uas.ps.product.repository.ProductUsersDao;
 import com.uas.ps.product.service.ProductService;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.ui.ModelMap;
 import org.springframework.util.CollectionUtils;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -34,6 +41,9 @@ public class ProductServiceImpl implements ProductService {
     @Autowired
     private ProductUsersDao productUsersDao;
 
+    @Autowired
+    private ProductStoreStatusDao productStoreStatusDao;
+
     /**
      * 保存物料
      *
@@ -73,9 +83,47 @@ public class ProductServiceImpl implements ProductService {
     }
 
     @Override
-    public ModelMap match(Long enUU, Long userUU) {
+    public ModelMap match(Long enUU, Long userUU, String matchtype) {
         ModelMap map = new ModelMap();
-        // TODO
+        //TODO
+//        boolean flag = true;
+//        ProductStoreStatus status = productStoreStatusDao.findByEnuu(enUU);
+//        if (status != null) {
+//            if (status.getStatus().equals(Status.RUNNING.value())) {// 有人正在操作这张单据,不能进行操作
+//                map.put("error", "当前有人正在进行匹配操作,无法进行匹配");
+//                flag = false;
+//            } else {
+//                status.setStatus(Status.RUNNING.value());
+//                status = productStoreStatusDao.save(status);
+//            }
+//        } else {
+//            ProductStoreStatus stroestatus = new ProductStoreStatus();
+//            stroestatus.setDate(new Date());
+//            stroestatus.setEnuu(enUU);
+//            stroestatus.setUseruu(userUU);
+//            stroestatus.setStatus(Status.RUNNING.value());
+//            status = productStoreStatusDao.save(stroestatus);
+//        }
+//        String num = null;
+//        if (flag) {
+//            if (matchtype.equals("sale")) {
+//                num = productDao.updateResultByEnuuForSale(enUU);
+////                logger.log("产品匹配", "一键匹配了产品信息", "大小" + num);
+//            } else if (matchtype.equals("purc")) {
+//                num = productDao.updateResultByEnuuForPurc(enUU);
+////                logger.log("物料匹配", "一键匹配了物料信息", "大小" + num);
+//            } else if (matchtype.equals("all")) {
+//                num = productDao.updateResultByEnuu(enUU);
+////                logger.log("物料匹配", "一键匹配了产品(物料)信息", "大小" + num);
+//            }
+//            if (null == num) {
+//                map.put("size", 0);
+//            } else {
+//                map.put("size", num);
+//            }
+//            status.setStatus(Status.FINISH.value());
+//            productStoreStatusDao.save(status);
+//        }
         return map;
     }
 
@@ -174,4 +222,147 @@ public class ProductServiceImpl implements ProductService {
             }
         }
     }
+
+    /**
+     * 批量导入物料信息
+     *
+     * @param workbook excel解析的物料信息
+     * @param enUU     企业UU
+     * @param userUU   用户UU
+     * @return
+     */
+    @Override
+    public ModelMap releaseByWorkbook(Workbook workbook, Long enUU, Long userUU) {
+        ModelMap modelMap = new ModelMap();
+        List<String> alters = new ArrayList<>();
+        List<String> infos = new ArrayList<>();
+        List<Product> products = new ArrayList<>();
+        List<Product> productsInfo = new ArrayList<>();
+        Sheet sheet = workbook.getSheetAt(0);
+        int rowNum = sheet.getLastRowNum();
+        Row headerRow = sheet.getRow(0);
+        int total = 0;
+        if (headerRow != null) {
+            for (int r = 3; r <= rowNum; r++) {
+                Row row = sheet.getRow(r);
+                if (row != null && row.getCell(0) != null && row.getCell(0).getCellType() != Cell.CELL_TYPE_BLANK) {
+                    total++;
+                    Product product = new Product();
+
+                    // 物料编号
+                    if (row.getCell(0) != null) {
+                        row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
+                        product.setCode(row.getCell(0).getStringCellValue().trim());
+                    }
+
+                    // 物料名称
+                    if (row.getCell(1) != null) {
+                        row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
+                        product.setTitle(row.getCell(1).getStringCellValue().trim());
+                    }
+
+                    // 原厂型号
+                    if (row.getCell(2) != null) {
+                        row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
+                        product.setCmpCode(row.getCell(2).getStringCellValue().trim());
+                        if (product.getCode() == null) {
+                            // 生成随机物料编码
+                            SimpleDateFormat sdf = new SimpleDateFormat("mmsssss");
+                            String code = enUU + sdf.format(new Date());
+                            product.setCode(code);
+                        }
+                    }
+
+                    // 品牌
+                    if (row.getCell(3) != null) {
+                        row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
+                        product.setBrand(row.getCell(3).getStringCellValue().trim());
+                    }
+
+                    // 单位
+                    if (row.getCell(4) != null) {
+                        row.getCell(4).setCellType(Cell.CELL_TYPE_STRING);
+                        product.setUnit(row.getCell(4).getStringCellValue().trim());
+                    }
+
+                    // 最小包装量
+                    if (row.getCell(5) != null) {
+                        row.getCell(5).setCellType(Cell.CELL_TYPE_STRING);
+                        if (null != row.getCell(5).getStringCellValue()
+                                && !row.getCell(5).getStringCellValue().trim().equals("")) {
+                            product.setMinPack(Double.valueOf(row.getCell(5).getStringCellValue()));
+                        }
+                    }
+                    // 最小订购量
+                    if (row.getCell(6) != null) {
+                        row.getCell(6).setCellType(Cell.CELL_TYPE_STRING);
+                        if (null != row.getCell(6).getStringCellValue().trim()
+                                && !row.getCell(6).getStringCellValue().trim().equals("")) {
+                            product.setMinOrder(Double.valueOf(row.getCell(6).getStringCellValue()));
+                        }
+                    }
+                    // 交货周期
+                    if (row.getCell(7) != null) {
+                        row.getCell(7).setCellType(Cell.CELL_TYPE_STRING);
+                        if (null != row.getCell(7).getStringCellValue().trim()
+                                && !row.getCell(7).getStringCellValue().trim().equals("")) {
+                            product.setLeadTime(Double.valueOf(row.getCell(7).getStringCellValue()));
+                        }
+                    }
+                    // 交货提前期
+                    if (row.getCell(8) != null) {
+                        row.getCell(8).setCellType(Cell.CELL_TYPE_STRING);
+                        if (null != row.getCell(8).getStringCellValue().trim()
+                                && !row.getCell(8).getStringCellValue().trim().equals("")) {
+                            product.setLtinstock(Double.valueOf(row.getCell(8).getStringCellValue()));
+                        }
+                    }
+                    // 判断是否存在
+                    List<Product> prods = productDao.findByEnUUAndCode(enUU, product.getCode());
+                    if (org.apache.commons.collections.CollectionUtils.isEmpty(prods)) {
+                    } else {
+                        Product oldProd = prods.get(0);
+                        if (oldProd.getIsSale() == null) {
+                            oldProd.setIsSale(Constant.YES);
+                            productDao.save(oldProd);
+                        }
+                        alters.add(product.getCode());
+                        product.setCode(null);
+                    }
+                    product.setEnUU(enUU);
+                    product.setUserUU(userUU);
+                    product.setSourceApp("B2B");
+                    product.setIsPubsale(Constant.NO);
+                    product.setIsShow(Constant.NO);
+                    product.setIsSale(Constant.YES);
+                    if (alters.size() > 0) {
+                        modelMap.put("alters", alters);
+                    }
+                    if (infos.size() > 0) {
+                        modelMap.put("infos", infos);
+                    }
+                    if (product.getCode() != null) {
+                        products.add(product);
+                    }
+                    if (product.getStandard() == null) {
+                        product.setStandard(Constant.NO);
+                    }
+                    product.setErpDate(new Date());
+                    productsInfo.add(product);
+                    modelMap.put("total", total);
+                    modelMap.put("products", productsInfo);
+                }
+            }
+            if (!org.apache.commons.collections.CollectionUtils.isEmpty(products)) {
+                try {
+                    products = productDao.save(products);
+//					saveUserOrders(products);
+                    modelMap.put("success", products.size());
+                } catch (Exception e) {
+                    modelMap.put("error", "存在编号相同的产品");
+                }
+            }
+        }
+        return modelMap;
+    }
 }