|
@@ -16,6 +16,7 @@ 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;
|
|
@@ -87,17 +88,16 @@ public class LiftService {
|
|
|
|
|
|
/**
|
|
|
* @param mtCompanyId 公司id
|
|
|
- * @param code 注册代码
|
|
|
+ * @param code 注册代码
|
|
|
+ * @param liftId 电梯id
|
|
|
* @return RestResponse 判断结果
|
|
|
- * @description 新增电梯前置判断条件
|
|
|
+ * @description 新增/修改电梯前置判断条件
|
|
|
* @date 2019/12/20 2:31 PM
|
|
|
*/
|
|
|
- public RestResponse preJudgment(Long mtCompanyId, String code) {
|
|
|
- /*if (judge(mtCompanyId))
|
|
|
- return RestResponse.fail(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.limit.num"));*/
|
|
|
+ public RestResponse preJudgment(Long mtCompanyId, String code, String liftId) {
|
|
|
//查询电梯表是否有该电梯
|
|
|
- Long id = findLiftExist(code);
|
|
|
- if (ObjectUtil.isNotEmpty(id)) {
|
|
|
+ Long id = findLiftExist(code, liftId);
|
|
|
+ if (ObjectUtil.isNotEmpty(id) && ObjectUtil.isEmpty(liftId)) {
|
|
|
Map<String, Object> paramMap = new HashMap<>(2);
|
|
|
paramMap.put("id", id);
|
|
|
paramMap.put("mtCompanyId", mtCompanyId);
|
|
@@ -109,6 +109,8 @@ public class LiftService {
|
|
|
Lift detail = detail(id);
|
|
|
return RestResponse.success(detail, ApiConstants.RESULT_SUCCESS, 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"));
|
|
|
}
|
|
@@ -131,12 +133,13 @@ public class LiftService {
|
|
|
|
|
|
/**
|
|
|
* @param registrationCode 电梯注册代码
|
|
|
+ * @param liftId 电梯id
|
|
|
* @return 电梯id
|
|
|
* @description 查询电梯是否存在
|
|
|
* @date 2019/12/20 11:04 AM
|
|
|
*/
|
|
|
- public Long findLiftExist(String registrationCode) {
|
|
|
- return liftMapper.findLiftExist(registrationCode);
|
|
|
+ public Long findLiftExist(String registrationCode, String liftId) {
|
|
|
+ return liftMapper.findLiftExist(registrationCode, liftId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -150,7 +153,13 @@ public class LiftService {
|
|
|
//获取新增标记 (0:新增,1:查询后带入)
|
|
|
String mark = request.getMark();
|
|
|
Lift lift = request.getLift();
|
|
|
- if ("0".equals(mark)){
|
|
|
+ //公司id
|
|
|
+ Long mtCompanyId = request.getMtCompanyId();
|
|
|
+ /*if (judge(mtCompanyId))
|
|
|
+ return RestResponse.fail(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.limit.num"));*/
|
|
|
+ RestResponse response = preJudgment(mtCompanyId, lift.getRegistrationCode(), null);
|
|
|
+ if (ObjectUtil.isNotEmpty(response.getData())) return response;
|
|
|
+ if ("0".equals(mark)) {
|
|
|
//按当前日期时间戳自动生成电梯编号
|
|
|
String liftCode = ApiConstants.STRAIGHT_LADDER + DateUtils.generateCode();
|
|
|
if (CommonEnum.LiftType.STAIRCASE.getCode().equals(Objects.toString(lift.getLiftType()))) {
|
|
@@ -164,8 +173,6 @@ public class LiftService {
|
|
|
}
|
|
|
//电梯id
|
|
|
Long id = lift.getId();
|
|
|
- //公司id
|
|
|
- Long mtCompanyId = request.getMtCompanyId();
|
|
|
//新增电梯来源
|
|
|
String source = request.getSource();
|
|
|
switch (source) {
|
|
@@ -212,8 +219,18 @@ public class LiftService {
|
|
|
* @description 修改电梯
|
|
|
* @date 2019/11/27 2:22 PM
|
|
|
*/
|
|
|
- public Integer modify(Lift lift) {
|
|
|
- return liftMapper.updateById(lift);
|
|
|
+ public RestResponse modify(Lift lift) {
|
|
|
+ String liftId = StrUtil.EMPTY;
|
|
|
+ if (ObjectUtil.isNotEmpty(lift.getId())) {
|
|
|
+ liftId = lift.getId().toString();
|
|
|
+ }
|
|
|
+ RestResponse response = preJudgment(null, lift.getRegistrationCode(), liftId);
|
|
|
+ if (ObjectUtil.isNotEmpty(response.getData())) return response;
|
|
|
+ int result = liftMapper.updateById(lift);
|
|
|
+ if (result > 0) {
|
|
|
+ return RestResponse.success();
|
|
|
+ }
|
|
|
+ return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
}
|
|
|
|
|
|
/**
|