123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- package com.sinosoft.nwyj.integration.hessian;
- import java.io.InputStream;
- import java.net.MalformedURLException;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.GregorianCalendar;
- import java.util.List;
- import java.util.Properties;
- import javax.ws.rs.POST;
- import javax.ws.rs.Path;
- import javax.ws.rs.ProduceMime;
- import javax.xml.datatype.DatatypeConfigurationException;
- import javax.xml.datatype.DatatypeFactory;
- import org.aspectj.lang.JoinPoint;
- import org.aspectj.lang.annotation.Aspect;
- import org.aspectj.lang.annotation.Before;
- import org.springframework.stereotype.Component;
- import com.caucho.hessian.client.HessianProxyFactory;
- import com.formaction.Utils;
- import com.persistence.service.JDBCHelper;
- import com.persistence.service.exception.PersistenceException;
- import com.sinosoft.common.util.DateUtil;
- import com.sinosoft.nwyj.integration.cxf.dc.querySingleTabData.QuerySingleTabDataRequest;
- import com.sinosoft.nwyj.integration.cxf.dc.querySingleTabData.QuerySingleTabDataResponse;
- import com.sinosoft.nwyj.integration.cxf.powerSupplyTask.PowerSupplyTask;
- @Aspect
- @Component
- public class GpsTaskWebService {
- @Before("execution(* com.formaction.service.CRUDServiceImpl.update(..))")
- public void PublishPowerSupplyTask(JoinPoint joinPoint) {
- // 取得参数
- String params = (String) joinPoint.getArgs()[0];
- String taskPublish = Utils.getParameter("taskPublish", params) == null ? ""
- : Utils.getParameter("taskPublish", params);
- // 需要调用webservice
- if (!taskPublish.equals("")) {
- // 保供电id
- String id = Utils.getParameter("FD_OBJECTID610", params) == null ? ""
- : Utils.getParameter("FD_OBJECTID610", params);
- String url = getPath("path") + "/hessian/hessianService";
- HessianProxyFactory factory = new HessianProxyFactory();
- HessianService hs;
- try {
- hs = (HessianService) factory.create(HessianService.class, url);
- // 取得保供电实体
- PowerSupplyTask pst = getPst(id);
- hs.PublishPowerSupplyTask(pst);
- } catch (MalformedURLException e) {
- e.printStackTrace();
- } catch (PersistenceException e) {
- e.printStackTrace();
- } catch (DatatypeConfigurationException e) {
- e.printStackTrace();
- }
- }
- }
- // 根据保供电id获取保供电任务实体
- public PowerSupplyTask getPst(String id) throws PersistenceException, DatatypeConfigurationException {
- if (id == null || id.equals("")) {
- return null;
- }
- PowerSupplyTask pst = null;
- String sql = "select a.FD_OBJECTID,PROGRAM_NAME,GPS_LEVEL ,GPS_AREA_NAME,START_TIME, END_TIME,IMPLEMENT_TIME,"
- + "INPUT_UNIT_ID,b.savename,a.INPUT_UNIT_ID,c.saphrorgid from ECM_GPS_PROGRAM_MANAGEMENT a "
- + "left join sys_comm_fileimg b on a.fd_objectid = b.mainid left join sys_department c on c.dept_id=a.INPUT_UNIT_ID " + "where a.fd_objectid ='" + id + "'";
- JDBCHelper jdbc = new JDBCHelper();
- jdbc.begin();
- ArrayList<String[]> list = jdbc.getSearchResult(610, sql);
- int i = 0;
- String filePath = "";
- GregorianCalendar calendar = new GregorianCalendar();
- if (list != null && list.size() > 0) {
- pst = new PowerSupplyTask();
- for (String[] s : list) {
- if (i == 0) {
- pst.setTaskId(s[0]);
- pst.setTaskName(s[1]);
- pst.setTaskLevel(s[2]);
- Date startDate = DateUtil.format(s[4], DateUtil.formatStr_yyyyMMddHHmmssS);
- calendar.setTime(startDate);
- pst.setStartDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));// W3C—XML日期格式
- Date endDate = DateUtil.format(s[5], DateUtil.formatStr_yyyyMMddHHmmssS);
- calendar.setTime(endDate);
- pst.setEndDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));// W3C—XML日期格式
- Date yearMon = DateUtil.format(s[6], DateUtil.YYYY_MM);
- calendar.setTime(yearMon);
- pst.setPlanYearMon(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));// W3C—XML日期格式
- pst.setPowerSupplyArea(s[7]);
- pst.setBusinessCode(s[10]);
- }
- filePath += s[8] + ";";
- i++;
- }
- if (!filePath.equals("")) {
- filePath = filePath.substring(0, filePath.length() - 1);
- }
- //pst.setDocument(filePath);
- }
- jdbc.commit();
- return pst;
- }
- // 获取配置的webservice路径的方法
- public static String getPath(String key) {
- String path = "";
- if (key == null || key.equals("")) {
- return "";
- }
- Properties prop = new Properties();
- try {
- // 读取属性文件a.properties
- InputStream in = GpsTaskWebService.class.getClassLoader()
- .getResourceAsStream("webserviceProperty.properties");
- prop.load(in); /// 加载属性列表
- path = prop.getProperty(key);
- in.close();
- } catch (Exception e) {
- System.out.println(e);
- }
- return path;
- }
- /**
- * 查询95598来电
- *
- * @param startDate
- * 开始时间 yyyy-MM-dd hh24:mm:ss
- * @param endDate
- * 结束时间yyyy-MM-dd hh24:mm:ss
- * @param organizationId
- * 组织ID mrid
- * @return json数据
- */
- public String call95598(String startDate, String endDate, List<String> organizationId) {
- String url = getPath("path") + "/hessian/hessianService";
- HessianProxyFactory factory = new HessianProxyFactory();
- HessianService hs;
- String jsonResult = null;
- try {
- hs = (HessianService) factory.create(HessianService.class, url);
- jsonResult = hs.calls95598(startDate, endDate, organizationId);
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- return jsonResult;
- }
-
- public String getCSGRDBDataInfo(String compId,String startTime,String endTime){
- String url = getPath("path") + "/hessian/hessianService";
- HessianProxyFactory factory = new HessianProxyFactory();
- HessianService hs;
- try {
- hs = (HessianService) factory.create(HessianService.class, url);
- String jsonStr=hs.getCSGRDBDataInfo(compId, startTime, endTime);
-
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return jsonStr;
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * hessian服务:
- * 获取设备台账数据
- */
- public QuerySingleTabDataResponse querySingleTabData(QuerySingleTabDataRequest request){
- String url = getPath("path") + "/hessian/hessianService";
- HessianProxyFactory factory = new HessianProxyFactory();
- HessianService hs;
- try {
- hs = (HessianService) factory.create(HessianService.class, url);
- QuerySingleTabDataResponse response=hs.querySingleTabData(request);
- return response;
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- return null;
- }
- }
|