123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536 |
- package com.sinosoft.am.resource.generator_car.dao;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.List;
- import org.apache.log4j.Logger;
- import com.formaction.Parameter;
- import com.formaction.vo.Msg;
- import com.persistence.DbConnection;
- import com.persistence.service.PersistenceFactory;
- import com.persistence.service.SysPersistence;
- import com.persistence.service.exception.PersistenceException;
- import com.sinosoft.am.resource.generator_car.vo.CarNum;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- public class GeneratorCarDao{
- private Logger log = Logger.getLogger(this.getClass());
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer json = new StringBuffer();
- private List<CarNum>numList=new ArrayList<CarNum>();
- /**
- * 根据传过来的ID进行检测,有子节点且子节点在明细表中有数据的,继续查询该节点下面的数据
- * @param id
- * @return
- */
- public String carNumInit(String id,String content1,String content2,String valueType,String valueType2,String valueType3,String deptId){
-
- try{
-
- // String sql="select dept_id from sys_department where (parent_id='"+id+"' or dept_id='"+id+"')";
- // if(deptId!=null&&!"".equals(deptId)&&!"null".equals(deptId)){
- // sql+=" and DEPT_ID in("+deptId+") ";
- // }
- // sql+="order by sort";
- String sql="";
- if("1".equals(levelId(id))){
-
- }else if("2".equals(levelId(id))){
- sql="select dept_id from sys_department where dept_type='1' and (parent_id='"+id+"' )";//or dept_id='"+id+"'
- if(deptId!=null && !"".equals(deptId)){
- sql+=" and dept_id in("+deptId+")";
- }
- sql+=" order by sort";
- }else if("3".equals(levelId(id))||"4".equals(levelId(id))||"5".equals(levelId(id))){
- sql="select dept_id from sys_department where dept_type='1' and (parent_id='"+id+"' or dept_id='"+id+"' )";
- if(deptId!=null && !"".equals(deptId)){
- sql+=" and dept_id in("+deptId+")";
- }
- sql+=" order by dept_level,sort";
- }
-
- if(checkId(id)){
- List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
- log.info("carNum.tempList.size===="+tempList.size());
- List<String>list=new ArrayList<String>();
- for(int i=0;i<tempList.size();i++){
- list.add(tempList.get(i)[0]);
- }
- getCarNum(list, list.get(0),content1,content2,valueType,valueType2,valueType3,id);
- }else{
- List<String>list=new ArrayList<String>();
- list.add(id);
- getNoChildCarNum(list, id,content1,content2,valueType,valueType2,valueType3);
- }}catch(Exception e){
- this.log.error(e.getMessage(), e);
- }
- // log.info("最终JSON==="+json.toString());
- /*if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- }*/
- CarNum numBean=new CarNum();
- for(int i=0;i<numList.size();i++){
- numBean.setContent_min(numBean.getContent_min()+numList.get(i).getContent_min());
- numBean.setContent_mid(numBean.getContent_mid()+numList.get(i).getContent_mid());
- numBean.setContent_max(numBean.getContent_max()+numList.get(i).getContent_max());
- numBean.setLevel_max(numBean.getLevel_max()+numList.get(i).getLevel_max());
- numBean.setLevel_min(numBean.getLevel_min()+numList.get(i).getLevel_min());
- numBean.setGenerator(numBean.getGenerator()+numList.get(i).getGenerator());
- numBean.setUps(numBean.getUps()+numList.get(i).getUps());
- numBean.setFly_circle(numBean.getFly_circle()+numList.get(i).getFly_circle());
- numBean.setNum(numBean.getNum()+numList.get(i).getNum());
- numBean.setSum(numBean.getSum()+numList.get(i).getSum());
- numBean.setKused(numBean.getKused()+numList.get(i).getKused());
- numBean.setBused(numBean.getBused()+numList.get(i).getBused());
- }
- json.append("{ ");
- json.append(" \"content_min\":\"" + numBean.getContent_min() + "\",");
- json.append(" \"content_mid\":\"" + numBean.getContent_mid() + "\",");
- json.append(" \"content_max\":\"" + numBean.getContent_max() + "\",");
- json.append(" \"level_min\":\"" + numBean.getLevel_min() + "\",");
- json.append(" \"level_max\":\"" + numBean.getLevel_max() + "\",");
- json.append(" \"generator\":\"" + numBean.getGenerator() + "\",");
- json.append(" \"ups\":\"" + numBean.getUps() + "\",");
- json.append(" \"fly_circle\":\"" + numBean.getFly_circle() + "\",");
- json.append(" \"num\":\"" + numBean.getNum() + "\",");
- json.append(" \"sum\":\"" + numBean.getSum() + "\",");
- json.append(" \"kused\":\"" + numBean.getKused() + "\",");
- json.append(" \"bused\":\"" + numBean.getBused() + "\",");
- json.append(" \"name\":\"" +"总计" + "\",");
- json.append(" \"dept_id\":\"" + "11111" + "\",");
- json.append(" \"isParent\":false,");
- json.append(" \"open\":false");
- json.append("} ");
- String result="{\"rows\":["+json.toString()+"]}";
- // List<String>list=getCmpList(id, new ArrayList<String>());
- log.info("result===="+result);
- return result;
- }
-
- public String carNum(String id,String content1,String content2,String valueType,String valueType2,String valueType3){
- try{
- if(checkId(id)){
- String sql="SELECT dept_id FROM SYS_DEPARTMENT WHERE PARENT_ID='"+id+"'";
- List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
- log.info("carNum.tempList.size===="+tempList.size());
- for(int i=0;i<tempList.size();i++){
- List<String>list=getCmpList(tempList.get(i)[0], new ArrayList<String>());
- getCarNum(list, tempList.get(i)[0],content1,content2,valueType,valueType2,valueType3,id);
- }
- }else{
- List<String>list=new ArrayList<String>();
- list.add(id);
- getNoChildCarNum(list, id,content1,content2,valueType,valueType2,valueType3);
- }}catch(Exception e){
- this.log.error(e.getMessage(), e);
- }
- // log.info("最终JSON==="+json.toString());
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- }
- String result="{\"rows\":["+json.toString()+"]}";
- // List<String>list=getCmpList(id, new ArrayList<String>());
- log.info("result===="+result);
- return result;
- }
-
- public List<String> getCmpList(String id,List<String>list) {
- try{
- if(checkId(id)){//存在子节点且子节点在明细表中有记录
- list.add(id);
- String sql="select DEPT_ID from sys_department where parent_id='"+id+"'";
- List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
- log.info("getCmpList.tempList.size===="+tempList.size());
- for(int i=0;i<tempList.size();i++){
- getCmpList(tempList.get(i)[0],list);
- }
- }
- else{//如果不存在自己点或者子节点在明细表中无记录,则返回该ID
- list.add(id);
- }}catch(Exception e){
- this.log.error(e.getMessage(), e);
- }
- return list;
- }
-
- public boolean checkId(String id) {
- try{
- String sql="select * from emc_am_generator_car WHERE COMP_ID IN(SELECT dept_id FROM SYS_DEPARTMENT WHERE DEPT_TYPE='1' AND PARENT_ID='"+id+"') union all "
- + "select * from emc_am_generator_car WHERE COMP_ID IN(SELECT dept_id FROM SYS_DEPARTMENT WHERE DEPT_TYPE='1' AND PARENT_ID in (SELECT dept_id FROM SYS_DEPARTMENT WHERE DEPT_TYPE='1' AND PARENT_ID='"+id+"')) union all "
- + "select * from emc_am_generator_car WHERE COMP_ID IN(SELECT dept_id FROM SYS_DEPARTMENT WHERE DEPT_TYPE='1' AND PARENT_ID in (SELECT dept_id FROM SYS_DEPARTMENT WHERE DEPT_TYPE='1' AND PARENT_ID in (SELECT dept_id FROM SYS_DEPARTMENT WHERE DEPT_TYPE='1' AND PARENT_ID='"+id+"')))";
- 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;
- }
- }
-
- public String levelId(String id) {
- try{
- String sql="select dept_level from SYS_DEPARTMENT WHERE dept_id = '"+id+"' ";
- List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
- if(tempList==null||tempList.size()==0){
- return "0";
- }else{
- return tempList.get(0)[0];
- }}catch(Exception e){
- this.log.error(e.getMessage(), e);
- return "0";
- }
- }
-
- public void getCarNum(List<String>list,String id,String content1,String content2,String valueType,String valueType2,String valueType3,String zsId) throws PersistenceException{
-
- try{
- String team_comp = "";
- for(int i=0;i<list.size();i++){
- CarNum cn=new CarNum();
- String comp_id = list.get(i);
- log.info(comp_id);
- if("3".equals(levelId(comp_id))){
- if(comp_id.equals(zsId)){
- team_comp = "select dept_id from sys_department where dept_id = '"+comp_id+"'";
- }else{
- team_comp = "select dept_id from sys_department where (dept_type='1' and (parent_id = '"+comp_id+"' or dept_id = '"+comp_id+"')) union all "
- + "select dept_id from sys_department where (dept_type='1' and parent_id in (select dept_id from sys_department where dept_type='1' and parent_id = '"+comp_id+"'))";
- }
- }else if("4".equals(levelId(comp_id))){
- if(comp_id.equals(zsId)){
- team_comp = "select dept_id from sys_department where dept_id = '"+comp_id+"'";
- }else{
- team_comp = "select dept_id from sys_department where dept_type='1' and (parent_id = '"+comp_id+"' or dept_id = '"+comp_id+"')";
- }
- }else if("5".equals(levelId(comp_id))){
- team_comp = "select dept_id from sys_department where dept_id = '"+comp_id+"'";
- }
-
-
- String sql="select is_del,sum(case when car_content<=250 then car_num else 0 end) as content_min,"
- + "sum(case when car_content>=251 and car_content<=500 then car_num else 0 end) as content_mid,"
- + "sum(case when car_content>=501 then car_num else 0 end) as content_max,"
- + "sum(case car_level when '139' then car_num else 0 end)as level_max,"
- + "sum(case car_level when '138' then car_num else 0 end)as level_min,"
- + "sum(case STORED_ENERGY_TYPE when '1' then car_num else 0 end)as generator,"
- + "sum(case STORED_ENERGY_TYPE when '2' then car_num else 0 end)as ups,"
- + "sum(case STORED_ENERGY_TYPE when '3' then car_num else 0 end)as fly_circle ,"
- + "sum(car_num)as num, sum(car_content*car_num) as sm,"
- + "sum(case IS_USED when '1' then car_num else 0 end)as kdy,"
- + "sum(case IS_USED when '2' then car_num else 0 end)as bkdy "
- + "from emc_am_generator_car where is_del='0' and comp_id in ("+team_comp+") ";
- /*//容量
- if(content1!=null&&!"".equals(content1)&&!"null".equals(content1)){
- sql+=" and CAR_CONTENT between '"+content1+"' and '"+content2+"'";
- }
- //电压等级valueType
- if(valueType!=null&&!"".equals(valueType)&&!"null".equals(valueType)){
- sql+=" and CAR_LEVEL in( "+valueType+")";
- }
- //储能方式
- if(valueType2!=null&&!"".equals(valueType2)&&!"null".equals(valueType2)){
- sql+=" and STORED_ENERGY_TYPE in ("+valueType2+") ";
- }*/
- //可否调用
- if(valueType3!=null&&!"".equals(valueType3)&&!"null".equals(valueType3)){
- sql+=" and IS_USED in( "+valueType3+" )";
- }
-
-
- //comp_id
- sql+=" group by is_del ";
-
- log.info("getCarNum.sql===="+sql);
- List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
- if(tempList.size()>0){
- cn.setContent_min(Integer.parseInt(tempList.get(0)[1]));
- cn.setContent_mid(Integer.parseInt(tempList.get(0)[2]));
- cn.setContent_max(Integer.parseInt(tempList.get(0)[3]));
- cn.setLevel_max(Integer.parseInt(tempList.get(0)[4]));
- cn.setLevel_min(Integer.parseInt(tempList.get(0)[5]));
- cn.setGenerator(Integer.parseInt(tempList.get(0)[6]));
- cn.setUps(Integer.parseInt(tempList.get(0)[7]));
- cn.setFly_circle(Integer.parseInt(tempList.get(0)[8]));
- cn.setNum(Integer.parseInt(tempList.get(0)[9]));
- cn.setSum(Double.parseDouble(tempList.get(0)[10]));
- cn.setKused(Integer.parseInt(tempList.get(0)[11]));
- cn.setBused(Integer.parseInt(tempList.get(0)[12]));
- numList.add(cn);
-
- if(cn.getNum()>0){
- if(checkId(id)){
- json.append("{ ");
- json.append(" \"content_min\":\"" + cn.getContent_min() + "\",");
- json.append(" \"content_mid\":\"" + cn.getContent_mid() + "\",");
- json.append(" \"content_max\":\"" + cn.getContent_max() + "\",");
- json.append(" \"level_min\":\"" + cn.getLevel_min() + "\",");
- json.append(" \"level_max\":\"" + cn.getLevel_max() + "\",");
- json.append(" \"generator\":\"" + cn.getGenerator() + "\",");
- json.append(" \"ups\":\"" + cn.getUps() + "\",");
- json.append(" \"fly_circle\":\"" + cn.getFly_circle() + "\",");
- json.append(" \"num\":\"" + cn.getNum() + "\",");
- json.append(" \"sum\":\"" + cn.getSum() + "\",");
- json.append(" \"kused\":\"" + cn.getKused() + "\",");
- json.append(" \"bused\":\"" + cn.getBused() + "\",");
- json.append(" \"name\":\"" + getNameById(list.get(i)) + "\",");
- json.append(" \"dept_id\":\"" + list.get(i) + "\",");
- json.append(" \"isParent\":true,");
- json.append(" \"open\":false");
- json.append("}, ");
- }else{
- json.append("{ ");
- json.append(" \"content_min\":\"" + cn.getContent_min() + "\",");
- json.append(" \"content_mid\":\"" + cn.getContent_mid() + "\",");
- json.append(" \"content_max\":\"" + cn.getContent_max() + "\",");
- json.append(" \"level_min\":\"" + cn.getLevel_min() + "\",");
- json.append(" \"level_max\":\"" + cn.getLevel_max() + "\",");
- json.append(" \"generator\":\"" + cn.getGenerator() + "\",");
- json.append(" \"ups\":\"" + cn.getUps() + "\",");
- json.append(" \"fly_circle\":\"" + cn.getFly_circle() + "\",");
- json.append(" \"num\":\"" + cn.getNum() + "\",");
- json.append(" \"sum\":\"" + cn.getSum() + "\",");
- json.append(" \"kused\":\"" + cn.getKused() + "\",");
- json.append(" \"bused\":\"" + cn.getBused() + "\",");
- json.append(" \"name\":\"" + getNameById(list.get(i))+ "\",");
- json.append(" \"dept_id\":\"" + list.get(i) + "\",");
- json.append(" \"isParent\":false,");
- json.append(" \"open\":false");
- json.append("}, ");
- }
- }
- }
- }}catch(Exception e){
- this.log.error(e.getMessage(), e);
- }
- // StringBuffer json=new StringBuffer();
- // json.append("{ ");
- // json.append(" \"content_min\":\"" + cn.getContent_min() + "\",");
- // json.append(" \"content_mid\":\"" + cn.getContent_mid() + "\",");
- // json.append(" \"content_max\":\"" + cn.getContent_max() + "\",");
- // json.append(" \"level_min\":\"" + cn.getLevel_min() + "\",");
- // json.append(" \"level_max\":\"" + cn.getLevel_max() + "\",");
- // json.append(" \"generator\":\"" + cn.getGenerator() + "\",");
- // json.append(" \"ups\":\"" + cn.getUps() + "\",");
- // json.append(" \"fly_circle\":\"" + cn.getFly_circle() + "\",");
- // json.append(" \"num\":\"" + cn.getNum() + "\",");
- // json.append(" \"name\":\"" + getNameById(id) + "\",");
- // json.append(" \"dept_id\":\"" + id + "\",");
- // json.append(" \"isParent\":true,");
- // json.append(" \"open\":false");
- // json.append("}, ");
-
-
- }
-
-
- public void getNoChildCarNum(List<String>list,String id,String content1,String content2,String valueType,String valueType2,String valueType3) throws PersistenceException{
- CarNum cn=new CarNum();
- try{
- for(int i=0;i<list.size();i++){
- String sql="select comp_id,sum(case when car_content<=250 then car_num else 0 end) as content_min,"
- + "sum(case when car_content>=251 and car_content<=500 then car_num else 0 end) as content_mid,"
- + "sum(case when car_content>=501 then car_num else 0 end) as content_max,"
- + "sum(case car_level when '139' then car_num else 0 end)as level_max,"
- + "sum(case car_level when '138' then car_num else 0 end)as level_min,"
- + "sum(case STORED_ENERGY_TYPE when '1' then car_num else 0 end)as generator,"
- + "sum(case STORED_ENERGY_TYPE when '2' then car_num else 0 end)as ups,"
- + "sum(case STORED_ENERGY_TYPE when '3' then car_num else 0 end)as fly_circle ,"
- + "sum(car_num)as num, sum(car_content*car_num) as sm,"
- + "sum(case IS_USED when '1' then car_num else 0 end)as kdy,"
- + "sum(case IS_USED when '2' then car_num else 0 end)as bkdy "
- + "from emc_am_generator_car where is_del='0' and comp_id='"+list.get(i)+"'";
-
- /*//容量
- if(content1!=null&&!"".equals(content1)&&!"null".equals(content1)){
- sql+=" and CAR_CONTENT between '"+content1+"' and '"+content2+"'";
- }
- //电压等级valueType
- if(valueType!=null&&!"".equals(valueType)&&!"null".equals(valueType)){
- sql+=" and CAR_LEVEL in( "+valueType+")";
- }
- //储能方式
- if(valueType2!=null&&!"".equals(valueType2)&&!"null".equals(valueType2)){
- sql+=" and STORED_ENERGY_TYPE in ("+valueType2+") ";
- }*/
- //可否调用
- if(valueType3!=null&&!"".equals(valueType3)&&!"null".equals(valueType3)){
- sql+=" and IS_USED in( "+valueType3+" )";
- }
- //comp_id
- sql+=" group by comp_id";
-
- log.info("getCarNum.sql===="+sql);
- List<String[]>numList= persistence.getSearchResult(99, sql.toString());
- if(numList.size()>0){
- cn.setContent_min(cn.getContent_min()+Integer.parseInt(numList.get(0)[1]));
- cn.setContent_mid(cn.getContent_mid()+Integer.parseInt(numList.get(0)[2]));
- cn.setContent_max(cn.getContent_max()+Integer.parseInt(numList.get(0)[3]));
- cn.setLevel_max(cn.getLevel_max()+Integer.parseInt(numList.get(0)[4]));
- cn.setLevel_min(cn.getLevel_min()+Integer.parseInt(numList.get(0)[5]));
- cn.setGenerator(cn.getGenerator()+Integer.parseInt(numList.get(0)[6]));
- cn.setUps(cn.getUps()+Integer.parseInt(numList.get(0)[7]));
- cn.setFly_circle(cn.getFly_circle()+Integer.parseInt(numList.get(0)[8]));
- cn.setNum(cn.getNum()+Integer.parseInt(numList.get(0)[9]));
- cn.setSum(cn.getSum()+Double.parseDouble(numList.get(0)[10]));
- cn.setKused(cn.getKused()+Integer.parseInt(numList.get(0)[11]));
- cn.setBused(cn.getBused()+Integer.parseInt(numList.get(0)[12]));
- }
- }}catch(Exception e){
- this.log.error(e.getMessage(), e);
- }
- // StringBuffer json=new StringBuffer();
- if(cn.getNum()>0){
- json.append("{ ");
- json.append(" \"content_min\":\"" + cn.getContent_min() + "\",");
- json.append(" \"content_mid\":\"" + cn.getContent_mid() + "\",");
- json.append(" \"content_max\":\"" + cn.getContent_max() + "\",");
- json.append(" \"level_min\":\"" + cn.getLevel_min() + "\",");
- json.append(" \"level_max\":\"" + cn.getLevel_max() + "\",");
- json.append(" \"generator\":\"" + cn.getGenerator() + "\",");
- json.append(" \"ups\":\"" + cn.getUps() + "\",");
- json.append(" \"fly_circle\":\"" + cn.getFly_circle() + "\",");
- json.append(" \"num\":\"" + cn.getNum() + "\",");
- json.append(" \"sum\":\"" + cn.getSum() + "\",");
- json.append(" \"kused\":\"" + cn.getKused() + "\",");
- json.append(" \"bused\":\"" + cn.getBused() + "\",");
- json.append(" \"name\":\"" + getNameById(id) + "\",");
- json.append(" \"dept_id\":\"" + id + "\",");
- json.append(" \"isParent\":false,");
- json.append(" \"open\":true");
- json.append("}, ");
- numList.add(cn);
- }
- }
-
- public String getNameById(String id){
- String sql="select dept_name from sys_department where dept_id='"+id+"'";
- try {
- List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
- if(tempList==null||tempList.size()==0){
- return "";
- }else{
- String name=tempList.get(0)[0].replace("供电局", "");
- log.info("name===="+name);
- return name;
- }
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return "";
- }
- }
-
- /**************************************调拨*************************************/
-
- /**
- * 调拨
- * @throws ClassNotFoundException
- */
- public Msg getCardiaobo(String fd_id,String number) throws ClassNotFoundException{
- Msg m=new Msg();
- String []arr=fd_id.split(",");
- log.info(number);
- String sql="";
- if(number.equals("1")){
- sql="UPDATE emc_am_generator_car SET USED_STAT='1',IS_USED='1' where fd_objectid=?";
- }else if(number.equals("2")){
- sql="UPDATE emc_am_generator_car SET USED_STAT='2',IS_USED='2' where fd_objectid=?";
- }else if(number.equals("3")){
- sql="UPDATE emc_am_generator_car SET USED_STAT='3',IS_USED='2' where fd_objectid=?";
- }
- Connection conn = null;
- PreparedStatement st = null;
- int num=0;
- DbConnection db = new DbConnection();
- try {
- conn = db.getConnection();
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for(int i=0;i<arr.length;i++){
- st.setString(1, arr[i]);
- st.executeUpdate();
- num++;
- }
- if(num==arr.length){
- log.info("发布----num===="+num);
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.OPER_SUCSESS);
- conn.commit();
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.OPER_FAILURE);
- conn.rollback();
- return m;
- }
- }catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 发布消息"
- + sql, e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- }
-
- /**
- * 调拨 通信车
- * @throws ClassNotFoundException
- */
- public Msg getComdiaobo(String fd_id,String number) throws ClassNotFoundException{
- Msg m=new Msg();
- String []arr=fd_id.split(",");
- log.info(number);
- String sql="";
- if(number.equals("1")){
- sql="UPDATE EMC_AM_EMERGENCY_COMMAND_CAR SET USED_STAT='1',IS_USED='1' where fd_objectid=?";
- }else if(number.equals("2")){
- sql="UPDATE EMC_AM_EMERGENCY_COMMAND_CAR SET USED_STAT='2',IS_USED='2' where fd_objectid=?";
- }else if(number.equals("3")){
- sql="UPDATE EMC_AM_EMERGENCY_COMMAND_CAR SET USED_STAT='3',IS_USED='2' where fd_objectid=?";
- }
- Connection conn = null;
- PreparedStatement st = null;
- int num=0;
- DbConnection db = new DbConnection();
- try {
- conn = db.getConnection();
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for(int i=0;i<arr.length;i++){
- st.setString(1, arr[i]);
- st.executeUpdate();
- num++;
- }
- if(num==arr.length){
- log.info("发布----num===="+num);
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.OPER_SUCSESS);
- conn.commit();
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.OPER_FAILURE);
- conn.rollback();
- return m;
- }
- }catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 发布消息"
- + sql, e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- }
-
-
- }
|