|
@@ -15,6 +15,7 @@ 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 cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -83,6 +84,36 @@ public class LiftService {
|
|
|
return liftMapper.selectById(id);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param mtCompanyId 公司id
|
|
|
+ * @param code 注册代码
|
|
|
+ * @return RestResponse 判断结果
|
|
|
+ * @description 新增电梯前置判断条件
|
|
|
+ * @date 2019/12/20 2:31 PM
|
|
|
+ */
|
|
|
+ public RestResponse preJudgment(Long mtCompanyId, String code) {
|
|
|
+ /*if (judge(mtCompanyId))
|
|
|
+ return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.limit.num"));*/
|
|
|
+ //查询电梯表是否有该电梯
|
|
|
+ Long id = findLiftExist(code);
|
|
|
+ if (ObjectUtil.isNotEmpty(id)) {
|
|
|
+ Map<String, Object> paramMap = new HashMap<>(2);
|
|
|
+ paramMap.put("id", id);
|
|
|
+ paramMap.put("mtCompanyId", mtCompanyId);
|
|
|
+ //查询该公司下是否有此电梯
|
|
|
+ boolean result = platformService.findCompanyLiftExist(paramMap);
|
|
|
+ if (result) {
|
|
|
+ return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.lift.exist"));
|
|
|
+ } else {
|
|
|
+ Lift detail = detail(id);
|
|
|
+ return RestResponse.ok(detail, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.lift.company.exist"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.pre.judge"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param mtCompanyId 维保公司id
|
|
|
* @return 比较结果
|
|
@@ -90,12 +121,24 @@ public class LiftService {
|
|
|
* @date 2019/12/12 5:27 PM
|
|
|
*/
|
|
|
public boolean judge(Long mtCompanyId) {
|
|
|
+ //查询维保公司设置的最大电梯台量
|
|
|
MaintenanceCompany company = maintenanceService.selectById(mtCompanyId);
|
|
|
Integer limitedNum = company.getLimitedNum();
|
|
|
+ //获取该公司企业电梯关联表的实际电梯台量
|
|
|
Integer currentNum = platformService.countLiftNum(mtCompanyId);
|
|
|
return currentNum >= limitedNum;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param registrationCode 电梯注册代码
|
|
|
+ * @return 电梯id
|
|
|
+ * @description 查询电梯是否存在
|
|
|
+ * @date 2019/12/20 11:04 AM
|
|
|
+ */
|
|
|
+ public Long findLiftExist(String registrationCode) {
|
|
|
+ return liftMapper.findLiftExist(registrationCode);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param request 新增电梯数据项
|
|
|
* @return RestResponse 状态码和返回消息
|
|
@@ -104,40 +147,52 @@ public class LiftService {
|
|
|
*/
|
|
|
@Transactional
|
|
|
public RestResponse add(LiftExtensionRequest request) {
|
|
|
- /*Long mtCompanyId = lift.getMtCompanyId();
|
|
|
- if (judge(mtCompanyId))
|
|
|
- return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.limit.num"));*/
|
|
|
- //新增电梯表
|
|
|
+ String mark = request.getMark();
|
|
|
Lift lift = request.getLift();
|
|
|
- //按当前日期时间戳自动生成电梯编号
|
|
|
- String liftCode = DateUtils.generateCode();
|
|
|
- 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"));
|
|
|
+ if ("0".equals(mark)){
|
|
|
+ //按当前日期时间戳自动生成电梯编号
|
|
|
+ String liftCode = ApiConstants.STRAIGHT_LADDER + DateUtils.generateCode();
|
|
|
+ if (CommonEnum.LiftType.STAIRCASE.getCode().equals(Objects.toString(lift.getLiftType()))) {
|
|
|
+ lift.setLiftCode(ApiConstants.STAIRCASE + liftCode);
|
|
|
+ }
|
|
|
+ //新增电梯表
|
|
|
+ int liftResult = liftMapper.insert(lift);
|
|
|
+ if (liftResult == 0) {
|
|
|
+ return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
|
|
|
+ }
|
|
|
}
|
|
|
+ //电梯id
|
|
|
+ Long id = lift.getId();
|
|
|
+ //公司id
|
|
|
+ Long mtCompanyId = request.getMtCompanyId();
|
|
|
//新增电梯来源
|
|
|
String source = request.getSource();
|
|
|
switch (source) {
|
|
|
//电梯管理入口
|
|
|
case "0":
|
|
|
- //新增平台企业电梯关联表
|
|
|
- PlatformCompanyLiftRelevance ret = platformService.save(request);
|
|
|
+ //新增企业电梯关联表
|
|
|
+ PlatformCompanyLiftRelevance ret = platformService.save(id, mtCompanyId);
|
|
|
if (ret == null) {
|
|
|
return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
|
|
|
}
|
|
|
+ //新增平台电梯关联表
|
|
|
+ PlatformCompanyLiftRelevance liftRelevance = platformService.save(id, ApiConstants.PLATFORM_COMPANY_ID);
|
|
|
+ if (liftRelevance == null) {
|
|
|
+ return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
|
|
|
+ }
|
|
|
break;
|
|
|
//项目管理入口
|
|
|
case "1":
|
|
|
- //新增平台企业电梯关联表
|
|
|
- PlatformCompanyLiftRelevance companyLiftEntry = platformService.save(request);
|
|
|
+ //新增企业电梯关联表
|
|
|
+ PlatformCompanyLiftRelevance companyLiftEntry = platformService.save(id, mtCompanyId);
|
|
|
if (companyLiftEntry == null) {
|
|
|
return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
|
|
|
}
|
|
|
+ //新增平台电梯关联表
|
|
|
+ PlatformCompanyLiftRelevance relevance = platformService.save(id, ApiConstants.PLATFORM_COMPANY_ID);
|
|
|
+ if (relevance == null) {
|
|
|
+ return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
|
|
|
+ }
|
|
|
//新增项目电梯关联表
|
|
|
boolean result = projectRelevanceService.save(request, companyLiftEntry.getId(), request.getWorkerId());
|
|
|
if (!result) {
|