hz-zhhq-app-service/greenH5modul/.svn/pristine/71/7121a59b42b88e09afbc147ed0b...

610 lines
25 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.nationalelectric.greenH5;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.nationalelectirc.Constant.Constant;
import com.nationalelectirc.utils.RestResult;
import com.nationalelectric.greenH5.bizc.BaseServiceImpl;
import com.nationalelectric.greenH5.po.GreenRentHouseApply;
import com.nationalelectric.greenH5.po.GreenUserInfo;
import com.nationalelectric.greenH5.utils.DateUtil;
import com.sgcc.uap.persistence.IHibernateDao;
import com.sgcc.uap.utils.StringUtils;
import com.sun.org.apache.xpath.internal.FoundIndex;
import com.aostarit.mobile.client.message.api.client.MsgQueryClient;
import com.aostarit.mobile.client.message.api.client.MsgRequestClient;
import com.aostarit.mobile.client.message.api.client.MsgSendClient;
import com.aostarit.mobile.client.message.api.config.WxMsgConfig;
import com.aostarit.mobile.client.message.api.entity.SendMsgParams;
import com.aostarit.mobile.client.message.api.entity.WxSendMsgResult;
/**
* 租房管理
* @author 96048
*
*/
@Controller
@RequestMapping("/greenHouse")
public class GreenHouseController extends GreenBaseController{
@Autowired
IHibernateDao hibernateDao;
@Autowired
private BaseServiceImpl baseService;
/**
* 房屋申请列表:个人查看
* @param rentHouseApply
* @return
*/
@SuppressWarnings("deprecation")
@RequestMapping(value="/page", method = RequestMethod.POST)
@Transactional(rollbackFor=Exception.class)
@ResponseBody
public RestResult page(@RequestBody GreenRentHouseApply rentHouseApply) {
try {
String userId = rentHouseApply.getUserId();
GreenUserInfo info = getUserInfo(userId);
if(info==null){
return new RestResult(Constant.FAILED, "非法用户");
}
int limit = ((rentHouseApply.getPageNum() > 0 ? rentHouseApply.getPageNum() : 1) - 1) * rentHouseApply.getPageSize();
int pageSize = rentHouseApply.getPageSize()*rentHouseApply.getPageNum();
String sql = "select * from (select rn.*,rownum from ( "
+ " SELECT ID as \"id\", USER_ID as \"userId\", USER_NAME as \"userName\", GENDER as \"gender\", "
+ " MARRIAGE_STATE as \"marriageState\", PHONE as \"phone\", ORG_ID as \"orgId\", ORG_NAME as \"orgName\", "
+ " POSITION as \"position\", USER_TYPE as \"userType\", HOUSE_TYPE as \"houseType\", APPLY_CAUSE as \"applyCause\","
+ " to_char(APPLY_TIME,'YYYY-MM-DD HH24:MI:SS') as \"applyTime\", EXAMINE_STATE as \"examineState\", EXAMINE_BATCH as \"examineBatch\" "
+ " FROM GREEN_HOUSE_APPLY where DEL_FLAG = 0 AND USER_ID = ? ORDER BY APPLY_TIME DESC "
+ ") rn )where rownum>? and rownum<=?";
List<GreenRentHouseApply> list = hibernateDao.queryForListWithSql(sql,new Object[]{userId,limit,pageSize});
return new RestResult(Constant.SUCCESS, "操作成功",list);
} catch (Exception e) {
e.printStackTrace();
return new RestResult(Constant.FAILED, "操作失败");
}
}
/**
* 房屋申请列表:审核人员查看
* @param rentHouseApply
* @return
*/
@SuppressWarnings("deprecation")
@RequestMapping(value="/examinePage", method = RequestMethod.POST)
@Transactional(rollbackFor=Exception.class)
@ResponseBody
public RestResult examinePage(@RequestBody GreenRentHouseApply rentHouseApply) {
try {
ArrayList<Object> paramList = new ArrayList<Object>();
String userId = rentHouseApply.getUserId();
GreenUserInfo info = getUserInfo(userId);
if(info==null){
return new RestResult(Constant.FAILED, "非法用户");
}
int limit = ((rentHouseApply.getPageNum() > 0 ? rentHouseApply.getPageNum() : 1) - 1) * rentHouseApply.getPageSize();
int pageSize = rentHouseApply.getPageSize()*rentHouseApply.getPageNum();
String examineState = rentHouseApply.getExamineState();
String examineBatch = rentHouseApply.getExamineBatch();
if (StringUtils.isBlank(examineState)) {
return new RestResult(Constant.FAILED, "审核状态不能为空");
}
if (StringUtils.isBlank(examineBatch)) {
return new RestResult(Constant.FAILED, "审核批次不能为空");
}
if ("0".equals(examineState)) {
String sql = "select count(*) from GREEN_DICTIONARY_INFO where data_type = 'houseExamineSwitch' and data_code = ? and data_value = 1 ";
int count = hibernateDao.queryForIntWithSql(sql,new Object[]{examineBatch});
if (count == 0) {
return new RestResult(Constant.SUCCESS, "操作成功",new ArrayList<Map<String,String>>());
}
}
String sql = "select * from (select rn.*,rownum from ( "
+ " SELECT A.ID as \"id\", A.USER_ID as \"userId\", A.USER_NAME as \"userName\", A.GENDER as \"gender\", "
+ " A.MARRIAGE_STATE as \"marriageState\", A.PHONE as \"phone\", A.ORG_ID as \"orgId\", A.ORG_NAME as \"orgName\", "
+ " A.POSITION as \"position\", A.USER_TYPE as \"userType\", A.HOUSE_TYPE as \"houseType\", A.APPLY_CAUSE as \"applyCause\","
+ " to_char(A.APPLY_TIME,'YYYY-MM-DD HH24:MI:SS') as \"applyTime\", A.EXAMINE_STATE as \"examineState\", A.EXAMINE_BATCH as \"examineBatch\" "
+ " FROM GREEN_HOUSE_APPLY A "
+ " LEFT JOIN (select * from GREEN_HOUSE_APPLY_EXAMINE where EXAMINE_BATCH= ? and DEL_FLAG=0) E ON A.ID = E.APPLY_ID "
+ " WHERE A.DEL_FLAG = 0 ";
paramList.add(examineBatch);
//当查询审核批次为1时只查询当前用户部门以及子部门的数据
if("1".equals(examineBatch)){
sql+= "AND A.ORG_ID IN (SELECT id FROM GREEN_DEPARTMENT START WITH ID = ? CONNECT BY PRIOR ID = PARENT_ID) ";
paramList.add(rentHouseApply.getOrgId());
}
if ("1".equals(examineState)) {//已审核
sql += "and e.ID is not NULL " ;
}else if("0".equals(examineState)) {//待审核
sql += "AND A.EXAMINE_STATE = 0 AND A.EXAMINE_BATCH = ? " ;
paramList.add(examineBatch);
}
sql+= " ORDER BY A.APPLY_TIME DESC "
+ " ) rn )where rownum>? and rownum<=? ";
paramList.add(limit);
paramList.add(pageSize);
List<GreenRentHouseApply> list = hibernateDao.queryForListWithSql(sql,paramList.toArray());
return new RestResult(Constant.SUCCESS, "操作成功",list);
} catch (Exception e) {
e.printStackTrace();
return new RestResult(Constant.FAILED, "操作失败");
}
}
/**
* 房屋申请列表详情
* @param rentHouseApply
* @return
*/
@SuppressWarnings("deprecation")
@RequestMapping(value="/detail", method = RequestMethod.POST)
@Transactional(rollbackFor=Exception.class)
@ResponseBody
public RestResult detail(@RequestBody GreenRentHouseApply rentHouseApply) {
try {
String userId = rentHouseApply.getUserId();
GreenUserInfo info = getUserInfo(userId);
if(info==null){
return new RestResult(Constant.FAILED, "非法用户");
}
String sql = "SELECT ID as \"id\", USER_ID as \"userId\", USER_NAME as \"userName\", GENDER as \"gender\", "
+ " MARRIAGE_STATE as \"marriageState\", PHONE as \"phone\", ORG_ID as \"orgId\", ORG_NAME as \"orgName\", "
+ " POSITION as \"position\", USER_TYPE as \"userType\", HOUSE_TYPE as \"houseType\", APPLY_CAUSE as \"applyCause\","
+ " to_char(APPLY_TIME,'YYYY-MM-DD HH24:MI:SS') as \"applyTime\", EXAMINE_STATE as \"examineState\", EXAMINE_BATCH as \"examineBatch\" "
+ " FROM GREEN_HOUSE_APPLY WHERE DEL_FLAG = 0 AND ID = ? ";
List<Map<String,Object>> list = hibernateDao.queryForListWithSql(sql,new Object[]{rentHouseApply.getId()});
//获取审核详情
if (list.size() > 0) {
String sqls = "SELECT EXAMINE_STATE as \"examineState\", to_char(EXAMINE_TIME,'YYYY-MM-DD HH24:MI:SS') as \"examineTime\","
+ " EXAMINE_OPINION as \"examineOpinion\",EXAMINE_BATCH as \"examineBatch\",BATCH_DESCRIPTION as \"batchDescription\" "
+ " FROM GREEN_HOUSE_APPLY_EXAMINE WHERE DEL_FLAG = 0 AND apply_id = ? order by EXAMINE_BATCH asc ";
List<Map<String,String>> lists = hibernateDao.queryForListWithSql(sqls,new Object[]{rentHouseApply.getId()});
if (lists.size() > 0) {
list.get(0).put("detail", lists.toArray());
}
}
return new RestResult(Constant.SUCCESS, "操作成功",list);
} catch (Exception e) {
e.printStackTrace();
return new RestResult(Constant.FAILED, "操作失败");
}
}
/**
* 新增租房申请
* @return
*/
@SuppressWarnings("deprecation")
@RequestMapping(value="/apply", method = RequestMethod.POST)
@Transactional(rollbackFor=Exception.class)
@ResponseBody
public RestResult apply(@RequestBody GreenRentHouseApply rentHouseApply) {
try {
String userId = rentHouseApply.getUserId();
GreenUserInfo info = getUserInfo(userId);
if(info==null){
return new RestResult(Constant.FAILED, "非法用户");
}
//查询当前用户是否已存在申请记录
String existsSql = "SELECT COUNT(*) FROM GREEN_HOUSE_APPLY WHERE DEL_FLAG = '0' AND USER_ID = ? ";
int count = hibernateDao.queryForIntWithSql(existsSql,new Object[]{userId});
// if (count > 0) {
// return new RestResult(Constant.FAILED, "已存在申请,不能重复提交");
// }
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
//查询第一审核批次
String batchSql = "SELECT * FROM GREEN_DICTIONARY_INFO WHERE DATA_TYPE = 'houseExamineSwitch' AND IS_DELETED = 'N' AND DATA_VALUE = 1 ORDER BY DATA_CODE ASC ";
List<Map<String,String>> list = hibernateDao.queryForListWithSql(batchSql);
String examineBatch = "0";
if (list.size() > 0) {
examineBatch = list.get(0).get("DATA_CODE");
}
String sql = "INSERT INTO GREEN_HOUSE_APPLY (ID,USER_ID,USER_NAME,GENDER,MARRIAGE_STATE,PHONE, "
+ "ORG_ID,ORG_NAME,POSITION,USER_TYPE,HOUSE_TYPE,APPLY_CAUSE,APPLY_TIME,DEL_FLAG,EXAMINE_STATE,EXAMINE_BATCH) "
+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,0,0,?) ";
hibernateDao.executeSqlUpdate(sql,new Object[]{uuid,rentHouseApply.getUserId(),rentHouseApply.getUserName(),rentHouseApply.getGender(),
rentHouseApply.getMarriageState(),rentHouseApply.getPhone(),rentHouseApply.getOrgId(),rentHouseApply.getOrgName(),
rentHouseApply.getPosition(),rentHouseApply.getUserType(),rentHouseApply.getHouseType(),rentHouseApply.getApplyCause(),examineBatch});
return new RestResult(Constant.SUCCESS, "操作成功");
} catch (Exception e) {
e.printStackTrace();
return new RestResult(Constant.FAILED, "操作失败");
}
}
/**
* 房屋申请审批
* @param map
* @return
*/
@SuppressWarnings("deprecation")
@RequestMapping(value="/examine", method = RequestMethod.POST)
@Transactional(rollbackFor=Exception.class)
@ResponseBody
public RestResult examine(@RequestBody Map<String, String> map) {
try {
String userId = map.get("userId");
GreenUserInfo info = getUserInfo(userId);
if(info==null){
return new RestResult(Constant.FAILED, "非法用户");
}
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
String applyId = map.get("applyId");
String userName = map.get("userName");
String examineState = map.get("examineState");
String examineOpinion = map.get("examineOpinion");
String examineBatch = map.get("examineBatch");
if (StringUtils.isBlank(examineState)) {
return new RestResult(Constant.FAILED, "审核状态不能为空");
}
if (StringUtils.isBlank(examineBatch)) {
return new RestResult(Constant.FAILED, "审核批次不能为空");
}
//查询下一审核批次
String batchSql = "SELECT * FROM GREEN_DICTIONARY_INFO WHERE DATA_TYPE = 'houseExamineSwitch' "
+ "AND IS_DELETED = 'N' AND DATA_VALUE = 1 AND DATA_CODE > ? ORDER BY DATA_CODE ASC ";
List<Map<String,String>> list = hibernateDao.queryForListWithSql(batchSql,new Object[]{examineBatch});
//不为空则更改审核批次,否则更改申请单的审核状态
if (list.size() > 0) {
if ("1".equals(examineState)) {
String lastExamineBatch = list.get(0).get("DATA_CODE");
String updateBatchSql = "UPDATE GREEN_HOUSE_APPLY SET EXAMINE_BATCH = ? WHERE ID = ? ";
hibernateDao.executeSqlUpdate(updateBatchSql,new Object[]{lastExamineBatch,applyId});
}else if("2".equals(examineState)){
String updateStateSql = "UPDATE GREEN_HOUSE_APPLY SET EXAMINE_STATE = ? WHERE ID = ? ";
hibernateDao.executeSqlUpdate(updateStateSql,new Object[]{examineState,applyId});
}
}else {
String updateStateSql = "UPDATE GREEN_HOUSE_APPLY SET EXAMINE_STATE = ? WHERE ID = ? ";
hibernateDao.executeSqlUpdate(updateStateSql,new Object[]{examineState,applyId});
}
//查询当前批次描述
String description = "";
String sqls = "SELECT DATA_CODE as \"id\",DATA_VALUE as \"name\",DESCRIPTION as \"description\" FROM GREEN_DICTIONARY_INFO "
+ "WHERE DATA_TYPE = 'houseExamineSwitch' AND IS_DELETED = 'N' and DATA_CODE = ? ";
List<Map<String,String>> lists = hibernateDao.queryForListWithSql(sqls,new Object[]{examineBatch});
if (lists.size() > 0) {
description = lists.get(0).get("description");
}
//插入数据
String sql = "INSERT INTO GREEN_HOUSE_APPLY_EXAMINE(ID,APPLY_ID,USER_ID,USER_NAME,EXAMINE_STATE,EXAMINE_OPINION,"
+ "EXAMINE_TIME,DEL_FLAG,EXAMINE_BATCH,BATCH_DESCRIPTION) "
+ "VALUES(?,?,?,?,?,?,SYSDATE,0,?,?) ";
hibernateDao.executeSqlUpdate(sql,new Object[]{uuid,applyId,userId,userName,examineState,examineOpinion,examineBatch,description});
return new RestResult(Constant.SUCCESS, "操作成功");
} catch (Exception e) {
e.printStackTrace();
return new RestResult(Constant.FAILED, "操作失败");
}
}
/**
* 新增在线选房
* @return
*/
@SuppressWarnings("deprecation")
@RequestMapping(value="/addSelectedHouse", method = RequestMethod.POST)
@Transactional(rollbackFor=Exception.class)
@ResponseBody
public RestResult addSelectedHouse(@RequestBody Map<String, Object> map) {
try {
String userId = map.get("userId") == null ? "" : String.valueOf(map.get("userId"));
GreenUserInfo info = getUserInfo(userId);
if(info==null){
return new RestResult(Constant.FAILED, "非法用户");
}
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
String applyId = map.get("applyId") == null ? "" : String.valueOf(map.get("applyId"));
String HOUSE_ID = map.get("HOUSE_ID") == null ? "" : String.valueOf(map.get("HOUSE_ID"));
String HOUSE_NAME = map.get("HOUSE_NAME") == null ? "" : String.valueOf(map.get("HOUSE_NAME"));
String HOUSE_TYPE = map.get("HOUSE_TYPE") == null ? "" : String.valueOf(map.get("HOUSE_TYPE"));
String HOUSE_ADDR = map.get("HOUSE_ADDR") == null ? "" : String.valueOf(map.get("HOUSE_ADDR"));
String ACREAGE = map.get("ACREAGE") == null ? "" : String.valueOf(map.get("ACREAGE"));
String MODEL = map.get("MODEL") == null ? "" : String.valueOf(map.get("MODEL"));
String BUILDING_YEAR = map.get("BUILDING_YEAR") == null ? "" : String.valueOf(map.get("BUILDING_YEAR"));
String DEVICE = map.get("DEVICE") == null ? "" : String.valueOf(map.get("DEVICE"));
String RESPONSIBLE = map.get("RESPONSIBLE") == null ? "" : String.valueOf(map.get("RESPONSIBLE"));
String RESPONSIBLE_PHONE = map.get("RESPONSIBLE_PHONE") == null ? "" : String.valueOf(map.get("RESPONSIBLE_PHONE"));
String PRICE = map.get("PRICE") == null ? "" : String.valueOf(map.get("PRICE"));
String RENT_TYPE = map.get("RENT_TYPE") == null ? "" : String.valueOf(map.get("RENT_TYPE"));
String sql = "insert into GREEN_HOUSE_SELECTED(UUID,HOUSE_ID,HOUSE_NAME,HOUSE_TYPE,HOUSE_ADDR,ACREAGE,MODEL, "
+ "BUILDING_YEAR,DEVICE,RESPONSIBLE,RESPONSIBLE_PHONE,CREATOR,GMT_CREATED,IS_DELETED,PRICE,RENT_TYPE,APPLY_ID) "
+ "values(?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,'N',?,?,?) ";
hibernateDao.executeSqlUpdate(sql,new Object[]{uuid,HOUSE_ID,HOUSE_NAME,HOUSE_TYPE,HOUSE_ADDR,ACREAGE,MODEL,BUILDING_YEAR,
DEVICE,RESPONSIBLE,RESPONSIBLE_PHONE,userId,PRICE,RENT_TYPE,applyId});
//修改租房申请表状态:已选房
String updateStateSql = "UPDATE GREEN_HOUSE_APPLY SET EXAMINE_STATE = ? WHERE ID = ? ";
hibernateDao.executeSqlUpdate(updateStateSql,new Object[]{3,applyId});
//修改房屋表状态:在租
String updateHosueStateSql = "UPDATE GREEN_HOUSE SET STATUS = ? WHERE UUID = ? ";
hibernateDao.executeSqlUpdate(updateHosueStateSql,new Object[]{2,HOUSE_ID});
return new RestResult(Constant.SUCCESS, "您已成功选房");
} catch (Exception e) {
e.printStackTrace();
return new RestResult(Constant.FAILED, "返回异常");
}
}
/**
* 查询用户已选房屋
* @return
*/
@SuppressWarnings("deprecation")
@RequestMapping(value="/getSelectedHouse", method = RequestMethod.POST)
@Transactional(rollbackFor=Exception.class)
@ResponseBody
public RestResult getSelectedHouse(@RequestBody Map<String, String> map) {
try {
String userId = map.get("userId");
GreenUserInfo info = getUserInfo(userId);
if(info==null){
return new RestResult(Constant.FAILED, "非法用户");
}
String APPLY_ID = map.get("APPLY_ID");
String sql = "SELECT H.*, P.PIC from GREEN_HOUSE_SELECTED H LEFT JOIN ( "
+ "SELECT HOUSE_ID, LISTAGG (to_char(PICTURE), ',') WITHIN GROUP (ORDER BY SORT) AS PIC "
+ "FROM GREEN_HOUSE_PICTURE GROUP BY HOUSE_ID ) P ON H.HOUSE_ID = P.HOUSE_ID "
+ "WHERE H.IS_DELETED='N' and APPLY_ID = ? "
+ "order by H.GMT_CREATED DESC " ;
List<Map<String, Object>> list = hibernateDao.queryForListWithSql(sql,new Object[]{APPLY_ID});
for (Map<String, Object> map1 : list) {
List<Object> pictures = new ArrayList<Object>();
String PICS = String.valueOf(map1.get("PIC"));
if (StringUtils.isNotBlank(PICS) && !"null".equals(PICS)) {
String[] split = PICS.split(",");
for (int i = 0; i < split.length; i++) {
String picture = split[i];
picture = baseService.getImageBase64(picture);
pictures.add(picture);
}
}
map1.put("PICTURE", pictures.toArray());
}
return new RestResult(Constant.SUCCESS, "操作成功",list);
} catch (Exception e) {
e.printStackTrace();
return new RestResult(Constant.FAILED, "返回异常");
}
}
/**
* 新增退租申请
* @return
*/
@SuppressWarnings("deprecation")
@RequestMapping(value="/houseCheckOut", method = RequestMethod.POST)
@Transactional(rollbackFor=Exception.class)
@ResponseBody
public RestResult houseCheckOut(@RequestBody Map<String, String> map) {
try {
String userId = map.get("userId");
GreenUserInfo info = getUserInfo(userId);
if(info==null){
return new RestResult(Constant.FAILED, "非法用户");
}
String applyId = map.get("applyId");
String status = map.get("status");
String HOUSE_ID = map.get("HOUSE_ID");
if (status == null && "".equals(status)) {
return new RestResult(Constant.FAILED, "返回异常");
}
String updateBatchSql = "UPDATE GREEN_HOUSE_APPLY SET EXAMINE_STATE = ? WHERE ID = ? ";
hibernateDao.executeSqlUpdate(updateBatchSql,new Object[]{status,applyId});
if ("5".equals(status)) {//通过
//修改房屋表状态:在租
String updateHosueStateSql = "UPDATE GREEN_HOUSE SET STATUS = ? WHERE UUID = ? ";
hibernateDao.executeSqlUpdate(updateHosueStateSql,new Object[]{1,HOUSE_ID});
}
return new RestResult(Constant.SUCCESS, "操作成功",map);
} catch (Exception e) {
e.printStackTrace();
return new RestResult(Constant.FAILED, "返回异常");
}
}
/**
* 获取字典数据:房屋类型
* @return
*/
@SuppressWarnings("deprecation")
@RequestMapping(value="/getHouseType", method = RequestMethod.POST)
@Transactional(rollbackFor=Exception.class)
@ResponseBody
public RestResult getHouseType(@RequestBody Map<String, String> map) {
try {
//String dataType = "houseType";
String dataType = map.get("dataType");
List<Map<String, String>> dictionaryInfo = getDictionaryInfo(dataType);
return new RestResult(Constant.SUCCESS, "操作成功",dictionaryInfo);
} catch (Exception e) {
e.printStackTrace();
return new RestResult(Constant.FAILED, "返回异常");
}
}
/**
* 根据房屋类型获取闲置房屋
* @return
*/
@SuppressWarnings("deprecation")
@RequestMapping(value="/getFreeHouse", method = RequestMethod.POST)
@Transactional(rollbackFor=Exception.class)
@ResponseBody
public RestResult getFreeHouse(@RequestBody Map<String, String> map) {
try {
String userId = map.get("userId");
GreenUserInfo info = getUserInfo(userId);
if(info==null){
return new RestResult(Constant.FAILED, "非法用户");
}
int pageNum = Integer.parseInt(String.valueOf(map.get("pageNum")));
int pageSize = Integer.parseInt(String.valueOf(map.get("pageSize")));
int limit = ((pageNum > 0 ? pageNum : 1) - 1) * pageSize;
pageSize = pageSize*pageNum;
String houseType = map.get("houseType");
String sql = "SELECT * FROM ( SELECT RN.*,ROWNUM rw FROM( "
+ "SELECT H.*, P.PIC from GREEN_HOUSE H LEFT JOIN ( "
+ "SELECT HOUSE_ID, LISTAGG (to_char(PICTURE), ',') WITHIN GROUP (ORDER BY SORT) AS PIC "
+ "FROM GREEN_HOUSE_PICTURE GROUP BY HOUSE_ID ) P ON H.UUID = P.HOUSE_ID WHERE H.IS_DELETED='N' "
+ "AND HOUSE_TYPE = ? AND STATUS = 1 "
+ "order by H.GMT_CREATED DESC )rn ) WHERE rw > ? AND rw <= ? " ;
List<Map<String, Object>> list = hibernateDao.queryForListWithSql(sql,new Object[]{houseType,limit,pageSize});
for (Map<String, Object> map1 : list) {
List<Object> pictures = new ArrayList<Object>();
String PICS = String.valueOf(map1.get("PIC"));
if (StringUtils.isNotBlank(PICS) && !"null".equals(PICS)) {
String[] split = PICS.split(",");
for (int i = 0; i < split.length; i++) {
String picture = split[i];
picture = baseService.getImageBase64(picture);
pictures.add(picture);
}
}
map1.put("PICTURE", pictures.toArray());
}
return new RestResult(Constant.SUCCESS, "操作成功",list);
} catch (Exception e) {
e.printStackTrace();
return new RestResult(Constant.FAILED, "返回异常");
}
}
@SuppressWarnings("deprecation")
@RequestMapping(value="/test", method = RequestMethod.POST)
@Transactional(rollbackFor=Exception.class)
@ResponseBody
public RestResult test(HttpServletRequest request, HttpServletResponse response) {
try {
//生产
String messageAppId = "0f4824416eca4c7e82753acaf222649e";
String producerId = "d1c6e3b0f94742dc91a13f9a780941d6";
String sm2key = "041C2174BC0227F8F7F9342522AED537C277B3AA6217246D892156B874702041D5180D121845E75DF9D31B05DEA490632C9DD6F2AFBF40540740AAE21D32CAF9A6";
String sm4key = "13276439115248968552415895716389";
String baseUrl = "https://id.sgcc.com.cn:10443/mobile-message";
//测试
// String messageAppId = "0f4824416eca4c7e82753acaf222649e";
// String producerId = "d1c6e3b0f94742dc91a13f9a780941d6";
// String sm2key = "041C2174BC0227F8F7F9342522AED537C277B3AA6217246D892156B874702041D5180D121845E75DF9D31B05DEA490632C9DD6F2AFBF40540740AAE21D32CAF9A6";
// String sm4key = "13276439115248968552415895716389";
// String baseUrl = "https://igw.isgcc.net:18443/isgcc_message/server";
WxMsgConfig wxMsgConfig = new WxMsgConfig();
wxMsgConfig.setBaseUrl(baseUrl);
// TODO : 以下三个参数需要进行替换
wxMsgConfig.setProducerId(producerId);
wxMsgConfig.setSm4Key(sm4key);
wxMsgConfig.setSm2PublicKey(sm2key);
// 以下三个Bean 建议在项目中以单例形式存在
MsgRequestClient requestClient = new MsgRequestClient(wxMsgConfig);
// 消息中心查询client
MsgQueryClient msgQueryClient = new MsgQueryClient(requestClient);
// 消息中心发送client
MsgSendClient msgSendClient = new MsgSendClient(requestClient);
// 构建发送消息参数
SendMsgParams wechatMsg = new SendMsgParams();
// TODO : 发送目标用户
wechatMsg.setTouser("sgitg_sunfenglin");
// 发送目标组织
// wechatMsg.setToparty("目标组织");
// 跳转链接地址
wechatMsg.setUrl("zipapp://appid.1001093/index.html");
wechatMsg.setTitle("点击进入应用" + System.currentTimeMillis());
wechatMsg.setType("textcard");
wechatMsg.setContent("对接测试内容" + System.currentTimeMillis());
// wechatMsg.setPicurl("https://www.baidu.com/img/PCjing_5e539553b5304b9f43deb8a0fc918e45.png");
wechatMsg.setDescription("对接测试内容" + System.currentTimeMillis());
// 目标应用appId
wechatMsg.setMessageAppId(messageAppId);
WxSendMsgResult wxSendMsgResult = msgSendClient.sendMsg(wechatMsg);
System.out.println(wxSendMsgResult);
return new RestResult(Constant.SUCCESS, "操作成功");
} catch (Exception e) {
e.printStackTrace();
return new RestResult(Constant.FAILED, "返回异常");
}
}
public static void main(String[] args) {
Map<String, String> map = new HashMap<String,String>();
String string = map.get("kk");
System.err.println(string);
}
}