Your Name
2023-03-17 e20c58a63d3827d9c55cd5f387568fb0916b9590
service-common/src/main/java/com/java110/common/cmd/chargeMachine/ListChargeMachineCmd.java
@@ -16,14 +16,18 @@
package com.java110.common.cmd.chargeMachine;
import com.alibaba.fastjson.JSONObject;
import com.java110.common.charge.IChargeCore;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.annotation.Java110Transactional;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.dto.smallWeChat.SmallWeChatDto;
import com.java110.intf.common.IChargeMachineV1InnerServiceSMO;
import com.java110.intf.store.ISmallWeChatInnerServiceSMO;
import com.java110.po.chargeMachine.ChargeMachinePo;
import com.java110.utils.cache.UrlCache;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
@@ -57,6 +61,12 @@
    @Autowired
    private IChargeMachineV1InnerServiceSMO chargeMachineV1InnerServiceSMOImpl;
    @Autowired
    private ISmallWeChatInnerServiceSMO smallWeChatInnerServiceSMOImpl;
    @Autowired
    private IChargeCore chargeCoreImpl;
    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
        super.validatePageInfo(reqJson);
@@ -74,6 +84,10 @@
        if (count > 0) {
            chargeMachineDtos = chargeMachineV1InnerServiceSMOImpl.queryChargeMachines(chargeMachineDto);
            freshQrCodeUrl(chargeMachineDtos);
            // todo  查询设备是否在线
            queryMachineState(chargeMachineDtos);
        } else {
            chargeMachineDtos = new ArrayList<>();
        }
@@ -84,4 +98,43 @@
        cmdDataFlowContext.setResponseEntity(responseEntity);
    }
    private void queryMachineState(List<ChargeMachineDto> chargeMachineDtos) {
        if(chargeMachineDtos == null || chargeMachineDtos.size() < 1 || chargeMachineDtos.size() > 10){
            return ;
        }
        chargeCoreImpl.queryChargeMachineState(chargeMachineDtos);
    }
    /**
     * 充电桩二维码
     *
     * @param chargeMachineDtos
     */
    private void freshQrCodeUrl(List<ChargeMachineDto> chargeMachineDtos) {
        if (chargeMachineDtos == null || chargeMachineDtos.size() < 1) {
            return;
        }
        SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
        smallWeChatDto.setObjId(chargeMachineDtos.get(0).getCommunityId());
        smallWeChatDto.setWeChatType(SmallWeChatDto.WECHAT_TYPE_PUBLIC);
        List<SmallWeChatDto> smallWeChatDtos = smallWeChatInnerServiceSMOImpl.querySmallWeChats(smallWeChatDto);
        String appId = "";
        if (smallWeChatDtos != null || smallWeChatDtos.size() > 0) {
            appId = smallWeChatDtos.get(0).getAppId();
        }
        String ownerUrl = UrlCache.getOwnerUrl();
        for (ChargeMachineDto chargeMachineDto : chargeMachineDtos) {
            chargeMachineDto.setQrCode(ownerUrl + "/#/pages/machine/machineToCharge?machineId="
                    + chargeMachineDto.getMachineId()
                    + "&communityId=" + chargeMachineDto.getCommunityId()
                    + "&wAppId=" + appId
            );
        }
    }
}