wanghaicheng 5 years ago
parent
commit
77eb45b1af

+ 1 - 36
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/custom/controller/PropertyCompanyController.java

@@ -3,14 +3,12 @@ package cn.com.ty.lift.enterprise.custom.controller;
 import cn.com.ty.lift.enterprise.custom.dao.entity.PropertyCompany;
 import cn.com.ty.lift.enterprise.custom.dao.entity.model.PropertyCompanyReq;
 import cn.com.ty.lift.enterprise.custom.service.impl.PropertyCompanyServiceImpl;
-import cn.com.ty.lift.enterprise.custom.service.impl.PropertyContactServiceImpl;
 import cn.com.xwy.boot.web.dto.RestResponse;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.AllArgsConstructor;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.client.RestTemplate;
 
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 
 @RestController
@@ -59,7 +57,6 @@ public class PropertyCompanyController {
      * @return cn.com.xwy.boot.web.dto.RestResponse
      */
     public RestResponse add(@RequestBody PropertyCompany propertyCompany) {
-        //service层判断了是否有相同名称的name//如果数据库客户名不重复,就删除里面判断name是否重复的逻辑
         if (propertyCompanyService.save(propertyCompany)) {
             return RestResponse.ok(null,"1","新增成功");
         }
@@ -88,41 +85,9 @@ public class PropertyCompanyController {
      * @return cn.com.xwy.boot.web.dto.RestResponse
      */
     public RestResponse delete(@RequestBody PropertyCompany propertyCompany) {
-        //判断维保电梯台数是否为0
-        //判断维保电梯台数是否为0
-        //判断维保电梯台数是否为0
-        //判断维保电梯台数是否为0
-        //也就是客户公司创建的所有项目的总电梯的在保电梯是否为0
-
         return propertyCompanyService.delete(propertyCompany.getId());
     }
 
-    @PostMapping("/project")
-    public RestResponse project(@RequestBody PropertyCompany propertyCompany) {
-        propertyCompany.getId();
-        propertyCompany.getStatus();
-        //分页查询正在服务的项目列表
-        //分页查询正在服务的项目列表
-        //分页查询正在服务的项目列表
-        //分页查询正在服务的项目列表
-        //分页查询正在服务的项目列表
-        List<HashMap<String, Object>> request = new ArrayList<>();
-        HashMap<String, Object> map = new HashMap<>();
-//        map.put("projectStatus",1);
-//        request.add("")
-//        restTemplate.postForEntity("http://132.232.206.88/project/list",)
-//        Map<String, Object> map = new HashMap<>();
-        map.put("项目编号", "1");
-        map.put("项目名称", "1");
-        map.put("项目地址", "1");
-        map.put("在保台量", "1");
-        map.put("开始时间", "1");
-        map.put("结束时间", "1");
-        map.put("甲方项目负责人", "1");
-        map.put("甲方联系电话", "1");
-        return RestResponse.ok(map, "待实现");
-    }
-
     @PostMapping("/project/customs")
     public RestResponse customs(@RequestBody PropertyCompany propertyCompany) {
         List<PropertyCompany> propertyCompanies = propertyCompanyService.list(new QueryWrapper<PropertyCompany>()

+ 0 - 2
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/custom/dao/entity/PropertyCertificate.java

@@ -79,6 +79,4 @@ public class PropertyCertificate implements Serializable {
      */
     @TableId(value = "id", type = IdType.AUTO)
     private Integer id;
-
-
 }

+ 31 - 37
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/custom/service/impl/PropertyCompanyServiceImpl.java

@@ -4,7 +4,6 @@ import cn.com.ty.lift.enterprise.custom.dao.entity.PropertyCompany;
 import cn.com.ty.lift.enterprise.custom.dao.entity.PropertyContact;
 import cn.com.ty.lift.enterprise.custom.dao.entity.model.PropertyCompanyReq;
 import cn.com.ty.lift.enterprise.custom.dao.mapper.PropertyCompanyMapper;
-import cn.com.ty.lift.enterprise.custom.dao.mapper.PropertyContactMapper;
 import cn.com.ty.lift.enterprise.custom.service.PropertyCompanyService;
 import cn.com.xwy.boot.web.dto.RestResponse;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -12,11 +11,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.AllArgsConstructor;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.client.RestTemplate;
 
+import java.util.HashMap;
 import java.util.Map;
 
+
 /**
  * <p>
  * (甲方公司)客户表 服务实现类
@@ -29,64 +32,55 @@ import java.util.Map;
 @Transactional
 @AllArgsConstructor
 public class PropertyCompanyServiceImpl extends ServiceImpl<PropertyCompanyMapper, PropertyCompany> implements PropertyCompanyService {
-    private final PropertyContactMapper contactMapper;
+    private final PropertyContactServiceImpl propertyContactService;
+    private final RestTemplate restTemplate;
 
     public RestResponse delete(Long id) {
-        //维保电梯大于0
-        if (this.getMaintenanceLiftNum(1L) > 0) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("projectStatus", 2);
+        map.put("ppCompanyId", id);
+        map.put("pageNum", 1);
+        map.put("pageSize", 1);
+        ResponseEntity<HashMap> objectResponseEntity = restTemplate.postForEntity("http://132.232.206.88:20227/project/companyProjectList", map, HashMap.class);
+        String statusCode = (String) objectResponseEntity.getBody().get("statusCode");
+        if (statusCode.equals("1")) {
             //就不删除
-            return RestResponse.ok(null, "0", "维保电梯大于0,无法删除");
+            return RestResponse.ok(null, "0", "有正在服务的关联项目,无法删除");
         }
-        //如果维保电梯小于等于0,逻辑删除
-        PropertyCompany one = this.getOne(new QueryWrapper<PropertyCompany>().eq("id", id));
-        if (null != one) {
-            one.setStatus(0);
-            this.updateById(one);
-            this.deleteForContact(id);
-            return RestResponse.ok(null, "1", "删除成功");
-        } else {
+        //如果有这项,逻辑删除
+        PropertyCompany one = this.getById(id);
+        if (null == one) {
             return RestResponse.ok(null, "0", "删除失败");
         }
+
+        one.setStatus(0);
+        this.updateById(one);
+        this.deleteForContact(id);
+        return RestResponse.ok(null, "1", "删除成功");
     }
 
-    public int deleteForContact(Long id) {
+    public boolean deleteForContact(Long id) {
         PropertyContact propertyContact = new PropertyContact();
         propertyContact.setStatus(0);
-        return contactMapper.update(propertyContact, new QueryWrapper<PropertyContact>().eq("pp_company_id", id));
-    }
-
-    private Integer getMaintenanceLiftNum(Long id) {
-        //查询维保电梯数
-        //查询维保电梯数
-        //查询维保电梯数
-        //查询维保电梯数
-        //查询维保电梯数
-        //查询维保电梯数
-        return 888;
+        return propertyContactService.update(propertyContact,
+                new QueryWrapper<PropertyContact>()
+                        .eq("pp_company_id", id));
     }
 
     public RestResponse propertyCompanies(PropertyCompanyReq propertyCompany) {
-        //判断是否有这些请求参数
-        boolean nameFlag = propertyCompany.getName() != null;
-        boolean addressFlag = propertyCompany.getAddress() != null;
-        boolean telephoneFlag = propertyCompany.getTelephone() != null;
-        boolean mailingAddressFlag = propertyCompany.getMailingAddress() != null;
-
-
         Page<PropertyCompany> page = new Page<>(propertyCompany.getPageNum(), propertyCompany.getPageSize());
         //根据请求参数查询客户列表
         IPage<PropertyCompany> records = this
                 .page(page, new QueryWrapper<PropertyCompany>()
                         .select("id", "mt_company_id", "name", "mailing_address", "telephone", "status")
                         .eq("mt_company_id", propertyCompany.getMtCompanyId())
-                        .like(nameFlag, "name", propertyCompany.getName())
-                        .like(addressFlag, "address", propertyCompany.getAddress())
-                        .like(telephoneFlag, "telephone", propertyCompany.getTelephone())
-                        .like(mailingAddressFlag, "mailing_address", propertyCompany.getMailingAddress()));
+                        .like(propertyCompany.getName() != null, "name", propertyCompany.getName())
+                        .like(propertyCompany.getAddress() != null, "address", propertyCompany.getAddress())
+                        .like(propertyCompany.getTelephone() != null, "telephone", propertyCompany.getTelephone())
+                        .like(propertyCompany.getMailingAddress() != null, "mailing_address", propertyCompany.getMailingAddress()));
         if (records.getRecords().isEmpty()) {
             return RestResponse.ok(null, "9", "无数据");
         }
-
         return RestResponse.ok(records, "1", "查询成功");
     }
 }

+ 22 - 6
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/custom/service/impl/PropertyContactServiceImpl.java

@@ -6,8 +6,13 @@ import cn.com.ty.lift.enterprise.custom.service.PropertyContactService;
 import cn.com.xwy.boot.web.dto.RestResponse;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.AllArgsConstructor;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.HashMap;
 
 /**
  * <p>
@@ -19,23 +24,34 @@ import org.springframework.transaction.annotation.Transactional;
  */
 @Service
 @Transactional
+@AllArgsConstructor
 public class PropertyContactServiceImpl extends ServiceImpl<PropertyContactMapper, PropertyContact> implements PropertyContactService {
+    private final RestTemplate restTemplate;
 
     public RestResponse delete(Long id) {
         PropertyContact byId = this.getById(id);
         if (null == byId) {
             return RestResponse.ok(null, "9", "无数据");
         }
-
-        if (byId.getStatus() == 2) {
-            return RestResponse.ok(null, "0", "有关联项目,无法删除");
+        //获取联系人在项目表中是否有还在维保中的项目信息
+        HashMap<String, Object> map = new HashMap<>();
+        map.put("projectStatus", 2);
+        map.put("ppContactId", id);
+        map.put("ppCompanyId", byId.getPpCompanyId());
+        map.put("pageNum", 1);
+        map.put("pageSize", 1);
+        ResponseEntity<HashMap> objectResponseEntity = restTemplate.postForEntity("http://132.232.206.88:20227/project/companyProjectList", map, HashMap.class);
+        String statusCode = (String) objectResponseEntity.getBody().get("statusCode");
+        //还有维保的项目就不能删除联系人
+        if (statusCode.equals("1")) {
+            //就不删除
+            return RestResponse.ok(null, "0", "有正在服务的关联项目,无法删除");
         }
-
         byId.setStatus(0);
         if (this.update(byId, new QueryWrapper<PropertyContact>().eq("id", byId.getId()))) {
-            return RestResponse.ok(null, "1","删除成功");
+            return RestResponse.ok(null, "1", "删除成功");
         } else {
-            return RestResponse.ok(null, "0","删除失败");
+            return RestResponse.ok(null, "0", "删除失败");
         }
     }
 }

+ 1 - 1
lift-quan-service/pom.xml

@@ -35,7 +35,7 @@
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
                 <configuration>
-                    <mainClass>cn.com.ty.lift.enterprise.EnterpriseApplication</mainClass>
+                    <mainClass>cn.com.ty.lift.quan.QuanApplication</mainClass>
                 </configuration>
             </plugin>
         </plugins>