Browse Source

收费标准导入

jz.kai 2 years ago
parent
commit
44ffcf70e2

+ 1 - 0
common/src/main/java/com/jpsoft/prices/modules/base/dao/CompanyDAO.java

@@ -15,4 +15,5 @@ public interface CompanyDAO {
 	int delete(String id);
 	List<Company> list();
 	List<Company> search(Map<String,Object> searchParams,List<Sort> sortList);
+	Company getByName(String name);
 }

+ 10 - 8
common/src/main/java/com/jpsoft/prices/modules/base/dao/DestinationDAO.java

@@ -1,6 +1,8 @@
 package com.jpsoft.prices.modules.base.dao;
 
 import java.util.List;
+
+import com.jpsoft.prices.modules.base.entity.Destination;
 import org.springframework.stereotype.Repository;
 
 import java.util.Map;
@@ -8,14 +10,14 @@ import com.jpsoft.prices.modules.common.dto.Sort;
 
 @Repository
 public interface DestinationDAO {
-	int insert(com.jpsoft.prices.modules.base.entity.Destination entity);
-	int update(com.jpsoft.prices.modules.base.entity.Destination entity);
+	int insert(Destination entity);
+	int update(Destination entity);
 	int exist(String id);
-	com.jpsoft.prices.modules.base.entity.Destination get(String id);
+	Destination get(String id);
 	int delete(String id);
-	List<com.jpsoft.prices.modules.base.entity.Destination> list();
-	List<com.jpsoft.prices.modules.base.entity.Destination> search(Map<String,Object> searchParams, List<Sort> sortList);
-	List<com.jpsoft.prices.modules.base.entity.Destination> getListByParentId(String parentId);
-	com.jpsoft.prices.modules.base.entity.Destination getByName(String name);
-	List<com.jpsoft.prices.modules.base.entity.Destination> listByParentId(String parentId);
+	List<Destination> list();
+	List<Destination> search(Map<String,Object> searchParams, List<Sort> sortList);
+	List<Destination> getListByParentId(String parentId);
+	List<Destination> findByName(String name);
+	List<Destination> listByParentId(String parentId);
 }

+ 1 - 0
common/src/main/java/com/jpsoft/prices/modules/base/service/CompanyService.java

@@ -14,4 +14,5 @@ public interface CompanyService {
 	int delete(String id);
 	List<Company> list();
 	Page<Company> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
+	Company getByName(String name);
 }

+ 9 - 8
common/src/main/java/com/jpsoft/prices/modules/base/service/DestinationService.java

@@ -4,17 +4,18 @@ import java.util.List;
 import java.util.Map;
 
 import com.github.pagehelper.Page;
+import com.jpsoft.prices.modules.base.entity.Destination;
 import com.jpsoft.prices.modules.common.dto.Sort;
 
 public interface DestinationService {
-	com.jpsoft.prices.modules.base.entity.Destination get(String id);
+	Destination get(String id);
 	boolean exist(String id);
-	int insert(com.jpsoft.prices.modules.base.entity.Destination model);
-	int update(com.jpsoft.prices.modules.base.entity.Destination model);
+	int insert(Destination model);
+	int update(Destination model);
 	int delete(String id);
-	List<com.jpsoft.prices.modules.base.entity.Destination> list();
-	Page<com.jpsoft.prices.modules.base.entity.Destination> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
-	List<com.jpsoft.prices.modules.base.entity.Destination> getListByParentId(String parentId);
-	com.jpsoft.prices.modules.base.entity.Destination getByName(String name);
-	List<com.jpsoft.prices.modules.base.entity.Destination> listByParentId(String parentId);
+	List<Destination> list();
+	Page<Destination> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
+	List<Destination> getListByParentId(String parentId);
+	List<Destination> findByName(String name);
+	List<Destination> listByParentId(String parentId);
 }

+ 6 - 0
common/src/main/java/com/jpsoft/prices/modules/base/service/impl/CompanyServiceImpl.java

@@ -67,4 +67,10 @@ public class CompanyServiceImpl implements CompanyService {
         
         return page;
 	}
+
+	@Override
+	public Company getByName(String name) {
+		// TODO Auto-generated method stub
+		return companyDAO.getByName(name);
+	}
 }

+ 12 - 10
common/src/main/java/com/jpsoft/prices/modules/base/service/impl/DestinationServiceImpl.java

@@ -3,6 +3,8 @@ package com.jpsoft.prices.modules.base.service.impl;
 import java.util.List;
 import java.util.Map;
 import javax.annotation.Resource;
