package com.hxzkoa.services;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
import javax.persistence.EntityManager;
|
import javax.persistence.PersistenceContext;
|
import javax.persistence.Query;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import com.hxzkoa.json.tb_map;
|
import com.hxzkoa.json.tb_person;
|
import com.hxzkoa.util.Config;
|
import com.hxzkoa.util.ModifyConfig;
|
|
@Service
|
public class MapService {
|
@PersistenceContext
|
private EntityManager em;
|
@Autowired
|
private CaozuoService cs;
|
|
public List<tb_map> getMapManagement() {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,floor,mapname,x_Truelength,y_Truewidth,x0_length,y0_width,x_Pixel,y_Pixel,addTime FROM tb_map order by addtime desc";
|
query = this.em.createNativeQuery(sql);
|
List resultList = query.getResultList();
|
List<tb_map> tb_mapList = new ArrayList<tb_map>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_map map = new tb_map();
|
Object[] obj = (Object[]) resultList.get(i);
|
map.setId((int) obj[0]);
|
map.setFloor(obj[1] == null ? "" : obj[1].toString());
|
map.setMapname(obj[2] == null ? "" : obj[2].toString());
|
map.setX_Truelength(obj[3] == null ? "" : obj[3].toString());
|
map.setY_Truewidth(obj[4] == null ? "" : obj[4].toString());
|
map.setX0_length(obj[5] == null ? "" : obj[5].toString());
|
map.setY0_width(obj[6] == null ? "" : obj[6].toString());
|
map.setX_Pixel(obj[7] == null ? "" : obj[7].toString());
|
map.setY_Pixel(obj[8] == null ? "" : obj[8].toString());
|
map.setAddTime(obj[9] == null ? "" : obj[9].toString());
|
tb_mapList.add(map);
|
}
|
}
|
return tb_mapList;
|
}
|
|
public List<tb_map> getMapManagement(int page) {
|
int perPage = Integer.parseInt(ModifyConfig.readData(Config.getPageConfig(), "perPage"));
|
int start = (page - 1) * perPage;
|
int end = perPage;
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,floor,mapname,x_Truelength,y_Truewidth,x0_length,y0_width,x_Pixel,y_Pixel,addTime,baoliu3,baoliu4 FROM tb_map LIMIT :start,:end";
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("start", start);
|
query.setParameter("end", end);
|
List resultList = query.getResultList();
|
List<tb_map> tb_mapList = new ArrayList<tb_map>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_map map = new tb_map();
|
Object[] obj = (Object[]) resultList.get(i);
|
map.setId((int) obj[0]);
|
map.setFloor(obj[1] == null ? "" : obj[1].toString());
|
map.setMapname(obj[2] == null ? "" : obj[2].toString());
|
map.setX_Truelength(obj[3] == null ? "" : obj[3].toString());
|
map.setY_Truewidth(obj[4] == null ? "" : obj[4].toString());
|
map.setX0_length(obj[5] == null ? "" : obj[5].toString());
|
map.setY0_width(obj[6] == null ? "" : obj[6].toString());
|
map.setX_Pixel(obj[7] == null ? "" : obj[7].toString());
|
map.setY_Pixel(obj[8] == null ? "" : obj[8].toString());
|
map.setAddTime(obj[9] == null ? "" : obj[9].toString());
|
map.setBaoliu3(obj[10] == null ? "" : obj[10].toString());
|
map.setBaoliu4(obj[11] == null ? "" : obj[11].toString());
|
tb_mapList.add(map);
|
}
|
}
|
return tb_mapList;
|
}
|
|
public List<tb_map> getMapManagementa() {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,floor,mapname,x_Truelength,y_Truewidth,x0_length,y0_width,x_Pixel,y_Pixel,addTime,baoliu3,baoliu4 FROM tb_map";
|
query = this.em.createNativeQuery(sql);
|
List resultList = query.getResultList();
|
List<tb_map> tb_mapList = new ArrayList<tb_map>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_map map = new tb_map();
|
Object[] obj = (Object[]) resultList.get(i);
|
map.setId((int) obj[0]);
|
map.setFloor(obj[1] == null ? "" : obj[1].toString());
|
map.setMapname(obj[2] == null ? "" : obj[2].toString());
|
map.setX_Truelength(obj[3] == null ? "" : obj[3].toString());
|
map.setY_Truewidth(obj[4] == null ? "" : obj[4].toString());
|
map.setX0_length(obj[5] == null ? "" : obj[5].toString());
|
map.setY0_width(obj[6] == null ? "" : obj[6].toString());
|
map.setX_Pixel(obj[7] == null ? "" : obj[7].toString());
|
map.setY_Pixel(obj[8] == null ? "" : obj[8].toString());
|
map.setAddTime(obj[9] == null ? "" : obj[9].toString());
|
map.setBaoliu3(obj[10] == null ? "" : obj[10].toString());
|
map.setBaoliu4(obj[11] == null ? "" : obj[11].toString());
|
tb_mapList.add(map);
|
}
|
}
|
return tb_mapList;
|
}
|
|
public int getMapManagementCount() {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT count(1) FROM tb_map";
|
query = this.em.createNativeQuery(sql);
|
return Integer.parseInt(query.getSingleResult().toString());
|
}
|
|
public List<tb_map> searchMapService(String input) {
|
String mapname = input;
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,floor,mapname,x_Truelength,y_Truewidth,x0_length,y0_width,x_Pixel,y_Pixel,addTime,baoliu3,baoliu4 FROM tb_map WHERE mapname = :mapname";
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("mapname", mapname);
|
List resultList = query.getResultList();
|
List<tb_map> tb_mapList = new ArrayList<tb_map>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_map map = new tb_map();
|
Object[] obj = (Object[]) resultList.get(i);
|
map.setId((int) obj[0]);
|
map.setFloor(obj[1] == null ? "" : obj[1].toString());
|
map.setMapname(obj[2] == null ? "" : obj[2].toString());
|
map.setX_Truelength(obj[3] == null ? "" : obj[3].toString());
|
map.setY_Truewidth(obj[4] == null ? "" : obj[4].toString());
|
map.setX0_length(obj[5] == null ? "" : obj[5].toString());
|
map.setY0_width(obj[6] == null ? "" : obj[6].toString());
|
map.setX_Pixel(obj[7] == null ? "" : obj[7].toString());
|
map.setY_Pixel(obj[8] == null ? "" : obj[8].toString());
|
map.setAddTime(obj[9] == null ? "" : obj[9].toString());
|
map.setBaoliu3(obj[10] == null ? "" : obj[10].toString());
|
map.setBaoliu4(obj[11] == null ? "" : obj[11].toString());
|
tb_mapList.add(map);
|
}
|
}
|
return tb_mapList;
|
}
|
|
@Transactional
|
public void mapManagement_delete(String[] checkVal) {
|
String sql = null;
|
Query query = null;
|
for (int i = 0; i < checkVal.length; i++) {
|
String floor = checkVal[i];
|
sql = "DELETE FROM tb_map WHERE floor=:floor";
|
cs.tb_caozuo("tb_map", 2);
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("floor", floor);
|
query.executeUpdate();
|
}
|
}
|
|
@Transactional
|
public void mapManagement_deleteAll() {
|
String sql = null;
|
Query query = null;
|
sql = "DELETE FROM tb_map";
|
cs.tb_caozuo("tb_map", 2);
|
query = this.em.createNativeQuery(sql);
|
query.executeUpdate();
|
}
|
|
@Transactional
|
public int mapManagement_add(tb_map map) {
|
String sql = null;
|
Query query = null;
|
sql = "INSERT INTO tb_map(floor,mapname,x_Truelength,y_Truewidth,x0_length,y0_width,x_Pixel,y_Pixel,addTime,baoliu3,baoliu4) VALUES(:floor,:mapname,:x_Truelength,:y_Truewidth,:x0_length,:y0_width,:x_Pixel,:y_Pixel,now(),:baoliu3,:baoliu4)";
|
cs.tb_caozuo("tb_map", 1);
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("floor", map.getFloor());
|
query.setParameter("mapname", map.getMapname());
|
query.setParameter("x_Truelength", map.getX_Truelength());
|
query.setParameter("y_Truewidth", map.getY_Truewidth());
|
query.setParameter("x0_length", map.getX0_length());
|
query.setParameter("y0_width", map.getY0_width());
|
query.setParameter("x_Pixel", map.getX_Pixel());
|
query.setParameter("y_Pixel", map.getY_Pixel());
|
query.setParameter("baoliu3", map.getBaoliu3());
|
query.setParameter("baoliu4", map.getBaoliu4());
|
int executeUpdate = query.executeUpdate();
|
return executeUpdate;
|
}
|
|
@Transactional
|
public int mapManagement_modify(tb_map map) {
|
String sql = null;
|
Query query = null;
|
sql = "UPDATE tb_map SET floor = :floor,mapname = :mapname,x_Truelength = :x_Truelength,y_Truewidth = :y_Truewidth,x0_length = :x0_length,y0_width = :y0_width,x_Pixel = :x_Pixel,y_Pixel = :y_Pixel,addTime = now(),baoliu3 = :baoliu3,baoliu4 = :baoliu4 WHERE id= :id";
|
cs.tb_caozuo("tb_map", 3);
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("id", map.getId());
|
query.setParameter("floor", map.getFloor());
|
query.setParameter("mapname", map.getMapname());
|
query.setParameter("x_Truelength", map.getX_Truelength());
|
query.setParameter("y_Truewidth", map.getY_Truewidth());
|
query.setParameter("x0_length", map.getX0_length());
|
query.setParameter("y0_width", map.getY0_width());
|
query.setParameter("x_Pixel", map.getX_Pixel());
|
query.setParameter("y_Pixel", map.getY_Pixel());
|
query.setParameter("baoliu3", map.getBaoliu3());
|
query.setParameter("baoliu4", map.getBaoliu4());
|
int executeUpdate = query.executeUpdate();
|
return executeUpdate;
|
}
|
|
@Transactional
|
public int mapManagement_modify2(tb_map map) {
|
String sql = null;
|
Query query = null;
|
sql = "UPDATE tb_map SET floor = :floor,x_Truelength = :x_Truelength,y_Truewidth = :y_Truewidth,x0_length = :x0_length,y0_width = :y0_width,x_Pixel = :x_Pixel,y_Pixel = :y_Pixel,addTime = now(),baoliu3 = :baoliu3,baoliu4 = :baoliu4 WHERE id= :id";
|
cs.tb_caozuo("tb_map", 3);
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("id", map.getId());
|
query.setParameter("floor", map.getFloor());
|
query.setParameter("x_Truelength", map.getX_Truelength());
|
query.setParameter("y_Truewidth", map.getY_Truewidth());
|
query.setParameter("x0_length", map.getX0_length());
|
query.setParameter("y0_width", map.getY0_width());
|
query.setParameter("x_Pixel", map.getX_Pixel());
|
query.setParameter("y_Pixel", map.getY_Pixel());
|
query.setParameter("baoliu3", map.getBaoliu3());
|
query.setParameter("baoliu4", map.getBaoliu4());
|
int executeUpdate = query.executeUpdate();
|
return executeUpdate;
|
}
|
|
public List<tb_map> getMap_floor(String input) {
|
String floor = input;
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,floor,mapname,x_Truelength,y_Truewidth,x0_length,y0_width,x_Pixel,y_Pixel,addTime FROM tb_map WHERE floor = :floor";
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("floor", floor);
|
List resultList = query.getResultList();
|
List<tb_map> tb_mapList = new ArrayList<tb_map>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_map map = new tb_map();
|
Object[] obj = (Object[]) resultList.get(i);
|
map.setId((int) obj[0]);
|
map.setFloor(obj[1] == null ? "" : obj[1].toString());
|
map.setMapname(obj[2] == null ? "" : obj[2].toString());
|
map.setX_Truelength(obj[3] == null ? "" : obj[3].toString());
|
map.setY_Truewidth(obj[4] == null ? "" : obj[4].toString());
|
map.setX0_length(obj[5] == null ? "" : obj[5].toString());
|
map.setY0_width(obj[6] == null ? "" : obj[6].toString());
|
map.setX_Pixel(obj[7] == null ? "" : obj[7].toString());
|
map.setY_Pixel(obj[8] == null ? "" : obj[8].toString());
|
map.setAddTime(obj[9] == null ? "" : obj[9].toString());
|
tb_mapList.add(map);
|
}
|
}
|
return tb_mapList;
|
}
|
|
public List<tb_map> searchMapfloorService(String floor) {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,floor,mapname,x_Truelength,y_Truewidth,x0_length,y0_width,x_Pixel,y_Pixel,addTime FROM tb_map WHERE floor = :floor";
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("floor", floor);
|
List resultList = query.getResultList();
|
List<tb_map> tb_mapList = new ArrayList<tb_map>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_map map = new tb_map();
|
Object[] obj = (Object[]) resultList.get(i);
|
map.setId((int) obj[0]);
|
map.setFloor(obj[1] == null ? "" : obj[1].toString());
|
map.setMapname(obj[2] == null ? "" : obj[2].toString());
|
map.setX_Truelength(obj[3] == null ? "" : obj[3].toString());
|
map.setY_Truewidth(obj[4] == null ? "" : obj[4].toString());
|
map.setX0_length(obj[5] == null ? "" : obj[5].toString());
|
map.setY0_width(obj[6] == null ? "" : obj[6].toString());
|
map.setX_Pixel(obj[7] == null ? "" : obj[7].toString());
|
map.setY_Pixel(obj[8] == null ? "" : obj[8].toString());
|
map.setAddTime(obj[9] == null ? "" : obj[9].toString());
|
tb_mapList.add(map);
|
}
|
}
|
return tb_mapList;
|
}
|
|
}
|