|
@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -34,7 +35,6 @@ public class PropertyCompanyServiceImpl extends ServiceImpl<PropertyCompanyMappe
|
|
|
if (null != this.getOne(new QueryWrapper<PropertyCompany>().eq("name", propertyCompany.getName()))) {
|
|
|
return RestResponse.ok(null, "0", "客户已存在");
|
|
|
}
|
|
|
-
|
|
|
if (this.save(propertyCompany)) {
|
|
|
return RestResponse.ok(null, "1", "新增客户成功");
|
|
|
} else {
|
|
@@ -47,18 +47,18 @@ public class PropertyCompanyServiceImpl extends ServiceImpl<PropertyCompanyMappe
|
|
|
if (this.getMaintenanceLiftNum() > 0) {
|
|
|
//就不删除
|
|
|
return "维保电梯大于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 "删除成功";
|
|
|
} else {
|
|
|
- //如果维保电梯小于等于0,逻辑删除
|
|
|
- PropertyCompany one = this.getOne(new QueryWrapper<PropertyCompany>().eq("id", id));
|
|
|
- if (null != one) {
|
|
|
- one.setStatus(0);
|
|
|
- this.updateById(one);
|
|
|
- this.deleteForContact(id);
|
|
|
- return "删除成功";
|
|
|
- } else {
|
|
|
- return "删除失败";
|
|
|
- }
|
|
|
+ return "删除失败";
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public int deleteForContact(Long id) {
|
|
@@ -84,40 +84,6 @@ public class PropertyCompanyServiceImpl extends ServiceImpl<PropertyCompanyMappe
|
|
|
return 888;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @param
|
|
|
- * @return
|
|
|
- * @description 根据id分页查询客户
|
|
|
- * @date 2019/12/2 10:15
|
|
|
- */
|
|
|
- public RestResponse propertyCompanies(Long mtCompanyId, Integer pageNum, Integer pageSize) {
|
|
|
- Page<PropertyCompany> page = new Page<>(pageNum, pageSize);
|
|
|
- IPage<Map<String, Object>> records = this.pageMaps(page, new QueryWrapper<PropertyCompany>()
|
|
|
- .select("id", "code", "name", "address", "telephone")
|
|
|
- .eq("mt_company_id", mtCompanyId));
|
|
|
- records.getRecords().forEach(record -> {
|
|
|
- record.put("maintenanceLiftNum", this.getMaintenanceLiftNum());
|
|
|
- });
|
|
|
- return RestResponse.ok(records, "查询成功");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param
|
|
|
- * @return
|
|
|
- * @description 根据rowName(字段名),分页查询
|
|
|
- * @date 2019/12/2 10:16
|
|
|
- */
|
|
|
- public RestResponse propertyCompaniesFromRowName(Long mtCompanyId, Integer pageNum, Integer pageSize, String rowName, Object rowValue) {
|
|
|
- Page<PropertyCompany> page = new Page<>(pageNum, pageSize);
|
|
|
- IPage<Map<String, Object>> records = this.pageMaps(page, new QueryWrapper<PropertyCompany>()
|
|
|
- .select("id", "code", "name", "address", "telephone").like(rowName, rowValue)
|
|
|
- .eq("mt_company_id", mtCompanyId));
|
|
|
- records.getRecords().forEach(record -> {
|
|
|
- record.put("maintenanceLiftNum", this.getMaintenanceLiftNum());
|
|
|
- });
|
|
|
- return RestResponse.ok(records, "1", "查询成功");
|
|
|
- }
|
|
|
-
|
|
|
public RestResponse propertyCompaniesForCondition(PropertyCompanyReq propertyCompany) {
|
|
|
String name = propertyCompany.getName();
|
|
|
String address = propertyCompany.getAddress();
|
|
@@ -131,7 +97,9 @@ public class PropertyCompanyServiceImpl extends ServiceImpl<PropertyCompanyMappe
|
|
|
.pageMaps(page, new QueryWrapper<PropertyCompany>()
|
|
|
.select("id", "code", "name", "address", "telephone")
|
|
|
.eq("mt_company_id", propertyCompany.getMtCompanyId())
|
|
|
- .like(nameFlag, "name", name).like(addressFlag, "address", address).like(telephoneFlag, "telephone", telephone));
|
|
|
+ .like(nameFlag, "name", name)
|
|
|
+ .like(addressFlag, "address", address)
|
|
|
+ .like(telephoneFlag, "telephone", telephone));
|
|
|
if (!records.getRecords().isEmpty()) {
|
|
|
records.getRecords().forEach(record -> {
|
|
|
record.put("maintenanceLiftNum", this.getMaintenanceLiftNum());
|