package com.hxzkoa.controller;
|
|
import java.io.File;
|
import java.io.IOException;
|
import java.io.OutputStream;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
|
import org.hibernate.dialect.function.VarArgsSQLFunction;
|
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 org.springframework.web.multipart.MultipartFile;
|
|
import com.hxzkoa.json.tb_department;
|
import com.hxzkoa.json.tb_icon;
|
import com.hxzkoa.json.tb_led;
|
import com.hxzkoa.json.tb_person;
|
import com.hxzkoa.json.tb_realkaoqing;
|
import com.hxzkoa.json.tb_tag;
|
import com.hxzkoa.services.BasicInfoService;
|
import com.hxzkoa.services.LabelService;
|
import com.hxzkoa.udp.GetNowTime;
|
import com.hxzkoa.udp.Udp_Out;
|
/*import com.hxzkoa.udp.Udp_Receive;*/
|
import com.hxzkoa.util.Config;
|
import com.hxzkoa.util.ExcelUtils;
|
import com.hxzkoa.util.HttpUtil;
|
import com.hxzkoa.util.ModifyConfig;
|
import com.hxzkoa.util.PageUtil;
|
import com.hxzkoa.util.RequestUtils;
|
|
import jxl.Sheet;
|
import jxl.Workbook;
|
import jxl.read.biff.BiffException;
|
import net.sf.json.JSONObject;
|
|
@Controller
|
public class BasicInfoController {
|
@Autowired
|
private BasicInfoService basicInfoService;
|
@Autowired
|
private LabelService labelService;
|
|
@RequestMapping(value = "/iconManagement.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public String iconManagement(HttpServletRequest request) {
|
String toPage = "forward:/hxzk/basicInfo/iconManagement.jsp";
|
List<tb_icon> iconManagementList = basicInfoService.getIconManagement(1);
|
int count = basicInfoService.getIconManagementCount();
|
int curPage = 1;
|
request.setAttribute("iconManagementList", iconManagementList);
|
int minPage = PageUtil.getMinPage(count);
|
request.setAttribute("pageList", PageUtil.getPage(minPage));
|
request.setAttribute("curPage", curPage);
|
return toPage;
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/iconManagement_page.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public String iconManagement_page(HttpServletRequest request) {
|
String pageStr = request.getParameter("page");
|
String curPageStr = request.getParameter("curPage");
|
int count = basicInfoService.getIconManagementCount();
|
int minPage = PageUtil.getMinPage(count);
|
int curPage = Integer.parseInt(curPageStr);
|
int page = 1;
|
if ("pre".equals(pageStr)) {
|
if (curPage > 1) {
|
page = curPage - 1;
|
}
|
} else if ("next".equals(pageStr)) {
|
if (curPage < minPage) {
|
page = curPage + 1;
|
}
|
} else {
|
page = Integer.parseInt(pageStr);
|
}
|
List<tb_icon> iconManagementList = basicInfoService.getIconManagement(page);
|
List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
|
JSONObject json = new JSONObject();
|
json.put("dataList", iconManagementList);
|
json.put("pageList", pageList);
|
json.put("curPage", page);
|
return json.toString();
|
}
|
|
@RequestMapping(value = "/uploadIcon.do")
|
public String upload(@RequestParam("file") MultipartFile[] files, HttpServletRequest request) {
|
String toPage = "redirect:/iconManagement.do";
|
String filePath1 = Config.getIconPath() + "/";
|
String filePath2 = request.getServletContext().getRealPath("/") + "hxzk/image/targeticon/";
|
try {
|
File existFile1 = new File(filePath1);
|
if (!existFile1.exists()) {
|
existFile1.mkdir();
|
}
|
for (MultipartFile file : files) {
|
file.transferTo(new File(filePath1 + file.getOriginalFilename()));
|
}
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
try {
|
File existFile2 = new File(filePath2);
|
if (!existFile2.exists()) {
|
existFile2.mkdir();
|
}
|
for (MultipartFile file : files) {
|
file.transferTo(new File(filePath2 + file.getOriginalFilename()));
|
}
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
return toPage;
|
}
|
|
@RequestMapping(value = "/iconManagement_add.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public void iconManagement_add(HttpServletRequest request) {
|
tb_icon icon = new tb_icon();
|
icon.setIcon_name(request.getParameter("name"));
|
icon.setIcon_adress("image/targeticon/" + request.getParameter("filePath"));
|
icon.setBeizhu(request.getParameter("beizhu"));
|
basicInfoService.iconManagement_add(icon);
|
}
|
|
@RequestMapping(value = "/iconManagement_check.do", method = { RequestMethod.POST, RequestMethod.GET })
|
@ResponseBody
|
public String iconManagement_check(HttpServletRequest request) {
|
String iconName = (request.getParameter("name"));
|
int exist = basicInfoService.iconManagement_check(iconName);
|
return String.valueOf(exist);
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/iconManagement_delete.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public void iconManagement_delete(HttpServletRequest request) {
|
String checkValStr = request.getParameter("checkVal");
|
checkValStr = checkValStr.replaceAll("\"", "");
|
String[] checkVal = checkValStr.split(",");
|
basicInfoService.iconManagement_delete(checkVal);
|
}
|
|
@RequestMapping(value = "/departmentManagement.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public String departmentManagement(HttpServletRequest request) {
|
String toPage = "forward:/hxzk/basicInfo/departmentManagement.jsp";
|
List<tb_department> departmentManagementList = basicInfoService.getDepartmentManagement(1);
|
request.setAttribute("departmentManagementList", departmentManagementList);
|
List<tb_icon> iconList = basicInfoService.getIconList();
|
request.setAttribute("iconList", iconList);
|
int curPage = 1;
|
int count = basicInfoService.getDepartmentManagementCount();
|
int minPage = PageUtil.getMinPage(count);
|
request.setAttribute("pageList", PageUtil.getPage(minPage));
|
request.setAttribute("curPage", curPage);
|
return toPage;
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/departmentManagement_page.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public String departmentManagement_page(HttpServletRequest request) {
|
String pageStr = request.getParameter("page");
|
String curPageStr = request.getParameter("curPage");
|
int count = basicInfoService.getDepartmentManagementCount();
|
int minPage = PageUtil.getMinPage(count);
|
int curPage = Integer.parseInt(curPageStr);
|
int page = 1;
|
if ("pre".equals(pageStr)) {
|
if (curPage > 1) {
|
page = curPage - 1;
|
}
|
} else if ("next".equals(pageStr)) {
|
if (curPage < minPage) {
|
page = curPage + 1;
|
}
|
} else {
|
page = Integer.parseInt(pageStr);
|
}
|
List<tb_department> departmentManagementList = basicInfoService.getDepartmentManagement(page);
|
List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
|
JSONObject json = new JSONObject();
|
json.put("dataList", departmentManagementList);
|
json.put("pageList", pageList);
|
json.put("curPage", page);
|
return json.toString();
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/departmentManagement_search.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public String departmentManagement_search(HttpServletRequest request) {
|
String input = request.getParameter("input");
|
int curPage = 1;
|
List<Integer> pageList = new ArrayList<Integer>();
|
List<tb_department> departmentManagementList = basicInfoService.searchDepartmentManagement(input);
|
pageList.add(1);
|
JSONObject json = new JSONObject();
|
json.put("dataList", departmentManagementList);
|
json.put("pageList", pageList);
|
json.put("curPage", curPage);
|
return json.toString();
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/departmentManagement_delete.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public void departmentManagement_delete(HttpServletRequest request) {
|
String checkValStr = request.getParameter("checkVal");
|
checkValStr = checkValStr.replaceAll("\"", "");
|
String[] checkVal = checkValStr.split(",");
|
basicInfoService.departmentManagement_delete(checkVal);
|
for(int i = 0;i < checkVal.length;i++) {
|
String xieyi = "BSTOCS1,DELETEBUMEN,"+checkVal[i]+",END";
|
Udp_Out.udp_to_cs(xieyi);
|
}
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/departmentManagement_deleteAll.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public void departmentManagement_deleteAll(HttpServletRequest request) {
|
basicInfoService.departmentManagement_deleteAll();
|
String xieyi = "BSTOCS1,DELETEALLBUMEN,END";
|
Udp_Out.udp_to_cs(xieyi);
|
}
|
|
@RequestMapping(value = "/departmentManagement_add.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public void departmentManagement_add(HttpServletRequest request) {
|
tb_department department = new tb_department();
|
department.setDepartmentName(request.getParameter("addName"));
|
department.setIconadress(request.getParameter("addIcon"));
|
basicInfoService.departmentManagement_add(department);
|
String xieyi = "BSTOCS1,ADDBUMEN,"+department.getDepartmentName()+","+department.getIconadress()+",END";
|
Udp_Out.udp_to_cs(xieyi);
|
}
|
|
@RequestMapping(value = "/departmentManagement_check.do", method = { RequestMethod.POST, RequestMethod.GET })
|
@ResponseBody
|
public String departmentManagement_check(HttpServletRequest request) {
|
String name = (request.getParameter("name"));
|
int exist = basicInfoService.departmentManagement_check(name);
|
return String.valueOf(exist);
|
}
|
|
@RequestMapping(value = "/departmentManagement_modify.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public void departmentManagement_modify(HttpServletRequest request) {
|
tb_department department = new tb_department();
|
department.setId(Integer.parseInt(request.getParameter("id")));
|
department.setDepartmentName(request.getParameter("addName"));
|
department.setIconadress(request.getParameter("addIcon"));
|
basicInfoService.departmentManagement_modify(department);
|
String xieyi = "BSTOCS1,ALTERBUMEN,"+department.getDepartmentName()+","+department.getIconadress()+",END";
|
Udp_Out.udp_to_cs(xieyi);
|
}
|
|
// 对象转数组
|
public static List<Object[]> objectToArray(List<tb_department> departmentManagementList) {
|
List<Object[]> reList = new ArrayList<>();
|
for (int i = 0; i < departmentManagementList.size(); i++) {
|
List<String> words = new ArrayList<String>();
|
tb_department department = (tb_department) departmentManagementList.get(i);
|
words.add(department.getDepartmentName());
|
words.add(department.getIconadress());
|
words.add(String.valueOf(department.getAddtime()));
|
String[] array = words.toArray(new String[0]);
|
reList.add(array);
|
}
|
return reList;
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/departmentManagement_export.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public String departmentManagement_export(HttpServletRequest request, HttpServletResponse response) {
|
String toPage = "forward:/hxzk/basicInfo/departmentManagement.jsp";
|
List<tb_department> departmentManagementList = basicInfoService.getDepartmentManagement();
|
String[] rowName = { "部门名称", "图标预览", "添加时间" };
|
List<Object[]> dataList = objectToArray(departmentManagementList);
|
ExcelUtils excel = new ExcelUtils("部门管理", rowName, dataList);
|
OutputStream out;
|
try {
|
String fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls";
|
String headStr = "attachment; filename=\"" + fileName + "\"";
|
response.setContentType("APPLICATION/OCTET-STREAM");
|
response.setHeader("Content-Disposition", headStr);
|
out = response.getOutputStream();
|
excel.export(out);
|
out.flush();
|
out.close();
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return toPage;
|
}
|
|
@RequestMapping(value = "/personManagement.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public String personManagement(HttpServletRequest request) {
|
String toPage = "forward:/hxzk/basicInfo/personManagement.jsp";
|
List<tb_person> personManagementList = basicInfoService.getPersonManagement(1);
|
request.setAttribute("personManagementList", personManagementList);
|
List<tb_department> departmentList = basicInfoService.getDepartmentList();
|
request.setAttribute("departmentList", departmentList);
|
int curPage = 1;
|
int count = basicInfoService.getPersonManagementCount();
|
int minPage = PageUtil.getMinPage(count);
|
request.setAttribute("pageList", PageUtil.getPage(minPage));
|
request.setAttribute("curPage", curPage);
|
return toPage;
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/personManagement_page.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public String personManagement_page(HttpServletRequest request) {
|
String pageStr = request.getParameter("page");
|
String curPageStr = request.getParameter("curPage");
|
int count = basicInfoService.getPersonManagementCount();
|
int minPage = PageUtil.getMinPage(count);
|
int curPage = Integer.parseInt(curPageStr);
|
int page = 1;
|
if ("pre".equals(pageStr)) {
|
if (curPage > 1) {
|
page = curPage - 1;
|
}
|
} else if ("next".equals(pageStr)) {
|
if (curPage < minPage) {
|
page = curPage + 1;
|
}
|
} else {
|
page = Integer.parseInt(pageStr);
|
}
|
List<tb_person> personManagementList = basicInfoService.getPersonManagement(page);
|
List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
|
JSONObject json = new JSONObject();
|
json.put("dataList", personManagementList);
|
json.put("pageList", pageList);
|
json.put("curPage", page);
|
return json.toString();
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/personManagement_search.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public String personManagement_search(HttpServletRequest request) throws IOException {
|
JSONObject json = new JSONObject();
|
String input = request.getParameter("input");
|
if (("").equals(input) || input == null) {
|
String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
|
tb_tag tag = (tb_tag) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_tag.class);
|
input = tag.getTag_id();
|
List<tb_person> personManagementList = basicInfoService.searchPersonManagement(input);
|
if (personManagementList.size()>0){
|
json.put("result", personManagementList.get(0));
|
} else {
|
json.put("result", "null");
|
}
|
} else {
|
int curPage = 1;
|
List<Integer> pageList = new ArrayList<Integer>();
|
List<tb_person> personManagementList = basicInfoService.searchPersonManagement(input);
|
pageList.add(1);
|
json.put("dataList", personManagementList);
|
json.put("pageList", pageList);
|
json.put("curPage", curPage);
|
}
|
return json.toString();
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/personManagement_delete.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public void personManagement_delete(HttpServletRequest request) {
|
String checkValStr = request.getParameter("checkVal");
|
checkValStr = checkValStr.replaceAll("\"", "");
|
String[] checkVal = checkValStr.split(",");
|
for (int i = 0; i < checkVal.length; i++) {
|
basicInfoService.personManagement_delete(checkVal[i]);
|
String xieyi = "BSTOCS1,DELETEFPERSON,"+checkVal[i]+",END";
|
Udp_Out.udp_to_cs(xieyi);
|
}
|
// 删除tb_person同时需要删除标签
|
labelService.labelManagement_delete(checkVal);
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/personManagement_deleteAll.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public void personManagement_deleteAll(HttpServletRequest request) {
|
basicInfoService.personManagement_deleteAll();
|
String xieyi = "BSTOCS1,DELETEALLPERSON,END";
|
Udp_Out.udp_to_cs(xieyi);
|
// 删除tb_person同时需要删除标签
|
labelService.labelManagement_deleteAll();
|
}
|
|
@RequestMapping(value = "/personManagement_modify.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public void personManagement_modify(HttpServletRequest request) {
|
tb_person person = new tb_person();
|
person.setP_tagid(request.getParameter("p_tagid"));
|
person.setP_department(request.getParameter("p_department"));
|
person.setP_name(request.getParameter("p_name"));
|
person.setP_sex(request.getParameter("p_sex"));
|
person.setP_phone(request.getParameter("p_phone"));
|
basicInfoService.personManagement_modify(person);
|
String xieyi = "BSTOCS1,ALTERPERSON,"+person.getP_name()+","+person.getP_tagid()+","+person.getP_sex()+","+person.getP_department()+","+person.getP_phone()+",END";
|
Udp_Out.udp_to_cs(xieyi);
|
// 修改tb_person同时需要修改标签 需要先查再改否则覆盖空
|
List<tb_tag> searchLabelManagement = labelService.searchLabelManagement(person.getP_tagid());
|
if(searchLabelManagement!=null){
|
tb_tag tag = searchLabelManagement.get(0);
|
tag.setState(person.getP_name());
|
labelService.labelManagement_modify(tag);
|
}
|
}
|
|
@RequestMapping(value = "/uploadPerson.do")
|
public String uploadPerson(@RequestParam("file") MultipartFile[] files, HttpServletRequest request) {
|
String toPage = "forward:/hxzk/basicInfo/personManagement.jsp";
|
String filePath = request.getServletContext().getRealPath("/") + "hxzk\\upload\\";
|
String filename = files[0].getOriginalFilename();
|
try {
|
File existFile = new File(filePath);
|
if (!existFile.exists()) {
|
existFile.mkdir();
|
}
|
for (MultipartFile file : files) {
|
file.transferTo(new File(filePath + file.getOriginalFilename()));
|
////System.out.print(file.getOriginalFilename());
|
}
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
int result = 0;
|
String path = filePath + filename;
|
// 选取Excel文件得到工作薄
|
Workbook workbook;
|
try {
|
File file = new File(path);
|
workbook = Workbook.getWorkbook(file);
|
// 选择工作表,通过Workbook的getSheet方法选择第一个工作表(从0开始)
|
Sheet sheet = workbook.getSheet(0);
|
int rows = sheet.getRows();
|
// 选择Cell,读取单元格 通过Sheet的getCell方法选择位置为C2的单元格(两个参数都从0开始)
|
for (int i = 3; i < rows; i++) {
|
// 读取信息,通过Cell的getContents方法读取单元格的值把单元格中的信息以字符的形式读取出来
|
String p_name = sheet.getCell(0, i).getContents();
|
String p_tagid = sheet.getCell(1, i).getContents();
|
String p_sex = sheet.getCell(2, i).getContents();
|
String p_department = sheet.getCell(3, i).getContents();
|
String p_phone = sheet.getCell(4, i).getContents();
|
if (!("").equals(p_tagid)) {
|
tb_person person = new tb_person();
|
person.setP_name(p_name);
|
person.setP_tagid(p_tagid);
|
person.setP_sex(p_sex);
|
person.setP_department(p_department);
|
person.setP_phone(p_phone);
|
basicInfoService.personManagement_add(person);
|
result = 1;
|
}
|
}
|
// 释放资源
|
workbook.close();
|
} catch (BiffException e) {
|
e.printStackTrace();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
request.setAttribute("resultList", result);
|
List<tb_person> personManagementList = basicInfoService.getPersonManagement(1);
|
request.setAttribute("personManagementList", personManagementList);
|
List<tb_department> departmentList = basicInfoService.getDepartmentList();
|
request.setAttribute("departmentList", departmentList);
|
int curPage = 1;
|
int count = basicInfoService.getPersonManagementCount();
|
int minPage = PageUtil.getMinPage(count);
|
request.setAttribute("pageList", PageUtil.getPage(minPage));
|
request.setAttribute("curPage", curPage);
|
File file = new File(path);
|
file.delete();
|
return toPage;
|
}
|
|
// 对象转数组
|
public static List<Object[]> personobjectToArray(List<tb_person> personList) {
|
List<Object[]> reList = new ArrayList<>();
|
for (int i = 0; i < personList.size(); i++) {
|
List<String> words = new ArrayList<String>();
|
tb_person person = (tb_person) personList.get(i);
|
words.add(String.valueOf(person.getId()));
|
words.add(person.getP_name());
|
words.add(person.getP_tagid());
|
words.add(person.getP_sex());
|
words.add(person.getP_department());
|
words.add(person.getP_phone());
|
words.add(person.getP_power());
|
words.add(person.getP_image());
|
words.add(person.getP_addtiem());
|
String[] array = words.toArray(new String[0]);
|
reList.add(array);
|
}
|
return reList;
|
}
|
|
// 对象转数组
|
public static List<Object[]> personTemplateobjectToArray(List<tb_person> personList) {
|
List<Object[]> reList = new ArrayList<>();
|
for (int i = 0; i < personList.size(); i++) {
|
List<String> words = new ArrayList<String>();
|
tb_person person = (tb_person) personList.get(i);
|
words.add(person.getP_name());
|
words.add(person.getP_tagid());
|
words.add(person.getP_sex());
|
words.add(person.getP_department());
|
words.add(person.getP_phone());
|
String[] array = words.toArray(new String[0]);
|
reList.add(array);
|
}
|
return reList;
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/personManagement_export.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public String personManagement_export(HttpServletRequest request, HttpServletResponse response) {
|
String toPage = "forward:/hxzk/basicInfo/personmentManagement.jsp";
|
List<tb_person> personList = basicInfoService.getPersonManagement();
|
String[] rowName = { "序号", "姓名", "标签ID", "性别", "部门", "电话", "电量%", "图标", "添加时间" };
|
List<Object[]> dataList = personobjectToArray(personList);
|
ExcelUtils excel = new ExcelUtils("人员管理", rowName, dataList);
|
OutputStream out;
|
try {
|
String fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls";
|
String headStr = "attachment; filename=\"" + fileName + "\"";
|
response.setContentType("APPLICATION/OCTET-STREAM");
|
response.setHeader("Content-Disposition", headStr);
|
out = response.getOutputStream();
|
excel.export(out);
|
out.flush();
|
out.close();
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return toPage;
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/personManagement_exportTemplate.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public String personManagement_exportTemplate(HttpServletRequest request, HttpServletResponse response) {
|
String toPage = "forward:/hxzk/basicInfo/personmentManagement.jsp";
|
List<tb_person> personTemplateList = basicInfoService.getPersonManagementTemplate(1);
|
String[] rowName = { "姓名", "标签ID", "性别", "部门", "电话"};
|
List<Object[]> dataList = personTemplateobjectToArray(personTemplateList);
|
ExcelUtils excel = new ExcelUtils("人员管理", rowName, dataList);
|
OutputStream out;
|
try {
|
String fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls";
|
String headStr = "attachment; filename=\"" + fileName + "\"";
|
response.setContentType("APPLICATION/OCTET-STREAM");
|
response.setHeader("Content-Disposition", headStr);
|
out = response.getOutputStream();
|
excel.export(out);
|
out.flush();
|
out.close();
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return toPage;
|
}
|
|
|
@RequestMapping(value = "/person_bw_kaoqin.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public void person_bw_kaoqin(HttpServletRequest request) throws IOException {
|
String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
|
tb_person person = (tb_person) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_person.class);
|
//显示sql
|
String sqlString = "UPDATE tb_person SET p_kaoqin = "+person.getP_kaoqing() +"WHERE p_tagid= +"+person.getP_tagid();
|
String messageJson = GetNowTime.timestamp2()+ " 收:"+ sqlString ;
|
String BaowenPath = Config.getBaowenConfig();
|
String baowenStatus = ModifyConfig.readData(BaowenPath, "baowenSwitch");
|
if (baowenStatus.equals("1")){
|
/* Udp_Receive.mysqlMessage.add(messageJson); */
|
}
|
//
|
basicInfoService.person_modify_kaoqin(person);
|
}
|
@RequestMapping(value = "/person_bw_power.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public void person_bw_power(HttpServletRequest request) throws IOException {
|
String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
|
tb_person person = (tb_person) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_person.class);
|
//显示sql
|
String sqlString = "UPDATE tb_person SET p_kaoqin = "+person.getP_kaoqing() +"WHERE p_tagid= +"+person.getP_tagid();
|
String messageJson = GetNowTime.timestamp2()+ " 收:"+ sqlString ;
|
String BaowenPath = Config.getBaowenConfig();
|
String baowenStatus = ModifyConfig.readData(BaowenPath, "baowenSwitch");
|
if (baowenStatus.equals("1")){
|
/* Udp_Receive.mysqlMessage.add(messageJson); */
|
}
|
//
|
basicInfoService.person_modify_power(person);
|
}
|
|
@RequestMapping(value = "/person_bw_SOS.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public void person_bw_SOS(HttpServletRequest request) throws IOException {
|
String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
|
tb_person person = (tb_person) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_person.class);
|
//显示sql
|
String sqlString = "UPDATE tb_person SET p_sos = "+person.getP_sos() +"WHERE p_tagid= +"+person.getP_tagid();
|
String messageJson = GetNowTime.timestamp2()+ " 收:"+ sqlString ;
|
String BaowenPath = Config.getBaowenConfig();
|
String baowenStatus = ModifyConfig.readData(BaowenPath, "baowenSwitch");
|
if (baowenStatus.equals("1")){
|
/* Udp_Receive.mysqlMessage.add(messageJson); */
|
}
|
//
|
basicInfoService.person_modify_sos(person);
|
}
|
|
@RequestMapping(value = "/person_bw_warning.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public void person_bw_warning(HttpServletRequest request) throws IOException {
|
String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
|
tb_person person = (tb_person) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_person.class);
|
//显示sql
|
String sqlString = "UPDATE tb_person SET p_sos = "+person.getP_sos() +"WHERE p_tagid= +"+person.getP_tagid();
|
String messageJson = GetNowTime.timestamp2()+ " 收:"+ sqlString ;
|
String BaowenPath = Config.getBaowenConfig();
|
String baowenStatus = ModifyConfig.readData(BaowenPath, "baowenSwitch");
|
if (baowenStatus.equals("1")){
|
/* Udp_Receive.mysqlMessage.add(messageJson); */
|
}
|
//
|
basicInfoService.person_modify_warning(person);
|
}
|
|
@RequestMapping(value = "/person_bw_XYF.do", method = { RequestMethod.POST, RequestMethod.GET })
|
public void person_bw_XYF(HttpServletRequest request) throws IOException {
|
String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
|
tb_person person = (tb_person) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_person.class);
|
//显示sql
|
String sqlString = "UPDATE tb_person SET p_x = "+person.getP_x()+",p_y = "+person.getP_y()+",p_floor = "+person.getP_floor()+"WHERE p_tagid= "+person.getP_tagid();
|
String messageJson = GetNowTime.timestamp2()+ " 收:"+ sqlString ;
|
String BaowenPath = Config.getBaowenConfig();
|
String baowenStatus = ModifyConfig.readData(BaowenPath, "baowenSwitch");
|
if (baowenStatus.equals("1")){
|
/* Udp_Receive.mysqlMessage.add(messageJson); */
|
}
|
//
|
basicInfoService.person_modify_XYF(person);
|
}
|
|
}
|