|
@@ -45,7 +45,7 @@ import java.util.*;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
-public class LiftService extends ServiceImpl<LiftMapper,Lift> {
|
|
|
+public class LiftService extends ServiceImpl<LiftMapper, Lift> {
|
|
|
|
|
|
@Resource
|
|
|
private LiftMapper liftMapper;
|
|
@@ -109,7 +109,7 @@ public class LiftService extends ServiceImpl<LiftMapper,Lift> {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * @param mtCompanyId 公司id
|
|
|
+ * @param mtCompanyId 公司id
|
|
|
* @param registrationCode 注册代码
|
|
|
* @return RestResponse 判断结果
|
|
|
* @description 新增电梯前置判断条件
|
|
@@ -131,7 +131,7 @@ public class LiftService extends ServiceImpl<LiftMapper,Lift> {
|
|
|
LiftExtendResponse detail = detail(liftId);
|
|
|
return RestResponse.success(detail, MessageUtils.get("msg.lift.company.exist"));
|
|
|
}
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
return RestResponse.success(null, MessageUtils.get("msg.pre.judge"));
|
|
|
}
|
|
|
}
|
|
@@ -257,14 +257,15 @@ public class LiftService extends ServiceImpl<LiftMapper,Lift> {
|
|
|
|
|
|
/**
|
|
|
* 解析excel导入电梯
|
|
|
+ *
|
|
|
* @param liftImportModels
|
|
|
* @param mtCompanyId
|
|
|
* @param projectId
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public RestResponse assemble(List<LiftImportModel> liftImportModels,Long mtCompanyId, Long projectId){
|
|
|
- Judge.notNull(liftImportModels,"没有数据");
|
|
|
+ public RestResponse assemble(List<LiftImportModel> liftImportModels, Long mtCompanyId, Long projectId) {
|
|
|
+ Judge.notNull(liftImportModels, "没有数据");
|
|
|
//存放新建的lift
|
|
|
List<Lift> lifts = new ArrayList<>();
|
|
|
//存放新建的project-lift关联信息
|
|
@@ -273,28 +274,30 @@ public class LiftService extends ServiceImpl<LiftMapper,Lift> {
|
|
|
List<PlatformCompanyLiftRelevance> platformCompanyLiftRelevances = new ArrayList<>();
|
|
|
|
|
|
//根据维保公司和项目id查询
|
|
|
- List<LiftProjectModel> liftProjectModelList = liftMapper.listByCompanyAndProject(mtCompanyId,projectId);
|
|
|
+ List<LiftProjectModel> liftProjectModelList = liftMapper.listByCompanyAndProject(mtCompanyId, projectId);
|
|
|
//根据维保公司和项目查询
|
|
|
+
|
|
|
List<ProjectLiftRelevance> projectLiftRelevanceList = projectRelevanceService.findLiftList(mtCompanyId,projectId);
|
|
|
+
|
|
|
//根据维保公司
|
|
|
List<PlatformCompanyLiftRelevance> platformCompanyLiftRelevanceList = platformService.listByCompany(mtCompanyId);
|
|
|
|
|
|
- for(int i = 0; i< liftImportModels.size();i++){
|
|
|
+ for (int i = 0; i < liftImportModels.size(); i++) {
|
|
|
LiftImportModel item = liftImportModels.get(i);
|
|
|
Lift lift = new Lift();
|
|
|
//复制解析model中的值到lift中
|
|
|
- BeanUtil.copyProperties(item,lift,true);
|
|
|
- log.info("复制电梯属性后:{}",lift);
|
|
|
+ BeanUtil.copyProperties(item, lift, true);
|
|
|
+ log.info("复制电梯属性后:{}", lift);
|
|
|
|
|
|
String registrationCode = item.getRegistrationCode();
|
|
|
LiftProjectModel liftProjectModel = liftProjectModelList.stream().filter(lpm -> (
|
|
|
StrUtil.equals(registrationCode, lpm.getRegistrationCode())
|
|
|
)).distinct().limit(1).findFirst().get();
|
|
|
|
|
|
- if(null != liftProjectModel){
|
|
|
+ if (null != liftProjectModel) {
|
|
|
//如果已经存在lift,取出id赋值
|
|
|
lift.setId(liftProjectModel.getLiftId());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//如果不存在,新建id赋值
|
|
|
lift.setId(IdWorker.getId());
|
|
|
//加入list中批量插入
|
|
@@ -303,8 +306,8 @@ public class LiftService extends ServiceImpl<LiftMapper,Lift> {
|
|
|
|
|
|
PlatformCompanyLiftRelevance platformCompanyLiftRelevance = platformCompanyLiftRelevanceList.stream().filter(pclr -> (
|
|
|
pclr.getLiftId() == lift.getId()
|
|
|
- )).distinct().limit(1).findFirst().get();
|
|
|
- if(null == platformCompanyLiftRelevance){
|
|
|
+ )).distinct().limit(1).findFirst().get();
|
|
|
+ if (null == platformCompanyLiftRelevance) {
|
|
|
//如果不存在就新建
|
|
|
platformCompanyLiftRelevance = new PlatformCompanyLiftRelevance();
|
|
|
Long relevanceId = IdWorker.getId();
|
|
@@ -313,7 +316,7 @@ public class LiftService extends ServiceImpl<LiftMapper,Lift> {
|
|
|
platformCompanyLiftRelevance.setMtCompanyId(mtCompanyId);
|
|
|
platformCompanyLiftRelevance.setLiftId(lift.getId());
|
|
|
platformCompanyLiftRelevance.setLiftCompanyStatus(CommonEnum.LiftStatus.NORMAL.getCode());
|
|
|
- log.info("新建PlatformCompanyLiftRelevance:{}",platformCompanyLiftRelevance);
|
|
|
+ log.info("新建PlatformCompanyLiftRelevance:{}", platformCompanyLiftRelevance);
|
|
|
//加入到新建list中批量插入
|
|
|
platformCompanyLiftRelevances.add(platformCompanyLiftRelevance);
|
|
|
}
|
|
@@ -322,39 +325,39 @@ public class LiftService extends ServiceImpl<LiftMapper,Lift> {
|
|
|
ProjectLiftRelevance projectLiftRelevance = projectLiftRelevanceList.stream().filter(plr -> (
|
|
|
plr.getLiftId() == lift.getId()
|
|
|
)).distinct().limit(1).findFirst().get();
|
|
|
- if(null == projectLiftRelevance){
|
|
|
+ if (null == projectLiftRelevance) {
|
|
|
projectLiftRelevance = new ProjectLiftRelevance();
|
|
|
projectLiftRelevance.setMtCompanyId(mtCompanyId);
|
|
|
projectLiftRelevance.setLiftId(lift.getId());
|
|
|
projectLiftRelevance.setProjectId(projectId);
|
|
|
projectLiftRelevance.setRelevanceId(platformCompanyLiftRelevance.getId());
|
|
|
- log.info("新建ProjectLiftRelevance:{}",projectLiftRelevance);
|
|
|
+ log.info("新建ProjectLiftRelevance:{}", projectLiftRelevance);
|
|
|
projectLiftRelevances.add(projectLiftRelevance);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//批量插入platform-company-lift关联数据
|
|
|
- if(!platformCompanyLiftRelevances.isEmpty()){
|
|
|
+ if (!platformCompanyLiftRelevances.isEmpty()) {
|
|
|
boolean plat = platformService.saveOrUpdateBatch(platformCompanyLiftRelevances);
|
|
|
- if(!plat){
|
|
|
+ if (!plat) {
|
|
|
//强制手动事务回滚
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return RestResponse.fail();
|
|
|
}
|
|
|
}
|
|
|
//批量插入project-lift关联数据
|
|
|
- if(!projectLiftRelevances.isEmpty()){
|
|
|
+ if (!projectLiftRelevances.isEmpty()) {
|
|
|
boolean proj = projectRelevanceService.saveOrUpdateBatch(projectLiftRelevances);
|
|
|
- if(!proj){
|
|
|
+ if (!proj) {
|
|
|
//强制手动事务回滚
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return RestResponse.fail();
|
|
|
}
|
|
|
}
|
|
|
//批量插入lift数据
|
|
|
- if(!lifts.isEmpty()){
|
|
|
+ if (!lifts.isEmpty()) {
|
|
|
boolean lift = saveOrUpdateBatch(lifts);
|
|
|
- if(!lift){
|
|
|
+ if (!lift) {
|
|
|
//强制手动事务回滚
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return RestResponse.fail();
|