|
|
@@ -27,7 +27,6 @@ import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import com.uas.platform.core.model.PageInfo;
|
|
|
import com.uas.platform.core.persistence.criteria.PredicateUtils;
|
|
|
import com.uas.platform.core.util.HttpUtil;
|
|
|
-import com.uas.platform.core.util.OkHttpUtils;
|
|
|
import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.math.BigDecimal;
|
|
|
@@ -48,8 +47,6 @@ import javax.persistence.criteria.CriteriaBuilder;
|
|
|
import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
-import net.sf.json.JSONArray;
|
|
|
-import okhttp3.Response;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
@@ -72,7 +69,7 @@ import org.springframework.util.StringUtils;
|
|
|
* @version 2018/1/19 15:06
|
|
|
*/
|
|
|
@Service
|
|
|
-public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService{
|
|
|
+public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
|
|
|
@Autowired
|
|
|
private SeekPurchaseDao seekPurchasedao;
|
|
|
@@ -110,25 +107,28 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService{
|
|
|
@Autowired
|
|
|
private SearcherService searcherService;
|
|
|
|
|
|
- private static Long deadlineTime = Long.valueOf(90 * 24 * 60 * 60 * 1000);
|
|
|
+ private int mallColNum = 8;
|
|
|
+ private int mallRowNum = 500;
|
|
|
+ private int startRow = 3;
|
|
|
|
|
|
/**
|
|
|
* 导入bom
|
|
|
* @param workbook
|
|
|
* @param bomName
|
|
|
- * @param user
|
|
|
* @return
|
|
|
*/
|
|
|
+
|
|
|
@Override
|
|
|
public ResultMap importBom(Workbook workbook, String bomName) {
|
|
|
// 获取第一个工作表
|
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
|
int colNum = sheet.getRow(0).getPhysicalNumberOfCells();
|
|
|
- if (colNum != 8) {
|
|
|
+
|
|
|
+ if (colNum != mallColNum) {
|
|
|
return new ResultMap(CodeType.PARAMETER_ERROR, "表格模板不正确!请重新下载最新模板");
|
|
|
}
|
|
|
int rowNum = sheet.getLastRowNum();
|
|
|
- if (rowNum > 500) {
|
|
|
+ if (rowNum > mallRowNum) {
|
|
|
return new ResultMap(CodeType.PARAMETER_ERROR, "您上传的信息超过500条,请拆分成2000以再在上传");
|
|
|
}
|
|
|
// 插入Bom求购中
|
|
|
@@ -149,7 +149,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService{
|
|
|
return new ResultMap(CodeType.PARAMETER_ERROR, "您上传的信息列信息不正确,请与模板的列做比较");
|
|
|
}
|
|
|
List<SeekPurchaseByBatch> seekPurchaseByBatchList = new ArrayList<>();
|
|
|
- for (int r = 3; r <= rowNum; r++) {
|
|
|
+ for (int r = startRow; r <= rowNum; r++) {
|
|
|
Row row = sheet.getRow(r);
|
|
|
if (row != null) {
|
|
|
SeekPurchaseByBatch seekPurchaseByBatch = new SeekPurchaseByBatch();
|
|
|
@@ -169,7 +169,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService{
|
|
|
* @param headerRow
|
|
|
* @return
|
|
|
*/
|
|
|
- private boolean vaildTemplete(Row headerRow){
|
|
|
+ private boolean vaildTemplete(Row headerRow) {
|
|
|
Object codeCellObj = readWorkBookCell(headerRow.getCell(0), Cell.CELL_TYPE_STRING,
|
|
|
0, 0);
|
|
|
if (!"产品型号".equals(StringUtilB2C.getStr(codeCellObj))) {
|
|
|
@@ -200,8 +200,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService{
|
|
|
* @param rowNum
|
|
|
* @return
|
|
|
*/
|
|
|
- private int convertValueToSeekPurchaseByBatch(Row row, SeekPurchaseByBatch seekPurchaseByBatch, int rowNum)
|
|
|
- throws UnsupportedEncodingException {
|
|
|
+ private int convertValueToSeekPurchaseByBatch(Row row, SeekPurchaseByBatch seekPurchaseByBatch, int rowNum) {
|
|
|
// 统计为空的个数
|
|
|
int result = 0;
|
|
|
// 型号
|
|
|
@@ -211,7 +210,11 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService{
|
|
|
result += 1;
|
|
|
} else {
|
|
|
String code = StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(codeValue));
|
|
|
- code = com.uas.platform.b2c.fa.payment.utils.StringUtils.cutOutString(code, 100);
|
|
|
+ try {
|
|
|
+ code = com.uas.platform.b2c.fa.payment.utils.StringUtils.cutOutString(code, 100);
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
seekPurchaseByBatch.setCode(code);
|
|
|
}
|
|
|
|
|
|
@@ -222,7 +225,11 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService{
|
|
|
result += 1;
|
|
|
} else {
|
|
|
String brand = StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(brandValue));
|
|
|
- brand = com.uas.platform.b2c.fa.payment.utils.StringUtils.cutOutString(brand, 50);
|
|
|
+ try {
|
|
|
+ brand = com.uas.platform.b2c.fa.payment.utils.StringUtils.cutOutString(brand, 50);
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
seekPurchaseByBatch.setBrand(StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(brandValue)));
|
|
|
}
|
|
|
|
|
|
@@ -238,7 +245,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService{
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
Date deadlineDate = sdf.parse(deadline);
|
|
|
if (deadlineDate.getTime() < System.currentTimeMillis()) {
|
|
|
- seekPurchaseByBatch.setDeadline(DateUtils.addTime(new Date(), 0, 23, 59,59));
|
|
|
+ seekPurchaseByBatch.setDeadline(DateUtils.addTime(new Date(), 0, 23, 59, 59));
|
|
|
} else {
|
|
|
seekPurchaseByBatch.setDeadline(DateUtils.addTime(deadlineDate));
|
|
|
}
|
|
|
@@ -326,10 +333,6 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService{
|
|
|
|
|
|
/**
|
|
|
* 读取excel
|
|
|
- * @param cell
|
|
|
- * @param cellType
|
|
|
- * @param r
|
|
|
- * @param n
|
|
|
* @return
|
|
|
*/
|
|
|
private Object readWorkBookCell(Cell cell, int cellType, int r, int n) {
|
|
|
@@ -341,7 +344,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService{
|
|
|
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
|
|
String str = cell.getStringCellValue().trim();
|
|
|
if (str.indexOf("\u00A0") > 0) {
|
|
|
- str= str.replaceAll("\u00A0", "");
|
|
|
+ str = str.replaceAll("\u00A0", "");
|
|
|
}
|
|
|
str = StringUtilB2C.replaceTabAndLineBreak(str);
|
|
|
obj = str.trim();
|
|
|
@@ -362,8 +365,8 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService{
|
|
|
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
|
|
|
Matcher m = p.matcher(productTime);
|
|
|
String time = m.replaceAll("");
|
|
|
- if (time.indexOf("\u00A0") > 0){
|
|
|
- time= time.replaceAll("\u00A0", "");
|
|
|
+ if (time.indexOf("\u00A0") > 0) {
|
|
|
+ time = time.replaceAll("\u00A0", "");
|
|
|
}
|
|
|
DateFormat format1 = new SimpleDateFormat("yyyy/MM/dd");
|
|
|
obj = format1.parse(time);
|
|
|
@@ -392,7 +395,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService{
|
|
|
}
|
|
|
}, pageInfo);
|
|
|
List<SeekPurchaseByBatch> seekPurchaseByBatchList = pageSeeks.getContent();
|
|
|
- for (int i = 0;i < seekPurchaseByBatchList.size(); i++) {
|
|
|
+ for (int i = 0; i < seekPurchaseByBatchList.size(); i++) {
|
|
|
if (!StringUtils.isEmpty(seekPurchaseByBatchList.get(i).getCode()) && !StringUtils.isEmpty(seekPurchaseByBatchList.get(i).getBrand())) {
|
|
|
List<Map<String, Object>> codeWord = searcherService.getSimilarComponents(seekPurchaseByBatchList.get(i).getCode());
|
|
|
if (codeWord != null && codeWord.size() > 0) {
|