Commit f55217d0 by wangxing

导出数据修改

parent fb80a5e1
package com.cc.controller;
import com.cc.model.AsjRyRelateVO;
import com.cc.model.MisAsjRyRelateVO;
import com.cc.model.Record;
import com.cc.model.User;
import com.cc.service.IMisSolrService;
import com.cc.service.IRecordService;
import com.cc.utils.CodeUtils;
import com.cc.utils.EasyUIPage;
import com.cc.utils.Utils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
import static com.cc.utils.propertiesUtil.propertiesUtil;
@Controller
public class MisSolrController {
@Autowired
IMisSolrService iMisSolrService;
@Autowired
IRecordService recordService;
private static final Logger logger = LoggerFactory.getLogger(MisSolrController.class);
@RequestMapping("/listMisAsj")
@ResponseBody
public EasyUIPage listMisAsj(HttpServletRequest request, MisAsjRyRelateVO misAsjRyRelateVO, String unitcode, String grade, String groupids, String sort, String order, String sorlInstance, String selectedCols, String daohan, String groupidvalue){
User user=(User)request.getSession().getAttribute("user");
Properties properties=propertiesUtil("solr.properties");
String sorlAddress =properties.getProperty("sorlAddress");
Properties configProperties=propertiesUtil("config.properties");
Map<String,Object> configMap = new HashedMap();
configMap.put("zhyyPath",configProperties.getProperty("zhyyPath"));
configMap.put("mainurl",configProperties.getProperty("main.url"));
configMap.put("caijiurl",configProperties.getProperty("caiji.url"));
configMap.put("zxajurl",configProperties.getProperty("zxaj.url"));
Map<String,Object> map = getMisAsjFqList(misAsjRyRelateVO,unitcode,grade);
List<String> fqList = (List<String>)map.get("fqList");
String q = (String)map.get("q");
//Sorl查询
Record record=new Record();
record.setAjzlz_record(selectedCols);
record.setUserid(user.getIdentitycard());
recordService.updateRecord(record);
String page = request.getParameter("page");
String rows = request.getParameter("rows");
System.out.println("当前页:"+page+"----------行数:"+rows);
return iMisSolrService.queryMisSolrAsj(q,fqList,misAsjRyRelateVO,page,rows, sorlAddress, sorlInstance,groupids,sort,order,unitcode,configMap,daohan,groupidvalue);
}
private Map<String,Object> getMisAsjFqList(MisAsjRyRelateVO misAsjRyRelateVO,String unitcode,String grade) {
Map<String, Object> map = new HashedMap();
List<String> fqList = new ArrayList<>();
String misAsjq = "IFDET:0";
if(null!=misAsjRyRelateVO.getCaseid() && !"".equals(misAsjRyRelateVO.getCaseid())){
misAsjq += " AND CASEID:*" + misAsjRyRelateVO.getCaseid()+"*";
}
fqList.add(misAsjq);
String str = "";
String q = "*:*";
String jyaq = misAsjRyRelateVO.getBrief();
if(null!=jyaq && !"".equals(jyaq)){
jyaq=jyaq.replaceAll("and","AND").replaceAll("or","OR");
if(jyaq.indexOf("AND")>0) {
String[] andArr = jyaq.split("AND");
for (int i = 0; i < andArr.length; i++) {
if (andArr[i].indexOf("OR") > 0) {
String[] orArr = andArr[i].split("OR");
for (int j = 0; j < orArr.length; j++) {
if ((orArr[j].indexOf("(") != -1) || (orArr[j].indexOf("(") != -1)) {
str += " (JYAQ:*" + orArr[j].substring(1, orArr[j].length()) + "* OR ";
} else if (orArr[j].indexOf(")") > 0 || orArr[j].indexOf(")") > 0) {
str += " JYAQ:*" + orArr[j].substring(0, orArr[j].length() - 1) + "*)";
} else {
str += " JYAQ:*" + orArr[j]+"*";
}
}
if (i < andArr.length - 1) {
str += " AND ";
}
} else {
if (i == andArr.length - 1) {
str += " JYAQ:*" + andArr[i]+"*";
} else {
str += " JYAQ:*" + andArr[i] + "* AND ";
}
}
}
}else if(jyaq.indexOf("OR")>0){
str +="(";
String[] orArr = jyaq.split("OR");
for (int j = 0; j < orArr.length; j++) {
if (j == orArr.length - 1) {
str += " JYAQ:*" + orArr[j]+"*";
} else {
str += " JYAQ:*" + orArr[j] + "* OR ";
}
}
str +=")";
}else{
str =" JYAQ:*" + jyaq+"*";
}
System.out.println(str);
q = str;
}
System.out.println("过虑查询条件fqList==================="+fqList);
System.out.println("查询的关键字q==================="+q);
map.put("fqList",fqList);
map.put("q",q);
return map;
}
/**
* @return 生成文件
*/
@RequestMapping("/createFileMisAsj")
@ResponseBody
public String createFileMisAsj(HttpServletRequest request,String listMapStr,String selectedCols,Integer maxValue,String ssdw,String sorlInstance,@RequestParam(value = "checkIds[]",required = false) String [] checkIds) {
User user=(User)request.getSession().getAttribute("user");
//String ssdw = "";
if(null!=user){
ssdw = user.getUnitcode().substring(0,2);
}
Properties properties = propertiesUtil("solr.properties");
String sorlAddress = properties.getProperty("sorlAddress");
List<Map<String, Object>> listMap = iMisSolrService.getMisAsjSorlByFQ(ssdw,listMapStr,maxValue,sorlAddress, sorlInstance,checkIds);
// 表格头
String [] cols = selectedCols.split(",");
Object [] head = new String[cols.length];
String [] names = new String[cols.length];
for(int i=0;i<cols.length;i++){
String col = cols[i];
String [] arr = col.split(":");
head[i] = arr[0];
names[i] = arr[1];
}
List<Object> headList = Arrays.asList(head);
String fileName = null;//文件名称
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");// 可以方便地修改日期格式
String filePath = System.getProperty("evan.webapp")+"/csvFile"; //文件路径
if(null!=user){
fileName = user.getUsername() + "-" + dateFormat.format(now) + ".csv";
}else{
fileName = dateFormat.format(now) + ".csv";
}
//判断文件夹是否存在
File file = new File(filePath);
if(!file.exists() && !file.isFile()){
file.mkdir();
}
File csvFile = null;
BufferedWriter csvWtriter = null;
try {
csvFile = new File(filePath +"/"+ fileName);
File parent = csvFile.getParentFile();
if (parent != null && !parent.exists()) {
parent.mkdirs();
}
csvFile.createNewFile();
// GB2312使正确读取分隔符","
csvWtriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(csvFile), "GB2312"), 1024);
int num = headList.size() / 2;
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < num; i++) {
buffer.append(" ,");
}
// 写入文件头部
Utils.writeRow(headList, csvWtriter);
// 写入文件内容
for (Map<String, Object> map : listMap) {
List<Object> list = new ArrayList<Object>();
for(int j=0;j<names.length;j++){
if(names[j].indexOf("zjhm") != -1){
list.add("\t"+map.get(names[j]));
}else{
list.add(map.get(names[j]));
}
}
Utils.writeRow(list, csvWtriter);
}
csvWtriter.flush();
return fileName;
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
csvWtriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println("================================:创建文件成功");
return "";
}
}
......@@ -40,6 +40,7 @@ public class RecordController {
record.setAj_record("案事件编号:id,案件名称:ajmc,侦查阶段:zcjdmc,业务状态:sjzt,案件类别:ajlbdmmc,案件时间:ajxgsj,立案单位:ladw_gajgmc,简要案情:jyaq");
record.setXyr_record("案事件编号:asjbh,证件号码:cyzj_zjhm,姓名:xm,性别:xbdmmc,民族:mzmc,户籍地行政区划:hjdz_xzqhmc,现住地行政区划:xzz_xzqhmc,到案状态:zhfzxyr_fzxyrdaztmc");
record.setRybh_record("案事件编号:asjbh,证件号码:cyzj_zjhm,姓名:xm,性别:xbdmmc,民族:mzmc,户籍地行政区划:hjdz_xzqhmc,人身侵犯结果:rsqfjgmc,人身伤害程度:rsshcdmc");
record.setAjzlz_record("案事件编号:caseid,简要案情:brief");
recordService.insertRecord(record);
}else{
record = recordService.queryRybhRecord(users.getIdentitycard());
......
......@@ -12,9 +12,19 @@ public class Record {
private String rybh_record;
private String xyr_record;
private String aj_record;
private String ajzlz_record;
private String gxsj;
private String id;
public String getAjzlz_record() {
return ajzlz_record;
}
public void setAjzlz_record(String ajzlz_record) {
this.ajzlz_record = ajzlz_record;
}
public String getUserid() {
return userid;
}
......
package com.cc.service;
import com.cc.model.AsjRyRelateVO;
import com.cc.model.MisAsjRyRelateVO;
import com.cc.model.Record;
import com.cc.utils.EasyUIPage;
import java.util.List;
import java.util.Map;
public interface IMisSolrService {
EasyUIPage queryMisSolrAsj(String q, List<String> fqList, MisAsjRyRelateVO misAsjRyRelateVO, String page, String rows, String solrAddress, String sorlInstance, String groupids, String sort, String order, String unitcode, Map<String,Object> configMap, String daohan, String groupidvalue);
List<Map<String, Object>> getMisAsjSorlByFQ(String ssdw,String fq,Integer maxValue,String solrAddress, String sorlInstance,String[] checkIds);
}
......@@ -7,6 +7,7 @@
<result column="rybh_record" jdbcType="VARCHAR" property="rybh_record" />
<result column="xyr_record" jdbcType="VARCHAR" property="xyr_record" />
<result column="aj_record" jdbcType="VARCHAR" property="aj_record" />
<result column="ajzlz_record" jdbcType="VARCHAR" property="ajzlz_record" />
<result column="gxsj" jdbcType="VARCHAR" property="gxsj" />
</resultMap>
<!--查询被害人的记录-->
......@@ -18,13 +19,16 @@
update TB_RECORD
<set>
<if test="rybh_record != null">
rybh_record = #{rybh_record,jdbcType=INTEGER},
rybh_record = #{rybh_record,jdbcType=VARCHAR},
</if>
<if test="xyr_record != null">
xyr_record = #{xyr_record,jdbcType=VARCHAR},
</if>
<if test="aj_record != null">
aj_record = #{aj_record,jdbcType=CHAR},
aj_record = #{aj_record,jdbcType=VARCHAR},
</if>
<if test="ajzlz_record != null">
ajzlz_record = #{ajzlz_record,jdbcType=VARCHAR},
</if>
GXSJ =SYSDATE
</set>
......@@ -37,6 +41,7 @@
RYBH_RECORD,
XYR_RECORD,
AJ_RECORD,
AJZLZ_RECORD,
USERID,
GXSJ
) VALUES (
......@@ -47,6 +52,8 @@
<if test="xyr_record==null">NULL,</if>
<if test="aj_record!=null">#{aj_record},</if>
<if test="aj_record==null">NULL,</if>
<if test="ajzlz_record!=null">#{ajzlz_record},</if>
<if test="ajzlz_record==null">NULL,</if>
<if test="userid!=null">#{userid},</if>
<if test="userid==null">NULL,</if>
sysdate
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -214,6 +214,11 @@ var navCategory = {
url = "listTbXwStjy";
sorlInstance = "TB_XW_STJY";
}
else if(searchType=='ajzlz'){
presentType = $('input[type=radio][name="ajzlzPresentType"]:checked ').val();
url = "listMisAsj";
sorlInstance = "CASE_M_AJZLZ";
}
searchTerm.sorlInstance=sorlInstance;
if(presentType=='DList'){
$("#dListContainer").show();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment