csjoz11

导航

统计

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);
        }*/
}

posted on   csjoz11  阅读(55)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示