浏览代码

Merge branches 'develop' and 'huangyuan-user' of http://132.232.206.88:3000/lift-manager/lift-server into huangyuan-user

黄远 5 年之前
父节点
当前提交
b2a84df37e

+ 40 - 11
lift-business-service/src/main/java/cn/com/ty/lift/business/project/service/ProjectAppService.java

@@ -7,6 +7,7 @@ import cn.com.ty.lift.business.library.dao.entity.Lift;
 import cn.com.ty.lift.business.library.dao.entity.PlatformCompanyLiftRelevance;
 import cn.com.ty.lift.business.library.dao.entity.model.request.LiftExtensionRequest;
 import cn.com.ty.lift.business.library.service.LiftService;
+import cn.com.ty.lift.business.library.service.PlatformCompanyLiftRelevanceService;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.MaintenanceCount;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MaintenanceRecordRequest;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MaintenanceAppResponse;
@@ -25,6 +26,7 @@ import cn.com.ty.lift.business.project.dao.mapper.ProjectMapper;
 import cn.com.ty.lift.business.project.dao.mapper.ProjectUserMapper;
 import cn.com.xwy.boot.web.dto.RestResponse;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
@@ -76,6 +78,9 @@ public class ProjectAppService extends ServiceImpl<ProjectMapper, Project> {
     @Resource
     private MaintenanceService maintenanceService;
 
+    @Resource
+    private PlatformCompanyLiftRelevanceService platformService;
+
     /**
      * @param request 公司id
      * @return RestResponse 项目列表
@@ -109,6 +114,27 @@ public class ProjectAppService extends ServiceImpl<ProjectMapper, Project> {
         return baseMapper.findListByProjectId(request.getPage(), request);
     }
 
+    /**
+     * @param mtCompanyId      公司id
+     * @param registrationCode 注册代码
+     * @return RestResponse 判断结果
+     * @description 新增电梯前置判断条件
+     * @date 2019/12/20 2:31 PM
+     */
+    public boolean preJudgment(Long mtCompanyId, String registrationCode) {
+        //查询电梯表是否有该电梯
+        Optional<Lift> lift = liftService.getOne(registrationCode, null);
+        Long liftId = lift.map(Lift::getId).orElse(null);
+        if (ObjectUtil.isNotEmpty(liftId)) {
+            Map<String, Object> paramMap = new HashMap<>(2);
+            paramMap.put("liftId", liftId);
+            paramMap.put("mtCompanyId", mtCompanyId);
+            //查询该公司下是否有此电梯
+            boolean result = platformService.findCompanyLiftExist(paramMap);
+            return !result;
+        } else return true;
+    }
+
     /**
      * @param request 新增电梯数据项
      * @return RestResponse 状态码和返回消息
@@ -117,13 +143,25 @@ public class ProjectAppService extends ServiceImpl<ProjectMapper, Project> {
      */
     @Transactional(rollbackFor = Exception.class)
     public RestResponse add(LiftExtensionRequest request) {
+        Long mtCompanyId = request.getMtCompanyId();
         Lift lift = request.getLift();
+        if (!preJudgment(mtCompanyId, lift.getRegistrationCode()))
+            return RestResponse.fail(MessageUtils.get("msg.lift.exist"));
+
         boolean result = liftService.save(lift);
         if (!result) {
             return RestResponse.fail(MessageUtils.get("msg.add.fail"));
         }
         Long liftId = lift.getId();
-        Long mtCompanyId = request.getMtCompanyId();
+        //判断当前公司台量是否大于企业设置的台量
+        if (!maintenanceService.judge(mtCompanyId))
+            return RestResponse.fail(MessageUtils.get("msg.limit.num"));
+
+        PlatformCompanyLiftRelevance companyLiftEntry = liftService.saveCompanyLiftInfo(liftId, mtCompanyId);
+        if (Objects.isNull(companyLiftEntry)) {
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            return RestResponse.fail(MessageUtils.get("msg.add.fail"));
+        }
         Long projectId = request.getProjectId();
         Optional<Project> optional = projectService.getOne(projectId);
         int num = 0;
@@ -136,15 +174,6 @@ public class ProjectAppService extends ServiceImpl<ProjectMapper, Project> {
         if (currentNum >= num) {
             return RestResponse.fail(MessageUtils.get("msg.project.limit.num"));
         }
-        //判断当前公司台量是否大于企业设置的台量
-        if (!maintenanceService.judge(mtCompanyId))
-            return RestResponse.fail(MessageUtils.get("msg.limit.num"));
-
-        PlatformCompanyLiftRelevance companyLiftEntry = liftService.saveCompanyLiftInfo(liftId, mtCompanyId);
-        if (Objects.isNull(companyLiftEntry)) {
-            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-            return RestResponse.fail(MessageUtils.get("msg.add.fail"));
-        }
         //新增项目电梯关联表
         ProjectLiftRelevance projectLiftRelevance = projectLiftRelevanceService
                 .save(lift.getId(), request.getProjectId(), companyLiftEntry.getId(), request.getWorkerId(), mtCompanyId);
@@ -154,7 +183,7 @@ public class ProjectAppService extends ServiceImpl<ProjectMapper, Project> {
         }
         //新增电梯发送消息
         liftService.sendAddMessage(liftId, projectLiftRelevance.getProjectId(), mtCompanyId);
-        return RestResponse.success(MessageUtils.get("msg.add.success"));
+        return RestResponse.success(null, MessageUtils.get("msg.add.success"));
     }
 
     /**

+ 4 - 0
lift-business-service/src/main/resources/application-prod.yml

@@ -40,6 +40,10 @@ spring:
   jms:
     #如果是点对点(queue),那么此处默认应该是false,如果发布订阅,那么一定设置为true
     pub-sub-domain: false
+  servlet:
+    multipart:
+      #配置文件接收大小最大为3MB
+      max-file-size: 3MB
 
 #aliyun OSS服务配置信息,加载到SystemConfiguration
 aliyun:

+ 1 - 1
lift-common/src/main/java/cn.com.ty.lift.common/constants/SqlConstants.java

@@ -151,7 +151,7 @@ public interface SqlConstants {
                     "   from region r" +
                     "         left join user_info ui on r.user_id = ui.user_id" +
                     "     where mt_company_id = #{mtCompanyId}" +
-                    "       and (r.area_name like '%${name}%' or ui.name like '%${name}%')" +
+                    "       and r.area_name like '%${name}%' and ui.name like '%${name}%'" +
                     "   order by create_time desc";
 
     //根据用户id查询待维保数量