a070017ff2aa347a4cd9bc986bd765ea63ed6a1e.svn-base 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. package com.sinosoft.common.excel;
  2. import java.io.FileInputStream;
  3. import java.io.FileNotFoundException;
  4. import java.io.IOException;
  5. import java.io.UnsupportedEncodingException;
  6. import java.sql.Connection;
  7. import java.sql.PreparedStatement;
  8. import java.sql.ResultSet;
  9. import java.sql.SQLException;
  10. import java.sql.Statement;
  11. import java.text.DateFormat;
  12. import java.text.ParseException;
  13. import java.text.SimpleDateFormat;
  14. import java.util.ArrayList;
  15. import java.util.Date;
  16. import java.util.HashMap;
  17. import java.util.Iterator;
  18. import java.util.List;
  19. import java.util.Map;
  20. import java.util.Vector;
  21. import javax.servlet.http.HttpServletRequest;
  22. import javax.servlet.http.HttpServletResponse;
  23. import javax.ws.rs.POST;
  24. import javax.ws.rs.Path;
  25. import javax.ws.rs.ProduceMime;
  26. import javax.ws.rs.core.Context;
  27. import org.apache.log4j.Logger;
  28. import org.apache.poi.hssf.usermodel.HSSFCell;
  29. import org.apache.poi.hssf.usermodel.HSSFDateUtil;
  30. import org.apache.poi.hssf.usermodel.HSSFRow;
  31. import org.apache.poi.hssf.usermodel.HSSFSheet;
  32. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  33. import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  34. import org.apache.poi.ss.usermodel.Cell;
  35. import org.apache.poi.ss.usermodel.DateUtil;
  36. import org.apache.poi.xssf.usermodel.XSSFCell;
  37. import org.apache.poi.xssf.usermodel.XSSFRow;
  38. import org.apache.poi.xssf.usermodel.XSSFSheet;
  39. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  40. import com.formaction.Parameter;
  41. import com.formaction.Utils;
  42. import com.formaction.vo.Msg;
  43. import com.persistence.DbConnection;
  44. import com.persistence.service.PersistenceFactory;
  45. import com.persistence.service.SysPersistence;
  46. import com.sinosoft.common.upLoad.service.UploadManageImpl;
  47. import com.sinosoft.lz.system.util.JsonUtil;
  48. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  49. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  50. /**
  51. * 读取Excel将数据返回到頁面
  52. *
  53. * @author 彭志超
  54. *
  55. */
  56. @Path("/TeamerExcelToDBTableTool/")
  57. public class TeamerExcelToDBTableTool {
  58. private static final Logger log = Logger.getLogger(TeamerExcelToDBTableTool.class);
  59. @ProduceMime("text/html")
  60. @POST
  61. @Path("/importInTeamer")
  62. public String importInTeamer(@Context HttpServletRequest request,
  63. @Context HttpServletResponse response) throws Exception{//新增保存
  64. UploadManageImpl upload2 = new UploadManageImpl();
  65. String path = upload2.uploadFilePath(request, response);
  66. String result="";
  67. log.info("saveFile.path===="+path);
  68. if("success".equals(path.split(";")[1])){
  69. //将数据返回到界面
  70. path=path.split(";")[2];
  71. TeamerExcelToDBTableTool xte = new TeamerExcelToDBTableTool();
  72. result=xte.readExcelByNameIn(path);
  73. }else{
  74. //返回失败信息
  75. result="";
  76. }
  77. log.info("result======"+result);
  78. return result;
  79. }
  80. @ProduceMime("application/json")
  81. @POST
  82. @Path("/importOutTeamer")
  83. public String importOutTeamer(@Context HttpServletRequest request,
  84. @Context HttpServletResponse response) throws Exception{//新增保存
  85. UploadManageImpl upload2 = new UploadManageImpl();
  86. String path = upload2.uploadFilePath(request, response);
  87. String result="";
  88. log.info("saveFile.path===="+path);
  89. if("success".equals(path.split(";")[1])){
  90. //将数据返回到界面
  91. path=path.split(";")[2];
  92. TeamerExcelToDBTableTool xte = new TeamerExcelToDBTableTool();
  93. result=xte.readExcelByNameOut(path);
  94. }else{
  95. //返回失败信息
  96. result="";
  97. }
  98. return result;
  99. }
  100. /**
  101. * 内部队伍
  102. * @param params
  103. * @return
  104. * @throws Exception
  105. */
  106. @ProduceMime("application/json")
  107. @POST
  108. @Path("/getTeamerInExpertExcel")
  109. public String readExcelByNameIn(String fileName) throws Exception {
  110. TeamerExcelToDBTableTool tool = new TeamerExcelToDBTableTool();
  111. // String fileName=Utils.getParameter("fileName", params) == null ? "" : Utils.getParameter(
  112. // "fileName", params);
  113. // String fileName="E:\\javaDemo\\person.xls";
  114. int i=fileName.lastIndexOf(".");
  115. String type=fileName.substring(i+1);
  116. log.info("fileName===="+fileName);
  117. String result="";
  118. if("xls".equals(type)){
  119. result=tool.readExcelIn(fileName,"person");
  120. }else if("xlsx".equals(type)){
  121. result= tool.readExcel2007In(fileName,"person");
  122. }
  123. result="{\"rows\":"+result+"}";
  124. log.info(result);
  125. return result;
  126. }
  127. /**
  128. * 外部队伍
  129. * @param params
  130. * @return
  131. * @throws Exception
  132. */
  133. @ProduceMime("application/json")
  134. @POST
  135. @Path("/getTeamerOutExpertExcel")
  136. public String readExcelByNameOut(String fileName) throws Exception {
  137. TeamerExcelToDBTableTool tool = new TeamerExcelToDBTableTool();
  138. // String fileName=Utils.getParameter("fileName", params) == null ? "" : Utils.getParameter(
  139. // "fileName", params);
  140. // String fileName="E:\\javaDemo\\person.xls";
  141. int i=fileName.lastIndexOf(".");
  142. String type=fileName.substring(i+1);
  143. log.info("fileName===="+fileName);
  144. String result="";
  145. if("xls".equals(type)){
  146. result=tool.readExcelOut(fileName,"person");
  147. }else if("xlsx".equals(type)){
  148. result= tool.readExcel2007Out(fileName,"person");
  149. }
  150. result="{\"rows\":"+result+"}";
  151. log.info(result);
  152. return result;
  153. }
  154. // public void readExcel2007(DBModel dbConn, String filePath, String tableName)
  155. @SuppressWarnings({ "resource", "unused", "rawtypes", "unchecked" })
  156. public String readExcel2007In( String filePath, String tableName)
  157. throws Exception {
  158. String result="";
  159. try {
  160. // InputStream inp = new FileInputStream(filePath);
  161. // Workbook wb = WorkbookFactory.create(inp);
  162. XSSFWorkbook wb = new XSSFWorkbook(filePath);
  163. int sheetSize = wb.getNumberOfSheets();
  164. // for (int i = 0; i < sheetSize; i++) {
  165. List list=new ArrayList();
  166. XSSFSheet sheet = wb.getSheetAt(0);
  167. // Sheet sheet = wb.getSheetAt(i);
  168. for (Iterator rit = sheet.rowIterator(); rit.hasNext();) {
  169. // 迭代行
  170. XSSFRow row = (XSSFRow) rit.next();
  171. // 迭代单元格
  172. Vector datas = new Vector();
  173. StringBuffer sb=new StringBuffer();
  174. Map<String, String>lineMap=new HashMap<String, String>();
  175. for (Iterator cit = row.cellIterator(); cit.hasNext();) {
  176. // 定义集合datas用于存Excel中一个行的数据
  177. XSSFCell cell = (XSSFCell) cit.next();
  178. String value = getValue2007(cell);
  179. sb.append(value+"|");
  180. // 注意行和列是基于0索引的
  181. // System.out.print(cell.getRowIndex() + ":" + cell.getColumnIndex() + " ");
  182. datas.add(value);
  183. // System.out.println();
  184. // 开始操作单元格
  185. }
  186. String[] arr=sb.toString().split("[|]");
  187. list.add(arr);
  188. // result = fillMap(list);;
  189. // 向表中插入数据
  190. // DBFactory.insertData(dbConn, tableName, datas);
  191. }
  192. result = inFillMap(list);
  193. System.out.println(result);
  194. // }
  195. } catch (FileNotFoundException e) {
  196. e.printStackTrace();
  197. throw e;
  198. } catch (IOException e) {
  199. e.printStackTrace();
  200. throw e;
  201. }
  202. return result;
  203. }
  204. /**
  205. * 将Excel数据导入到表中
  206. *
  207. * @param filePath
  208. * Excel路径
  209. * @param tableName
  210. * 表名
  211. */
  212. // public void readExcel(DBModel dbConn, String filePath, String tableName)
  213. @SuppressWarnings({ "resource", "rawtypes", "deprecation", "unchecked" })
  214. public String readExcelIn( String filePath, String tableName)
  215. throws Exception {
  216. String result="";
  217. try {
  218. POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream( filePath));
  219. // 创建工作簿
  220. HSSFWorkbook workBook = new HSSFWorkbook(fs);
  221. log.info(workBook.getNumberOfSheets());
  222. // System.out.println("工作表个数 :" + workBook.getNumberOfSheets());
  223. for (int i = 0; i < workBook.getNumberOfSheets(); i++) {
  224. // 创建工作表
  225. HSSFSheet sheet = workBook.getSheetAt(i);
  226. int rows = sheet.getPhysicalNumberOfRows(); // 获得行数
  227. if (rows > 0) {
  228. sheet.getMargin(HSSFSheet.TopMargin);
  229. List list=new ArrayList();
  230. for (int r = 0; r < rows; r++) { // 行循环
  231. HSSFRow row = sheet.getRow(r);
  232. if (row != null && r != 0 && r != 1) {// 不取第二行
  233. int cells = row.getLastCellNum();// 获得列数
  234. // 定义集合datas用于存Excel中一个行的数据
  235. Vector datas = new Vector();
  236. String[]arr=new String[cells];
  237. List<String>paramList=new ArrayList<String>();
  238. for (short c = 0; c < cells; c++) { // 列循环
  239. HSSFCell cell = row.getCell(c);
  240. if (cell != null) {
  241. String value = getValue(cell);
  242. // System.out.println("第" + r + "行 " + "第" + c + "列:" + value);
  243. datas.add(value);
  244. paramList.add(value);
  245. arr[c]=value;
  246. }
  247. }
  248. list.add(arr);
  249. result = inFillMap(list);
  250. // dataIntoDb(tableName, paramList);
  251. // 向表中插入数据
  252. // DBFactory.insertData(dbConn, tableName, datas);
  253. }
  254. }
  255. } else {
  256. }
  257. }
  258. } catch (Exception ex) {
  259. ex.printStackTrace();
  260. log.info(ex);
  261. throw ex;
  262. }
  263. return result;
  264. }
  265. // public void readExcel2007(DBModel dbConn, String filePath, String tableName)
  266. @SuppressWarnings({ "resource", "unused", "rawtypes", "unchecked" })
  267. public String readExcel2007Out( String filePath, String tableName)
  268. throws Exception {
  269. String result="";
  270. try {
  271. // InputStream inp = new FileInputStream(filePath);
  272. // Workbook wb = WorkbookFactory.create(inp);
  273. XSSFWorkbook wb = new XSSFWorkbook(filePath);
  274. int sheetSize = wb.getNumberOfSheets();
  275. // for (int i = 0; i < sheetSize; i++) {
  276. List list=new ArrayList();
  277. XSSFSheet sheet = wb.getSheetAt(0);
  278. // Sheet sheet = wb.getSheetAt(i);
  279. for (Iterator rit = sheet.rowIterator(); rit.hasNext();) {
  280. // 迭代行
  281. XSSFRow row = (XSSFRow) rit.next();
  282. // 迭代单元格
  283. Vector datas = new Vector();
  284. StringBuffer sb=new StringBuffer();
  285. Map<String, String>lineMap=new HashMap<String, String>();
  286. for (Iterator cit = row.cellIterator(); cit.hasNext();) {
  287. // 定义集合datas用于存Excel中一个行的数据
  288. XSSFCell cell = (XSSFCell) cit.next();
  289. String value = getValue2007(cell);
  290. sb.append(value+"|");
  291. // 注意行和列是基于0索引的
  292. // System.out.print(cell.getRowIndex() + ":" + cell.getColumnIndex() + " ");
  293. datas.add(value);
  294. // System.out.println();
  295. // 开始操作单元格
  296. }
  297. String[] arr=sb.toString().split("[|]");
  298. list.add(arr);
  299. // result = fillMap(list);;
  300. // 向表中插入数据
  301. // DBFactory.insertData(dbConn, tableName, datas);
  302. }
  303. result = outFillMap(list);
  304. System.out.println(result);
  305. // }
  306. } catch (FileNotFoundException e) {
  307. e.printStackTrace();
  308. throw e;
  309. } catch (IOException e) {
  310. e.printStackTrace();
  311. throw e;
  312. }
  313. return result;
  314. }
  315. /**
  316. * 将Excel数据导入到表中
  317. *
  318. * @param filePath
  319. * Excel路径
  320. * @param tableName
  321. * 表名
  322. */
  323. // public void readExcel(DBModel dbConn, String filePath, String tableName)
  324. @SuppressWarnings({ "rawtypes", "deprecation", "unchecked", "resource" })
  325. public String readExcelOut( String filePath, String tableName)
  326. throws Exception {
  327. String result="";
  328. try {
  329. POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream( filePath));
  330. // 创建工作簿
  331. HSSFWorkbook workBook = new HSSFWorkbook(fs);
  332. log.info(workBook.getNumberOfSheets());
  333. // System.out.println("工作表个数 :" + workBook.getNumberOfSheets());
  334. for (int i = 0; i < workBook.getNumberOfSheets(); i++) {
  335. // 创建工作表
  336. HSSFSheet sheet = workBook.getSheetAt(i);
  337. int rows = sheet.getPhysicalNumberOfRows(); // 获得行数
  338. if (rows > 0) {
  339. sheet.getMargin(HSSFSheet.TopMargin);
  340. List list=new ArrayList();
  341. for (int r = 0; r < rows; r++) { // 行循环
  342. HSSFRow row = sheet.getRow(r);
  343. if (row != null && r != 0) {// 不取第一行
  344. int cells = row.getLastCellNum();// 获得列数
  345. // 定义集合datas用于存Excel中一个行的数据
  346. Vector datas = new Vector();
  347. String[]arr=new String[cells];
  348. List<String>paramList=new ArrayList<String>();
  349. for (short c = 0; c < cells; c++) { // 列循环
  350. HSSFCell cell = row.getCell(c);
  351. if (cell != null) {
  352. String value = getValue(cell);
  353. // System.out.println("第" + r + "行 " + "第" + c + "列:" + value);
  354. datas.add(value);
  355. paramList.add(value);
  356. arr[c]=value;
  357. }
  358. }
  359. list.add(arr);
  360. result = outFillMap(list);
  361. // dataIntoDb(tableName, paramList);
  362. // 向表中插入数据
  363. // DBFactory.insertData(dbConn, tableName, datas);
  364. }
  365. }
  366. } else {
  367. }
  368. }
  369. } catch (Exception ex) {
  370. ex.printStackTrace();
  371. log.info(ex);
  372. throw ex;
  373. }
  374. return result;
  375. }
  376. public String getValue2007(XSSFCell cell) {
  377. String value = "";
  378. switch (cell.getCellType()) {
  379. case Cell.CELL_TYPE_STRING:
  380. // System.out.println(cell.getRichStringCellValue().getString());
  381. break;
  382. case Cell.CELL_TYPE_NUMERIC:
  383. if (DateUtil.isCellDateFormatted(cell)) {
  384. // System.out.println(cell.getDateCellValue());
  385. java.util.Date date = cell.getDateCellValue();
  386. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  387. value = format.format(date);
  388. } else {
  389. // System.out.println(cell.getNumericCellValue());
  390. value = String.valueOf(cell.getNumericCellValue());
  391. }
  392. break;
  393. case Cell.CELL_TYPE_BOOLEAN:
  394. // System.out.println(cell.getBooleanCellValue());
  395. value = " " + cell.getBooleanCellValue();
  396. break;
  397. case Cell.CELL_TYPE_FORMULA:
  398. // System.out.println(cell.getCellFormula());
  399. value = cell.getCellFormula();
  400. break;
  401. default:
  402. System.out.println();
  403. }
  404. return value;
  405. }
  406. /**
  407. * 获取Excel中某个单元格的值
  408. *
  409. * @param cell
  410. * @return
  411. * @throws ParseException
  412. */
  413. public String getValue(HSSFCell cell) throws ParseException {
  414. String value = "";
  415. String value1 = "";
  416. switch (cell.getCellType()) {
  417. case HSSFCell.CELL_TYPE_NUMERIC: // 数值型
  418. System.out.println("数字类型");
  419. if (HSSFDateUtil.isCellDateFormatted(cell)) {
  420. log.info("时间类型=============");
  421. // 如果是date类型则 ,获取该cell的date值
  422. Date d = cell.getDateCellValue();
  423. log.info(d);
  424. DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  425. value = format.format(d);
  426. } else
  427. {// 纯数字
  428. cell.setCellType(Cell.CELL_TYPE_STRING);
  429. value = cell.getStringCellValue();
  430. }
  431. break;
  432. /* 此行表示单元格的内容为string类型 */
  433. case HSSFCell.CELL_TYPE_STRING: // 字符串型
  434. value = cell.getStringCellValue();
  435. break;
  436. case HSSFCell.CELL_TYPE_FORMULA:// 公式型
  437. // 读公式计算值
  438. value = String.valueOf(cell.getNumericCellValue());
  439. if (value.equals("NaN")) {// 如果获取的数据值为非法值,则转换为获取字符串
  440. value = cell.getStringCellValue().toString();
  441. }
  442. cell.getCellFormula();
  443. break;
  444. case HSSFCell.CELL_TYPE_BOOLEAN:// 布尔
  445. value = " " + cell.getBooleanCellValue();
  446. break;
  447. /* 此行表示该单元格值为空 */
  448. case HSSFCell.CELL_TYPE_BLANK: // 空值
  449. value = "";
  450. break;
  451. case HSSFCell.CELL_TYPE_ERROR: // 故障
  452. value = "";
  453. break;
  454. default:
  455. value = cell.getStringCellValue().toString();
  456. }
  457. return value;
  458. }
  459. /**
  460. * 將数据转换成json
  461. * @param list
  462. * @return
  463. * @throws UnsupportedEncodingException
  464. */
  465. public String inFillMap(List<String[]> list) throws UnsupportedEncodingException{
  466. List<Map<String, String>>dataList=new ArrayList<Map<String,String>>();
  467. for(int i=0;i<list.size();i++){
  468. Map<String, String>tempMap=new HashMap<String, String>();
  469. String[]arr=list.get(i);
  470. String[] SEX_262 = arr[4]==null ? null:arr[4].split(":");
  471. String[] PROFESSIONAL_262 = arr[10]==null ? null:arr[10].split(":");
  472. String[] VOLTAGE_LEVEL_262 = arr[11]==null ? null:arr[11].split(":");
  473. String[] TEAM_QUARTERS_262 = arr[14]==null ? null:arr[14].split(":");
  474. // tempMap.put("TEAM_UNIT_262", arr[0]);
  475. // tempMap.put("TEAM_NAME_262", arr[1]);
  476. tempMap.put("CODE_262", new String(java.net.URLEncoder.encode(arr[0]==null ? "":arr[0].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  477. tempMap.put("NAME_262", new String(java.net.URLEncoder.encode(arr[1]==null ? "":arr[1].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  478. tempMap.put("ID_NUMBER_262", new String(java.net.URLEncoder.encode(arr[2]==null ? "":arr[2].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  479. tempMap.put("BIRTH_DATE_262", new String(java.net.URLEncoder.encode(arr[3]==null ? "":arr[3].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  480. if(SEX_262!=null)
  481. tempMap.put("SEX_262", new String(java.net.URLEncoder.encode(SEX_262[0].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  482. else
  483. tempMap.put("SEX_262","");
  484. 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"));
  485. tempMap.put("DEPT_ID_262", new String(java.net.URLEncoder.encode(arr[6]==null ? "":arr[6].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  486. tempMap.put("DEPT_QUARTERS_262", new String(java.net.URLEncoder.encode(arr[7]==null ? "":arr[7].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  487. tempMap.put("TECHNICAL_TITLE_262", new String(java.net.URLEncoder.encode(arr[8]==null ? "":arr[8].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  488. tempMap.put("SKILL_LEVEL_262",new String(java.net.URLEncoder.encode(arr[9]==null ? "":arr[9].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  489. if(PROFESSIONAL_262!=null)
  490. tempMap.put("PROFESSIONAL_262", new String(java.net.URLEncoder.encode(PROFESSIONAL_262[0].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  491. else
  492. tempMap.put("PROFESSIONAL_262", "");
  493. if(VOLTAGE_LEVEL_262!=null)
  494. tempMap.put("VOLTAGE_LEVEL_262", new String(java.net.URLEncoder.encode(VOLTAGE_LEVEL_262[0].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  495. else
  496. tempMap.put("VOLTAGE_LEVEL_262","");
  497. tempMap.put("TELEPHONE_262", new String(java.net.URLEncoder.encode(arr[12]==null ? "":arr[12].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  498. tempMap.put("RESCUE_EXP_262", new String(java.net.URLEncoder.encode(arr[13]==null ? "":arr[13].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  499. if(TEAM_QUARTERS_262!=null)
  500. tempMap.put("TEAM_QUARTERS_262", new String(java.net.URLEncoder.encode(TEAM_QUARTERS_262[0].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  501. else
  502. tempMap.put("TEAM_QUARTERS_262","");
  503. tempMap.put("REMARK_262", new String(java.net.URLEncoder.encode(arr[15]==null ? "":arr[15].replace("\n", ""), "UTF-8").getBytes(), "ISO-8859-1"));
  504. dataList.add(tempMap);
  505. }
  506. String result=JsonUtil.list2json(dataList);
  507. return result;
  508. }
  509. /**
  510. * 將数据转换成json
  511. * @param list
  512. * @return
  513. */
  514. public String outFillMap(List<String[]> list){
  515. List<Map<String, String>>dataList=new ArrayList<Map<String,String>>();
  516. for(int i=0;i<list.size();i++){
  517. Map<String, String>tempMap=new HashMap<String, String>();
  518. String[]arr=list.get(i);
  519. // tempMap.put("TEAM_UNIT_262", arr[0]);
  520. // tempMap.put("TEAM_NAME_262", arr[1]);
  521. // tempMap.put("CODE_262", arr[2]);
  522. tempMap.put("NAME_262", arr[0]);//姓名
  523. tempMap.put("ID_NUMBER_262", arr[1]);//身份证号码
  524. tempMap.put("CERTIFICATE_262", arr[2]);//持证证书编号
  525. tempMap.put("BIRTH_DATE_262", arr[3]);//出身年月
  526. tempMap.put("SEX_262", arr[4]);//性别
  527. tempMap.put("WORK_TYPE_AGE_262", arr[5]);//本工种工龄
  528. tempMap.put("DEPT_ID_262", arr[6]);//所在单位
  529. tempMap.put("DEPT_QUARTERS_262", arr[7]);//原单位职务岗位
  530. tempMap.put("TECHNICAL_TITLE_262", arr[8]);//技术职称
  531. tempMap.put("SKILL_LEVEL_262", arr[9]);//技能等级
  532. tempMap.put("PROFESSIONAL_262", arr[10]);//专业
  533. tempMap.put("VOLTAGE_LEVEL_262", arr[11]);//电压等级
  534. tempMap.put("TELEPHONE_262", arr[12]);//联系手机
  535. tempMap.put("RESCUE_EXP_262", arr[13]);//抢险经历
  536. tempMap.put("TEAM_QUARTERS_262", arr[14]);//队伍岗位
  537. dataList.add(tempMap);
  538. }
  539. String result=JsonUtil.list2json(dataList);
  540. return result;
  541. }
  542. /**
  543. * 将界面传输过来的数据保存到数据库
  544. * @param params
  545. * @return
  546. * @throws ClassNotFoundException
  547. */
  548. @SuppressWarnings("static-access")
  549. @ProduceMime("application/json")
  550. @POST
  551. @Path("/teamerInToDb")
  552. public Msg teamerInToDb(String params) throws ClassNotFoundException{
  553. Msg m=new Msg();
  554. String json = Utils.getParameter("json", params) == null ? "" : Utils.getParameter(
  555. "json", params);
  556. log.info("json===" + json);
  557. String classId = Utils.getParameter("classId", params) == null ? "" : Utils
  558. .getParameter("classId", params);
  559. log.info("classId===" + classId);
  560. String teamId = Utils.getParameter("teamId", params) == null ? "" : Utils
  561. .getParameter("teamId", params);
  562. String unit = Utils.getParameter("unit", params) == null ? "" : Utils
  563. .getParameter("unit", params);
  564. String teamName = Utils.getParameter("teamName", params) == null ? "" : Utils
  565. .getParameter("teamName", params);
  566. json=json.replace("_"+classId, "");
  567. String userId = Utils.getParameter("userid", params) == null ? "" : Utils
  568. .getParameter("userid", params);
  569. log.info("userId===" + userId);
  570. Connection conn = null;
  571. PreparedStatement st = null;
  572. PreparedStatement st1 = null;
  573. DbConnection db = new DbConnection();
  574. List<TeamerBean> list = JsonPluginsUtil.jsonToBeanList(json, TeamerBean.class);
  575. Map<String, String> tempMap = new HashMap<String, String>();
  576. String sql="INSERT INTO EMC_AM_TEAM_PERSONNEL (FD_OBJECTID,TEAM_UNIT,TEAM_NAME,CODE,NAME,"
  577. + "ID_NUMBER,BIRTH_DATE,SEX,WORK_TYPE_AGE,DEPT_ID,DEPT_QUARTERS,TECHNICAL_TITLE,"
  578. + "SKILL_LEVEL,PROFESSIONAL,VOLTAGE_LEVEL,TELEPHONE,RESCUE_EXP,TEAM_QUARTERS,"
  579. + "UPDATEDATE,IS_DEL,TEAM_SYSTEM,TEAM_ID,TYPEIN_PEOPLE,SORT_NO,REMARK) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  580. try {
  581. conn = db.getConnection();
  582. int num=0;
  583. conn.setAutoCommit(false);
  584. st = conn.prepareStatement(sql);
  585. for(int i=0;i<list.size();i++){
  586. TeamerBean teamer=list.get(i);
  587. log.info("teamer.getNAME()===="+ teamer.getNAME());
  588. st.setString(1, createMsgId(getMsgId()));
  589. st.setString(2, unit);
  590. st.setString(3, teamName);
  591. st.setString(4, teamer.getCODE());
  592. st.setString(5, teamer.getNAME());
  593. st.setString(6, teamer.getID_NUMBER());
  594. st.setString(7, teamer.getBIRTH_DATE());
  595. st.setString(8, teamer.getSEX());
  596. st.setString(9, teamer.getWORK_TYPE_AGE());
  597. st.setString(10, teamer.getDEPT_ID());
  598. st.setString(11, teamer.getDEPT_QUARTERS());
  599. st.setString(12, teamer.getTECHNICAL_TITLE());
  600. st.setString(13, teamer.getSKILL_LEVEL());
  601. st.setString(14, teamer.getPROFESSIONAL());
  602. st.setString(15, teamer.getVOLTAGE_LEVEL());
  603. st.setString(16, teamer.getTELEPHONE());
  604. st.setString(17, teamer.getRESCUE_EXP());
  605. st.setString(18, teamer.getTEAM_QUARTERS());
  606. st.setString(19, formatDate(new Date()));
  607. st.setString(20, "0");
  608. st.setString(21, "0");
  609. st.setString(22, teamId);
  610. st.setString(23, userId);
  611. //判断有没有初始值
  612. if(!checkhaveId(teamId)){
  613. st.setString(24, String.valueOf(555555551+i));
  614. }else{
  615. st.setString(24, String.valueOf(houxuzhi(teamId)+i+1));
  616. }
  617. st.setString(25, teamer.getREMARK());
  618. int type=Integer.parseInt(teamer.getPROFESSIONAL());
  619. switch (type) {
  620. case 1:
  621. 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)+"");
  622. tempMap.put("SD_XIANLU", (Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+1)+"");
  623. tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
  624. tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
  625. tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
  626. tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
  627. tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
  628. tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
  629. tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
  630. tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
  631. tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
  632. tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
  633. break;
  634. case 2:
  635. 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)+"");
  636. tempMap.put("SD_XIANLANG", (Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+1)+"");
  637. tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
  638. tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
  639. tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
  640. tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
  641. tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
  642. tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
  643. tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
  644. tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
  645. tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
  646. tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
  647. break;
  648. case 3:
  649. 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)+"");
  650. tempMap.put("BD_YICI", (Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+1)+"");
  651. tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
  652. tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
  653. tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
  654. tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
  655. tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
  656. tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
  657. tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
  658. tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
  659. tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
  660. tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
  661. break;
  662. case 4:
  663. 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)+"");
  664. tempMap.put("BD_ERCI", (Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+1)+"");
  665. tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
  666. tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
  667. tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
  668. tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
  669. tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
  670. tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
  671. tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
  672. tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
  673. tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
  674. tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
  675. break;
  676. case 5:
  677. 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)+"");
  678. tempMap.put("PD_XIANLU", (Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+1)+"");
  679. tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
  680. tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
  681. tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
  682. tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
  683. tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
  684. tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
  685. tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
  686. tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
  687. tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
  688. tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
  689. break;
  690. case 6:
  691. 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)+"");
  692. tempMap.put("PD_XIANLANG", (Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+1)+"");
  693. tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
  694. tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
  695. tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
  696. tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
  697. tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
  698. tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
  699. tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
  700. tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
  701. tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
  702. tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
  703. break;
  704. case 7:
  705. 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)+"");
  706. tempMap.put("PD_DIANFANG", (Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+1)+"");
  707. tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
  708. tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
  709. tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
  710. tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
  711. tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
  712. tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
  713. tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
  714. tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
  715. tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
  716. tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
  717. break;
  718. case 8:
  719. 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)+"");
  720. tempMap.put("PD_BAODIAN", (Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+1)+"");
  721. tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
  722. tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
  723. tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
  724. tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
  725. tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
  726. tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
  727. tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
  728. tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
  729. tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
  730. tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
  731. break;
  732. case 9:
  733. 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)+"");
  734. tempMap.put("TONGXING", (Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+1)+"");
  735. tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
  736. tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
  737. tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
  738. tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
  739. tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
  740. tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
  741. tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
  742. tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
  743. tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
  744. tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
  745. break;
  746. case 10:
  747. 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)+"");
  748. tempMap.put("WANGLUO", (Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+1)+"");
  749. tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
  750. tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
  751. tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
  752. tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
  753. tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
  754. tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
  755. tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
  756. tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
  757. tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
  758. tempMap.put("SHIYAN", Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+"");
  759. break;
  760. case 11:
  761. 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)+"");
  762. tempMap.put("SHIYAN", (Integer.parseInt((("SHIYAN".equals(tempMap.get("SHIYAN"))||tempMap.get("SHIYAN")==null)?"0":tempMap.get("SHIYAN")))+1)+"");
  763. tempMap.put("SD_XIANLANG", Integer.parseInt((("SD_XIANLANG".equals(tempMap.get("SD_XIANLANG"))||tempMap.get("SD_XIANLANG")==null)?"0":tempMap.get("SD_XIANLANG")))+"");
  764. tempMap.put("SD_XIANLU", Integer.parseInt((("SD_XIANLU".equals(tempMap.get("SD_XIANLU"))||tempMap.get("SD_XIANLU")==null)?"0":tempMap.get("SD_XIANLU")))+"");
  765. tempMap.put("BD_YICI", Integer.parseInt((("BD_YICI".equals(tempMap.get("BD_YICI"))||tempMap.get("BD_YICI")==null)?"0":tempMap.get("BD_YICI")))+"");
  766. tempMap.put("BD_ERCI", Integer.parseInt((("BD_ERCI".equals(tempMap.get("BD_ERCI"))||tempMap.get("BD_ERCI")==null)?"0":tempMap.get("BD_ERCI")))+"");
  767. tempMap.put("PD_XIANLU", Integer.parseInt((("PD_XIANLU".equals(tempMap.get("PD_XIANLU"))||tempMap.get("PD_XIANLU")==null)?"0":tempMap.get("PD_XIANLU")))+"");
  768. tempMap.put("PD_XIANLANG", Integer.parseInt((("PD_XIANLANG".equals(tempMap.get("PD_XIANLANG"))||tempMap.get("PD_XIANLANG")==null)?"0":tempMap.get("PD_XIANLANG")))+"");
  769. tempMap.put("PD_DIANFANG", Integer.parseInt((("PD_DIANFANG".equals(tempMap.get("PD_DIANFANG"))||tempMap.get("PD_DIANFANG")==null)?"0":tempMap.get("PD_DIANFANG")))+"");
  770. tempMap.put("PD_BAODIAN", Integer.parseInt((("PD_BAODIAN".equals(tempMap.get("PD_BAODIAN"))||tempMap.get("PD_BAODIAN")==null)?"0":tempMap.get("PD_BAODIAN")))+"");
  771. tempMap.put("TONGXING", Integer.parseInt((("TONGXING".equals(tempMap.get("TONGXING"))||tempMap.get("TONGXING")==null)?"0":tempMap.get("TONGXING")))+"");
  772. tempMap.put("WANGLUO", Integer.parseInt((("WANGLUO".equals(tempMap.get("WANGLUO"))||tempMap.get("WANGLUO")==null)?"0":tempMap.get("WANGLUO")))+"");
  773. break;
  774. default:
  775. break;
  776. }
  777. st.executeUpdate();
  778. num++;
  779. }
  780. log.info("tempMap.get(TEAM_MEMBER_NUMBER)===="+ tempMap.get("TEAM_MEMBER_NUMBER"));
  781. 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")+"'), "
  782. + "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")+"'),"
  783. + " 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")+"'),"
  784. + "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+"'))";
  785. log.info("sql1====="+ sql1);
  786. st1 = conn.prepareStatement(sql1);
  787. int k=st1.executeUpdate();
  788. if(num+k==list.size()+1){
  789. log.info("保存成功");
  790. conn.commit();
  791. m.setSucsess(new Boolean(true).toString());
  792. m.setInfo(Parameter.DELETE_SUCSESS);
  793. return m;
  794. }else{
  795. m.setSucsess(new Boolean(false).toString());
  796. m.setInfo(Parameter.DELETE_FAILURE);
  797. // st.executeBatch();
  798. conn.rollback();
  799. log.info("保存失败");
  800. return m;
  801. }
  802. } catch (SQLException e) {
  803. this.log.error(e.getMessage(), e);
  804. throw new ClassNotFoundException("DAO Layou: 消息保存", e);
  805. } finally {
  806. db.close(st);
  807. db.close(conn);
  808. }
  809. }
  810. /**
  811. * 将界面传输过来的数据保存到数据库
  812. * @param params
  813. * @return
  814. * @throws ClassNotFoundException
  815. */
  816. @SuppressWarnings("static-access")
  817. @ProduceMime("application/json")
  818. @POST
  819. @Path("/teamerOutToDb")
  820. public Msg teamerOutToDb(String params) throws ClassNotFoundException{
  821. Msg m=new Msg();
  822. String json = Utils.getParameter("json", params) == null ? "" : Utils.getParameter(
  823. "json", params);
  824. log.info("json===" + json);
  825. String classId = Utils.getParameter("classId", params) == null ? "" : Utils
  826. .getParameter("classId", params);
  827. log.info("classId===" + classId);
  828. String teamId = Utils.getParameter("teamId", params) == null ? "" : Utils
  829. .getParameter("teamId", params);
  830. String unit = Utils.getParameter("unit", params) == null ? "" : Utils
  831. .getParameter("unit", params);
  832. String teamName = Utils.getParameter("teamName", params) == null ? "" : Utils
  833. .getParameter("teamName", params);
  834. json=json.replace("_"+classId, "");
  835. Connection conn = null;
  836. PreparedStatement st = null;
  837. DbConnection db = new DbConnection();
  838. List<TeamerBean> list = JsonPluginsUtil.jsonToBeanList(json, TeamerBean.class);
  839. String sql="INSERT INTO EMC_AM_TEAM_PERSONNEL (FD_OBJECTID,TEAM_UNIT,TEAM_NAME,NAME,"
  840. + "ID_NUMBER,BIRTH_DATE,SEX,WORK_TYPE_AGE,DEPT_ID,DEPT_QUARTERS,TECHNICAL_TITLE,"
  841. + "SKILL_LEVEL,PROFESSIONAL,VOLTAGE_LEVEL,TELEPHONE,RESCUE_EXP,TEAM_QUARTERS,"
  842. + "UPDATEDATE,IS_DEL,CERTIFICATE,TEAM_SYSTEM,TEAM_ID,REMARK,SORT_NO) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  843. try {
  844. conn = db.getConnection();
  845. int num=0;
  846. conn.setAutoCommit(false);
  847. st = conn.prepareStatement(sql);
  848. for(int i=0;i<list.size();i++){
  849. TeamerBean eb=list.get(i);
  850. log.info(" eb.getEXPERT_AREA()===="+ eb.getTEAM_NAME());
  851. st.setString(1, createMsgId(getMsgId()));
  852. st.setString(2, unit);
  853. st.setString(3, teamName);
  854. st.setString(4, eb.getNAME());
  855. st.setString(5, eb.getID_NUMBER());
  856. st.setString(6, eb.getBIRTH_DATE());
  857. st.setString(7, eb.getSEX());
  858. st.setString(8, eb.getWORK_TYPE_AGE());
  859. st.setString(9, eb.getDEPT_ID());
  860. st.setString(10, eb.getDEPT_QUARTERS());
  861. st.setString(11, eb.getTECHNICAL_TITLE());
  862. st.setString(12, eb.getSKILL_LEVEL());
  863. st.setString(13, eb.getPROFESSIONAL());
  864. st.setString(14, eb.getVOLTAGE_LEVEL());
  865. st.setString(15, eb.getTELEPHONE());
  866. st.setString(16, eb.getRESCUE_EXP());
  867. st.setString(17, eb.getTEAM_QUARTERS());
  868. st.setString(18, formatDate(new Date()));
  869. st.setString(19, "0");
  870. st.setString(20, eb.getCERTIFICATE());
  871. st.setString(21, "1");
  872. st.setString(22, teamId);
  873. st.setString(23, eb.getREMARK());
  874. //判断有没有初始值
  875. if(!checkhaveId(teamId)){
  876. st.setString(24, String.valueOf(555555551+i));
  877. }else{
  878. st.setString(24, String.valueOf(houxuzhi(teamId)+i+1));
  879. }
  880. st.executeUpdate();
  881. num++;
  882. }
  883. if(num==list.size()){
  884. log.info("保存成功");
  885. conn.commit();
  886. m.setSucsess(new Boolean(true).toString());
  887. m.setInfo(Parameter.DELETE_SUCSESS);
  888. return m;
  889. }else{
  890. m.setSucsess(new Boolean(false).toString());
  891. m.setInfo(Parameter.DELETE_FAILURE);
  892. // st.executeBatch();
  893. conn.rollback();
  894. log.info("保存失败");
  895. return m;
  896. }
  897. } catch (SQLException e) {
  898. this.log.error(e.getMessage(), e);
  899. throw new ClassNotFoundException("DAO Layou: 消息保存", e);
  900. } finally {
  901. db.close(st);
  902. db.close(conn);
  903. }
  904. }
  905. public String formatDate(Date d) {
  906. SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  907. String date = sd.format(d);
  908. return date;
  909. }
  910. @SuppressWarnings({ "rawtypes", "unchecked" })
  911. public List<String> getMsgId() throws ClassNotFoundException {
  912. String sql = "SELECT FD_OBJECTID FROM EMC_AM_TEAM_PERSONNEL";
  913. Connection conn = null;
  914. Statement stat = null;
  915. ResultSet rs = null;
  916. DbConnection db = new DbConnection();
  917. try {
  918. conn = db.getConnection();
  919. stat = conn.createStatement();
  920. rs = stat.executeQuery(sql);
  921. List<String> list = new ArrayList();
  922. while (rs.next()) {
  923. list.add(rs.getString("FD_OBJECTID"));
  924. }
  925. return list;
  926. } catch (SQLException e) {
  927. // this.log.error(e.getMessage(), e);
  928. throw new ClassNotFoundException("DAO Layou: 获得数据库消息ID集合"
  929. + sql, e);
  930. } finally {
  931. db.close(rs);
  932. db.close(stat);
  933. db.close(conn);
  934. }
  935. }
  936. public String createMsgId(List<String> list) throws ClassNotFoundException{
  937. long l=(long) ((Math.random()+1)*1000000000);
  938. String msgId=l+"";
  939. if(list.contains(msgId)){
  940. return createMsgId(list);
  941. }
  942. else{
  943. // log.info("msgid==="+msgId);
  944. return msgId;
  945. }
  946. }
  947. /*************************************排序****************************************/
  948. @SuppressWarnings("static-access")
  949. public boolean checkhaveId(String id) {
  950. try{
  951. String sql="select * from EMC_AM_TEAM_PERSONNEL where TEAM_ID ='"+id+"' and IS_DEL = '0' and sort_no is not null";
  952. SysModel sysmodel = ModelFactory.getSysmodel();
  953. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  954. List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
  955. if(tempList==null||tempList.size()==0){
  956. return false;
  957. }else{
  958. return true;
  959. }}catch(Exception e){
  960. this.log.error(e.getMessage(), e);
  961. return false;
  962. }
  963. }
  964. @SuppressWarnings("static-access")
  965. public int houxuzhi(String id) throws ClassNotFoundException {
  966. try{
  967. 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";
  968. SysModel sysmodel = ModelFactory.getSysmodel();
  969. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  970. List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
  971. return Integer.parseInt(tempList.get(0)[0]);
  972. }catch(Exception e){
  973. this.log.error(e.getMessage(), e);
  974. throw new ClassNotFoundException("DAO Layou: 消息保存", e);
  975. }
  976. }
  977. @ProduceMime("application/json")
  978. @POST
  979. @Path("/getAddSort")
  980. public String getAddSort(String params) throws ClassNotFoundException{
  981. String id=Utils.getParameter("id", params);
  982. String json = null;
  983. //判断有没有初始值
  984. if(!checkhaveId(id)){
  985. json = "555555551";
  986. }else{
  987. json = String.valueOf(houxuzhi(id)+1);
  988. }
  989. return json;
  990. }
  991. }