package com.java110.fee.api.z2;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.java110.dto.importData.OwnerPropertySurvey;
|
import com.java110.utils.util.Assert;
|
import com.java110.utils.util.BeanConvertUtil;
|
import org.mybatis.spring.SqlSessionTemplate;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.ResponseEntity;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 业主房屋产调记录表信息接口
|
* 适配 owner_property_survey 表
|
* @author dev
|
* @date 2025-12-24
|
*/
|
@RestController
|
@RequestMapping(value = "/ownerPropertySurvey")
|
public class OwnerPropertySurveyApi {
|
|
@Autowired
|
protected SqlSessionTemplate sqlSessionTemplate;
|
|
/**
|
* 保存单条业主房屋产调记录信息
|
*
|
* @param reqJson 请求参数
|
* @return 响应结果
|
* @serviceCode /ownerPropertySurvey/saveOwnerPropertySurveyInfo
|
* @path /app/ownerPropertySurvey/saveOwnerPropertySurveyInfo
|
*/
|
@RequestMapping(value = "/saveOwnerPropertySurvey", method = RequestMethod.POST)
|
public ResponseEntity<String> saveOwnerPropertySurveyInfo(@RequestBody JSONObject reqJson) {
|
// 核心参数校验(业主ID、房屋ID为非空字段)
|
Assert.hasKeyAndValue(reqJson, "ownerId", "请求报文中未包含业主编号ownerId");
|
Assert.hasKeyAndValue(reqJson, "roomId", "请求报文中未包含房屋编号roomId");
|
|
// 转换为实体类
|
OwnerPropertySurvey survey = BeanConvertUtil.covertBean(reqJson, OwnerPropertySurvey.class);
|
|
// 调用Mapper保存方法
|
int insert = sqlSessionTemplate.insert("ownerPropertySurveyServiceDaoImpl.saveOwnerPropertySurveyInfo",
|
BeanConvertUtil.beanCovertMap(survey));
|
|
// 构造响应结果
|
JSONObject resJson = new JSONObject();
|
if (insert > 0) {
|
resJson.put("code", "0000");
|
resJson.put("msg", "保存业主房屋产调记录信息成功");
|
} else {
|
resJson.put("code", "0001");
|
resJson.put("msg", "保存业主房屋产调记录信息失败");
|
}
|
resJson.put("count", insert);
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 批量保存业主房屋产调记录信息
|
*
|
* @param reqJson 请求参数(包含ownerPropertySurveyList数组)
|
* @return 响应结果
|
* @serviceCode /ownerPropertySurvey/saveOwnerPropertySurveys
|
* @path /app/ownerPropertySurvey/saveOwnerPropertySurveys
|
*/
|
@RequestMapping(value = "/saveOwnerPropertySurveys", method = RequestMethod.POST)
|
public ResponseEntity<String> saveOwnerPropertySurveys(@RequestBody JSONObject reqJson) {
|
Assert.hasKeyAndValue(reqJson, "ownerPropertySurveyList", "请求报文中未包含批量数据列表ownerPropertySurveyList");
|
|
// 转换批量数据
|
List<OwnerPropertySurvey> surveyList = BeanConvertUtil.covertBeanList(
|
reqJson.getJSONArray("ownerPropertySurveyList"), OwnerPropertySurvey.class);
|
|
Map<String, Object> param = new HashMap<>();
|
param.put("ownerPropertySurveyPos", surveyList);
|
|
// 批量插入
|
int insert = sqlSessionTemplate.insert("ownerPropertySurveyServiceDaoImpl.saveOwnerPropertySurveys", param);
|
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "批量保存业主房屋产调记录信息成功");
|
resJson.put("count", insert);
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 修改业主房屋产调记录信息
|
*
|
* @param reqJson 请求参数
|
* @return 响应结果
|
* @serviceCode /ownerPropertySurvey/updateOwnerPropertySurveyInfo
|
* @path /app/ownerPropertySurvey/updateOwnerPropertySurveyInfo
|
*/
|
@RequestMapping(value = "/updateOwnerPropertySurveyInfo", method = RequestMethod.POST)
|
public ResponseEntity<String> updateOwnerPropertySurveyInfo(@RequestBody JSONObject reqJson) {
|
// 主键校验(id 或 ownerId+roomId 二选一)
|
boolean hasId = reqJson.containsKey("id") && reqJson.getString("id") != null && !reqJson.getString("id").isEmpty();
|
boolean hasOwnerAndRoomId = reqJson.containsKey("ownerId") && !reqJson.getString("ownerId").isEmpty()
|
&& reqJson.containsKey("roomId") && !reqJson.getString("roomId").isEmpty();
|
Assert.isTrue(hasId || hasOwnerAndRoomId, "请求报文中需包含主键ID,或同时包含业主编号和房屋编号");
|
|
// 转换为实体类
|
OwnerPropertySurvey survey = BeanConvertUtil.covertBean(reqJson, OwnerPropertySurvey.class);
|
|
// 调用Mapper修改方法
|
int update = sqlSessionTemplate.update("ownerPropertySurveyServiceDaoImpl.updateOwnerPropertySurveyInfo",
|
BeanConvertUtil.beanCovertMap(survey));
|
|
JSONObject resJson = new JSONObject();
|
if (update > 0) {
|
resJson.put("code", "0000");
|
resJson.put("msg", "修改业主房屋产调记录信息成功");
|
} else {
|
resJson.put("code", "0001");
|
resJson.put("msg", "修改业主房屋产调记录信息失败,未找到对应记录");
|
}
|
resJson.put("count", update);
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 删除业主房屋产调记录信息
|
*
|
* @param reqJson 请求参数
|
* @return 响应结果
|
* @serviceCode /ownerPropertySurvey/deleteOwnerPropertySurveyInfo
|
* @path /app/ownerPropertySurvey/deleteOwnerPropertySurveyInfo
|
*/
|
@RequestMapping(value = "/deleteOwnerPropertySurveyInfo", method = RequestMethod.POST)
|
public ResponseEntity<String> deleteOwnerPropertySurveyInfo(@RequestBody JSONObject reqJson) {
|
// 必要参数校验(至少包含一个筛选条件)
|
boolean hasFilter = reqJson.containsKey("id") && reqJson.getString("id") != null && !reqJson.getString("id").isEmpty()
|
|| reqJson.containsKey("ownerId") && !reqJson.getString("ownerId").isEmpty()
|
|| reqJson.containsKey("roomId") && !reqJson.getString("roomId").isEmpty();
|
Assert.isTrue(hasFilter, "请求报文中需包含id/ownerId/roomId至少一个筛选条件");
|
|
// 转换为实体类
|
OwnerPropertySurvey survey = BeanConvertUtil.covertBean(reqJson, OwnerPropertySurvey.class);
|
|
// 调用Mapper删除方法
|
int delete = sqlSessionTemplate.delete("ownerPropertySurveyServiceDaoImpl.deleteOwnerPropertySurveyInfo",
|
BeanConvertUtil.beanCovertMap(survey));
|
|
JSONObject resJson = new JSONObject();
|
if (delete > 0) {
|
resJson.put("code", "0000");
|
resJson.put("msg", "删除业主房屋产调记录信息成功");
|
} else {
|
resJson.put("code", "0001");
|
resJson.put("msg", "删除业主房屋产调记录信息失败,未找到对应记录");
|
}
|
resJson.put("count", delete);
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 分页查询业主房屋产调记录信息列表
|
*
|
* @param page 页码(默认1)
|
* @param row 每页条数(默认10)
|
* @param id 主键ID(可选)
|
* @param ownerId 业主编号(可选)
|
* @param roomId 房屋编号(可选)
|
* @param surveyWarrantApplyDate 调查令申请日期(可选)
|
* @param propertySurveyDate 产调日期(可选)
|
* @param name 业主姓名(可选)
|
* @param startPropertySurveyDate 产调日期开始范围(可选)
|
* @param endPropertySurveyDate 产调日期结束范围(可选)
|
* @return 响应结果
|
* @serviceCode /ownerPropertySurvey/queryOwnerPropertySurveyInfo
|
* @path /app/ownerPropertySurvey/queryOwnerPropertySurveyInfo
|
*/
|
@RequestMapping(value = "/queryOwnerPropertySurveyInfo", method = RequestMethod.GET)
|
public ResponseEntity<String> queryOwnerPropertySurveyInfo(
|
@RequestParam(value = "page", defaultValue = "1") int page,
|
@RequestParam(value = "row", defaultValue = "10") int row,
|
@RequestParam(value = "id", required = false) String id,
|
@RequestParam(value = "ownerId", required = false) String ownerId,
|
@RequestParam(value = "roomId", required = false) String roomId,
|
@RequestParam(value = "surveyWarrantApplyDate", required = false) String surveyWarrantApplyDate,
|
@RequestParam(value = "propertySurveyDate", required = false) String propertySurveyDate,
|
@RequestParam(value = "name", required = false) String name,
|
@RequestParam(value = "startPropertySurveyDate", required = false) String startPropertySurveyDate,
|
@RequestParam(value = "endPropertySurveyDate", required = false) String endPropertySurveyDate) {
|
|
// 封装查询参数
|
Map<String, Object> param = new HashMap<>();
|
param.put("page", (page - 1) * row); // 转换为MySQL分页偏移量
|
param.put("row", row);
|
param.put("id", id);
|
param.put("ownerId", ownerId);
|
param.put("roomId", roomId);
|
param.put("surveyWarrantApplyDate", surveyWarrantApplyDate);
|
param.put("propertySurveyDate", propertySurveyDate);
|
param.put("name", name);
|
param.put("startPropertySurveyDate", startPropertySurveyDate);
|
param.put("endPropertySurveyDate", endPropertySurveyDate);
|
|
// 查询列表数据
|
List<Map<String, Object>> list = sqlSessionTemplate.selectList(
|
"ownerPropertySurveyServiceDaoImpl.getOwnerPropertySurveyInfo", param);
|
|
// 查询总数
|
Map<String, Object> countMap = sqlSessionTemplate.selectOne(
|
"ownerPropertySurveyServiceDaoImpl.queryOwnerPropertySurveysCount", param);
|
int total = countMap != null ? Integer.parseInt(countMap.get("count").toString()) : 0;
|
|
// 构造分页响应
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "查询业主房屋产调记录信息成功");
|
resJson.put("page", page);
|
resJson.put("row", row);
|
resJson.put("total", total);
|
resJson.put("data", BeanConvertUtil.covertBeanList(list, OwnerPropertySurvey.class));
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 查询业主房屋产调记录统计信息
|
*
|
* @param ownerId 业主编号(可选)
|
* @param roomId 房屋编号(可选)
|
* @param startPropertySurveyDate 产调日期开始范围(可选)
|
* @param endPropertySurveyDate 产调日期结束范围(可选)
|
* @return 响应结果
|
* @serviceCode /ownerPropertySurvey/queryOwnerPropertySurveyStatistics
|
* @path /app/ownerPropertySurvey/queryOwnerPropertySurveyStatistics
|
*/
|
@RequestMapping(value = "/queryOwnerPropertySurveyStatistics", method = RequestMethod.GET)
|
public ResponseEntity<String> queryOwnerPropertySurveyStatistics(
|
@RequestParam(value = "ownerId", required = false) String ownerId,
|
@RequestParam(value = "roomId", required = false) String roomId,
|
@RequestParam(value = "startPropertySurveyDate", required = false) String startPropertySurveyDate,
|
@RequestParam(value = "endPropertySurveyDate", required = false) String endPropertySurveyDate) {
|
|
// 封装查询参数
|
Map<String, Object> param = new HashMap<>();
|
param.put("ownerId", ownerId);
|
param.put("roomId", roomId);
|
param.put("startPropertySurveyDate", startPropertySurveyDate);
|
param.put("endPropertySurveyDate", endPropertySurveyDate);
|
|
// 统计查询
|
Map<String, Object> statistics = sqlSessionTemplate.selectOne(
|
"ownerPropertySurveyServiceDaoImpl.queryOwnerPropertySurveyStatistics", param);
|
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "统计业主房屋产调记录信息成功");
|
resJson.put("data", statistics);
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 按产调日期年月维度统计业主房屋产调记录
|
*
|
* @param startPropertySurveyDate 产调日期开始范围(可选)
|
* @param endPropertySurveyDate 产调日期结束范围(可选)
|
* @return 响应结果
|
* @serviceCode /ownerPropertySurvey/queryOwnerPropertySurveyByMonth
|
* @path /app/ownerPropertySurvey/queryOwnerPropertySurveyByMonth
|
*/
|
@RequestMapping(value = "/queryOwnerPropertySurveyByMonth", method = RequestMethod.GET)
|
public ResponseEntity<String> queryOwnerPropertySurveyByMonth(
|
@RequestParam(value = "startPropertySurveyDate", required = false) String startPropertySurveyDate,
|
@RequestParam(value = "endPropertySurveyDate", required = false) String endPropertySurveyDate) {
|
|
// 封装查询参数
|
Map<String, Object> param = new HashMap<>();
|
param.put("startPropertySurveyDate", startPropertySurveyDate);
|
param.put("endPropertySurveyDate", endPropertySurveyDate);
|
|
// 按年月统计查询
|
List<Map<String, Object>> resultList = sqlSessionTemplate.selectList(
|
"ownerPropertySurveyServiceDaoImpl.queryOwnerPropertySurveyByMonth", param);
|
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "按年月维度统计业主房屋产调记录成功");
|
resJson.put("data", resultList);
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 查询未完成产调的记录(产调日期为空)
|
*
|
* @param page 页码(默认1)
|
* @param row 每页条数(默认10)
|
* @param ownerId 业主编号(可选)
|
* @param roomId 房屋编号(可选)
|
* @param startSurveyWarrantDate 调查令申请日期开始范围(可选)
|
* @param endSurveyWarrantDate 调查令申请日期结束范围(可选)
|
* @return 响应结果
|
* @serviceCode /ownerPropertySurvey/queryUnfinishedPropertySurveys
|
* @path /app/ownerPropertySurvey/queryUnfinishedPropertySurveys
|
*/
|
@RequestMapping(value = "/queryUnfinishedPropertySurveys", method = RequestMethod.GET)
|
public ResponseEntity<String> queryUnfinishedPropertySurveys(
|
@RequestParam(value = "page", defaultValue = "1") int page,
|
@RequestParam(value = "row", defaultValue = "10") int row,
|
@RequestParam(value = "ownerId", required = false) String ownerId,
|
@RequestParam(value = "roomId", required = false) String roomId,
|
@RequestParam(value = "startSurveyWarrantDate", required = false) String startSurveyWarrantDate,
|
@RequestParam(value = "endSurveyWarrantDate", required = false) String endSurveyWarrantDate) {
|
|
// 封装查询参数
|
Map<String, Object> param = new HashMap<>();
|
param.put("page", (page - 1) * row);
|
param.put("row", row);
|
param.put("ownerId", ownerId);
|
param.put("roomId", roomId);
|
param.put("startSurveyWarrantDate", startSurveyWarrantDate);
|
param.put("endSurveyWarrantDate", endSurveyWarrantDate);
|
|
// 查询未完成记录
|
List<Map<String, Object>> list = sqlSessionTemplate.selectList(
|
"ownerPropertySurveyServiceDaoImpl.queryUnfinishedPropertySurveys", param);
|
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "查询未完成产调记录成功");
|
resJson.put("page", page);
|
resJson.put("row", row);
|
resJson.put("total", list.size()); // 如需精准总数可新增count方法,此处简化
|
resJson.put("data", list);
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
}
|