|
@@ -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);
|
|
|
+ }
|
|
|
}
|