package com.java110.fee.api;
|
|
import com.alibaba.fastjson.JSONObject;
|
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.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 业主质保金支取信息接口
|
* 适配 owner_quality_guarantee 表
|
* @author dev
|
* @date 2025-12-24
|
*/
|
@RestController
|
@RequestMapping(value = "/ownerQualityGuarantee")
|
public class OwnerQualityGuaranteeApi {
|
|
@Autowired
|
protected SqlSessionTemplate sqlSessionTemplate;
|
|
/**
|
* 保存业主质保金支取信息
|
*
|
* @param reqJson 请求参数
|
* @return 响应结果
|
* @serviceCode /ownerQualityGuarantee/saveOwnerQualityGuarantee
|
* @path /app/ownerQualityGuarantee/saveOwnerQualityGuarantee
|
*/
|
@RequestMapping(value = "/saveOwnerQualityGuarantee", method = RequestMethod.POST)
|
public ResponseEntity<String> saveOwnerQualityGuarantee(@RequestBody JSONObject reqJson) {
|
// 核心参数校验
|
Assert.hasKeyAndValue(reqJson, "mpId", "请求报文中未包含业务标识mpId");
|
|
// 转换为POJO
|
OwnerQualityGuaranteePo po = BeanConvertUtil.covertBean(reqJson, OwnerQualityGuaranteePo.class);
|
|
|
String test = "";
|
|
if (po.getQualityGuaranteePeriod2Start() != null){
|
test += po.getQualityGuaranteePeriod2Start();
|
}
|
test += " ~ ";
|
if (po.getQualityGuaranteePeriod2End() != null){
|
test += po.getQualityGuaranteePeriod2End();
|
}
|
|
if (!test.equals(" ~ ")){
|
po.setQualityGuaranteePeriod2(test);
|
}
|
|
// 调用Mapper保存方法
|
int insert = sqlSessionTemplate.insert("ownerQualityGuaranteeServiceDaoImpl.saveOwnerQualityGuarantee",
|
BeanConvertUtil.beanCovertMap(po));
|
|
// 构造响应结果
|
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());
|
}
|
|
|
public ResponseEntity<String> saveOwnerQualityGuarantee(OwnerQualityGuaranteePo po) {
|
String test = "";
|
|
if (po.getQualityGuaranteePeriod2Start() != null){
|
test += po.getQualityGuaranteePeriod2Start();
|
}
|
test += " ~ ";
|
if (po.getQualityGuaranteePeriod2End() != null){
|
test += po.getQualityGuaranteePeriod2End();
|
}
|
|
if (!test.equals(" ~ ")){
|
po.setQualityGuaranteePeriod2(test);
|
}
|
|
// 调用Mapper保存方法
|
int insert = sqlSessionTemplate.insert("ownerQualityGuaranteeServiceDaoImpl.saveOwnerQualityGuarantee",
|
BeanConvertUtil.beanCovertMap(po));
|
|
// 构造响应结果
|
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 请求参数(包含ownerQualityGuaranteeList数组)
|
* @return 响应结果
|
* @serviceCode /ownerQualityGuarantee/saveOwnerQualityGuarantees
|
* @path /app/ownerQualityGuarantee/saveOwnerQualityGuarantees
|
*/
|
@RequestMapping(value = "/saveOwnerQualityGuarantees", method = RequestMethod.POST)
|
public ResponseEntity<String> saveOwnerQualityGuarantees(@RequestBody JSONObject reqJson) {
|
Assert.hasKeyAndValue(reqJson, "ownerQualityGuaranteeList", "请求报文中未包含批量数据列表");
|
|
// 转换批量数据
|
List<OwnerQualityGuaranteePo> poList = BeanConvertUtil.covertBeanList(
|
reqJson.getJSONArray("ownerQualityGuaranteeList"), OwnerQualityGuaranteePo.class);
|
|
Map<String, Object> param = BeanConvertUtil.beanCovertMap(reqJson);
|
param.put("guaranteeList", poList);
|
|
// 批量插入
|
int insert = sqlSessionTemplate.insert("ownerQualityGuaranteeServiceDaoImpl.batchSaveOwnerQualityGuarantee", 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 /ownerQualityGuarantee/updateOwnerQualityGuarantee
|
* @path /app/ownerQualityGuarantee/updateOwnerQualityGuarantee
|
*/
|
@RequestMapping(value = "/updateOwnerQualityGuarantee", method = RequestMethod.POST)
|
public ResponseEntity<String> updateOwnerQualityGuarantee(@RequestBody JSONObject reqJson) {
|
// 主键校验
|
Assert.hasKeyAndValue(reqJson, "id", "请求报文中未包含主键ID");
|
|
OwnerQualityGuaranteePo po = BeanConvertUtil.covertBean(reqJson, OwnerQualityGuaranteePo.class);
|
|
String test = "";
|
|
if (po.getQualityGuaranteePeriod2Start() != null){
|
test += po.getQualityGuaranteePeriod2Start();
|
}
|
test += " ~ ";
|
if (po.getQualityGuaranteePeriod2End() != null){
|
test += po.getQualityGuaranteePeriod2End();
|
}
|
|
if (!test.equals(" ~ ")){
|
po.setQualityGuaranteePeriod2(test);
|
}
|
|
// 调用Mapper修改方法
|
int update = sqlSessionTemplate.update("ownerQualityGuaranteeServiceDaoImpl.updateOwnerQualityGuarantee",
|
BeanConvertUtil.beanCovertMap(po));
|
|
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 /ownerQualityGuarantee/deleteOwnerQualityGuarantee
|
* @path /app/ownerQualityGuarantee/deleteOwnerQualityGuarantee
|
*/
|
@RequestMapping(value = "/deleteOwnerQualityGuarantee", method = RequestMethod.POST)
|
public ResponseEntity<String> deleteOwnerQualityGuarantee(@RequestBody JSONObject reqJson) {
|
// 必要参数校验
|
Assert.hasKeyAndValue(reqJson, "id", "主键ID不能为空");
|
|
OwnerQualityGuaranteePo po = BeanConvertUtil.covertBean(reqJson, OwnerQualityGuaranteePo.class);
|
|
// 调用Mapper删除方法
|
int delete = sqlSessionTemplate.delete("ownerQualityGuaranteeServiceDaoImpl.deleteOwnerQualityGuarantee",
|
BeanConvertUtil.beanCovertMap(po));
|
|
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 mpId 业务标识(必传)
|
* @param page 页码(默认1)
|
* @param row 每页条数(默认10)
|
* @param id 主键ID(可选)
|
* @param availableWithdrawalDate 可启动支取日期(可选)
|
* @param qualityGuaranteePeriod2 质保期(可选)
|
* @return 响应结果
|
* @serviceCode /ownerQualityGuarantee/queryOwnerQualityGuarantee
|
* @path /app/ownerQualityGuarantee/queryOwnerQualityGuarantee
|
*/
|
@RequestMapping(value = "/queryOwnerQualityGuarantee", method = RequestMethod.GET)
|
public ResponseEntity<String> queryOwnerQualityGuarantee(
|
@RequestParam(value = "mpId") String mpId,
|
@RequestParam(value = "page", defaultValue = "1") int page,
|
@RequestParam(value = "row", defaultValue = "10") int row,
|
@RequestParam(value = "id", required = false) Long id,
|
@RequestParam(value = "availableWithdrawalDate", required = false) String availableWithdrawalDate,
|
@RequestParam(value = "qualityGuaranteePeriod2", required = false) String qualityGuaranteePeriod2) {
|
|
// 封装查询参数
|
OwnerQualityGuaranteePo queryPo = new OwnerQualityGuaranteePo();
|
queryPo.setMpId(mpId);
|
queryPo.setPage((page - 1) * row); // 转换为MySQL分页偏移量
|
queryPo.setRow(row);
|
|
if (id != null) {
|
queryPo.setId(id);
|
}
|
if (availableWithdrawalDate != null && !availableWithdrawalDate.isEmpty()) {
|
queryPo.setAvailableWithdrawalDate(availableWithdrawalDate);
|
}
|
if (qualityGuaranteePeriod2 != null && !qualityGuaranteePeriod2.isEmpty()) {
|
queryPo.setQualityGuaranteePeriod2(qualityGuaranteePeriod2);
|
}
|
|
// 查询列表数据
|
List<Map<String, Object>> list = sqlSessionTemplate.selectList(
|
"ownerQualityGuaranteeServiceDaoImpl.getOwnerQualityGuarantee",
|
BeanConvertUtil.beanCovertMap(queryPo));
|
|
// 查询总数
|
Object total = ((HashMap) sqlSessionTemplate.selectOne(
|
"ownerQualityGuaranteeServiceDaoImpl.queryOwnerQualityGuaranteeCount",
|
BeanConvertUtil.beanCovertMap(queryPo))).get("count");
|
|
// 构造分页响应
|
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, OwnerQualityGuaranteePo.class));
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 根据ID查询单条业主质保金支取信息
|
*
|
* @param id 主键ID
|
* @return 响应结果
|
* @serviceCode /ownerQualityGuarantee/getOwnerQualityGuaranteeById
|
* @path /app/ownerQualityGuarantee/getOwnerQualityGuaranteeById
|
*/
|
@RequestMapping(value = "/getOwnerQualityGuaranteeById", method = RequestMethod.GET)
|
public ResponseEntity<String> getOwnerQualityGuaranteeById(@RequestParam(value = "id") Long id) {
|
// 主键校验
|
Assert.notNull(id, "主键ID不能为空");
|
|
OwnerQualityGuaranteePo queryPo = new OwnerQualityGuaranteePo();
|
queryPo.setId(id);
|
|
// 查询单条数据
|
Map<String, Object> result = sqlSessionTemplate.selectOne(
|
"ownerQualityGuaranteeServiceDaoImpl.getOwnerQualityGuarantee",
|
BeanConvertUtil.beanCovertMap(queryPo));
|
|
JSONObject resJson = new JSONObject();
|
if (result != null) {
|
resJson.put("code", "0000");
|
resJson.put("msg", "查询业主质保金支取信息成功");
|
resJson.put("data", result);
|
} else {
|
resJson.put("code", "0001");
|
resJson.put("msg", "未找到对应业主质保金支取记录");
|
}
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 根据mpId查询业主质保金支取信息
|
*
|
* @param mpId 业务标识
|
* @return 响应结果
|
* @serviceCode /ownerQualityGuarantee/getOwnerQualityGuaranteeByMpId
|
* @path /app/ownerQualityGuarantee/getOwnerQualityGuaranteeByMpId
|
*/
|
@RequestMapping(value = "/getOwnerQualityGuaranteeByMpId", method = RequestMethod.GET)
|
public ResponseEntity<String> getOwnerQualityGuaranteeByMpId(@RequestParam(value = "mpId") String mpId) {
|
Assert.hasLength(mpId, "业务标识mpId不能为空");
|
|
OwnerQualityGuaranteePo queryPo = new OwnerQualityGuaranteePo();
|
queryPo.setMpId(mpId);
|
|
List<Map<String, Object>> result = sqlSessionTemplate.selectList(
|
"ownerQualityGuaranteeServiceDaoImpl.getOwnerQualityGuarantee",
|
BeanConvertUtil.beanCovertMap(queryPo));
|
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "查询业主质保金支取信息成功");
|
resJson.put("data", result);
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 统计业主质保金支取信息
|
*
|
* @param mpId 业务标识(可选)
|
* @param startCreateTime 开始创建时间(可选,格式:yyyy-MM-dd HH:mm:ss)
|
* @param endCreateTime 结束创建时间(可选)
|
* @return 响应结果
|
* @serviceCode /ownerQualityGuarantee/queryOwnerQualityGuaranteeStatistics
|
* @path /app/ownerQualityGuarantee/queryOwnerQualityGuaranteeStatistics
|
*/
|
@RequestMapping(value = "/queryOwnerQualityGuaranteeStatistics", method = RequestMethod.GET)
|
public ResponseEntity<String> queryOwnerQualityGuaranteeStatistics(
|
@RequestParam(value = "mpId", required = false) String mpId,
|
@RequestParam(value = "startCreateTime", required = false) String startCreateTime,
|
@RequestParam(value = "endCreateTime", required = false) String endCreateTime) {
|
|
OwnerQualityGuaranteePo queryPo = new OwnerQualityGuaranteePo();
|
queryPo.setMpId(mpId);
|
queryPo.setStartCreateTime(startCreateTime);
|
queryPo.setEndCreateTime(endCreateTime);
|
|
// 统计查询
|
Map<String, Object> statistics = sqlSessionTemplate.selectOne(
|
"ownerQualityGuaranteeServiceDaoImpl.queryOwnerQualityGuaranteeStatistics",
|
BeanConvertUtil.beanCovertMap(queryPo));
|
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "统计业主质保金支取信息成功");
|
resJson.put("data", statistics);
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
}
|