+
+import com.jpsoft.prices.modules.base.entity.Destination;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 import com.github.pagehelper.Page;
@@ -16,13 +18,13 @@ public class DestinationServiceImpl implements com.jpsoft.prices.modules.base.se
 	private com.jpsoft.prices.modules.base.dao.DestinationDAO destinationDAO;
 
 	@Override
-	public com.jpsoft.prices.modules.base.entity.Destination get(String id) {
+	public Destination get(String id) {
 		// TODO Auto-generated method stub
 		return destinationDAO.get(id);
 	}
 
 	@Override
-	public int insert(com.jpsoft.prices.modules.base.entity.Destination model) {
+	public int insert(Destination model) {
 		// TODO Auto-generated method stub
 		//model.setId(UUID.randomUUID().toString());
 		
@@ -30,7 +32,7 @@ public class DestinationServiceImpl implements com.jpsoft.prices.modules.base.se
 	}
 
 	@Override
-	public int update(com.jpsoft.prices.modules.base.entity.Destination model) {
+	public int update(Destination model) {
 		// TODO Auto-generated method stub
 		return destinationDAO.update(model);
 	}
@@ -50,14 +52,14 @@ public class DestinationServiceImpl implements com.jpsoft.prices.modules.base.se
 	}
 	
 	@Override
-	public List<com.jpsoft.prices.modules.base.entity.Destination> list() {
+	public List<Destination> list() {
 		// TODO Auto-generated method stub
 		return destinationDAO.list();
 	}
 		
 	@Override
-	public Page<com.jpsoft.prices.modules.base.entity.Destination> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList) {
-        Page<com.jpsoft.prices.modules.base.entity.Destination> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
+	public Page<Destination> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList) {
+        Page<Destination> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
             destinationDAO.search(searchParams,sortList);
         });
         
@@ -65,19 +67,19 @@ public class DestinationServiceImpl implements com.jpsoft.prices.modules.base.se
 	}
 
 	@Override
