java110 3 years ago
parent
commit
0065477ef8

+ 10 - 0
java110-bean/src/main/java/com/java110/dto/chargeMachine/ChargeMachineDto.java

@@ -33,6 +33,8 @@ public class ChargeMachineDto extends PageDto implements Serializable {
 
     private String factoryName;
 
+    private String qrCode;
+
 
     public String getHeartbeatTime() {
         return heartbeatTime;
@@ -130,4 +132,12 @@ public class ChargeMachineDto extends PageDto implements Serializable {
     public void setFactoryName(String factoryName) {
         this.factoryName = factoryName;
     }
+
+    public String getQrCode() {
+        return qrCode;
+    }
+
+    public void setQrCode(String qrCode) {
+        this.qrCode = qrCode;
+    }
 }

+ 37 - 0
service-common/src/main/java/com/java110/common/cmd/chargeMachine/ListChargeMachineCmd.java

@@ -22,8 +22,11 @@ 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 +60,9 @@ public class ListChargeMachineCmd extends Cmd {
     @Autowired
     private IChargeMachineV1InnerServiceSMO chargeMachineV1InnerServiceSMOImpl;
 
+    @Autowired
+    private ISmallWeChatInnerServiceSMO smallWeChatInnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         super.validatePageInfo(reqJson);
@@ -74,6 +80,7 @@ public class ListChargeMachineCmd extends Cmd {
 
         if (count > 0) {
             chargeMachineDtos = chargeMachineV1InnerServiceSMOImpl.queryChargeMachines(chargeMachineDto);
+            freshQrCodeUrl(chargeMachineDtos);
         } else {
             chargeMachineDtos = new ArrayList<>();
         }
@@ -84,4 +91,34 @@ public class ListChargeMachineCmd extends Cmd {
 
         cmdDataFlowContext.setResponseEntity(responseEntity);
     }
+
+    /**
+     * 充电桩二维码
+     *
+     * @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
+            );
+        }
+    }
 }