1、flyway增加V4.1,新增表t_region

2、修改基础设施页面地图中根据区域聚合查询的方法,区市信息以t_region表为准
This commit is contained in:
yitonglei 2022-07-22 11:22:39 +08:00
parent 1ebd70df03
commit 6f72e38a56
4 changed files with 57 additions and 10 deletions

View File

@ -0,0 +1,25 @@
DROP TABLE IF EXISTS `t_region`;
CREATE TABLE `t_region` (
`id` int(0) NOT NULL AUTO_INCREMENT,
`region_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`region_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`channel_count` int(0) NULL DEFAULT 0,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of t_region
-- ----------------------------
INSERT INTO `t_region` VALUES (1, '市南区', '370202', 4367);
INSERT INTO `t_region` VALUES (2, '市北区', '370203', 7193);
INSERT INTO `t_region` VALUES (3, '西海岸新区', '370211', 41402);
INSERT INTO `t_region` VALUES (4, '崂山区', '370212', 19573);
INSERT INTO `t_region` VALUES (5, '李沧区', '370213', 5702);
INSERT INTO `t_region` VALUES (6, '城阳区', '370214', 14565);
INSERT INTO `t_region` VALUES (7, '即墨区', '370215', 13794);
INSERT INTO `t_region` VALUES (8, '高新区', '370271', 0);
INSERT INTO `t_region` VALUES (9, '胶州市', '370281', 14874);
INSERT INTO `t_region` VALUES (10, '平度市', '370283', 16383);
INSERT INTO `t_region` VALUES (11, '莱西市', '370285', 10046);
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -54,15 +54,12 @@ public interface CameraOrgenizationMapper extends BaseDao<CameraOrganization> {
@Update("UPDATE t_camera_organization SET channelCount = #{channelCount} where orgaid = #{orgaId}") @Update("UPDATE t_camera_organization SET channelCount = #{channelCount} where orgaid = #{orgaId}")
void editChannelCount(@Param("channelCount") Integer channelCount,@Param("orgaId") Integer orgaId); void editChannelCount(@Param("channelCount") Integer channelCount,@Param("orgaId") Integer orgaId);
@Update(" UPDATE t_region a inner join \n" +
" (SELECT COUNT(idt_camera_channel) AS channel_count,region_code FROM t_camera_channel GROUP BY region_code) b\n" +
" ON a.region_code = b.region_code set a.channel_count = b.channel_count")
void updateRegionChannelCount(); void updateRegionChannelCount();
@Select(" SELECT id FROM t_camera_organization WHERE orgaid >(SELECT a.orgaid FROM t_camera_organization a INNER JOIN \n" + // @Select(" SELECT id FROM t_camera_organization WHERE orgaid >(SELECT a.orgaid FROM t_camera_organization a INNER JOIN \n" +
"\t(\n" + // "\t(\n" +
"\t\tSELECT parent_id FROM t_camera_channel ORDER BY idt_camera_channel desc LIMIT 1\n" + // "\t\tSELECT parent_id FROM t_camera_channel ORDER BY idt_camera_channel desc LIMIT 1\n" +
"\t) b ON a.id = b.parent_id \n" + // "\t) b ON a.id = b.parent_id \n" +
") ORDER BY orgaid ASC ") // ") ORDER BY orgaid ASC ")
List<Map> listOrgenization2(); // List<Map> listOrgenization2();
} }

View File

@ -215,7 +215,11 @@
<select id="selectChannelNumByRegion" resultType="java.util.Map"> <select id="selectChannelNumByRegion" resultType="java.util.Map">
SELECT ROUND(COUNT(idt_camera_channel) /10000,1) AS channelCount,region_code,region_name FROM t_camera_channel WHERE region_name is not null GROUP BY region_code,region_name SELECT ROUND(COUNT(a.idt_camera_channel) /10000,1) AS channelCount,b.region_code,b.region_name
FROM t_camera_channel a INNER JOIN t_region b
ON a.region_code = b.region_code
WHERE a.region_name is not null or a.region_name != ''
GROUP BY b.region_code,b.region_name
</select> </select>
<insert id="batchSaveMtmLabel" parameterType="java.util.List"> <insert id="batchSaveMtmLabel" parameterType="java.util.List">

View File

@ -29,4 +29,25 @@
) )
</foreach> </foreach>
</insert> </insert>
<update id="updateRegionChannelCount">
UPDATE t_region a
INNER JOIN
(
SELECT COUNT(idt_camera_channel) AS channel_count,region_code FROM t_camera_channel GROUP BY region_code
) b
ON a.region_code = b.region_code
SET a.channel_count = b.channel_count
</update>
<!-- <select id="listOrgenization2" resultType="java.util.Map">-->
<!-- SELECT id FROM t_camera_organization-->
<!-- WHERE orgaid &gt;-->
<!-- (SELECT a.orgaid FROM t_camera_organization a INNER JOIN-->
<!-- (-->
<!-- SELECT parent_id FROM t_camera_channel ORDER BY idt_camera_channel desc LIMIT 1-->
<!-- ) b-->
<!-- ON a.id = b.parent_id-->
<!-- ) ORDER BY orgaid ASC-->
<!-- </select>-->
</mapper> </mapper>