李天标 vor 3 Jahren
Ursprung
Commit
f82999c93b

+ 43 - 1
src/main/java/com/szwl/controller/TOrderController.java

@@ -259,14 +259,56 @@ public class TOrderController {
         //  判断是否为外国
         param.setIfForeign(isForeignUser(param.getAdminId()));
         log.info("param:{}", param);
+        TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(param.getAdminId()));
+        if(admin.getType()<2){
+            param.setAdminId(null);
+            if(param.getEquipmentId()!=null){
+                //查机器
+                TEquipment equipment = R.getDataIfSuccess(szwlFeign.findById(param.getEquipmentId()));
+                param.setClientId(equipment.getClientId());
+            }
+        }else {
+            if(admin.getType()==2){
+                //商家
+                if(param.getEquipmentId()!=null){
+                    //查机器
+                    TEquipment equipment = R.getDataIfSuccess(szwlFeign.findById(param.getEquipmentId()));
+                    param.setClientId(equipment.getClientId());
+                }
+            }
+            if(admin.getType()==3){
+                //子账户只能查相对的机器的订单
+                if(param.getEquipmentId()==null){
+                    //找出相对的clientId集合
+
+                }else {
+
+                }
+            }
 
+        }
+        if(StringUtils.isNotEmpty(param.getUsername())){
+            if(param.getUsername().equals("all")){
+                //商家查全部
+                //判断是不是商家账户
+                if(admin.getType()==3){
+                    //查下级账户id集合
+                    List<Long> list = R.getDataIfSuccess(szwlFeign.getAdminIdList(param.getAdminId()));
+                    if(list.size()>0){
+                        param.setAdminIds(list);
+                        param.setAdminId(null);
+                    }
+                }
+            }
+        }
         FgObjectUtil.objectNullOrEmptySel(param, "chartType$");
         ChartColumn chartColumn = new ChartColumn();
         if(StringUtils.isNotEmpty(param.getIfForeign())&&param.getIfForeign().equals("1")){
-            if(StringUtils.isNotEmpty(param.getPayType())&&param.getPayType().equals("All")){
+            if(StringUtils.isNotEmpty(param.getPayType())&&param.getPayType().equals("all")){
                 param.setPayType(null);
             }
             //国外查MYSQL
+
             chartColumn  = orderService.getStatistics(param);
         }else{
             //查去年的数据找数据库

+ 6 - 0
src/main/java/com/szwl/feign/SzwlFeign.java

@@ -7,6 +7,8 @@ import com.szwl.model.entity.TAdminEquipment;
 import com.szwl.model.entity.TEquipment;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 
 import java.util.List;
 
@@ -26,4 +28,8 @@ public interface SzwlFeign {
     ResponseModel<TAdminEquipment>  getClientIdList(String adminId);
     @GetMapping("/tEquipment/findEquipmentByClientId")
     ResponseModel<TEquipment> findEquipmentByClientId(String clientId);
+    @PostMapping("/tEquipment/getEquipmentByNameAndId")
+    ResponseModel<TEquipment> getEquipmentByNameAndId(@RequestBody TEquipment equipment);
+    @PostMapping("/tEquipment/findById")
+    ResponseModel<TEquipment> findById(String id);
 }

+ 12 - 0
src/main/java/com/szwl/mapper/xml/TOrderMapper.xml

@@ -67,6 +67,9 @@
         <if test="merchantId != null and merchantId !=''">
             and a.merchant_id= #{merchantId} and a.type > '2'
         </if>
+        <if test="adminIds != null and adminIds !=''">
+            and a.admin_id in #{adminIds}
+        </if>
         <if test="equipmentId != null and equipmentId !=''">
             <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
                 and a.equipment_id= #{equipmentId} -- 设备id
@@ -122,6 +125,9 @@
         <if test="merchantId != null and merchantId !=''">
             and a.merchant_id= #{merchantId} and a.type > '2'
         </if>
+        <if test="adminIds != null and adminIds !=''">
+            and a.admin_id in #{adminIds}
+        </if>
         <if test="equipmentId != null and equipmentId !=''">
             <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
                 and a.equipment_id= #{equipmentId} -- 设备id
@@ -166,6 +172,9 @@
         <if test="merchantId != null and merchantId !=''">
             and a.merchant_id= #{merchantId} and a.type > '2'
         </if>
+        <if test="adminIds != null and adminIds !=''">
+            and a.admin_id in #{adminIds}
+        </if>
         <if test="equipmentId != null and equipmentId !=''">
             <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
                 and a.equipment_id= #{equipmentId} -- 设备id
@@ -222,6 +231,9 @@
         <if test="merchantId != null and merchantId !=''">
             and a.merchant_id= #{merchantId} and a.type > '2'
         </if>
+        <if test="adminIds != null and adminIds !=''">
+            and a.admin_id in #{adminIds}
+        </if>
         <if test="equipmentId != null and equipmentId !=''">
             <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
                 and a.equipment_id= #{equipmentId} -- 设备id

+ 7 - 0
src/main/java/com/szwl/model/query/StatisticsParam.java

@@ -21,8 +21,12 @@ public class StatisticsParam {
 
     @ApiModelProperty(value="设备id")
     private String equipmentId;
+    @ApiModelProperty(value="设备名")
+    private String equipmentName;
     @ApiModelProperty(value="设备编号")
     private String clientId;
+    @ApiModelProperty(value="商家")
+    private String username;
     @ApiModelProperty(value="开关炉头,开机为1,关机为0")
     private String eqeStatus;
     @ApiModelProperty(value="代理商id")
@@ -34,6 +38,9 @@ public class StatisticsParam {
     @ApiModelProperty(value="地址id")
     private List<Long> areaIds;
 
+    @ApiModelProperty(value="")
+    private List<Long> adminIds;
+
     @ApiModelProperty(value="开始日期")
     private String startDate;
 

+ 1 - 1
src/main/java/com/szwl/model/query/TCoinOrderParam.java

@@ -5,8 +5,8 @@
 
 package com.szwl.model.query;
 
-import com.szwl.common.myAnnotation.CamelCaseToUnderscore;
 import com.szwl.model.entity.TCoinOrder;
+import com.szwl.myAnnotation.CamelCaseToUnderscore;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.NoArgsConstructor;

+ 2 - 1
src/main/java/com/szwl/model/query/TOrderParam.java

@@ -5,8 +5,8 @@
 
 package com.szwl.model.query;
 
-import com.szwl.common.myAnnotation.CamelCaseToUnderscore;
 import com.szwl.model.entity.TOrder;
+import com.szwl.myAnnotation.CamelCaseToUnderscore;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
@@ -60,6 +60,7 @@ public class TOrderParam extends TOrder {
 	private Integer type_gt;
 
 	private List equipmentId_inList;
+	private List adminId_inList;
 /*==================================以上是自动生成部分字段======================================*/
 
 }

+ 11 - 0
src/main/java/com/szwl/myAnnotation/CamelCaseToUnderscore.java

@@ -0,0 +1,11 @@
+package com.szwl.myAnnotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.ANNOTATION_TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface CamelCaseToUnderscore {
+
+}

+ 38 - 0
src/main/java/com/szwl/myAnnotation/CamelCaseToUnderscoreFormatAnnotationFormatterFactory.java

@@ -0,0 +1,38 @@
+package com.szwl.myAnnotation;
+
+import org.springframework.format.AnnotationFormatterFactory;
+import org.springframework.format.Parser;
+import org.springframework.format.Printer;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class CamelCaseToUnderscoreFormatAnnotationFormatterFactory 
+implements AnnotationFormatterFactory<CamelCaseToUnderscore> {//①指定可以解析/格式化的字段注解类型
+	private final Set<Class<?>> fieldTypes;  
+    private final CamelCaseToUnderscoreFormatter formatter;  
+    public CamelCaseToUnderscoreFormatAnnotationFormatterFactory() {  
+        Set<Class<?>> set = new HashSet<Class<?>>();  
+        set.add(String.class);  
+        this.fieldTypes = set;  
+        this.formatter = new CamelCaseToUnderscoreFormatter();//此处使用之前定义的Formatter实现  
+    }  
+    
+    //②指定可以被解析/格式化的字段类型集合  
+    @Override  
+    public Set<Class<?>> getFieldTypes() {  
+        return fieldTypes;  
+    }  
+    //③根据注解信息和字段类型获取解析器  
+    @Override  
+    public Parser<?> getParser(CamelCaseToUnderscore annotation, Class<?> fieldType) {
+        return formatter;  
+    }  
+    //④根据注解信息和字段类型获取格式化器  
+    @Override     
+    public Printer<?> getPrinter(CamelCaseToUnderscore annotation, Class<?> fieldType) {
+        return formatter;  
+    }  
+
+
+}

+ 50 - 0
src/main/java/com/szwl/myAnnotation/CamelCaseToUnderscoreFormatter.java

@@ -0,0 +1,50 @@
+package com.szwl.myAnnotation;
+
+import org.apache.commons.lang.StringUtils;
+import org.springframework.format.Formatter;
+
+import java.text.ParseException;
+import java.util.Locale;
+
+public class CamelCaseToUnderscoreFormatter implements Formatter<String> {
+
+	@Override
+	public String print(String paramT, Locale paramLocale) {
+		return convertCamelCaseToUnderscore(paramT);
+	}
+
+	@Override
+	public String parse(String paramString, Locale paramLocale) throws ParseException {
+		// TODO Auto-generated method stub
+		return convertCamelCaseToUnderscore(paramString);
+	}
+
+	public static String convertCamelCaseToUnderscore(String str) {
+		String result = "";
+		String[] parts = str.split(",");
+		for (int i = 0; i < parts.length; i++) {
+			String part = parts[i];
+			String[] fields = part.split(" ");
+			for (String field : fields) {
+				field = field.trim();
+				String _str = StringUtils.upperCase(field);
+				if(!"ASC".equals(StringUtils.upperCase(field))&&!"DESC".equals(StringUtils.upperCase(field))) {
+					String[] strings = StringUtils.splitByCharacterTypeCamelCase(field);
+					_str = StringUtils.join(strings, "_");
+					_str = StringUtils.upperCase(_str);
+				}
+				System.out.println(_str);
+				result = result + " " + _str;
+			}
+			if(i+1!= parts.length) {
+				result = result + ",";
+			}
+		}
+		return result;
+	}
+	
+//	public static void main(String[] args) {
+//		String result = convertCamelCaseToUnderscore("myFi desc,myEntity asc");
+//		System.out.println(result);
+//	}
+}

+ 6 - 0
src/main/java/com/szwl/service/es/EsTOrderService.java

@@ -203,6 +203,9 @@ public class EsTOrderService extends EsBaseService<TOrder, TOrderParam> {
                 tOrderParam.setMerchantId(param.getMerchantId());
                 tOrderParam.setType_gt(2);
             }
+            if(param.getAdminIds().size()>0){
+                tOrderParam.setAdminId_inList(param.getAdminIds());
+            }
 
             boolQueryBuilder = this.getParam2QueryBuilder(tOrderParam);
 
@@ -218,6 +221,9 @@ public class EsTOrderService extends EsBaseService<TOrder, TOrderParam> {
             tCoinOrderParam.setCreateDate_start(start);
             tCoinOrderParam.setCreateDate_end(end);
             tCoinOrderParam.setClientId_inList(clientIdList);
+            if(param.getAdminIds().size()>0){
+                tCoinOrderParam.setAdminId_inList(param.getAdminIds());
+            }
             if(StringUtils.isNotEmpty(param.getAdminId())){ // 所属商家id
                 tCoinOrderParam.setAdminId(Long.parseLong(param.getAdminId()));
             }