123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074 |
- package com.sinosoft.common.excel;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.io.UnsupportedEncodingException;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.text.DateFormat;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
- import java.util.Vector;
-
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.ws.rs.POST;
- import javax.ws.rs.Path;
- import javax.ws.rs.ProduceMime;
- import javax.ws.rs.core.Context;
- import org.apache.log4j.Logger;
- import org.apache.poi.hssf.usermodel.HSSFCell;
- import org.apache.poi.hssf.usermodel.HSSFDateUtil;
- import org.apache.poi.hssf.usermodel.HSSFRow;
- import org.apache.poi.hssf.usermodel.HSSFSheet;
- import org.apache.poi.hssf.usermodel.HSSFWorkbook;
- import org.apache.poi.poifs.filesystem.POIFSFileSystem;
- import org.apache.poi.ss.usermodel.Cell;
- import org.apache.poi.ss.usermodel.DateUtil;
- import org.apache.poi.xssf.usermodel.XSSFCell;
- import org.apache.poi.xssf.usermodel.XSSFRow;
- import org.apache.poi.xssf.usermodel.XSSFSheet;
- import org.apache.poi.xssf.usermodel.XSSFWorkbook;
- import com.formaction.Parameter;
- import com.formaction.Utils;
- import com.formaction.vo.Msg;
- import com.persistence.DbConnection;
- import com.persistence.service.PersistenceFactory;
- import com.persistence.service.SysPersistence;
- import com.sinosoft.common.upLoad.service.UploadManageImpl;
- import com.sinosoft.lz.system.util.JsonUtil;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- /**
- * 读取Excel将数据返回到頁面
- *
- * @author 彭志超
- *
- */
- @Path("/TeamerExcelToDBTableTool/")
- public class TeamerExcelToDBTableTool {
- private static final Logger log = Logger.getLogger(TeamerExcelToDBTableTool.class);
-
- @ProduceMime("text/html")
- @POST
- @Path("/importInTeamer")
- public String importInTeamer(@Context HttpServletRequest request,
- @Context HttpServletResponse response) throws Exception{//新增保存
- UploadManageImpl upload2 = new UploadManageImpl();
- String path = upload2.uploadFilePath(request, response);
- String result="";
- log.info("saveFile.path===="+path);
- if("success".equals(path.split(";")[1])){
- //将数据返回到界面
- path=path.split(";")[2];
- TeamerExcelToDBTableTool xte = new TeamerExcelToDBTableTool();
- result=xte.readExcelByNameIn(path);
- }else{
- //返回失败信息
- result="";
- }
- log.info("result======"+result);
- return result;
-
- }
-
- @ProduceMime("application/json")
- @POST
- @Path("/importOutTeamer")
- public String importOutTeamer(@Context HttpServletRequest request,
- @Context HttpServletResponse response) throws Exception{//新增保存
- UploadManageImpl upload2 = new UploadManageImpl();
- String path = upload2.uploadFilePath(request, response);
- String result="";
- log.info("saveFile.path===="+path);
- if("success".equals(path.split(";")[1])){
- //将数据返回到界面
- path=path.split(";")[2];
- TeamerExcelToDBTableTool xte = new TeamerExcelToDBTableTool();
- result=xte.readExcelByNameOut(path);
- }else{
- //返回失败信息
- result="";
- }
- return result;
-
- }
-
- /**
- * 内部队伍
- * @param params
- * @return
- * @throws Exception
- */
- @ProduceMime("application/json")
- @POST
- @Path("/getTeamerInExpertExcel")
- public String readExcelByNameIn(String fileName) throws Exception {
- TeamerExcelToDBTableTool tool = new TeamerExcelToDBTableTool();
- // String fileName=Utils.getParameter("fileName", params) == null ? "" : Utils.getParameter(
- // "fileName", params);
- // String fileName="E:\\javaDemo\\person.xls";
- int i=fileName.lastIndexOf(".");
- String type=fileName.substring(i+1);
- log.info("fileName===="+fileName);
- String result="";
- if("xls".equals(type)){
- result=tool.readExcelIn(fileName,"person");
- }else if("xlsx".equals(type)){
- result= tool.readExcel2007In(fileName,"person");
- }
- result="{\"rows\":"+result+"}";
- log.info(result);
- return result;
- }
- /**
- * 外部队伍
- * @param params
- * @return
- * @throws Exception
- */
- @ProduceMime("application/json")
- @POST
- @Path("/getTeamerOutExpertExcel")
- public String readExcelByNameOut(String fileName) throws Exception {
- TeamerExcelToDBTableTool tool = new TeamerExcelToDBTableTool();
- // String fileName=Utils.getParameter("fileName", params) == null ? "" : Utils.getParameter(
- // "fileName", params);
- // String fileName="E:\\javaDemo\\person.xls";
- int i=fileName.lastIndexOf(".");
- String type=fileName.substring(i+1);
- log.info("fileName===="+fileName);
- String result="";
- if("xls".equals(type)){
- result=tool.readExcelOut(fileName,"person");
- }else if("xlsx".equals(type)){
- result= tool.readExcel2007Out(fileName,"person");
- }
- result="{\"rows\":"+result+"}";
- log.info(result);
- return result;
- }
-
- // public void readExcel2007(DBModel dbConn, String filePath, String tableName)
- @SuppressWarnings({ "resource", "unused", "rawtypes", "unchecked" })
- public String readExcel2007In( String filePath, String tableName)
- throws Exception {
- String result="";
- try {
- // InputStream inp = new FileInputStream(filePath);
- // Workbook wb = WorkbookFactory.create(inp);
- XSSFWorkbook wb = new XSSFWorkbook(filePath);
- int sheetSize = wb.getNumberOfSheets();
- // for (int i = 0; i < sheetSize; i++) {
- List list=new ArrayList();
- XSSFSheet sheet = wb.getSheetAt(0);
- // Sheet sheet = wb.getSheetAt(i);
- for (Iterator rit = sheet.rowIterator(); rit.hasNext();) {
- // 迭代行
- XSSFRow row = (XSSFRow) rit.next();
- // 迭代单元格
- Vector datas = new Vector();
- StringBuffer sb=new StringBuffer();
- Map<String, String>lineMap=new HashMap<String, String>();
- for (Iterator cit = row.cellIterator(); cit.hasNext();) {
- // 定义集合datas用于存Excel中一个行的数据
- XSSFCell cell = (XSSFCell) cit.next();
- String value = getValue2007(cell);
- sb.append(value+"|");
- // 注意行和列是基于0索引的
- // System.out.print(cell.getRowIndex() + ":" + cell.getColumnIndex() + " ");
- datas.add(value);
- // System.out.println();
- // 开始操作单元格
- }
- String[] arr=sb.toString().split("[|]");
- list.add(arr);
- // result = fillMap(list);;
- // 向表中插入数据
- // DBFactory.insertData(dbConn, tableName, datas);
- }
- result = inFillMap(list);
- System.out.println(result);
- // }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- throw e;
- } catch (IOException e) {
- e.printStackTrace();
- throw e;
- }
- return result;
- }
-
-
- /**
- * 将Excel数据导入到表中
- *
- * @param filePath
- * Excel路径
- * @param tableName
- * 表名
- */
- // public void readExcel(DBModel dbConn, String filePath, String tableName)
- @SuppressWarnings({ "resource", "rawtypes", "deprecation", "unchecked" })
- public String readExcelIn( String filePath, String tableName)
- throws Exception {
- String result="";
- try {
- POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream( filePath));
- // 创建工作簿
- HSSFWorkbook workBook = new HSSFWorkbook(fs);
- log.info(workBook.getNumberOfSheets());
- // System.out.println("工作表个数 :" + workBook.getNumberOfSheets());
- for (int i = 0; i < workBook.getNumberOfSheets(); i++) {
- // 创建工作表
- HSSFSheet sheet = workBook.getSheetAt(i);
- int rows = sheet.getPhysicalNumberOfRows(); // 获得行数
- if (rows > 0) {
- sheet.getMargin(HSSFSheet.TopMargin);
- List list=new ArrayList();
- for (int r = 0; r < rows; r++) { // 行循环
- HSSFRow row = sheet.getRow(r);
- if (row != null && r != 0 && r != 1) {// 不取第二行
- int cells = row.getLastCellNum();// 获得列数
- // 定义集合datas用于存Excel中一个行的数据
- Vector datas = new Vector();
- String[]arr=new String[cells];
- List<String>paramList=new ArrayList<String>();
- for (short c = 0; c < cells; c++) { // 列循环
- HSSFCell cell = row.getCell(c);
- if (cell != null) {
- String value = getValue(cell);
- // System.out.println("第" + r + "行 " + "第" + c + "列:" + value);
- datas.add(value);
- paramList.add(value);
- arr[c]=value;
- }
- }
- list.add(arr);
- result = inFillMap(list);
- // dataIntoDb(tableName, paramList);
- // 向表中插入数据
- // DBFactory.insertData(dbConn, tableName, datas);
- }
- }
- } else {
-
- }
- }
-
- } catch (Exception ex) {
- ex.printStackTrace();
- log.info(ex);
- throw ex;
- }
- return result;
- }
-
- // public void readExcel2007(DBModel dbConn, String filePath, String tableName)
- @SuppressWarnings({ "resource", "unused", "rawtypes", "unchecked" })
- public String readExcel2007Out( String filePath, String tableName)
- throws Exception {
- String result="";
- try {
- // InputStream inp = new FileInputStream(filePath);
- // Workbook wb = WorkbookFactory.create(inp);
- XSSFWorkbook wb = new XSSFWorkbook(filePath);
- int sheetSize = wb.getNumberOfSheets();
- // for (int i = 0; i < sheetSize; i++) {
- List list=new ArrayList();
- XSSFSheet sheet = wb.getSheetAt(0);
- // Sheet sheet = wb.getSheetAt(i);
- for (Iterator rit = sheet.rowIterator(); rit.hasNext();) {
- // 迭代行
- XSSFRow row = (XSSFRow) rit.next();
- // 迭代单元格
- Vector datas = new Vector();
- StringBuffer sb=new StringBuffer();
- Map<String, String>lineMap=new HashMap<String, String>();
- for (Iterator cit = row.cellIterator(); cit.hasNext();) {
- // 定义集合datas用于存Excel中一个行的数据
- XSSFCell cell = (XSSFCell) cit.next();
- String value = getValue2007(cell);
- sb.append(value+"|");
- // 注意行和列是基于0索引的
- // System.out.print(cell.getRowIndex() + ":" + cell.getColumnIndex() + " ");
- datas.add(value);
- // System.out.println();
- // 开始操作单元格
- }
- String[] arr=sb.toString().split("[|]");
- list.add(arr);
- // result = fillMap(list);;
- // 向表中插入数据
- // DBFactory.insertData(dbConn, tableName, datas);
- }
- result = outFillMap(list);
- System.out.println(result);
- // }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- throw e;
- } catch (IOException e) {
- e.printStackTrace();
- throw e;
- }
- return result;
- }
-
-
- /**
- * 将Excel数据导入到表中
- *
- * @param filePath
- * Excel路径
- * @param tableName
- * 表名
- */
- // public void readExcel(DBModel dbConn, String filePath, String tableName)
- @SuppressWarnings({ "rawtypes", "deprecation", "unchecked", "resource" })
- public String readExcelOut( String filePath, String tableName)
- throws Exception {
- String result="";
- try {
- POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream( filePath));
- // 创建工作簿
- HSSFWorkbook workBook = new HSSFWorkbook(fs);
- log.info(workBook.getNumberOfSheets());
- // System.out.println("工作表个数 :" + workBook.getNumberOfSheets());
- for (int i = 0; i < workBook.getNumberOfSheets(); i++) {
- // 创建工作表
- HSSFSheet sheet = workBook.getSheetAt(i);
- int rows = sheet.getPhysicalNumberOfRows(); // 获得行数
- if (rows > 0) {
- sheet.getMargin(HSSFSheet.TopMargin);
- List list=new ArrayList();
- for (int r = 0; r < rows; r++) { // 行循环
- HSSFRow row = sheet.getRow(r);
- if (row != null && r != 0) {// 不取第一行
- int cells = row.getLastCellNum();// 获得列数
- // 定义集合datas用于存Excel中一个行的数据
- Vector datas = new Vector();
- String[]arr=new String[cells];
- List<String>paramList=new ArrayList<String>();
- for (short c = 0; c < cells; c++) { // 列循环
- HSSFCell cell = row.getCell(c);
- if (cell != null) {
- String value = getValue(cell);
- // System.out.println("第" + r + "行 " + "第" + c + "列:" + value);
- datas.add(value);
- paramList.add(value);
- arr[c]=value;
- }
- }
- list.add(arr);
- result = outFillMap(list);
- // dataIntoDb(tableName, paramList);
- // 向表中插入数据
- // DBFactory.insertData(dbConn, tableName, datas);
- }
- }
- } else {
-
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- log.info(ex);
- throw ex;
- }
- return result;
- }
-
- public String getValue2007(XSSFCell cell) {
- String value = "";
- switch (cell.getCellType()) {
- case Cell.CELL_TYPE_STRING:
- // System.out.println(cell.getRichStringCellValue().getString());
- break;
- case Cell.CELL_TYPE_NUMERIC:
- if (DateUtil.isCellDateFormatted(cell)) {
- // System.out.println(cell.getDateCellValue());
- java.util.Date date = cell.getDateCellValue();
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- value = format.format(date);
- } else {
- // System.out.println(cell.getNumericCellValue());
- value = String.valueOf(cell.getNumericCellValue());
- }
- break;
- case Cell.CELL_TYPE_BOOLEAN:
- // System.out.println(cell.getBooleanCellValue());
- value = " " + cell.getBooleanCellValue();
- break;
- case Cell.CELL_TYPE_FORMULA:
- // System.out.println(cell.getCellFormula());
- value = cell.getCellFormula();
- break;
- default:
- System.out.println();
- }
- return value;
- }
-
- /**
- * 获取Excel中某个单元格的值
- *
- * @param cell
- * @return
- * @throws ParseException
- */
- public String getValue(HSSFCell cell) throws ParseException {
- String value = "";
- String value1 = "";
- switch (cell.getCellType()) {
- case HSSFCell.CELL_TYPE_NUMERIC: // 数值型
- System.out.println("数字类型");
- if (HSSFDateUtil.isCellDateFormatted(cell)) {
- log.info("时间类型=============");
- // 如果是date类型则 ,获取该cell的date值
- Date d = cell.getDateCellValue();
- log.info(d);
- DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- value = format.format(d);
- } else
- {// 纯数字
- cell.setCellType(Cell.CELL_TYPE_STRING);
- value = cell.getStringCellValue();
- }
- break;
- /* 此行表示单元格的内容为string类型 */
- case HSSFCell.CELL_TYPE_STRING: // 字符串型
- value = cell.getStringCellValue();
- break;
- case HSSFCell.CELL_TYPE_FORMULA:// 公式型
- // 读公式计算值
- value = String.valueOf(cell.getNumericCellValue());
- if (value.equals("NaN")) {// 如果获取的数据值为非法值,则转换为获取字符串
- value = cell.getStringCellValue().toString();
- }
- cell.getCellFormula();
- break;
- case HSSFCell.CELL_TYPE_BOOLEAN:// 布尔
- value = " " + cell.getBooleanCellValue();
- break;
- /* 此行表示该单元格值为空 */
- case HSSFCell.CELL_TYPE_BLANK: // 空值
- value = "";
- break;
- case HSSFCell.CELL_TYPE_ERROR: // 故障
- value = "";
- break;
- default:
- value = cell.getStringCellValue().toString();
- }
- return value;
- }
-
- /**
- * 將数据转换成json
- * @param list
- * @return
- * @throws UnsupportedEncodingException
- */
- public String inFillMap(List<String[]> list) throws UnsupportedEncodingException{
-
- List<Map<String, String>>dataList=new ArrayList<Map<String,String>>();
- for(int i=0;i<list.size();i++){
- Map<String, String>tempMap=new HashMap<String, String>();
- String[]arr=list.get(i);
- String[] SEX_262 = arr[4]==null ? null:arr[4].split(":");
- String[] PROFESSIONAL_262 = arr[10]==null ? null:arr[10].split(":");
- String[] VOLTAGE_LEVEL_262 = arr[11]==null ? null:arr[11].split(":");
- String[] TEAM_QUARTERS_262 = arr[14]==null ? null:arr[14].split(":");
- // tempMap.put("TEAM_UNIT_262", arr[0]);
- // tempMap.put("TEAM_NAME_262", arr[1]);
- tempMap.put("CODE_262", new String(java.net.URLEncoder.encode(arr[0]==null ? "":arr[0].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- tempMap.put("NAME_262", new String(java.net.URLEncoder.encode(arr[1]==null ? "":arr[1].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- tempMap.put("ID_NUMBER_262", new String(java.net.URLEncoder.encode(arr[2]==null ? "":arr[2].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- tempMap.put("BIRTH_DATE_262", new String(java.net.URLEncoder.encode(arr[3]==null ? "":arr[3].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- if(SEX_262!=null)
- tempMap.put("SEX_262", new String(java.net.URLEncoder.encode(SEX_262[0].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- else
- tempMap.put("SEX_262","");
- tempMap.put("WORK_TYPE_AGE_262", new String(java.net.URLEncoder.encode(arr[5]==null ? "":arr[5].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- tempMap.put("DEPT_ID_262", new String(java.net.URLEncoder.encode(arr[6]==null ? "":arr[6].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- tempMap.put("DEPT_QUARTERS_262", new String(java.net.URLEncoder.encode(arr[7]==null ? "":arr[7].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- tempMap.put("TECHNICAL_TITLE_262", new String(java.net.URLEncoder.encode(arr[8]==null ? "":arr[8].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- tempMap.put("SKILL_LEVEL_262",new String(java.net.URLEncoder.encode(arr[9]==null ? "":arr[9].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- if(PROFESSIONAL_262!=null)
- tempMap.put("PROFESSIONAL_262", new String(java.net.URLEncoder.encode(PROFESSIONAL_262[0].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- else
- tempMap.put("PROFESSIONAL_262", "");
- if(VOLTAGE_LEVEL_262!=null)
- tempMap.put("VOLTAGE_LEVEL_262", new String(java.net.URLEncoder.encode(VOLTAGE_LEVEL_262[0].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- else
- tempMap.put("VOLTAGE_LEVEL_262","");
- tempMap.put("TELEPHONE_262", new String(java.net.URLEncoder.encode(arr[12]==null ? "":arr[12].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- tempMap.put("RESCUE_EXP_262", new String(java.net.URLEncoder.encode(arr[13]==null ? "":arr[13].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- if(TEAM_QUARTERS_262!=null)
- tempMap.put("TEAM_QUARTERS_262", new String(java.net.URLEncoder.encode(TEAM_QUARTERS_262[0].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- else
- tempMap.put("TEAM_QUARTERS_262","");
- tempMap.put("REMARK_262", new String(java.net.URLEncoder.encode(arr[15]==null ? "":arr[15].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
- dataList.add(tempMap);
- }
- String result=JsonUtil.list2json(dataList);
- return result;
- }
-
- /**
- * 將数据转换成json
- * @param list
- * @return
- */
- public String outFillMap(List<String[]> list){
-
- List<Map<String, String>>dataList=new ArrayList<Map<String,String>>();
- for(int i=0;i<list.size();i++){
- Map<String, String>tempMap=new HashMap<String, String>();
- String[]arr=list.get(i);
- // tempMap.put("TEAM_UNIT_262", arr[0]);
- // tempMap.put("TEAM_NAME_262", arr[1]);
- // tempMap.put("CODE_262", arr[2]);
- tempMap.put("NAME_262", arr[0]);//姓名
- tempMap.put("ID_NUMBER_262", arr[1]);//身份证号码
- tempMap.put("CERTIFICATE_262", arr[2]);//持证证书编号
- tempMap.put("BIRTH_DATE_262", arr[3]);//出身年月
- tempMap.put("SEX_262", arr[4]);//性别
- tempMap.put("WORK_TYPE_AGE_262", arr[5]);//本工种工龄
- tempMap.put("DEPT_ID_262", arr[6]);//所在单位
- tempMap.put("DEPT_QUARTERS_262", arr[7]);//原单位职务岗位
- tempMap.put("TECHNICAL_TITLE_262", arr[8]);//技术职称
- tempMap.put("SKILL_LEVEL_262", arr[9]);//技能等级
- tempMap.put("PROFESSIONAL_262", arr[10]);//专业
- tempMap.put("VOLTAGE_LEVEL_262", arr[11]);//电压等级
- tempMap.put("TELEPHONE_262", arr[12]);//联系手机
- tempMap.put("RESCUE_EXP_262", arr[13]);//抢险经历
- tempMap.put("TEAM_QUARTERS_262", arr[14]);//队伍岗位
- dataList.add(tempMap);
- }
- String result=JsonUtil.list2json(dataList);
- return result;
- }
-
-
-
- /**
- * 将界面传输过来的数据保存到数据库
- * @param params
- * @return
- * @throws ClassNotFoundException
- */
- @SuppressWarnings("static-access")
- @ProduceMime("application/json")
- @POST
- @Path("/teamerInToDb")
- public Msg teamerInToDb(String params) throws ClassNotFoundException{
- Msg m=new Msg();
- String json = Utils.getParameter("json", params) == null ? "" : Utils.getParameter(
- "json", params);
- log.info("json===" + json);
- String classId = Utils.getParameter("classId", params) == null ? "" : Utils
- .getParameter("classId", params);
- log.info("classId===" + classId);
- String teamId = Utils.getParameter("teamId", params) == null ? "" : Utils
- .getParameter("teamId", params);
- String unit = Utils.getParameter("unit", params) == null ? "" : Utils
- .getParameter("unit", params);
- String teamName = Utils.getParameter("teamName", params) == null ? "" : Utils
- .getParameter("teamName", params);
- json=json.replace("_"+classId, "");
- String userId = Utils.getParameter("userid", params) == null ? "" : Utils
- .getParameter("userid", params);
- log.info("userId===" + userId);
- Connection conn = null;
- PreparedStatement st = null;
- PreparedStatement st1 = null;
- DbConnection db = new DbConnection();
- List<TeamerBean> list = JsonPluginsUtil.jsonToBeanList(json, TeamerBean.class);
- Map<String, String> tempMap = new HashMap<String, String>();
- String sql="INSERT INTO EMC_AM_TEAM_PERSONNEL (FD_OBJECTID,TEAM_UNIT,TEAM_NAME,CODE,NAME,"
- + "ID_NUMBER,BIRTH_DATE,SEX,WORK_TYPE_AGE,DEPT_ID,DEPT_QUARTERS,TECHNICAL_TITLE,"
- + "SKILL_LEVEL,PROFESSIONAL,VOLTAGE_LEVEL,TELEPHONE,RESCUE_EXP,TEAM_QUARTERS,"
- + "UPDATEDATE,IS_DEL,TEAM_SYSTEM,TEAM_ID,TYPEIN_PEOPLE,SORT_NO,REMARK) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- try {
- conn = db.getConnection();
- int num=0;
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for(int i=0;i<list.size();i++){
- TeamerBean teamer=list.get(i);
- log.info("teamer.getNAME()===="+ teamer.getNAME());
- st.setString(1, createMsgId(getMsgId()));
- st.setString(2, unit);
- st.setString(3, teamName);
- st.setString(4, teamer.getCODE());
- st.setString(5, teamer.getNAME());
- st.setString(6, teamer.getID_NUMBER());
- st.setString(7, teamer.getBIRTH_DATE());
- st.setString(8, teamer.getSEX());
- st.setString(9, teamer.getWORK_TYPE_AGE());
- st.setString(10, teamer.getDEPT_ID());
- st.setString(11, teamer.getDEPT_QUARTERS());
- st.setString(12, teamer.getTECHNICAL_TITLE());
- st.setString(13, teamer.getSKILL_LEVEL());
- st.setString(14, teamer.getPROFESSIONAL());
- st.setString(15, teamer.getVOLTAGE_LEVEL());
- st.setString(16, teamer.getTELEPHONE());
- st.setString(17, teamer.getRESCUE_EXP());
- st.setString(18, teamer.getTEAM_QUARTERS());
- st.setString(19, formatDate(new Date()));
- st.setString(20, "0");
- st.setString(21, "0");
- st.setString(22, teamId);
- st.setString(23, userId);
- //判断有没有初始值
- if(!checkhaveId(teamId)){
- st.setString(24, String.valueOf(555555551+i));
- }else{
- st.setString(24, String.valueOf(houxuzhi(teamId)+i+1));
- }
- st.setString(25, teamer.getREMARK());
-
- int type=Integer.parseInt(teamer.getPROFESSIONAL());
- switch (type) {
- case 1:
- tempMap.put("TEAM_MEMBER_NUMBER", (Integer.parseInt((("TEAM_MEMBER_NUMBER".equals(tempMap.get("TEAM_MEMBER_NUMBER"))||tempMap.get("TEAM_MEMBER_NUMBER")==null)?"0":tempMap.get("TEAM_MEMBER_NUMBER")))+1)+"");
- tempMap.put("SD_XIANLU", (Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+1)+"");
- tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
- tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
- tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
- tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
- tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
- tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
- tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
- tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
- tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
- tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
- break;
- case 2:
- tempMap.put("TEAM_MEMBER_NUMBER", (Integer.parseInt((("TEAM_MEMBER_NUMBER".equals(tempMap.get("TEAM_MEMBER_NUMBER"))||tempMap.get("TEAM_MEMBER_NUMBER")==null)?"0":tempMap.get("TEAM_MEMBER_NUMBER")))+1)+"");
- tempMap.put("SD_XIANLANG", (Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+1)+"");
- tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
- tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
- tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
- tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
- tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
- tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
- tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
- tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
- tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
- tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
- break;
- case 3:
- tempMap.put("TEAM_MEMBER_NUMBER", (Integer.parseInt((("TEAM_MEMBER_NUMBER".equals(tempMap.get("TEAM_MEMBER_NUMBER"))||tempMap.get("TEAM_MEMBER_NUMBER")==null)?"0":tempMap.get("TEAM_MEMBER_NUMBER")))+1)+"");
- tempMap.put("BD_YICI", (Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+1)+"");
- tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
- tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
- tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
- tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
- tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
- tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
- tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
- tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
- tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
- tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
- break;
- case 4:
- tempMap.put("TEAM_MEMBER_NUMBER", (Integer.parseInt((("TEAM_MEMBER_NUMBER".equals(tempMap.get("TEAM_MEMBER_NUMBER"))||tempMap.get("TEAM_MEMBER_NUMBER")==null)?"0":tempMap.get("TEAM_MEMBER_NUMBER")))+1)+"");
- tempMap.put("BD_ERCI", (Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+1)+"");
- tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
- tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
- tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
- tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
- tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
- tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
- tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
- tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
- tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
- tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
- break;
- case 5:
- tempMap.put("TEAM_MEMBER_NUMBER", (Integer.parseInt((("TEAM_MEMBER_NUMBER".equals(tempMap.get("TEAM_MEMBER_NUMBER"))||tempMap.get("TEAM_MEMBER_NUMBER")==null)?"0":tempMap.get("TEAM_MEMBER_NUMBER")))+1)+"");
- tempMap.put("PD_XIANLU", (Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+1)+"");
- tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
- tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
- tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
- tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
- tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
- tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
- tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
- tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
- tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
- tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
- break;
- case 6:
- tempMap.put("TEAM_MEMBER_NUMBER", (Integer.parseInt((("TEAM_MEMBER_NUMBER".equals(tempMap.get("TEAM_MEMBER_NUMBER"))||tempMap.get("TEAM_MEMBER_NUMBER")==null)?"0":tempMap.get("TEAM_MEMBER_NUMBER")))+1)+"");
- tempMap.put("PD_XIANLANG", (Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+1)+"");
- tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
- tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
- tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
- tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
- tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
- tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
- tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
- tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
- tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
- tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
- break;
- case 7:
- tempMap.put("TEAM_MEMBER_NUMBER", (Integer.parseInt((("TEAM_MEMBER_NUMBER".equals(tempMap.get("TEAM_MEMBER_NUMBER"))||tempMap.get("TEAM_MEMBER_NUMBER")==null)?"0":tempMap.get("TEAM_MEMBER_NUMBER")))+1)+"");
- tempMap.put("PD_DIANFANG", (Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+1)+"");
- tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
- tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
- tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
- tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
- tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
- tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
- tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
- tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
- tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
- tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
- break;
- case 8:
- tempMap.put("TEAM_MEMBER_NUMBER", (Integer.parseInt((("TEAM_MEMBER_NUMBER".equals(tempMap.get("TEAM_MEMBER_NUMBER"))||tempMap.get("TEAM_MEMBER_NUMBER")==null)?"0":tempMap.get("TEAM_MEMBER_NUMBER")))+1)+"");
- tempMap.put("PD_BAODIAN", (Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+1)+"");
- tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
- tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
- tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
- tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
- tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
- tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
- tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
- tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
- tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
- tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
- break;
- case 9:
- tempMap.put("TEAM_MEMBER_NUMBER", (Integer.parseInt((("TEAM_MEMBER_NUMBER".equals(tempMap.get("TEAM_MEMBER_NUMBER"))||tempMap.get("TEAM_MEMBER_NUMBER")==null)?"0":tempMap.get("TEAM_MEMBER_NUMBER")))+1)+"");
- tempMap.put("TONGXING", (Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+1)+"");
- tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
- tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
- tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
- tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
- tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
- tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
- tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
- tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
- tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
- tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
- break;
- case 10:
- tempMap.put("TEAM_MEMBER_NUMBER", (Integer.parseInt((("TEAM_MEMBER_NUMBER".equals(tempMap.get("TEAM_MEMBER_NUMBER"))||tempMap.get("TEAM_MEMBER_NUMBER")==null)?"0":tempMap.get("TEAM_MEMBER_NUMBER")))+1)+"");
- tempMap.put("WANGLUO", (Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+1)+"");
- tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
- tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
- tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
- tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
- tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
- tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
- tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
- tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
- tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
- tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
- break;
- case 11:
- tempMap.put("TEAM_MEMBER_NUMBER", (Integer.parseInt((("TEAM_MEMBER_NUMBER".equals(tempMap.get("TEAM_MEMBER_NUMBER"))||tempMap.get("TEAM_MEMBER_NUMBER")==null)?"0":tempMap.get("TEAM_MEMBER_NUMBER")))+1)+"");
- tempMap.put("SHIYAN", (Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+1)+"");
- tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
- tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
- tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
- tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
- tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
- tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
- tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
- tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
- tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
- tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
- break;
- default:
- break;
- }
-
- st.executeUpdate();
-
-
- num++;
- }
- log.info("tempMap.get(TEAM_MEMBER_NUMBER)===="+ tempMap.get("TEAM_MEMBER_NUMBER"));
-
- String sql1="update ECM_AM_EMERGENCY_TEAM set TEAM_MEMBER_NUMBER =to_number(TEAM_MEMBER_NUMBER)+to_number('"+tempMap.get("TEAM_MEMBER_NUMBER")+"'), SD_XIANLU =to_number(SD_XIANLU)+to_number('"+tempMap.get("SD_XIANLU")+"'), SD_XIANLANG =to_number(SD_XIANLANG)+to_number('"+tempMap.get("SD_XIANLANG")+"'), "
- + "BD_YICI =to_number(BD_YICI)+to_number('"+tempMap.get("BD_YICI")+"'), BD_ERCI =to_number(BD_ERCI)+to_number('"+tempMap.get("BD_ERCI")+"'), PD_XIANLU =to_number(PD_XIANLU)+to_number('"+tempMap.get("PD_XIANLU")+"'),"
- + " PD_XIANLANG =to_number(PD_XIANLANG)+to_number('"+tempMap.get("PD_XIANLANG")+"'),PD_DIANFANG =to_number(PD_DIANFANG)+to_number('"+tempMap.get("PD_DIANFANG")+"'),PD_BAODIAN =to_number(PD_BAODIAN)+to_number('"+tempMap.get("PD_BAODIAN")+"'),"
- + "TONGXING =to_number(TONGXING)+to_number('"+tempMap.get("TONGXING")+"'),WANGLUO =to_number(WANGLUO)+to_number('"+tempMap.get("WANGLUO")+"'),SHIYAN =to_number(SHIYAN)+to_number('"+tempMap.get("SHIYAN")+"') where is_del='0' and ((COLUMN_1='0' and FD_OBJECTID = '"+teamId+"') or (COLUMN_1='"+teamId+"'))";
- log.info("sql1====="+ sql1);
- st1 = conn.prepareStatement(sql1);
- int k=st1.executeUpdate();
- if(num+k==list.size()+1){
- log.info("保存成功");
- conn.commit();
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- // st.executeBatch();
- conn.rollback();
- log.info("保存失败");
- return m;
- }
- } catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 消息保存", e);
- } finally {
- db.close(st);
- db.close(conn);
- }
-
- }
-
- /**
- * 将界面传输过来的数据保存到数据库
- * @param params
- * @return
- * @throws ClassNotFoundException
- */
- @SuppressWarnings("static-access")
- @ProduceMime("application/json")
- @POST
- @Path("/teamerOutToDb")
- public Msg teamerOutToDb(String params) throws ClassNotFoundException{
- Msg m=new Msg();
- String json = Utils.getParameter("json", params) == null ? "" : Utils.getParameter(
- "json", params);
- log.info("json===" + json);
- String classId = Utils.getParameter("classId", params) == null ? "" : Utils
- .getParameter("classId", params);
- log.info("classId===" + classId);
- String teamId = Utils.getParameter("teamId", params) == null ? "" : Utils
- .getParameter("teamId", params);
- String unit = Utils.getParameter("unit", params) == null ? "" : Utils
- .getParameter("unit", params);
- String teamName = Utils.getParameter("teamName", params) == null ? "" : Utils
- .getParameter("teamName", params);
- json=json.replace("_"+classId, "");
- Connection conn = null;
- PreparedStatement st = null;
- DbConnection db = new DbConnection();
- List<TeamerBean> list = JsonPluginsUtil.jsonToBeanList(json, TeamerBean.class);
- String sql="INSERT INTO EMC_AM_TEAM_PERSONNEL (FD_OBJECTID,TEAM_UNIT,TEAM_NAME,NAME,"
- + "ID_NUMBER,BIRTH_DATE,SEX,WORK_TYPE_AGE,DEPT_ID,DEPT_QUARTERS,TECHNICAL_TITLE,"
- + "SKILL_LEVEL,PROFESSIONAL,VOLTAGE_LEVEL,TELEPHONE,RESCUE_EXP,TEAM_QUARTERS,"
- + "UPDATEDATE,IS_DEL,CERTIFICATE,TEAM_SYSTEM,TEAM_ID,REMARK,SORT_NO) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- try {
- conn = db.getConnection();
- int num=0;
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for(int i=0;i<list.size();i++){
- TeamerBean eb=list.get(i);
- log.info(" eb.getEXPERT_AREA()===="+ eb.getTEAM_NAME());
- st.setString(1, createMsgId(getMsgId()));
- st.setString(2, unit);
- st.setString(3, teamName);
- st.setString(4, eb.getNAME());
- st.setString(5, eb.getID_NUMBER());
- st.setString(6, eb.getBIRTH_DATE());
- st.setString(7, eb.getSEX());
- st.setString(8, eb.getWORK_TYPE_AGE());
- st.setString(9, eb.getDEPT_ID());
- st.setString(10, eb.getDEPT_QUARTERS());
- st.setString(11, eb.getTECHNICAL_TITLE());
- st.setString(12, eb.getSKILL_LEVEL());
- st.setString(13, eb.getPROFESSIONAL());
- st.setString(14, eb.getVOLTAGE_LEVEL());
- st.setString(15, eb.getTELEPHONE());
- st.setString(16, eb.getRESCUE_EXP());
- st.setString(17, eb.getTEAM_QUARTERS());
- st.setString(18, formatDate(new Date()));
- st.setString(19, "0");
- st.setString(20, eb.getCERTIFICATE());
- st.setString(21, "1");
- st.setString(22, teamId);
- st.setString(23, eb.getREMARK());
- //判断有没有初始值
- if(!checkhaveId(teamId)){
- st.setString(24, String.valueOf(555555551+i));
- }else{
- st.setString(24, String.valueOf(houxuzhi(teamId)+i+1));
- }
-
- st.executeUpdate();
- num++;
- }
- if(num==list.size()){
- log.info("保存成功");
- conn.commit();
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- // st.executeBatch();
- conn.rollback();
- log.info("保存失败");
- return m;
- }
- } catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 消息保存", e);
- } finally {
- db.close(st);
- db.close(conn);
- }
-
- }
-
-
- public String formatDate(Date d) {
- SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String date = sd.format(d);
- return date;
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public List<String> getMsgId() throws ClassNotFoundException {
- String sql = "SELECT FD_OBJECTID FROM EMC_AM_TEAM_PERSONNEL";
- Connection conn = null;
- Statement stat = null;
- ResultSet rs = null;
- DbConnection db = new DbConnection();
- try {
- conn = db.getConnection();
- stat = conn.createStatement();
- rs = stat.executeQuery(sql);
- List<String> list = new ArrayList();
- while (rs.next()) {
- list.add(rs.getString("FD_OBJECTID"));
- }
- return list;
- } catch (SQLException e) {
- // this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 获得数据库消息ID集合"
- + sql, e);
- } finally {
- db.close(rs);
- db.close(stat);
- db.close(conn);
- }
- }
-
- public String createMsgId(List<String> list) throws ClassNotFoundException{
- long l=(long) ((Math.random()+1)*1000000000);
- String msgId=l+"";
- if(list.contains(msgId)){
- return createMsgId(list);
- }
- else{
- // log.info("msgid==="+msgId);
- return msgId;
- }
- }
-
-
-
-
- /*************************************排序****************************************/
-
-
- @SuppressWarnings("static-access")
- public boolean checkhaveId(String id) {
- try{
- String sql="select * from EMC_AM_TEAM_PERSONNEL where TEAM_ID ='"+id+"' and IS_DEL = '0' and sort_no is not null";
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
- if(tempList==null||tempList.size()==0){
- return false;
- }else{
- return true;
- }}catch(Exception e){
- this.log.error(e.getMessage(), e);
- return false;
- }
- }
-
- @SuppressWarnings("static-access")
- public int houxuzhi(String id) throws ClassNotFoundException {
-
- try{
- String sql="select sort_no from EMC_AM_TEAM_PERSONNEL where TEAM_ID ='"+id+"' and IS_DEL='0' and sort_no is not null order by sort_no desc";
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
- return Integer.parseInt(tempList.get(0)[0]);
- }catch(Exception e){
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 消息保存", e);
- }
- }
-
-
- @ProduceMime("application/json")
- @POST
- @Path("/getAddSort")
- public String getAddSort(String params) throws ClassNotFoundException{
- String id=Utils.getParameter("id", params);
- String json = null;
- //判断有没有初始值
- if(!checkhaveId(id)){
- json = "555555551";
- }else{
- json = String.valueOf(houxuzhi(id)+1);
- }
- return json;
- }
-
-
- }
|