@ -34,29 +34,24 @@ import com.logpm.basicdata.service.IBasicdataVehicleService;
import com.logpm.basicdata.vo.BasicdataDriverArteryVO ;
import lombok.AllArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
import org.springblade.common.constant.driver.DriverTypeStatusConstant ;
import org.springblade.core.log.exception.ServiceException ;
import org.springblade.core.mp.base.BaseServiceImpl ;
import org.springblade.core.secure.BladeUser ;
import org.springblade.core.secure.utils.AuthUtil ;
import org.springblade.core.tool.api.R ;
import org.springblade.core.tool.utils.Func ;
import org.springblade.system.cache.DictBizCache ;
import org.springblade.system.entity.User ;
import org.springblade.system.feign.IUserClient ;
import org.springblade.system.feign.IUserSearchClient ;
import org.springframework.dao.DataAccessException ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.List ;
import java.util.function.Function ;
import java.util.stream.Collectors ;
import java.util.stream.Stream ;
import static com.alibaba.fastjson.JSONPatch.OperationType.copy ;
/ * *
* 司机信息表 服务实现类
*
@ -157,10 +152,13 @@ public class BasicdataDriverArteryServiceImpl extends BaseServiceImpl<BasicdataD
* @param data
* /
@Override
@Transactional
public void importDriverArtery ( List < BasicdataDriverArteryImproterExcel > data ) {
log . info ( "传入参数>>>>>>>>>>>>>>>>>>>>>>>{}" , data ) ;
outerLoop :
for ( BasicdataDriverArteryImproterExcel datum : data ) {
try {
List < BasicdataDrivermiddleEntity > driverMiddleEntity = new ArrayList < > ( ) ;
//检查数据是否为空
@ -168,14 +166,14 @@ public class BasicdataDriverArteryServiceImpl extends BaseServiceImpl<BasicdataD
// log.error("必填数据不能为空");
// continue;
throw new ServiceException ( "用户" + datum . getName ( ) + "必填数据不能为空!" ) ;
throw new ServiceException ( "必填数据不能为空!" ) ;
}
if ( ! ObjectUtils . isEmpty ( datum . getPhone ( ) ) ) {
R < User > userR = userClient . userInfoByPhone ( "627683" , datum . getPhone ( ) ) ;
if ( userR . getData ( ) = = null ) {
// log.error("未找到用户");
// continue;
throw new ServiceException ( "用户" + datum . getName ( ) + "未找到用户!" ) ;
throw new ServiceException ( "未找到用户!" ) ;
} else {
datum . setUserId ( userR . getData ( ) . getId ( ) ) ;
}
@ -187,7 +185,7 @@ public class BasicdataDriverArteryServiceImpl extends BaseServiceImpl<BasicdataD
if ( carListByName . isEmpty ( ) ) {
// log.error("未找到可绑定的车辆");
throw new ServiceException ( "用户" + datum . getName ( ) + "未找到可绑定的车辆!" ) ;
throw new ServiceException ( "未找到可绑定的车辆!" ) ;
} else {
BasicdataDrivermiddleEntity basicdataDrivermiddleEntity = new BasicdataDrivermiddleEntity ( ) ;
basicdataDrivermiddleEntity . setBrandId ( carListByName . get ( 0 ) . getId ( ) ) ;
@ -202,7 +200,7 @@ public class BasicdataDriverArteryServiceImpl extends BaseServiceImpl<BasicdataD
if ( ObjectUtils . isEmpty ( basicdataCarrierEntities ) ) {
// log.error("未找到承运商");
// continue;
throw new ServiceException ( "用户" + datum . getName ( ) + "未找到承运商!" ) ;
throw new ServiceException ( "未找到承运商!" ) ;
} else {
datum . setCarrierId ( basicdataCarrierEntities . get ( 0 ) . getId ( ) ) ;
}
@ -213,7 +211,7 @@ public class BasicdataDriverArteryServiceImpl extends BaseServiceImpl<BasicdataD
if ( ObjectUtils . isEmpty ( byName ) ) {
// log.error("未找到仓库");
// continue;
throw new ServiceException ( "用户" + datum . getName ( ) + "未找到仓库!" ) ;
throw new ServiceException ( "未找到仓库!" ) ;
} else {
datum . setWarehouseId ( String . valueOf ( byName . getId ( ) ) ) ;
}
@ -240,6 +238,14 @@ public class BasicdataDriverArteryServiceImpl extends BaseServiceImpl<BasicdataD
basicdataDrivermiddleEntity . setDriverId ( copy . getId ( ) ) ;
basicdataDrivermiddleServiceImpl . save ( basicdataDrivermiddleEntity ) ;
}
} catch ( DataAccessException e ) {
throw new ServiceException ( "用户" + datum . getName ( ) + "数据长度异常" ) ;
} catch ( ServiceException e ) {
throw new ServiceException ( "用户" + datum . getName ( ) + e . getMessage ( ) ) ;
} catch ( Exception e ) {
throw new RuntimeException ( "用户" + datum . getName ( ) + "数据错误" + e . getMessage ( ) ) ;
}
}
}