作者 钟来

坤泰日志功能对接

@@ -70,6 +70,16 @@ public class IotTerminal extends MyBaseEntity implements Serializable @@ -70,6 +70,16 @@ public class IotTerminal extends MyBaseEntity implements Serializable
70 private String operation_token; 70 private String operation_token;
71 @ApiModelProperty("管理用户id") 71 @ApiModelProperty("管理用户id")
72 private Long sys_user_id; 72 private Long sys_user_id;
  73 + @ApiModelProperty("排序")
  74 + private Integer order_by;
  75 +
  76 + public Integer getOrder_by() {
  77 + return order_by;
  78 + }
  79 +
  80 + public void setOrder_by(Integer order_by) {
  81 + this.order_by = order_by;
  82 + }
73 83
74 public Long getSys_user_id() { 84 public Long getSys_user_id() {
75 return sys_user_id; 85 return sys_user_id;
@@ -19,6 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -19,6 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
19 <result property="create_time" column="create_time" /> 19 <result property="create_time" column="create_time" />
20 <result property="sensor_number" column="sensor_number" /> 20 <result property="sensor_number" column="sensor_number" />
21 <result property="sys_user_id" column="sys_user_id" /> 21 <result property="sys_user_id" column="sys_user_id" />
  22 + <result property="order_by" column="order_by" />
22 <association property="userTerminalGroupRelation" column="id" javaType="UserTerminalGroupRelation" resultMap="userTerminalGroupRelationResult" /> 23 <association property="userTerminalGroupRelation" column="id" javaType="UserTerminalGroupRelation" resultMap="userTerminalGroupRelationResult" />
23 <association property="iotDevice" column="device_id" javaType="IotDevice" resultMap="iotDeviceResult" /> 24 <association property="iotDevice" column="device_id" javaType="IotDevice" resultMap="iotDeviceResult" />
24 </resultMap> 25 </resultMap>
@@ -96,7 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -96,7 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
96 ${params.dataScope} 97 ${params.dataScope}
97 </if> 98 </if>
98 </where> 99 </where>
99 - order by a.create_time desc 100 + order by a.create_time desc,a.order_by asc
100 </select> 101 </select>
101 102
102 <select id="selectIotTerminalListByUserId" parameterType="IotTerminal" resultMap="IotTerminalResult"> 103 <select id="selectIotTerminalListByUserId" parameterType="IotTerminal" resultMap="IotTerminalResult">
@@ -139,6 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -139,6 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
139 <if test="mqtt_username != null">mqtt_username,</if> 140 <if test="mqtt_username != null">mqtt_username,</if>
140 <if test="data_update_time != null">data_update_time,</if> 141 <if test="data_update_time != null">data_update_time,</if>
141 <if test="sys_user_id != null and sys_user_id != ''">sys_user_id,</if> 142 <if test="sys_user_id != null and sys_user_id != ''">sys_user_id,</if>
  143 + <if test="order_by != null and order_by != ''">order_by,</if>
142 </trim> 144 </trim>
143 <trim prefix="values (" suffix=")" suffixOverrides=","> 145 <trim prefix="values (" suffix=")" suffixOverrides=",">
144 <if test="device_id != null">#{device_id},</if> 146 <if test="device_id != null">#{device_id},</if>
@@ -151,6 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -151,6 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
151 <if test="mqtt_username != null">#{mqtt_username},</if> 153 <if test="mqtt_username != null">#{mqtt_username},</if>
152 <if test="data_update_time != null">#{data_update_time},</if> 154 <if test="data_update_time != null">#{data_update_time},</if>
153 <if test="sys_user_id != null">#{sys_user_id},</if> 155 <if test="sys_user_id != null">#{sys_user_id},</if>
  156 + <if test="order_by != null">#{order_by},</if>
154 </trim> 157 </trim>
155 </insert> 158 </insert>
156 159
@@ -166,6 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -166,6 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
166 <if test="mqtt_username != null">mqtt_username = #{mqtt_username},</if> 169 <if test="mqtt_username != null">mqtt_username = #{mqtt_username},</if>
167 <if test="data_update_time != null">data_update_time = #{data_update_time},</if> 170 <if test="data_update_time != null">data_update_time = #{data_update_time},</if>
168 <if test="sys_user_id != null">sys_user_id = #{sys_user_id},</if> 171 <if test="sys_user_id != null">sys_user_id = #{sys_user_id},</if>
  172 + <if test="order_by != null">order_by = #{order_by},</if>
169 </trim> 173 </trim>
170 where id = #{id} 174 where id = #{id}
171 </update> 175 </update>
@@ -185,7 +189,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -185,7 +189,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
185 </foreach> 189 </foreach>
186 </delete> 190 </delete>
187 <select id="selectNotUserIotTerminalListByImei" parameterType="String" resultMap="IotTerminalResult"> 191 <select id="selectNotUserIotTerminalListByImei" parameterType="String" resultMap="IotTerminalResult">
188 - SELECT a.* FROM `iot_terminal` a LEFT JOIN `user_terminal_group_relation` b ON a.`id`=b.`iot_terminal_id` WHERE b.user_info_id is null AND a.`device_id`= #{device_id} 192 + SELECT a.* FROM `iot_terminal` a LEFT JOIN `user_terminal_group_relation` b ON a.`id`=b.`iot_terminal_id` WHERE b.user_info_id is null AND a.`device_id`= #{device_id} ORDER BY `order_by` ASC
189 </select> 193 </select>
190 194
191 </mapper> 195 </mapper>
@@ -129,19 +129,59 @@ public class TestController { @@ -129,19 +129,59 @@ public class TestController {
129 @ApiOperation("修改多维表格数据") 129 @ApiOperation("修改多维表格数据")
130 @RequestMapping(value = "upExcelData") 130 @RequestMapping(value = "upExcelData")
131 public AjaxResult upExcelData(Integer system_type,String log_id,String excel_id,String sheet_id,@RequestBody String sub_data) throws IOException { 131 public AjaxResult upExcelData(Integer system_type,String log_id,String excel_id,String sheet_id,@RequestBody String sub_data) throws IOException {
132 - LogExcelSub logExcelSub = new LogExcelSub();  
133 - logExcelSub.setExcel_id(excel_id);  
134 - logExcelSub.setSheet_id(sheet_id);  
135 - logExcelSub.setSystem_type(system_type);  
136 - logExcelSub.setLog_id(log_id);  
137 - Long nub = publicService.getObjectListTotle(logExcelSub,null);  
138 132
139 - logExcelSub.setSub_data(sub_data);  
140 - if(0==nub) 133 +
  134 + String[] ls = log_id.split(" ");
  135 + if(ls.length>1) //表示有多个数据提交
141 { 136 {
142 - return AjaxResult.success(publicService.insert(logExcelSub)); 137 + JSONObject jsonObject = JSONObject.parseObject(sub_data);
  138 +
  139 + for (int i=0;i<ls.length;i++)
  140 + {
  141 + LogExcelSub logExcelSub = new LogExcelSub();
  142 + logExcelSub.setExcel_id(excel_id);
  143 + logExcelSub.setSheet_id(sheet_id);
  144 + logExcelSub.setSystem_type(system_type);
  145 + String l = ls[i];
  146 + logExcelSub.setLog_id(l);
  147 + Long nub = publicService.getObjectListTotle(logExcelSub,null);
  148 + JSONObject sub_data_json = new JSONObject();
  149 + for (String k:jsonObject.keySet())
  150 + {
  151 + String values = jsonObject.getString( k);
  152 + String[] vss = values.split(" ");
  153 + if(vss.length==ls.length)
  154 + {
  155 + sub_data_json.put(k,vss[i]);
  156 + }else {
  157 + sub_data_json.put(k,"");
  158 + }
  159 +
  160 + }
  161 + logExcelSub.setSub_data(sub_data_json.toJSONString());
  162 + if(0==nub)
  163 + {
  164 + publicService.insert(logExcelSub);
  165 + }else {
  166 + publicService.updateObject(logExcelSub,"system_type,excel_id,sheet_id,log_id");
  167 + }
  168 + }
  169 + return AjaxResult.success(ls.length);
  170 + }else {
  171 + LogExcelSub logExcelSub = new LogExcelSub();
  172 + logExcelSub.setExcel_id(excel_id);
  173 + logExcelSub.setSheet_id(sheet_id);
  174 + logExcelSub.setSystem_type(system_type);
  175 + logExcelSub.setLog_id(log_id);
  176 + Long nub = publicService.getObjectListTotle(logExcelSub,null);
  177 + logExcelSub.setSub_data(sub_data);
  178 + if(0==nub)
  179 + {
  180 + return AjaxResult.success(publicService.insert(logExcelSub));
  181 + }
  182 + return AjaxResult.success(publicService.updateObject(logExcelSub,"system_type,excel_id,sheet_id,log_id"));
143 } 183 }
144 - return AjaxResult.success(publicService.updateObject(logExcelSub,"system_type,excel_id,sheet_id,log_id")); 184 +
145 } 185 }
146 186
147 @ApiOperation("查询多维表格数据") 187 @ApiOperation("查询多维表格数据")
@@ -96,7 +96,7 @@ public class UserTerminalGroupRelationController extends BaseController @@ -96,7 +96,7 @@ public class UserTerminalGroupRelationController extends BaseController
96 { 96 {
97 stringBuffer.append(" AND b.product_id="+product_id); 97 stringBuffer.append(" AND b.product_id="+product_id);
98 } 98 }
99 - List<Map<String,Object>> list = publicService.getObjectListBySQL("SELECT b.*,a.id group_id,c.`things_model_value` host_things_model_value,c.`things_model_config` host_things_model_config FROM `user_terminal_group_relation` a LEFT JOIN `iot_terminal` b ON a.`iot_terminal_id`=b.`id` LEFT JOIN `iot_device` c ON b.`device_id`=c.`client_id` WHERE a.user_info_id="+SecurityUtils.getUserId().intValue()+stringBuffer); 99 + List<Map<String,Object>> list = publicService.getObjectListBySQL("SELECT b.*,a.id group_id,c.`things_model_value` host_things_model_value,c.`things_model_config` host_things_model_config FROM `user_terminal_group_relation` a LEFT JOIN `iot_terminal` b ON a.`iot_terminal_id`=b.`id` LEFT JOIN `iot_device` c ON b.`device_id`=c.`client_id` WHERE a.user_info_id="+SecurityUtils.getUserId().intValue()+stringBuffer+" order by iot_terminal_group_id asc,b.order_by asc");
100 return AjaxResult.success(list); 100 return AjaxResult.success(list);
101 } 101 }
102 102