package com.zy.acs.manager.core.integrate.charge; import com.ghgande.j2mod.modbus.facade.ModbusTCPMaster; import com.zy.acs.charge.ChargeCoreService; import com.zy.acs.charge.model.ChargerStatus; import com.zy.acs.common.constant.RedisConstant; import com.zy.acs.common.utils.RedisSupport; import com.zy.acs.framework.common.R; import com.zy.acs.manager.common.annotation.IntegrationAuth; import com.zy.acs.manager.core.domain.type.NamespaceType; import com.zy.acs.manager.core.service.ChargeService; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @Api(tags = "Open Api") @RestController @RequestMapping("/api/open") public class ChargeTestController { private final RedisSupport redis = RedisSupport.defaultRedisSupport; @Autowired private ChargeService chargeService; @Autowired private ChargeCoreService chargeCoreService; @IntegrationAuth(name = NamespaceType.RCS_STA_QUERY) @GetMapping("/charge/{type}") public R test(@PathVariable("type") String type){ ModbusTCPMaster modbusTCPMaster = chargeService.get(type); ChargerStatus status = chargeCoreService.getStatus(modbusTCPMaster); return R.ok(status); } @IntegrationAuth(name = NamespaceType.RCS_STA_QUERY) @GetMapping("/write/{agvId}/{type}") public R test2(@PathVariable("agvId") Integer agvId,@PathVariable("type") Integer type){ redis.setMap(RedisConstant.AGV_CHARGE_FLAG, agvId+"", type); return R.ok(); } }