|
@@ -16,6 +16,7 @@ import cn.com.ty.lift.common.constants.ApiConstants;
|
|
|
import cn.com.ty.lift.common.constants.RedisConstants;
|
|
|
import cn.com.ty.lift.common.export.ExportUtils;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
@@ -70,12 +71,14 @@ public class LiftService {
|
|
|
*/
|
|
|
public RestResponse list(LiftRequest request) {
|
|
|
IPage<LiftResponse> page = new Page<>(request.getPageNum(), request.getPageSize());
|
|
|
- List<LiftResponse> lifts = liftMapper.findByCondition(page, request);
|
|
|
- if (lifts.isEmpty()) {
|
|
|
- page.setRecords(new ArrayList<>());
|
|
|
+ if (request.getCondition() != null) {
|
|
|
+ request.setCondition(StrUtil.format("%{}%", request.getCondition()));
|
|
|
+ }
|
|
|
+ IPage<LiftResponse> lifts = liftMapper.findByCondition(page, request);
|
|
|
+ List<LiftResponse> responseList = lifts.getRecords();
|
|
|
+ if (responseList.isEmpty()) {
|
|
|
return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, MessageUtils.get("msg.data.empty"));
|
|
|
}
|
|
|
- page.setRecords(lifts);
|
|
|
return RestResponse.ok(page, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.query.success"));
|
|
|
}
|
|
|
|
|
@@ -118,15 +121,15 @@ public class LiftService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param lift 电梯
|
|
|
+ * @param mtCompanyId 维保公司id
|
|
|
* @return 比较结果
|
|
|
* @description 判断当前公司台量是否大于企业设置的台量
|
|
|
* @date 2019/12/12 5:27 PM
|
|
|
*/
|
|
|
- public boolean judge(Lift lift) {
|
|
|
- MaintenanceCompany company = maintenanceService.selectById(lift.getMtCompanyId());
|
|
|
+ public boolean judge(Long mtCompanyId) {
|
|
|
+ MaintenanceCompany company = maintenanceService.selectById(mtCompanyId);
|
|
|
Integer limitedNum = company.getLimitedNum();
|
|
|
- Integer currentNum = platformService.countLiftNum(lift.getMtCompanyId());
|
|
|
+ Integer currentNum = platformService.countLiftNum(mtCompanyId);
|
|
|
return currentNum >= limitedNum;
|
|
|
}
|
|
|
|
|
@@ -138,7 +141,8 @@ public class LiftService {
|
|
|
*/
|
|
|
@Transactional
|
|
|
public RestResponse add(Lift lift) {
|
|
|
- if (judge(lift))
|
|
|
+ Long mtCompanyId = lift.getMtCompanyId();
|
|
|
+ if (judge(mtCompanyId))
|
|
|
return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.limit.num"));
|
|
|
//新增电梯表
|
|
|
int liftResult = liftMapper.insert(lift);
|