|
|
@@ -1,13 +1,26 @@
|
|
|
package com.uas.platform.b2c.prod.product.kind.service.impl;
|
|
|
|
|
|
+import com.uas.platform.b2c.core.support.view.JxlsExcelView;
|
|
|
+import com.uas.platform.b2c.core.utils.FastjsonUtils;
|
|
|
+import com.uas.platform.b2c.core.utils.PathUtils;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.PCBDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.PCBPropertyValue;
|
|
|
import com.uas.platform.b2c.prod.product.brand.dao.BrandInfoDao;
|
|
|
import com.uas.platform.b2c.prod.product.brand.modal.BrandInfo;
|
|
|
import com.uas.platform.b2c.prod.product.component.dao.ComponentDao;
|
|
|
import com.uas.platform.b2c.prod.product.component.modal.Component;
|
|
|
-import com.uas.platform.b2c.prod.product.kind.dao.*;
|
|
|
-import com.uas.platform.b2c.prod.product.kind.model.*;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.dao.KindContrastDao;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.dao.KindDao;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.dao.KindInfoDao;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.dao.KindPropertyDao;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.dao.KindPropertyValueDao;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.model.Kind;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.model.KindCrawl;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.model.KindInfo;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.model.KindProperty;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.model.KindPropertyOption;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.model.KindPropertyUnit;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.model.KindPropertyValues;
|
|
|
import com.uas.platform.b2c.prod.product.kind.service.KindService;
|
|
|
import com.uas.platform.b2c.prod.product.property.dao.PropertyCrawlDao;
|
|
|
import com.uas.platform.b2c.prod.product.property.dao.PropertyDao;
|
|
|
@@ -15,16 +28,28 @@ import com.uas.platform.b2c.prod.product.property.dao.PropertyValueDao;
|
|
|
import com.uas.platform.b2c.prod.product.property.model.Property;
|
|
|
import com.uas.platform.b2c.prod.product.property.model.PropertyCrawl;
|
|
|
import com.uas.platform.b2c.prod.product.property.model.PropertyValue;
|
|
|
-import com.uas.platform.b2c.core.utils.FastjsonUtils;
|
|
|
-import com.uas.platform.b2c.core.utils.PathUtils;
|
|
|
-import com.uas.platform.b2c.core.support.view.JxlsExcelView;
|
|
|
import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import com.uas.platform.core.model.Constant;
|
|
|
import com.uas.platform.core.model.PageInfo;
|
|
|
import com.uas.platform.core.model.PageParams;
|
|
|
import com.uas.platform.core.util.ArrayUtils;
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
+import java.io.FileReader;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import javax.persistence.criteria.CriteriaBuilder;
|
|
|
+import javax.persistence.criteria.CriteriaQuery;
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+import javax.persistence.criteria.Root;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
-import org.apache.velocity.runtime.directive.Foreach;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
|
|
@@ -35,13 +60,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
-import javax.persistence.criteria.CriteriaBuilder;
|
|
|
-import javax.persistence.criteria.CriteriaQuery;
|
|
|
-import javax.persistence.criteria.Predicate;
|
|
|
-import javax.persistence.criteria.Root;
|
|
|
-import java.io.*;
|
|
|
-import java.util.*;
|
|
|
-
|
|
|
@Service
|
|
|
public class KindServiceImpl implements KindService {
|
|
|
|
|
|
@@ -128,10 +146,10 @@ public class KindServiceImpl implements KindService {
|
|
|
} else {
|
|
|
parent = kindDao.findOne(parentid);
|
|
|
if (parent == null) {
|
|
|
- throw new IllegalOperatorException("不可在不存在类目下添加子类目");
|
|
|
+ throw new IllegalOperatorException("不可在不存在物料名称(类目)下添加子物料名称(类目)");
|
|
|
}
|
|
|
if (parent.getLevel() == 3) {
|
|
|
- throw new IllegalOperatorException("不允许在三级类目下添加子类目");
|
|
|
+ throw new IllegalOperatorException("不允许在三级物料名称(类目)下添加子物料名称(类目)");
|
|
|
}
|
|
|
if (parent.getIsLeaf() == 1) {
|
|
|
// 如果parent是叶子节点,且带有标准器件,则禁止新增
|
|
|
@@ -147,7 +165,7 @@ public class KindServiceImpl implements KindService {
|
|
|
// 验证父类目下是否已存在相同的类目,存在则无法保存
|
|
|
List<Kind> exists = kindDao.findByParentidAndNameCn(parentid, kind.getNameCn());
|
|
|
if (CollectionUtils.isNotEmpty(exists)) {
|
|
|
- throw new IllegalOperatorException("父类目下存在相同类目,无法保存");
|
|
|
+ throw new IllegalOperatorException("父物料名称(类目)下存在相同物料名称(类目),无法保存");
|
|
|
}
|
|
|
|
|
|
kind.setIsLeaf(Constant.YES);
|
|
|
@@ -305,7 +323,7 @@ public class KindServiceImpl implements KindService {
|
|
|
throw new IllegalArgumentException();
|
|
|
}
|
|
|
if (!preKind.getParentid().equals(postKind.getParentid())) {
|
|
|
- throw new IllegalOperatorException("交换顺序的类目不属于同一父类目");
|
|
|
+ throw new IllegalOperatorException("交换顺序的物料名称(类目)不属于同一父物料名称(类目)");
|
|
|
}
|
|
|
// 交换序号,同时对序号为空的类目作默认赋值
|
|
|
short lastNumber = kindDao.findLastNumberByParentid(preKind.getParentid());
|
|
|
@@ -334,18 +352,18 @@ public class KindServiceImpl implements KindService {
|
|
|
public void delete(Long kindId) {
|
|
|
Kind kind = kindDao.findOne(kindId);
|
|
|
if (kind == null) {
|
|
|
- throw new IllegalArgumentException("要删除的类目不存在");
|
|
|
+ throw new IllegalArgumentException("要删除的物料名称(类目)不存在");
|
|
|
}
|
|
|
|
|
|
// 不是叶子类目,不允许删除
|
|
|
if (!kind.isLeaf()) {
|
|
|
- throw new IllegalOperatorException("您要删除的类目含有子类目,不可以删除");
|
|
|
+ throw new IllegalOperatorException("您要删除的物料名称(类目)含有子物料名称(类目),不可以删除");
|
|
|
}
|
|
|
// 检测有没有有效器件带有这个属性
|
|
|
try {
|
|
|
kindDao.delete(kind);
|
|
|
} catch (Exception e) {
|
|
|
- throw new IllegalOperatorException("此类目下有有效的标准器件,禁止删除类目属性");
|
|
|
+ throw new IllegalOperatorException("此物料名称(类目)下有有效的标准器件,禁止删除物料名称(类目)属性");
|
|
|
}
|
|
|
// 如果父节点没有了子节点了,修改父节点为叶子节点
|
|
|
List<Kind> bothers = getChildProductKinds(kind.getParentid());
|
|
|
@@ -368,7 +386,7 @@ public class KindServiceImpl implements KindService {
|
|
|
private List<Kind> getParentsByChildId(Long childId, List<Kind> container) {
|
|
|
Kind child = kindDao.findOne(childId);
|
|
|
if (child == null) {
|
|
|
- throw new IllegalOperatorException("要获取的父类目不存在");
|
|
|
+ throw new IllegalOperatorException("要获取的父物料名称(类目)不存在");
|
|
|
}
|
|
|
if (child.getParentid() != 0) {
|
|
|
getParentsByChildId(child.getParentid(), container);
|
|
|
@@ -409,7 +427,7 @@ public class KindServiceImpl implements KindService {
|
|
|
addCount(kindid, count);
|
|
|
}
|
|
|
long endTimeDate = new Date().getTime();
|
|
|
- System.out.println("类目所属器件数量统计共耗时: " + (endTimeDate - starTimeDate) + "毫秒");
|
|
|
+ System.out.println("物料名称(类目)所属器件数量统计共耗时: " + (endTimeDate - starTimeDate) + "毫秒");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -596,7 +614,7 @@ public class KindServiceImpl implements KindService {
|
|
|
kindPropertyDao.save(kindProperty_T);
|
|
|
}
|
|
|
long endTimeDate = new Date().getTime();
|
|
|
- System.out.println("类目标准属性的可能值全部洗一遍共耗时: " + (endTimeDate - startTimeDate) + "毫秒");
|
|
|
+ System.out.println("物料名称(类目)标准属性的可能值全部洗一遍共耗时: " + (endTimeDate - startTimeDate) + "毫秒");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -688,7 +706,7 @@ public class KindServiceImpl implements KindService {
|
|
|
|
|
|
}
|
|
|
long endTimeDate = new Date().getTime();
|
|
|
- System.out.println("对于新增的类目属性的值,计算时间是:" + (startTimeDate - endTimeDate) + "毫秒");
|
|
|
+ System.out.println("对于新增的物料名称(类目)属性的值,计算时间是:" + (startTimeDate - endTimeDate) + "毫秒");
|
|
|
}
|
|
|
});
|
|
|
t.start();
|
|
|
@@ -775,7 +793,7 @@ public class KindServiceImpl implements KindService {
|
|
|
public List<KindInfo> getStructruingKinds(Long id) {
|
|
|
KindInfo kindInfo = kindInfoDao.findOne(id);
|
|
|
if (kindInfo == null) {
|
|
|
- throw new IllegalOperatorException("类目不存在");
|
|
|
+ throw new IllegalOperatorException("物料名称(类目)不存在");
|
|
|
}
|
|
|
return findStructingKinds(id);
|
|
|
}
|
|
|
@@ -923,7 +941,7 @@ public class KindServiceImpl implements KindService {
|
|
|
Kind kind = kindDao.findOne(kindProperty.getKindId());
|
|
|
for (KindProperty kp : kind.getProperties()) {
|
|
|
if (kp.getPropertyId().equals(kindProperty.getPropertyId())) {
|
|
|
- throw new IllegalOperatorException("此类目中已有属性" + kindProperty.getProperty().getLabelCn() + ",请不要重复添加");
|
|
|
+ throw new IllegalOperatorException("此物料名称(类目)中已有属性" + kindProperty.getProperty().getLabelCn() + ",请不要重复添加");
|
|
|
}
|
|
|
if (kp.getDetno() >= kindProperty.getDetno()) {
|
|
|
kp.setDetno((short) (kp.getDetno() + 1));
|
|
|
@@ -963,10 +981,10 @@ public class KindServiceImpl implements KindService {
|
|
|
KindProperty active = kindPropertyDao.findOne(activeId);
|
|
|
KindProperty passive = kindPropertyDao.findOne(passiveId);
|
|
|
if (active == null || passive == null) {
|
|
|
- throw new IllegalOperatorException("当前操作的类目属性不存在");
|
|
|
+ throw new IllegalOperatorException("当前操作的物料名称(类目)属性不存在");
|
|
|
}
|
|
|
if (!(active.getKindId().equals(passive.getKindId()))) {
|
|
|
- throw new IllegalOperatorException("当前操作的类目属性不属于同一类目");
|
|
|
+ throw new IllegalOperatorException("当前操作的物料名称(类目)属性不属于同一物料名称(类目)");
|
|
|
}
|
|
|
short actNo = active.getDetno();
|
|
|
short passNo = passive.getDetno();
|
|
|
@@ -995,7 +1013,7 @@ public class KindServiceImpl implements KindService {
|
|
|
public KindProperty changeKindProperty(String labelCn, Long kindPropertyId) {
|
|
|
KindProperty kindProperty = kindPropertyDao.findOne(kindPropertyId);
|
|
|
if (kindProperty == null) {
|
|
|
- throw new IllegalOperatorException("该类目属性不存在");
|
|
|
+ throw new IllegalOperatorException("该物料名称(类目)属性不存在");
|
|
|
}
|
|
|
final Long oldPropertyId = kindProperty.getPropertyId();
|
|
|
final Long kindId = kindProperty.getKindId();
|
|
|
@@ -1055,7 +1073,7 @@ public class KindServiceImpl implements KindService {
|
|
|
}
|
|
|
}
|
|
|
long endTime = new Date().getTime();
|
|
|
- System.out.println("对于更改的类目属性的值,计算时间是:" + (startTime - endTime) + "毫秒");
|
|
|
+ System.out.println("对于更改的物料名称(类目)属性的值,计算时间是:" + (startTime - endTime) + "毫秒");
|
|
|
}
|
|
|
});
|
|
|
t.start();
|
|
|
@@ -1255,7 +1273,7 @@ public class KindServiceImpl implements KindService {
|
|
|
private List<KindInfo> getPCBParentsByChildId(Long childId, List<KindInfo> container) {
|
|
|
KindInfo child = kindInfoDao.findOne(childId);
|
|
|
if (child == null) {
|
|
|
- throw new IllegalOperatorException("要获取的父类目不存在");
|
|
|
+ throw new IllegalOperatorException("要获取的父物料名称(类目)不存在");
|
|
|
}
|
|
|
if (child.getParentid() != 0) {
|
|
|
getPCBParentsByChildId(child.getParentid(), container);
|