|
@@ -2,23 +2,21 @@ package cn.com.ty.lift.business.library.service;
|
|
|
|
|
|
import cn.com.ty.lift.business.framework.util.MessageUtils;
|
|
|
import cn.com.ty.lift.business.library.dao.entity.Lift;
|
|
|
-import cn.com.ty.lift.business.library.dao.entity.LiftExtension;
|
|
|
import cn.com.ty.lift.business.library.dao.entity.PlatformCompanyLiftRelevance;
|
|
|
import cn.com.ty.lift.business.library.dao.entity.model.LiftExtensionRequest;
|
|
|
import cn.com.ty.lift.business.library.dao.entity.model.LiftRequest;
|
|
|
import cn.com.ty.lift.business.library.dao.entity.model.LiftResponse;
|
|
|
-import cn.com.ty.lift.business.library.dao.mapper.LiftExtensionMapper;
|
|
|
import cn.com.ty.lift.business.library.dao.mapper.LiftMapper;
|
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.MaintenanceCompany;
|
|
|
import cn.com.ty.lift.business.maintenance.service.MaintenanceService;
|
|
|
import cn.com.ty.lift.common.base.ExportRequest;
|
|
|
import cn.com.ty.lift.common.constants.ApiConstants;
|
|
|
+import cn.com.ty.lift.common.constants.CommonEnum;
|
|
|
import cn.com.ty.lift.common.export.ExportUtils;
|
|
|
import cn.com.ty.lift.common.utils.DateUtils;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -36,9 +34,6 @@ public class LiftService {
|
|
|
@Resource
|
|
|
private LiftMapper liftMapper;
|
|
|
|
|
|
- @Resource
|
|
|
- private LiftExtensionMapper liftExtensionMapper;
|
|
|
-
|
|
|
@Resource
|
|
|
private PlatformCompanyLiftRelevanceService platformService;
|
|
|
|
|
@@ -48,9 +43,6 @@ public class LiftService {
|
|
|
@Resource
|
|
|
private MaintenanceService maintenanceService;
|
|
|
|
|
|
- @Resource
|
|
|
- private RedisTemplate redisTemplate;
|
|
|
-
|
|
|
private Map<String, String> paramMap = new HashMap<String, String>() {{
|
|
|
put("liftCode", "电梯号");
|
|
|
put("registrationCode", "注册代码");
|
|
@@ -91,22 +83,6 @@ public class LiftService {
|
|
|
return liftMapper.selectById(id);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @param request 电梯
|
|
|
- * @return 电梯扩展实体
|
|
|
- * @description 初始化电梯扩展实体
|
|
|
- * @date 2019/12/3 3:25 PM
|
|
|
- */
|
|
|
- private LiftExtension init(LiftExtensionRequest request) {
|
|
|
- Long id = request.getLift().getId();
|
|
|
- Date annualInspectionDate = DateUtils.localDate2Date(request.getAnnualInspectionDate());
|
|
|
- LiftExtension extension = new LiftExtension();
|
|
|
- extension.setId(id);
|
|
|
- extension.setAnnualInspectionDate(annualInspectionDate);
|
|
|
- extension.setMtCompanyId(request.getMtCompanyId());
|
|
|
- return extension;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @param mtCompanyId 维保公司id
|
|
|
* @return 比较结果
|
|
@@ -135,25 +111,22 @@ public class LiftService {
|
|
|
Lift lift = request.getLift();
|
|
|
//按当前日期时间戳自动生成电梯编号
|
|
|
String liftCode = DateUtils.generateCode();
|
|
|
- lift.setLiftCode("DT" + liftCode);
|
|
|
+ if (CommonEnum.LiftType.STRAIGHT_LADDER.getCode().equals(Objects.toString(lift.getLiftType()))) {
|
|
|
+ lift.setLiftCode("ZT" + liftCode);
|
|
|
+ } else {
|
|
|
+ lift.setLiftCode("FT" + liftCode);
|
|
|
+ }
|
|
|
int liftResult = liftMapper.insert(lift);
|
|
|
if (liftResult == 0) {
|
|
|
return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
|
|
|
}
|
|
|
- //初始化电梯扩展实体
|
|
|
- LiftExtension extension = init(request);
|
|
|
- //新增电梯扩展表
|
|
|
- int extensionResult = liftExtensionMapper.insert(extension);
|
|
|
- if (extensionResult == 0) {
|
|
|
- return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
|
|
|
- }
|
|
|
//新增电梯来源
|
|
|
String source = request.getSource();
|
|
|
switch (source) {
|
|
|
//电梯管理入口
|
|
|
case "0":
|
|
|
//新增平台企业电梯关联表
|
|
|
- PlatformCompanyLiftRelevance ret = platformService.save(extension);
|
|
|
+ PlatformCompanyLiftRelevance ret = platformService.save(request);
|
|
|
if (ret == null) {
|
|
|
return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
|
|
|
}
|
|
@@ -161,12 +134,12 @@ public class LiftService {
|
|
|
//项目管理入口
|
|
|
case "1":
|
|
|
//新增平台企业电梯关联表
|
|
|
- PlatformCompanyLiftRelevance companyLiftEntry = platformService.save(extension);
|
|
|
+ PlatformCompanyLiftRelevance companyLiftEntry = platformService.save(request);
|
|
|
if (companyLiftEntry == null) {
|
|
|
return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
|
|
|
}
|
|
|
//新增项目电梯关联表
|
|
|
- boolean result = projectRelevanceService.save(extension, companyLiftEntry.getId(), request.getWorkerId());
|
|
|
+ boolean result = projectRelevanceService.save(request, companyLiftEntry.getId(), request.getWorkerId());
|
|
|
if (!result) {
|
|
|
return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
|
|
|
}
|