• new ArrayList json.parse


    package com.sapdev.ws.getoperation;

    import java.text.MessageFormat;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Map;

    import javax.annotation.Resource;
    import javax.jws.WebMethod;
    import javax.jws.WebParam;
    import javax.jws.WebService;
    import javax.xml.ws.WebServiceContext;

    import com.sap.engine.services.webservices.espbase.configuration.ann.dt.AuthenticationDT;
    import com.sap.engine.services.webservices.espbase.configuration.ann.dt.AuthenticationEnumsAuthenticationLevel;
    import com.sap.engine.services.webservices.espbase.configuration.ann.rt.AuthenticationRT;
    import com.sap.me.extension.Services;
    import com.sapdev.service.LogicServiceInterface;
    import com.sapdev.service.dto.LogicQueryResponse;
    import com.sapdev.service.dto.SqlQueryRequest;

    import net.sf.json.JSONArray;
    import net.sf.json.JSONObject;

    @AuthenticationDT(authenticationLevel = AuthenticationEnumsAuthenticationLevel.BASIC)
    @AuthenticationRT(AuthenticationMethod = "sapsp:HTTPBasic")
    @WebService
    public class FirstOperationService {
        @Resource
        protected WebServiceContext wsContext;
        //private final String GET_OPERATION_OBJECT = "SELECT * FROM Z_DIALOG WHERE DIALOG_ID = ''{0}''";
        private final String GET_OPERATION_OBJECT = "SELECT operation,description,revision FROM operation WHERE status_bo =''StatusBO:{0},201'' ORDER BY operation";

        @WebMethod
        public String getOperation(@WebParam(name = "opRequest") OperationRequest opRequest) throws Exception {

            String site = opRequest.getSite();
            String sqls = MessageFormat.format(GET_OPERATION_OBJECT, site);
            LogicServiceInterface lservice = Services.getService("com.sapdev.service", "LogicService", site);
            // LogicService lservice = new LogicService();s
            SqlQueryRequest sqlrequest = new SqlQueryRequest();
            sqlrequest.setSql(sqls);
            LogicQueryResponse LQRresponse = lservice.query(sqlrequest);
            /*OperationResponse operationObj = new OperationResponse();

            List<Map> data = LQRresponse.getRecords();
            List<OperationRecord> operList = new ArrayList<OperationRecord>();
            if (data != null && data.size() > 0) {
                for (Map map : data) {
                    OperationRecord or = new OperationRecord();
                    or.setOperation(map.get("OPERATION").toString());
                    or.setDeacription(map.get("DESCRIPTION").toString());
                    or.setRevision(map.get("REVISION").toString());
                    operList.add(or);
                }
            }
            operationObj.setData(operList);

            return operationObj;*/
            
            JSONObject json = new JSONObject();
            List<Map> data = LQRresponse.getRecords();
            List<OperationRecord> operList = new ArrayList<OperationRecord>();
            JSONArray array = new JSONArray();
            if (data != null && data.size() > 0) {
                for (Map map : data) {
                    JSONObject object = new JSONObject();
                    object.put("operation", map.get("OPERATION").toString());
                    object.put("description", map.get("DESCRIPTION").toString());
                    object.put("revision", map.get("REVISION").toString());
                    
                    array.add(object);
                }
            }        
            json.put("json", array);
            return json.toString();
        }
        
        /*    public static void main(String[] args) throws GetOperationException, Exception {
                GetOperationRequest request=new GetOperationRequest();
                request.setSite("1000");
                GetOperationResponse a=new GetOperationService().getOperation(request);
            }*/
    }

  • 相关阅读:
    【codevs1515】 跳
    【bzoj1227】 SDOI2009—虔诚的墓主人
    【bzoj3505】 Cqoi2014—数三角形
    【bzoj1059】 ZJOI2007—矩阵游戏
    【poj2122】 Optimal Milking
    【poj2455】 Secret Milking Machine
    【poj3084】 Panic Room
    【poj2699】 The Maximum Number of Strong Kings
    【bzoj3218】 a + b Problem
    【bzoj3122】 Sdoi2013—随机数生成器
  • 原文地址:https://www.cnblogs.com/csjoz/p/15560469.html
Copyright © 2020-2023  润新知