-	public List<com.jpsoft.prices.modules.base.entity.Destination> getListByParentId(String parentId){
+	public List<Destination> getListByParentId(String parentId){
 		// TODO Auto-generated method stub
 		return destinationDAO.getListByParentId(parentId);
 	}
 
 	@Override
-	public com.jpsoft.prices.modules.base.entity.Destination getByName(String name) {
+	public List<Destination> findByName(String name) {
 		// TODO Auto-generated method stub
-		return destinationDAO.getByName(name);
+		return destinationDAO.findByName(name);
 	}
 
 	@Override
-	public List<com.jpsoft.prices.modules.base.entity.Destination> listByParentId(String parentId){
+	public List<Destination> listByParentId(String parentId){
 		// TODO Auto-generated method stub
 		return destinationDAO.listByParentId(parentId);
 	}

+ 6 - 0
common/src/main/resources/mapper/base/Company.xml

@@ -93,4 +93,10 @@
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+	<select id="getByName" parameterType="string" resultMap="CompanyMap">
+		select * from base_company
+		where del_flag = 0
+		and name_ = #{0}
+		limit 1
+	</select>
 </mapper>

+ 1 - 2
common/src/main/resources/mapper/base/Destination.xml

@@ -114,11 +114,10 @@ id_,parent_id,code_,name_,mileage_,del_flag,create_time,create_by,update_time,up
 		and parent_id = #{parentId}
 		ORDER BY create_time ASC
 	</select>
-	<select id="getByName" parameterType="string" resultMap="DestinationMap">
+	<select id="findByName" parameterType="string" resultMap="DestinationMap">
 		select * from base_destination
 		where del_flag=0
 		and name_=#{0}
-		limit 1
 	</select>
 	<select id="listByParentId" resultMap="DestinationMap">
 		SELECT * FROM base_destination

+ 257 - 26
web/src/main/java/com/jpsoft/prices/modules/base/controller/StandardController.java

@@ -2,6 +2,10 @@ package com.jpsoft.prices.modules.base.controller;
 
 import com.github.pagehelper.Page;
 import com.jpsoft.prices.config.OSSConfig;
+import com.jpsoft.prices.modules.base.entity.Company;
+import com.jpsoft.prices.modules.base.entity.Destination;
+import com.jpsoft.prices.modules.base.service.CompanyService;
+import com.jpsoft.prices.modules.base.service.DestinationService;
 import com.jpsoft.prices.modules.common.utils.OSSUtil;
 import com.jpsoft.prices.modules.common.utils.POIUtils;
 import com.jpsoft.prices.modules.common.utils.PojoUtils;
@@ -9,6 +13,8 @@ import com.jpsoft.prices.modules.common.dto.Sort;
 import com.jpsoft.prices.modules.common.dto.MessageResult;
 import com.jpsoft.prices.modules.base.entity.Standard;
 import com.jpsoft.prices.modules.base.service.StandardService;
+import com.jpsoft.prices.modules.sys.entity.DataDictionary;
+import com.jpsoft.prices.modules.sys.service.DataDictionaryService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -25,6 +31,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletRequest;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -38,6 +45,12 @@ public class StandardController {
     private OSSConfig ossConfig;
     @Autowired
     private StandardService standardService;
+    @Autowired
+    private CompanyService companyService;
+    @Autowired
+    private DestinationService destinationService;
+    @Autowired
+    private DataDictionaryService dataDictionaryService;
 
     @ApiOperation(value="创建空记录")
     @GetMapping("create")
@@ -252,35 +265,247 @@ public class StandardController {
 
             int insertCount = 0;
             int failCount = 0;
-            int validateColIndex = 2;
+            int validateColIndex = 15;
 
             for(int rowIndex=1; rowIndex<=sheet1.getLastRowNum(); rowIndex++){
                 try {
-                    String strArea = poiUtils.getCellValue(0,rowIndex,0).toString();
-                    String strName = poiUtils.getCellValue(0,rowIndex,1).toString();
-
-//                    Office office = officeList.get(0);
-//                    office.setUpdateBy(subject);
-//                    office.setUpdateTime(new Date());
-
-//                    if(StringUtils.isNotEmpty(strArea)){
-//                        Area area = areaService.getByName(strArea);
-//                        if(area != null) {
-//                            office.setAreaId(area.getId());
-//                        }
-//                        else{
-//                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("未找到该区域!");
-//                            failCount++;
-//                            continue;
-//                        }
-//                    }
-//                    else{
-//                        sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("请填写区域!");
-//                        failCount++;
-//                        continue;
-//                    }
-//
-//                    standardService.update(office);
+                    String strCompany = poiUtils.getCellValue(0,rowIndex,0).toString();
+                    String strParentDestination = poiUtils.getCellValue(0,rowIndex,1).toString();
+                    String strDestination = poiUtils.getCellValue(0,rowIndex,2).toString();
+                    String strLogic = poiUtils.getCellValue(0,rowIndex,3).toString();
+                    String strUnitPrice = poiUtils.getCellValue(0,rowIndex,4).toString();
+                    String strUnitName = poiUtils.getCellValue(0,rowIndex,5).toString();
+                    String strFirstWeight = poiUtils.getCellValue(0,rowIndex,6).toString();
+                    String strStartingPrice = poiUtils.getCellValue(0,rowIndex,7).toString();
+                    String strGuaranteedPrice = poiUtils.getCellValue(0,rowIndex,8).toString();
+                    String strDiscount = poiUtils.getCellValue(0,rowIndex,9).toString();
+                    String strDeliveryFee = poiUtils.getCellValue(0,rowIndex,10).toString();
+                    String strStorageFee = poiUtils.getCellValue(0,rowIndex,11).toString();
+                    String strInsureFee = poiUtils.getCellValue(0,rowIndex,12).toString();
+                    String strTaxFee = poiUtils.getCellValue(0,rowIndex,13).toString();
+                    String strReceiptFee = poiUtils.getCellValue(0,rowIndex,14).toString();
+
+                    Standard standard = new Standard();
+                    standard.setId(UUID.randomUUID().toString());
+                    standard.setDelFlag(false);
+                    standard.setCreateBy(subject);
+                    standard.setCreateTime(new Date());
+
+                    if(StringUtils.isNotEmpty(strCompany)){
+                        Company company = companyService.getByName(strCompany);
+                        if(company != null) {
+                            standard.setCompanyId(company.getId());
+                        }
+                        else{
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("未找到该公司!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+                    else{
+                        sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("请填写公司!");
+                        failCount++;
+                        continue;
+                    }
+
+                    if(StringUtils.isNotEmpty(strDestination)){
+                        List<Destination> destinations = destinationService.findByName(strDestination);
+                        if(destinations.size() == 1) {
+                            standard.setDestinationId(destinations.get(0).getId());
+                        }
+                        else if(destinations.size() > 1) {
+                            Boolean bl = false;
+                            for(Destination destination : destinations) {
+                                Destination parent = destinationService.get(destination.getParentId());
+                                if (parent.getName().equals(strParentDestination)) {
+                                    standard.setDestinationId(destination.getId());
+                                    bl = true;
+                                }
+                            }
+                            if(!bl){
+                                sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("未找到该目的地!");
+                                failCount++;
+                                continue;
+                            }
+                        }
+                        else{
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("未找到该目的地!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+                    else{
+                        sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("请填写目的地!");
+                        failCount++;
+                        continue;
+                    }
+
+                    if(StringUtils.isNotEmpty(strLogic)){
+                        DataDictionary dataDictionary = dataDictionaryService.findByName(strLogic);
+                        if(dataDictionary != null) {
+                            standard.setLogicId(dataDictionary.getId());
+                        }
+                        else{
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("未找到该运费逻辑!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+                    else{
+                        sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("请填写运费逻辑!");
+                        failCount++;
+                        continue;
+                    }
+
+                    if(StringUtils.isNotEmpty(strUnitPrice)){
+                        if(checkedNumber(strUnitPrice)){
+                            standard.setUnitPrice(new BigDecimal(strUnitPrice));
+                        }
+                        else{
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("单价数据类型错误!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+                    else{
+                        sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("请填写单价!");
+                        failCount++;
+                        continue;
+                    }
+
+                    if(StringUtils.isNotEmpty(strUnitName)) {
+                        if (StringUtils.isNotEmpty(strUnitName)) {
+                            standard.setUnitName(strUnitName);
+                        } else {
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("请填写单位!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+                    else{
+                        sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("请填写单位!");
+                        failCount++;
+                        continue;
+                    }
+
+                    if(StringUtils.isNotEmpty(strFirstWeight)) {
+                        if (checkedNumber(strFirstWeight)) {
+                            standard.setFirstWeight(new BigDecimal(strFirstWeight));
+                        } else {
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("首重数据类型错误!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+                    else{
+                        standard.setFirstWeight(new BigDecimal(0));
+                    }
+
+                    if(StringUtils.isNotEmpty(strStartingPrice)) {
+                        if (checkedNumber(strStartingPrice)) {
+                            standard.setStartingPrice(new BigDecimal(strStartingPrice));
+                        } else {
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("起步价数据类型错误!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+                    else{
+                        standard.setStartingPrice(new BigDecimal(0));
+                    }
+
+                    if(StringUtils.isNotEmpty(strGuaranteedPrice)) {
+                        if (checkedNumber(strGuaranteedPrice)) {
+                            standard.setGuaranteedPrice(new BigDecimal(strGuaranteedPrice));
+                        } else {
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("保底价数据类型错误!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+                    else{
+                        standard.setGuaranteedPrice(new BigDecimal(0));
+                    }
+
+                    if(StringUtils.isNotEmpty(strDiscount)) {
+                        if (checkedNumber(strDiscount)) {
+                            standard.setDiscount(new BigDecimal(strDiscount));
+                        } else {
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("折扣数据类型错误!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+                    else{
+                        standard.setDiscount(new BigDecimal(0));
+                    }
+
+                    if(StringUtils.isNotEmpty(strDeliveryFee)) {
+                        if (checkedNumber(strDeliveryFee)) {
+                            standard.setDeliveryFee(new BigDecimal(strDeliveryFee));
+                        } else {
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("送货费数据类型错误!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+                    else{
+                        standard.setDeliveryFee(new BigDecimal(0));
+                    }
+
+                    if(StringUtils.isNotEmpty(strStorageFee)) {
+                        if (checkedNumber(strStorageFee)) {
+                            standard.setStorageFee(new BigDecimal(strStorageFee));
+                        } else {
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("进仓费数据类型错误!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+                    else{
+                        standard.setStorageFee(new BigDecimal(0));
+                    }
+
+                    if(StringUtils.isNotEmpty(strInsureFee)) {
+                        if (checkedNumber(strInsureFee)) {
+                            standard.setInsureFee(new BigDecimal(strInsureFee));
+                        } else {
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("保费率数据类型错误!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+                    else{
+                        standard.setInsureFee(new BigDecimal(0));
+                    }
+
+                    if(StringUtils.isNotEmpty(strTaxFee)) {
+                        if (checkedNumber(strTaxFee)) {
+                            standard.setTaxFee(new BigDecimal(strTaxFee));
+                        } else {
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("税费率数据类型错误!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+                    else{
+                        standard.setTaxFee(new BigDecimal(0));
+                    }
+
+                    if(StringUtils.isNotEmpty(strReceiptFee)) {
+                        if (checkedNumber(strReceiptFee)) {
+                            standard.setReceiptFee(new BigDecimal(strReceiptFee));
+                        } else {
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("回单费数据类型错误!");
+                            failCount++;
+                            continue;
+                        }
+                    }
+                    else{
+                        standard.setReceiptFee(new BigDecimal(0));
+                    }
+
+                    standardService.insert(standard);
                     insertCount++;
                 }
                 catch(Exception innerEx){
@@ -326,4 +551,10 @@ public class StandardController {
 
         return msgResult;
     }
+
+    private Boolean checkedNumber(String str) {
+        String reg = "^-?[0-9]+(.[0-9]+)?$";
+
+        return str.matches(reg);
+    }
 }