|
@@ -16,7 +16,6 @@ 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 cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -88,16 +87,15 @@ public class LiftService {
|
|
|
|
|
|
/**
|
|
|
* @param mtCompanyId 公司id
|
|
|
- * @param code 注册代码
|
|
|
- * @param liftId 电梯id
|
|
|
+ * @param registrationCode 注册代码
|
|
|
* @return RestResponse 判断结果
|
|
|
- * @description 新增/修改电梯前置判断条件
|
|
|
+ * @description 新增电梯前置判断条件
|
|
|
* @date 2019/12/20 2:31 PM
|
|
|
*/
|
|
|
- public RestResponse preJudgment(Long mtCompanyId, String code, String liftId) {
|
|
|
+ public RestResponse preJudgment(Long mtCompanyId, String registrationCode) {
|
|
|
//查询电梯表是否有该电梯
|
|
|
- Long id = findLiftExist(code, liftId);
|
|
|
- if (ObjectUtil.isNotEmpty(id) && ObjectUtil.isEmpty(liftId)) {
|
|
|
+ Long id = findLiftExist(registrationCode);
|
|
|
+ if (ObjectUtil.isNotEmpty(id)) {
|
|
|
Map<String, Object> paramMap = new HashMap<>(2);
|
|
|
paramMap.put("id", id);
|
|
|
paramMap.put("mtCompanyId", mtCompanyId);
|
|
@@ -107,12 +105,10 @@ public class LiftService {
|
|
|
return RestResponse.fail(MessageUtils.get("msg.lift.exist"));
|
|
|
} else {
|
|
|
Lift detail = detail(id);
|
|
|
- return RestResponse.success(detail, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.lift.company.exist"));
|
|
|
+ return RestResponse.success(detail, MessageUtils.get("msg.lift.company.exist"));
|
|
|
}
|
|
|
- } else if (ObjectUtil.isNotEmpty(id) && ObjectUtil.isNotEmpty(liftId)) {
|
|
|
- return RestResponse.fail(MessageUtils.get("msg.lift.library.exist"));
|
|
|
- } else {
|
|
|
- return RestResponse.success(null, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.pre.judge"));
|
|
|
+ } else {
|
|
|
+ return RestResponse.success(null, MessageUtils.get("msg.pre.judge"));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -133,13 +129,12 @@ public class LiftService {
|
|
|
|
|
|
/**
|
|
|
* @param registrationCode 电梯注册代码
|
|
|
- * @param liftId 电梯id
|
|
|
* @return 电梯id
|
|
|
* @description 查询电梯是否存在
|
|
|
* @date 2019/12/20 11:04 AM
|
|
|
*/
|
|
|
- public Long findLiftExist(String registrationCode, String liftId) {
|
|
|
- return liftMapper.findLiftExist(registrationCode, liftId);
|
|
|
+ public Long findLiftExist(String registrationCode) {
|
|
|
+ return liftMapper.findLiftExist(registrationCode);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -150,19 +145,19 @@ public class LiftService {
|
|
|
*/
|
|
|
@Transactional
|
|
|
public RestResponse add(LiftExtensionRequest request) {
|
|
|
+ //电梯id
|
|
|
+ Long id;
|
|
|
//获取新增标记 (0:新增,1:查询后带入)
|
|
|
String mark = request.getMark();
|
|
|
//公司id
|
|
|
Long mtCompanyId = request.getMtCompanyId();
|
|
|
- //电梯id
|
|
|
- Long id;
|
|
|
+ Lift lift = request.getLift();
|
|
|
/*if (judge(mtCompanyId))
|
|
|
return RestResponse.fail(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.limit.num"));*/
|
|
|
- RestResponse response = preJudgment(mtCompanyId, request.getCode(), null);
|
|
|
- if (ApiConstants.RESULT_ERROR.equals(response.getMessage())) return response;
|
|
|
+ RestResponse response = preJudgment(mtCompanyId, lift.getRegistrationCode());
|
|
|
+ if (ApiConstants.RESULT_ERROR.equals(response.getStatusCode())) return response;
|
|
|
//新增标记 (0:新增,1:查询后带入)
|
|
|
if ("0".equals(mark)) {
|
|
|
- Lift lift = request.getLift();
|
|
|
//按当前日期时间戳自动生成电梯编号
|
|
|
String liftCode = ApiConstants.STRAIGHT_LADDER + DateUtils.generateCode();
|
|
|
if (CommonEnum.LiftType.STAIRCASE.getCode().equals(Objects.toString(lift.getLiftType()))) {
|
|
@@ -214,7 +209,7 @@ public class LiftService {
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
- return RestResponse.success(null, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.add.success"));
|
|
|
+ return RestResponse.success(null, MessageUtils.get("msg.add.success"));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -224,15 +219,9 @@ public class LiftService {
|
|
|
* @date 2019/11/27 2:22 PM
|
|
|
*/
|
|
|
public RestResponse modify(Lift lift) {
|
|
|
- String liftId = StrUtil.EMPTY;
|
|
|
- if (ObjectUtil.isNotEmpty(lift)) {
|
|
|
- liftId = lift.getId().toString();
|
|
|
- }
|
|
|
- RestResponse response = preJudgment(null, lift.getRegistrationCode(), liftId);
|
|
|
- if (ApiConstants.RESULT_ERROR.equals(response.getMessage())) return response;
|
|
|
int result = liftMapper.updateById(lift);
|
|
|
if (result > 0) {
|
|
|
- return RestResponse.success();
|
|
|
+ return RestResponse.success(null, MessageUtils.get("msg.modify.success"));
|
|
|
}
|
|
|
return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
}
|