nutz 架构何如何地址网址就能访问后台接口:
package com.ruyima.eop.controller.business;
import java.sql.Timestamp;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.nutz.ioc.annotation.InjectName;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.ruyima.eop.pageModel.CellOpen;
import com.ruyima.eop.pageModel.Command;
import com.ruyima.eop.pageModel.Json;
import com.ruyima.eop.pageModel.JsonObjectData;
import com.ruyima.model.BoxCode;
import com.ruyima.model.Tbl_cabinet_command;
import com.ruyima.model.Tbl_cell;
import com.ruyima.util.Const;
import com.ruyima.eop.service.*;
@IocBean
@InjectName
@At("/celltest")
public class CelltestModule {
// private static final Log log = Logs.getLog(ExpressModule.class);
//
@Inject
public ICabinetService cabinetService;
@Inject
protected ICellService cellService;
@Inject
protected ILoggerService loggerService;
// 远程开箱
@At
@Ok("json")
public Object yuanOpenCell(@Param("cell_id") Integer cell_id,
@Param("..") Tbl_cabinet_command cabinetCommand,
@Param("port") Integer port, @Param("openLevel") Integer openLevel,
HttpServletRequest req) {
Json j = new Json();
j.setSucc(false);
j.setMsg("控制指令创建失败!");
try {
if (port == null) {
Tbl_cell cell = cellService.findById(cell_id);
port = cell.getPort();
cabinetCommand.setCabinet_id(cell.getCabinet_id());
}
} catch (Exception e) {
e.printStackTrace();
return j;
}
cabinetCommand
.setCreate_time(new Timestamp(System.currentTimeMillis()));
cabinetCommand.setResult(BoxCode.tbl_cabinet_command.result.TOBESEND);
JsonObjectData jsonData = new JsonObjectData();
jsonData.setLevel(openLevel);
CellOpen cellOpen = new CellOpen();
cellOpen.setPort(port);
jsonData.setCells(new CellOpen[] { cellOpen });
Command command = new Command();
command.setServiceName(Const.REMOTE_SERVICENAME_OPENCELL);
command.setJsonObjectData(jsonData);
String commandJson = JSONObject
.toJSONStringWithDateFormat(command, "yyyy-MM-dd HH:mm:ss",
SerializerFeature.WriteDateUseDateFormat);
cabinetCommand.setCommand(commandJson);
cabinetCommand.setRemark("云端远程开箱");
if (cabinetService.remoteConsole(cabinetCommand) != null) {
j.setSucc(true);
j.setMsg("控制指令创建成功!");
/*
* loggerService.addCabinetRemoteLog(cabinetCommand,
* SessionInfo.getSessionInfo(req));
*/
}
// 记录开箱动作,写入格子操作日志
cellService.addCellPorcessLog(cell_id,
BoxCode.Tbl_cell_process_log.powder_type.PHOMEAPP,
BoxCode.Tbl_cell_process_log.process_code.INTPUT,
BoxCode.Tbl_cell_process_log.user_type.OWNER);
return j;
}
}