Browse Source

完善代码

yuansh 2 tháng trước cách đây
mục cha
commit
74cbfc8878

+ 71 - 1
srm-module-code/src/main/java/org/jeecg/modules/baseCode/controller/BaseShipArchiveController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.baseCode.controller;
 
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
@@ -21,8 +22,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 
 import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -212,7 +217,72 @@ public class BaseShipArchiveController extends JeecgController<BaseShipArchive,
     @RequiresPermissions("baseCode:base_ship_archive:importExcel")
     @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        return super.importExcel(request, response, BaseShipArchive.class);
+        return  importExcel(request, response, BaseShipArchive.class);
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    protected Result<?> importExcel(HttpServletRequest request, HttpServletResponse response, Class<BaseShipArchive> clazz) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            // 获取上传文件对象
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<BaseShipArchive> list = ExcelImportUtil.importExcel(file.getInputStream(), clazz, params);
+                //update-begin-author:taoyan date:20190528 for:批量插入数据
+                long start = System.currentTimeMillis();
+
+                for(BaseShipArchive o:list){
+                    String imo = o.getImo();
+                    QueryWrapper<BaseShipArchive> queryWrapper = new QueryWrapper();
+                    queryWrapper.eq("imo", imo);
+                    queryWrapper.eq("del_flag", "0");
+
+                    List<BaseShipArchive> list2 = baseShipArchiveService.list(queryWrapper);
+                    if (list2.size() != 0) {
+                        continue;
+                    }
+
+                    service.save(o);
+                }
+
+
+
+//                service.saveBatch(list);
+                //400条 saveBatch消耗时间1592毫秒  循环插入消耗时间1947毫秒
+                //1200条  saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒
+                log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
+                //update-end-author:taoyan date:20190528 for:批量插入数据
+                return Result.ok("文件导入成功!数据行数:" + list.size());
+            } catch (Exception e) {
+                //update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
+                String msg = e.getMessage();
+                log.error(msg, e);
+                if(msg!=null && msg.indexOf("Duplicate entry")>=0){
+                    return Result.error("文件导入失败:有重复数据!");
+                }else{
+                    return Result.error("文件导入失败:" + e.getMessage());
+                }
+                //update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.error("文件导入失败!");
     }
 
 }

+ 15 - 0
srm-module-code/src/main/java/org/jeecg/modules/cuspCode/controller/CuspCustomerProfileController.java

@@ -287,6 +287,21 @@ public class CuspCustomerProfileController {
               List<CuspCustomerProfilePage> list = ExcelImportUtil.importExcel(file.getInputStream(), CuspCustomerProfilePage.class, params);
               for (CuspCustomerProfilePage page : list) {
                   CuspCustomerProfile po = new CuspCustomerProfile();
+
+                  String name = page.getName();
+				  QueryWrapper<CuspCustomerProfile> queryWrapper = new QueryWrapper();
+				  queryWrapper.eq("name", name);
+				  queryWrapper.eq("del_flag", "0");
+
+				  List<CuspCustomerProfile> list2 = cuspCustomerProfileService.list(queryWrapper);
+				  if (list2.size() != 0) {
+					  continue;
+				  }
+				  Result<String> result = serialPatternService.getNextSerial("cusp_customer_profile", "code");
+				  if (!result.isSuccess()) {
+					  return result;
+				  }
+				  page.setCode(result.getMessage());
                   BeanUtils.copyProperties(page, po);
                   cuspCustomerProfileService.saveMain(po, page.getCuspCustomerProfileManList());
               }

+ 26 - 0
srm-module-code/src/main/java/org/jeecg/modules/purCode/service/impl/PurPaymentRequestServiceImpl.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Collection;
 
@@ -30,6 +31,18 @@ public class PurPaymentRequestServiceImpl extends ServiceImpl<PurPaymentRequestM
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void saveMain(PurPaymentRequest purPaymentRequest, List<PurPaymentRequestDetails> purPaymentRequestDetailsList) {
+
+		BigDecimal approveMoney = BigDecimal.ZERO;
+		if(purPaymentRequestDetailsList!=null && purPaymentRequestDetailsList.size()>0) {
+			for(PurPaymentRequestDetails entity:purPaymentRequestDetailsList) {
+
+				BigDecimal applyMoney = entity.getApplyMoney() == null ? BigDecimal.ZERO : entity.getApplyMoney();
+				approveMoney = approveMoney.add(applyMoney);
+			}
+		}
+
+		purPaymentRequest.setApproveMoney(approveMoney);
+
 		purPaymentRequestMapper.insert(purPaymentRequest);
 		if(purPaymentRequestDetailsList!=null && purPaymentRequestDetailsList.size()>0) {
 			for(PurPaymentRequestDetails entity:purPaymentRequestDetailsList) {
@@ -43,6 +56,19 @@ public class PurPaymentRequestServiceImpl extends ServiceImpl<PurPaymentRequestM
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void updateMain(PurPaymentRequest purPaymentRequest,List<PurPaymentRequestDetails> purPaymentRequestDetailsList) {
+
+		BigDecimal approveMoney = BigDecimal.ZERO;
+		if(purPaymentRequestDetailsList!=null && purPaymentRequestDetailsList.size()>0) {
+			for(PurPaymentRequestDetails entity:purPaymentRequestDetailsList) {
+
+				BigDecimal applyMoney = entity.getApplyMoney() == null ? BigDecimal.ZERO : entity.getApplyMoney();
+				approveMoney = approveMoney.add(applyMoney);
+			}
+		}
+
+		purPaymentRequest.setApproveMoney(approveMoney);
+
+
 		purPaymentRequestMapper.updateById(purPaymentRequest);
 		
 		//1.先删除子表数据

+ 3 - 2
srm-module-code/src/main/java/org/jeecg/modules/saleCode/entity/SaleInvoice.java

@@ -161,11 +161,12 @@ public class SaleInvoice implements Serializable {
 	@Excel(name = "备注(notes)", width = 15)
     @ApiModelProperty(value = "备注(notes)")
     private String notes;
-	/**来源*/
+
+	/**来源 发货单*/
 	@Excel(name = "来源", width = 15)
     @ApiModelProperty(value = "来源")
     private String sourceCode;
-	/**来源2*/
+	/**来源2 佣金订单*/
 	@Excel(name = "来源2", width = 15)
     @ApiModelProperty(value = "来源2")
     private String sourceCode2;

+ 1 - 1
srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/impl/SaleInvoiceServiceImpl.java

@@ -44,7 +44,7 @@ public class SaleInvoiceServiceImpl extends ServiceImpl<SaleInvoiceMapper, SaleI
 			saleInvoice.setOrderNumber(sourceCode);
 		}
 		if(StringUtils.isNotBlank(sourceCode2)){
-			saleInvoice.setOrderNumber(sourceCode);
+			saleInvoice.setOrderNumber(sourceCode2);
 		}
 
 		BigDecimal taxMoneyHead = BigDecimal.ZERO;