|
@@ -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", "查询成功");
|
|
|
}
|
|
|
}
|