|
@@ -11,6 +11,7 @@ import com.cirs.common.utils.bean.BeanValidators;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.cirs.biz.mapper.SysTrainMapper;
|
|
|
import com.cirs.biz.domain.SysTrain;
|
|
@@ -109,6 +110,7 @@ public class SysTrainServiceImpl implements ISysTrainService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Async
|
|
|
public String importTrain(List<SysTrain> trainList, boolean updateSupport, String operName) {
|
|
|
if (StringUtils.isNull(trainList) || trainList.size() == 0)
|
|
|
{
|
|
@@ -123,7 +125,7 @@ public class SysTrainServiceImpl implements ISysTrainService
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
-
|
|
|
+ BuildComponent(train);
|
|
|
BeanValidators.validateWithException(validator, train);
|
|
|
train.setCreateBy(operName);
|
|
|
sysTrainMapper.insertSysTrain(train);
|
|
@@ -151,10 +153,28 @@ public class SysTrainServiceImpl implements ISysTrainService
|
|
|
return successMsg.toString();
|
|
|
}
|
|
|
|
|
|
+ private void BuildComponent(SysTrain train) {
|
|
|
+ if(StringUtils.isNotEmpty(train.getResult1())){
|
|
|
+ train.setResult1Id(getComponentId(train.getResult1()));
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(train.getResult2())){
|
|
|
+ train.setResult2Id(getComponentId(train.getResult2()));
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(train.getResult3())){
|
|
|
+ train.setResult3Id(getComponentId(train.getResult3()));
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(train.getResult4())){
|
|
|
+ train.setResult4Id(getComponentId(train.getResult4()));
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(train.getResult5())){
|
|
|
+ train.setResult5Id(getComponentId(train.getResult5()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Long getComponentId(String result) {//型号规格-质量等级-元器件名称
|
|
|
String[] attrs = result.split("-");//切割不同属性
|
|
|
- return sysTrainMapper.getComponentId(attrs[0],attrs[1],attrs[2]);
|
|
|
+ return sysTrainMapper.getComponentId(attrs[0], attrs.length >= 2 ? attrs[1] : null, attrs.length >= 3 ? attrs[2] : null);
|
|
|
}
|
|
|
|
|
|
@Override
|