From dcfa1ebe1e5c7d5eaa4a92edd72156c2714176eb Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 01 十二月 2022 20:41:58 +0800 Subject: [PATCH] 1 --- JavaCode/cs/TabInfo.cs | 23 JavaCode/BsTemplate/GeoEntity.java | 20 JavaCode/Properties/AssemblyInfo.cs | 36 ExportMap/Sources/geo.qpt | 591 +++++++ JavaCode/DLL/Mono.Security.dll | 0 JavaCode/SysTemplate/Mapper.java | 96 + JavaCode/Program.cs | 22 JavaCode/FrmMain.Designer.cs | 76 + JavaCode/SysTemplate/Entity.java | 11 JavaCode/FrmMyBatisPlus.cs | 397 +++++ ExportMap/Sources/geo.qgz | 0 JavaCode/SysTemplate/Mapper.xml | 74 + JavaCode/DLL/Npgsql.dll | 0 JavaCode/SysTemplate/Controller.java | 253 +++ JavaCode/BsTemplate/Mapper.java | 17 JavaCode/FrmSys.resx | 120 + JavaCode/FrmSys.Designer.cs | 410 +++++ JavaCode/FrmMain.cs | 34 JavaCode/Properties/Settings.settings | 7 JavaCode/FrmMyBatisPlus.resx | 120 + JavaCode/Properties/Resources.Designer.cs | 71 JavaCode/BsTemplate/Entity.java | 20 JavaCode/Properties/Settings.Designer.cs | 30 JavaCode/cs/ModelHandler.cs | 83 + JavaCode/FrmMain.resx | 120 + ExportMap/Sources/geo_render.py | 127 + JavaCode/App.config | 12 JavaCode/JavaCode.csproj | 156 ++ JavaCode/Properties/Resources.resx | 117 + JavaCode/FrmSys.cs | 678 +++++++++ JavaCode/SysTemplate/Service.java | 69 JavaCode/BsTemplate/GeoMapper.java | 15 JavaCode/SysTemplate/pg.sql | 153 ++ JavaCode/cs/PostgreHelper.cs | 174 ++ JavaCode/FrmMyBatisPlus.Designer.cs | 284 +++ 35 files changed, 4,416 insertions(+), 0 deletions(-) diff --git a/ExportMap/Sources/geo.qgz b/ExportMap/Sources/geo.qgz new file mode 100644 index 0000000..214da11 --- /dev/null +++ b/ExportMap/Sources/geo.qgz Binary files differ diff --git a/ExportMap/Sources/geo.qpt b/ExportMap/Sources/geo.qpt new file mode 100644 index 0000000..d3950dd --- /dev/null +++ b/ExportMap/Sources/geo.qpt @@ -0,0 +1,591 @@ +<Layout units="mm" printResolution="300" worldFileMap="{c2e7494b-f754-46a4-9d6d-51420fcf9f74}" name="geo"> + <Snapper snapToItems="1" tolerance="5" snapToGrid="0" snapToGuides="1"/> + <Grid offsetY="0" resUnits="mm" resolution="10" offsetX="0" offsetUnits="mm"/> + <PageCollection> + <symbol force_rhr="0" name="" type="fill" alpha="1" clip_to_extent="1"> + <layer enabled="1" locked="0" pass="0" class="SimpleFill"> + <prop v="3x:0,0,0,0,0,0" k="border_width_map_unit_scale"/> + <prop v="255,255,255,255" k="color"/> + <prop v="miter" k="joinstyle"/> + <prop v="0,0" k="offset"/> + <prop v="3x:0,0,0,0,0,0" k="offset_map_unit_scale"/> + <prop v="MM" k="offset_unit"/> + <prop v="35,35,35,255" k="outline_color"/> + <prop v="no" k="outline_style"/> + <prop v="0.26" k="outline_width"/> + <prop v="MM" k="outline_width_unit"/> + <prop v="solid" k="style"/> + <data_defined_properties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </data_defined_properties> + </layer> + </symbol> + <LayoutItem groupUuid="" background="true" size="297,210,mm" templateUuid="{49cb9f24-a1ce-4551-a5ae-ba845af53892}" blendMode="0" opacity="1" visibility="1" referencePoint="0" type="65638" positionOnPage="0,0,mm" position="0,0,mm" zValue="0" positionLock="false" itemRotation="0" outlineWidthM="0.3,mm" frameJoinStyle="miter" frame="false" uuid="{49cb9f24-a1ce-4551-a5ae-ba845af53892}" excludeFromExports="0" id=""> + <FrameColor green="0" blue="0" red="0" alpha="255"/> + <BackgroundColor green="255" blue="255" red="255" alpha="255"/> + <LayoutObject> + <dataDefinedProperties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </dataDefinedProperties> + <customproperties/> + </LayoutObject> + <symbol force_rhr="0" name="" type="fill" alpha="1" clip_to_extent="1"> + <layer enabled="1" locked="0" pass="0" class="SimpleFill"> + <prop v="3x:0,0,0,0,0,0" k="border_width_map_unit_scale"/> + <prop v="255,255,255,255" k="color"/> + <prop v="miter" k="joinstyle"/> + <prop v="0,0" k="offset"/> + <prop v="3x:0,0,0,0,0,0" k="offset_map_unit_scale"/> + <prop v="MM" k="offset_unit"/> + <prop v="35,35,35,255" k="outline_color"/> + <prop v="no" k="outline_style"/> + <prop v="0.26" k="outline_width"/> + <prop v="MM" k="outline_width_unit"/> + <prop v="solid" k="style"/> + <data_defined_properties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </data_defined_properties> + </layer> + </symbol> + </LayoutItem> + <GuideCollection visible="1"/> + </PageCollection> + <LayoutItem mapUuid="{c2e7494b-f754-46a4-9d6d-51420fcf9f74}" groupUuid="" background="false" size="10.4237,11.1743,mm" templateUuid="{dd28aede-d877-4fa9-9cc2-0de19e79f0da}" blendMode="0" opacity="1" pictureHeight="11.1743" pictureWidth="8.85237" northOffset="0" svgFillColor="255,255,255,255" visibility="1" file=":/images/north_arrows/layout_default_north_arrow.svg" referencePoint="0" type="65640" positionOnPage="277.938,2.42978,mm" position="277.938,2.42978,mm" pictureRotation="0" zValue="8" positionLock="true" svgBorderColor="0,0,0,255" northMode="0" itemRotation="0" outlineWidthM="0.3,mm" frameJoinStyle="miter" frame="false" resizeMode="0" svgBorderWidth="0.2" anchorPoint="0" uuid="{dd28aede-d877-4fa9-9cc2-0de19e79f0da}" excludeFromExports="0" mode="0" id="鎸囧寳閽�"> + <FrameColor green="0" blue="0" red="0" alpha="255"/> + <BackgroundColor green="255" blue="255" red="255" alpha="255"/> + <LayoutObject> + <dataDefinedProperties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </dataDefinedProperties> + <customproperties/> + </LayoutObject> + </LayoutItem> + <LayoutItem groupUuid="" background="false" size="76.0244,9.39831,mm" templateUuid="{132788e0-98d4-469f-af33-23ef305f0322}" blendMode="0" opacity="1" valign="128" visibility="1" referencePoint="0" type="65641" marginY="0" positionOnPage="212.337,195.29,mm" position="212.337,195.29,mm" zValue="8" labelText="涓浗鐭虫补澶╃劧姘旂閬撳伐绋嬫湁闄愬叕鍙�" positionLock="true" itemRotation="0" outlineWidthM="0.3,mm" frameJoinStyle="miter" frame="false" marginX="0" uuid="{132788e0-98d4-469f-af33-23ef305f0322}" excludeFromExports="0" id="鍏徃" htmlState="0" halign="4"> + <FrameColor green="0" blue="0" red="0" alpha="255"/> + <BackgroundColor green="255" blue="255" red="255" alpha="255"/> + <LayoutObject> + <dataDefinedProperties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </dataDefinedProperties> + <customproperties/> + </LayoutObject> + <LabelFont style="甯歌" description="瀹嬩綋,14,-1,5,50,0,0,0,0,0,甯歌"/> + <FontColor green="0" blue="0" red="0" alpha="255"/> + </LayoutItem> + <LayoutItem mapUuid="" groupUuid="" background="false" size="11.6809,10.7409,mm" templateUuid="{8d8bcce4-d783-4e1f-b85d-50a2cde45228}" blendMode="0" opacity="1" pictureHeight="10.7409" pictureWidth="11.4207" northOffset="0" svgFillColor="255,255,255,255" visibility="1" file="./logo.png" referencePoint="0" type="65640" positionOnPage="200.5,194.948,mm" position="200.5,194.948,mm" pictureRotation="0" zValue="7" positionLock="true" svgBorderColor="0,0,0,255" northMode="0" itemRotation="0" outlineWidthM="0.3,mm" frameJoinStyle="miter" frame="false" resizeMode="0" svgBorderWidth="0.2" anchorPoint="0" uuid="{8d8bcce4-d783-4e1f-b85d-50a2cde45228}" excludeFromExports="0" mode="1" id="Logo"> + <FrameColor green="0" blue="0" red="0" alpha="255"/> + <BackgroundColor green="255" blue="255" red="255" alpha="255"/> + <LayoutObject> + <dataDefinedProperties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </dataDefinedProperties> + <customproperties/> + </LayoutObject> + </LayoutItem> + <LayoutItem groupUuid="" hidePageIfEmpty="0" background="false" size="43.1968,25.6574,mm" templateUuid="{33d726d8-6169-4351-997b-1564c5e4a026}" multiFrameTemplateUuid="{3f590e9a-19b4-46d3-90bb-6a188b24aaa6}" blendMode="0" opacity="1" hideBackgroundIfEmpty="0" visibility="1" referencePoint="0" multiFrame="{3f590e9a-19b4-46d3-90bb-6a188b24aaa6}" type="65647" positionOnPage="242.194,161,mm" position="242.194,161,mm" zValue="6" positionLock="true" sectionX="0" itemRotation="0" outlineWidthM="0.3,mm" frameJoinStyle="miter" frame="false" sectionY="0" uuid="{33d726d8-6169-4351-997b-1564c5e4a026}" excludeFromExports="0" sectionHeight="25.6574" id="璇存槑" sectionWidth="43.1968"> + <FrameColor green="0" blue="0" red="0" alpha="255"/> + <BackgroundColor green="255" blue="255" red="255" alpha="255"/> + <LayoutObject> + <dataDefinedProperties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </dataDefinedProperties> + <customproperties/> + </LayoutObject> + </LayoutItem> + <LayoutItem groupUuid="" background="false" size="129.364,11.1743,mm" templateUuid="{c4396cf7-2960-43ac-b2a3-7753f581f9b3}" blendMode="0" opacity="1" valign="128" visibility="1" referencePoint="0" type="65641" marginY="0" positionOnPage="84.816,2.42978,mm" position="84.816,2.42978,mm" zValue="4" labelText="绠¢亾鍩虹澶ф暟鎹钩鍙帮紙DW1-1锛�" positionLock="true" itemRotation="0" outlineWidthM="0.3,mm" frameJoinStyle="miter" frame="false" marginX="0" uuid="{c4396cf7-2960-43ac-b2a3-7753f581f9b3}" excludeFromExports="0" id="鏍囬" htmlState="0" halign="4"> + <FrameColor green="0" blue="0" red="0" alpha="255"/> + <BackgroundColor green="255" blue="255" red="255" alpha="255"/> + <LayoutObject> + <dataDefinedProperties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </dataDefinedProperties> + <customproperties/> + </LayoutObject> + <LabelFont style="Bold" description="寰蒋闆呴粦,24,-1,5,75,0,0,0,0,0,Bold"/> + <FontColor green="0" blue="0" red="0" alpha="255"/> + </LayoutItem> + <LayoutItem columnCount="1" wmsLegendHeight="18" position="12.988,153.18,mm" maxSymbolSize="0" splitLayer="0" rasterBorderColor="0,0,0,255" uuid="{88fdb1df-998d-4a99-8607-f97bc16a111c}" visibility="1" id="鍥句緥" lineSpacing="1" frame="true" background="true" templateUuid="{88fdb1df-998d-4a99-8607-f97bc16a111c}" blendMode="11" referencePoint="0" excludeFromExports="0" groupUuid="" opacity="1" outlineWidthM="0.1,mm" title="" frameJoinStyle="round" wrapChar="" itemRotation="0" rasterBorder="0" boxSpace="2" wmsLegendWidth="25" symbolHeight="4" fontColor="#000000" legendFilterByAtlas="0" equalColumnWidth="0" map_uuid="{c2e7494b-f754-46a4-9d6d-51420fcf9f74}" type="65642" minSymbolSize="0" titleAlignment="1" resizeToContents="0" zValue="3" size="33.5479,31.4278,mm" positionLock="true" rasterBorderWidth="0" symbolAlignment="1" positionOnPage="12.988,153.18,mm" symbolWidth="7" columnSpace="2"> + <FrameColor green="0" blue="0" red="0" alpha="255"/> + <BackgroundColor green="255" blue="255" red="255" alpha="255"/> + <LayoutObject> + <dataDefinedProperties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </dataDefinedProperties> + <customproperties/> + </LayoutObject> + <styles> + <style alignment="1" marginBottom="3.5" name="title"> + <styleFont style="" description="SimSun,16,-1,5,50,0,0,0,0,0"/> + </style> + <style marginTop="3" alignment="2" name="group"> + <styleFont style="" description="SimSun,14,-1,5,50,0,0,0,0,0"/> + </style> + <style marginTop="3" alignment="1" name="subgroup"> + <styleFont style="" description="SimSun,12,-1,5,50,0,0,0,0,0"/> + </style> + <style marginTop="2.5" alignment="1" name="symbol"> + <styleFont style="" description="SimSun,9,-1,5,50,0,0,0,0,0"/> + </style> + <style marginTop="2" alignment="1" marginLeft="2" name="symbolLabel"> + <styleFont style="" description="SimSun,12,-1,5,50,0,0,0,0,0"/> + </style> + </styles> + <layer-tree-group> + <customproperties/> + <layer-tree-group expanded="1" checked="Qt::Checked" name="WMS鏈嶅姟"> + <customproperties> + <property value="hidden" key="legend/title-style"/> + </customproperties> + <layer-tree-layer providerKey="wms" legend_split_behavior="0" id="USA_Population_c2b23a97_0d1f_4910_83e8_f9bd01abd348" expanded="1" checked="Qt::Checked" legend_exp="" name="USA Population" source="crs=EPSG:3857&dpiMode=7&format=image/png&layers=states&styles&url=http://localhost:8088/geoserver/topp/wms?version%3D1.1.0%26layers%3Dtopp:states%26bbox%3D-124.73142200000001,24.955967,-66.969849,49.371735%26width%3D768%26height%3D330%26srs%3DEPSG:4326%26styles%3D" patch_size="-1,-1"> + <customproperties> + <property value="USA Population" key="cached_name"/> + <property value="subgroup" key="legend/title-style"/> + </customproperties> + </layer-tree-layer> + </layer-tree-group> + <layer-tree-group expanded="1" checked="Qt::Checked" name="搴曞浘"> + <customproperties> + <property value="hidden" key="legend/title-style"/> + </customproperties> + <layer-tree-layer providerKey="wms" legend_split_behavior="0" id="楂樺痉褰卞儚娉ㄨ_9ea6949f_b59c_45de_a3ff_afa8d0306594" expanded="1" checked="Qt::Checked" legend_exp="" name="楂樺痉褰卞儚娉ㄨ" source="crs=EPSG:3857&format&type=xyz&url=http://wprd01.is.autonavi.com/appmaptile?x%3D%7Bx%7D%26y%3D%7By%7D%26z%3D%7Bz%7D%26lang%3Dzh_cn%26size%3D1%26scl%3D1%26style%3D8&zmax=18&zmin=0" patch_size="-1,-1"> + <customproperties> + <property value="楂樺痉褰卞儚娉ㄨ" key="cached_name"/> + <property value="hidden" key="legend/title-style"/> + </customproperties> + </layer-tree-layer> + <layer-tree-layer providerKey="wms" legend_split_behavior="0" id="楂樺痉褰卞儚_f5a87826_d61b_4fb2_9e06_8ea294512074" expanded="1" checked="Qt::Checked" legend_exp="" name="楂樺痉褰卞儚" source="crs=EPSG:3857&format&type=xyz&url=http://wprd01.is.autonavi.com/appmaptile?x%3D%7Bx%7D%26y%3D%7By%7D%26z%3D%7Bz%7D%26lang%3Dzh_cn%26size%3D1%26scl%3D1%26style%3D6&zmax=18&zmin=0" patch_size="-1,-1"> + <customproperties> + <property value="楂樺痉褰卞儚" key="cached_name"/> + <property value="hidden" key="legend/title-style"/> + </customproperties> + </layer-tree-layer> + </layer-tree-group> + <custom-order enabled="0"/> + </layer-tree-group> + </LayoutItem> + <LayoutItem drawCanvasItems="false" labelMargin="0,mm" groupUuid="" mapRotation="0" background="true" size="280,170,mm" templateUuid="{c2e7494b-f754-46a4-9d6d-51420fcf9f74}" mapFlags="0" blendMode="0" opacity="1" isTemporal="0" visibility="1" referencePoint="0" followPreset="false" type="65639" positionOnPage="9,18,mm" position="9,18,mm" zValue="2" positionLock="true" itemRotation="0" outlineWidthM="4,px" frameJoinStyle="round" keepLayerSet="false" frame="true" uuid="{c2e7494b-f754-46a4-9d6d-51420fcf9f74}" excludeFromExports="0" id="鍦板浘" followPresetName=""> + <FrameColor green="0" blue="0" red="0" alpha="255"/> + <BackgroundColor green="255" blue="255" red="255" alpha="255"/> + <LayoutObject> + <dataDefinedProperties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </dataDefinedProperties> + <customproperties/> + </LayoutObject> + <Extent xmin="-152.0824520553960042" ymin="-0.47086700485009203" xmax="-37.3774889618590862" ymax="69.17143201622589288"/> + <crs> + <spatialrefsys> + <wkt>GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["unknown"],AREA["World"],BBOX[-90,-180,90,180]],ID["EPSG",4326]]</wkt> + <proj4>+proj=longlat +datum=WGS84 +no_defs</proj4> + <srsid>3452</srsid> + <srid>4326</srid> + <authid>EPSG:4326</authid> + <description>WGS 84</description> + <projectionacronym>longlat</projectionacronym> + <ellipsoidacronym>EPSG:7030</ellipsoidacronym> + <geographicflag>true</geographicflag> + </spatialrefsys> + </crs> + <LayerSet/> + <ComposerMapGrid rotatedAnnotationsEnabled="0" topAnnotationDirection="0" show="1" rotatedAnnotationsLengthMode="0" position="3" rightAnnotationDisplay="0" rightAnnotationPosition="1" offsetX="0" annotationFormat="4" rightAnnotationDirection="2" leftFrameDivisions="0" uuid="{33b582a6-ae09-42c2-b50b-ae68c9d6d71a}" name="缃戞牸 1" leftAnnotationPosition="1" gridFrameMargin="0" bottomAnnotationDisplay="0" topFrameDivisions="0" gridFramePenColor="0,0,0,255" rotatedTicksLengthMode="0" frameFillColor2="0,0,0,255" minimumIntervalWidth="12" rotatedTicksMinimumAngle="0" blendMode="0" bottomAnnotationPosition="1" maximumIntervalWidth="10" rightFrameDivisions="0" annotationExpression="" topAnnotationPosition="1" annotationPrecision="3" unit="1" leftAnnotationDisplay="0" frameFillColor1="255,255,255,255" gridFrameWidth="2" gridFrameStyle="0" gridFrameSideFlags="15" rotatedTicksEnabled="0" bottomFrameDivisions="0" intervalX="30" rotatedAnnotationsMinimumAngle="0" gridStyle="3" rotatedAnnotationsMarginToCorner="0" bottomAnnotationDirection="0" topAnnotationDisplay="0" showAnnotation="1" crossLength="3" intervalY="30" frameAnnotationDistance="1" gridFramePenThickness="0.29999999999999999" offsetY="0" rotatedTicksMarginToCorner="0" leftAnnotationDirection="2"> + <lineStyle> + <symbol force_rhr="0" name="" type="line" alpha="0.616" clip_to_extent="1"> + <layer enabled="1" locked="0" pass="0" class="SimpleLine"> + <prop v="0" k="align_dash_pattern"/> + <prop v="round" k="capstyle"/> + <prop v="0.66;2" k="customdash"/> + <prop v="3x:0,0,0,0,0,0" k="customdash_map_unit_scale"/> + <prop v="MM" k="customdash_unit"/> + <prop v="0" k="dash_pattern_offset"/> + <prop v="3x:0,0,0,0,0,0" k="dash_pattern_offset_map_unit_scale"/> + <prop v="MM" k="dash_pattern_offset_unit"/> + <prop v="0" k="draw_inside_polygon"/> + <prop v="round" k="joinstyle"/> + <prop v="0,0,0,255" k="line_color"/> + <prop v="solid" k="line_style"/> + <prop v="0.5" k="line_width"/> + <prop v="MM" k="line_width_unit"/> + <prop v="0" k="offset"/> + <prop v="3x:0,0,0,0,0,0" k="offset_map_unit_scale"/> + <prop v="MM" k="offset_unit"/> + <prop v="0" k="ring_filter"/> + <prop v="0" k="tweak_dash_pattern_on_corners"/> + <prop v="1" k="use_custom_dash"/> + <prop v="3x:0,0,0,0,0,0" k="width_map_unit_scale"/> + <data_defined_properties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </data_defined_properties> + </layer> + </symbol> + </lineStyle> + <markerStyle> + <symbol force_rhr="0" name="" type="marker" alpha="1" clip_to_extent="1"> + <layer enabled="1" locked="0" pass="0" class="SimpleMarker"> + <prop v="0" k="angle"/> + <prop v="0,0,0,255" k="color"/> + <prop v="1" k="horizontal_anchor_point"/> + <prop v="bevel" k="joinstyle"/> + <prop v="circle" k="name"/> + <prop v="0,0" k="offset"/> + <prop v="3x:0,0,0,0,0,0" k="offset_map_unit_scale"/> + <prop v="MM" k="offset_unit"/> + <prop v="35,35,35,255" k="outline_color"/> + <prop v="solid" k="outline_style"/> + <prop v="0" k="outline_width"/> + <prop v="3x:0,0,0,0,0,0" k="outline_width_map_unit_scale"/> + <prop v="MM" k="outline_width_unit"/> + <prop v="diameter" k="scale_method"/> + <prop v="2" k="size"/> + <prop v="3x:0,0,0,0,0,0" k="size_map_unit_scale"/> + <prop v="MM" k="size_unit"/> + <prop v="1" k="vertical_anchor_point"/> + <data_defined_properties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </data_defined_properties> + </layer> + </symbol> + </markerStyle> + <spatialrefsys> + <wkt>GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["unknown"],AREA["World"],BBOX[-90,-180,90,180]],ID["EPSG",4326]]</wkt> + <proj4>+proj=longlat +datum=WGS84 +no_defs</proj4> + <srsid>3452</srsid> + <srid>4326</srid> + <authid>EPSG:4326</authid> + <description>WGS 84</description> + <projectionacronym>longlat</projectionacronym> + <ellipsoidacronym>EPSG:7030</ellipsoidacronym> + <geographicflag>true</geographicflag> + </spatialrefsys> + <text-style capitalization="0" namedStyle="" textOrientation="horizontal" textColor="0,0,0,255" blendMode="0" fontUnderline="0" fontItalic="0" fontStrikeout="0" fontSizeMapUnitScale="3x:0,0,0,0,0,0" fontWeight="50" fontSize="8" multilineHeight="1" previewBkgrdColor="255,255,255,255" fontKerning="1" allowHtml="0" textOpacity="1" fontWordSpacing="0" fontSizeUnit="Point" fontLetterSpacing="0" fontFamily="SimSun"> + <text-buffer bufferColor="255,255,255,255" bufferOpacity="1" bufferBlendMode="0" bufferSizeUnits="MM" bufferSize="1" bufferSizeMapUnitScale="3x:0,0,0,0,0,0" bufferNoFill="1" bufferDraw="0" bufferJoinStyle="128"/> + <text-mask maskedSymbolLayers="" maskSize="1.5" maskSizeUnits="MM" maskType="0" maskSizeMapUnitScale="3x:0,0,0,0,0,0" maskOpacity="1" maskEnabled="0" maskJoinStyle="128"/> + <background shapeRadiiMapUnitScale="3x:0,0,0,0,0,0" shapeBorderColor="128,128,128,255" shapeOpacity="1" shapeRotation="0" shapeDraw="0" shapeOffsetX="0" shapeBlendMode="0" shapeSizeType="0" shapeBorderWidthMapUnitScale="3x:0,0,0,0,0,0" shapeBorderWidth="0" shapeSizeMapUnitScale="3x:0,0,0,0,0,0" shapeOffsetUnit="MM" shapeSizeX="0" shapeBorderWidthUnit="MM" shapeSizeY="0" shapeJoinStyle="64" shapeRadiiX="0" shapeSizeUnit="MM" shapeOffsetY="0" shapeOffsetMapUnitScale="3x:0,0,0,0,0,0" shapeRadiiY="0" shapeRadiiUnit="MM" shapeType="0" shapeFillColor="255,255,255,255" shapeRotationType="0" shapeSVGFile=""> + <symbol force_rhr="0" name="markerSymbol" type="marker" alpha="1" clip_to_extent="1"> + <layer enabled="1" locked="0" pass="0" class="SimpleMarker"> + <prop v="0" k="angle"/> + <prop v="231,113,72,255" k="color"/> + <prop v="1" k="horizontal_anchor_point"/> + <prop v="bevel" k="joinstyle"/> + <prop v="circle" k="name"/> + <prop v="0,0" k="offset"/> + <prop v="3x:0,0,0,0,0,0" k="offset_map_unit_scale"/> + <prop v="MM" k="offset_unit"/> + <prop v="35,35,35,255" k="outline_color"/> + <prop v="solid" k="outline_style"/> + <prop v="0" k="outline_width"/> + <prop v="3x:0,0,0,0,0,0" k="outline_width_map_unit_scale"/> + <prop v="MM" k="outline_width_unit"/> + <prop v="diameter" k="scale_method"/> + <prop v="2" k="size"/> + <prop v="3x:0,0,0,0,0,0" k="size_map_unit_scale"/> + <prop v="MM" k="size_unit"/> + <prop v="1" k="vertical_anchor_point"/> + <data_defined_properties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </data_defined_properties> + </layer> + </symbol> + </background> + <shadow shadowRadius="1.5" shadowRadiusMapUnitScale="3x:0,0,0,0,0,0" shadowOpacity="0.7" shadowOffsetUnit="MM" shadowScale="100" shadowOffsetAngle="135" shadowRadiusUnit="MM" shadowOffsetMapUnitScale="3x:0,0,0,0,0,0" shadowOffsetGlobal="1" shadowRadiusAlphaOnly="0" shadowColor="0,0,0,255" shadowBlendMode="6" shadowOffsetDist="1" shadowUnder="0" shadowDraw="0"/> + <dd_properties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </dd_properties> + </text-style> + <LayoutObject> + <dataDefinedProperties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </dataDefinedProperties> + <customproperties/> + </LayoutObject> + </ComposerMapGrid> + <AtlasMap atlasDriven="0" scalingMode="2" margin="0.10000000000000001"/> + <labelBlockingItems/> + <atlasClippingSettings restrictLayers="0" enabled="0" forceLabelsInside="0" clippingType="1"> + <layersToClip/> + </atlasClippingSettings> + <itemClippingSettings enabled="0" forceLabelsInside="0" clipSource="" clippingType="1"/> + </LayoutItem> + <LayoutItem groupUuid="" background="false" size="292.354,205.447,mm" templateUuid="{e0b060ea-8dae-4b1b-a216-b36caed167c3}" blendMode="0" opacity="1" visibility="1" referencePoint="0" type="65643" positionOnPage="2.6816,2,mm" cornerRadiusMeasure="0,mm" position="2.6816,2,mm" zValue="1" positionLock="true" itemRotation="0" outlineWidthM="0.3,mm" frameJoinStyle="miter" frame="false" shapeType="1" uuid="{e0b060ea-8dae-4b1b-a216-b36caed167c3}" excludeFromExports="0" id="杈规"> + <FrameColor green="0" blue="0" red="0" alpha="255"/> + <BackgroundColor green="255" blue="255" red="255" alpha="255"/> + <LayoutObject> + <dataDefinedProperties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </dataDefinedProperties> + <customproperties/> + </LayoutObject> + <symbol force_rhr="0" name="" type="fill" alpha="1" clip_to_extent="1"> + <layer enabled="1" locked="0" pass="0" class="SimpleLine"> + <prop v="0" k="align_dash_pattern"/> + <prop v="square" k="capstyle"/> + <prop v="5;2" k="customdash"/> + <prop v="3x:0,0,0,0,0,0" k="customdash_map_unit_scale"/> + <prop v="Pixel" k="customdash_unit"/> + <prop v="0" k="dash_pattern_offset"/> + <prop v="3x:0,0,0,0,0,0" k="dash_pattern_offset_map_unit_scale"/> + <prop v="MM" k="dash_pattern_offset_unit"/> + <prop v="0" k="draw_inside_polygon"/> + <prop v="bevel" k="joinstyle"/> + <prop v="53,121,177,255" k="line_color"/> + <prop v="solid" k="line_style"/> + <prop v="0.96" k="line_width"/> + <prop v="Pixel" k="line_width_unit"/> + <prop v="0" k="offset"/> + <prop v="3x:0,0,0,0,0,0" k="offset_map_unit_scale"/> + <prop v="Pixel" k="offset_unit"/> + <prop v="0" k="ring_filter"/> + <prop v="0" k="tweak_dash_pattern_on_corners"/> + <prop v="0" k="use_custom_dash"/> + <prop v="3x:0,0,0,0,0,0" k="width_map_unit_scale"/> + <data_defined_properties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </data_defined_properties> + </layer> + </symbol> + </LayoutItem> + <LayoutMultiFrame gridColor="0,0,0,255" backgroundColor="255,255,255,255" templateUuid="{ac4d0d50-93b1-4429-be99-b888689f2d65}" emptyTableMode="0" wrapBehavior="0" verticalGrid="1" includeHeader="0" cellMargin="1" horizontalGrid="1" emptyTableMessage="" type="65652" headerMode="2" gridStrokeWidth="0.5" showEmptyRows="0" resizeMode="0" uuid="{ac4d0d50-93b1-4429-be99-b888689f2d65}" headerHAlignment="0" showGrid="0"> + <childFrame uuid="{33d726d8-6169-4351-997b-1564c5e4a026}" templateUuid="{33d726d8-6169-4351-997b-1564c5e4a026}"/> + <LayoutObject> + <dataDefinedProperties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </dataDefinedProperties> + <customproperties/> + </LayoutObject> + <headerTextFormat> + <text-style capitalization="0" namedStyle="" textOrientation="horizontal" textColor="0,0,0,255" blendMode="0" fontUnderline="0" fontItalic="0" fontStrikeout="0" fontSizeMapUnitScale="3x:0,0,0,0,0,0" fontWeight="50" fontSize="10" multilineHeight="1" previewBkgrdColor="255,255,255,255" fontKerning="1" allowHtml="0" textOpacity="1" fontWordSpacing="0" fontSizeUnit="Point" fontLetterSpacing="0" fontFamily="SimSun"> + <text-buffer bufferColor="255,255,255,255" bufferOpacity="1" bufferBlendMode="0" bufferSizeUnits="MM" bufferSize="1" bufferSizeMapUnitScale="3x:0,0,0,0,0,0" bufferNoFill="1" bufferDraw="0" bufferJoinStyle="128"/> + <text-mask maskedSymbolLayers="" maskSize="1.5" maskSizeUnits="MM" maskType="0" maskSizeMapUnitScale="3x:0,0,0,0,0,0" maskOpacity="1" maskEnabled="0" maskJoinStyle="128"/> + <background shapeRadiiMapUnitScale="3x:0,0,0,0,0,0" shapeBorderColor="128,128,128,255" shapeOpacity="1" shapeRotation="0" shapeDraw="0" shapeOffsetX="0" shapeBlendMode="0" shapeSizeType="0" shapeBorderWidthMapUnitScale="3x:0,0,0,0,0,0" shapeBorderWidth="0" shapeSizeMapUnitScale="3x:0,0,0,0,0,0" shapeOffsetUnit="MM" shapeSizeX="0" shapeBorderWidthUnit="MM" shapeSizeY="0" shapeJoinStyle="64" shapeRadiiX="0" shapeSizeUnit="MM" shapeOffsetY="0" shapeOffsetMapUnitScale="3x:0,0,0,0,0,0" shapeRadiiY="0" shapeRadiiUnit="MM" shapeType="0" shapeFillColor="255,255,255,255" shapeRotationType="0" shapeSVGFile=""/> + <shadow shadowRadius="1.5" shadowRadiusMapUnitScale="3x:0,0,0,0,0,0" shadowOpacity="0.7" shadowOffsetUnit="MM" shadowScale="100" shadowOffsetAngle="135" shadowRadiusUnit="MM" shadowOffsetMapUnitScale="3x:0,0,0,0,0,0" shadowOffsetGlobal="1" shadowRadiusAlphaOnly="0" shadowColor="0,0,0,255" shadowBlendMode="6" shadowOffsetDist="1" shadowUnder="0" shadowDraw="0"/> + <dd_properties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </dd_properties> + </text-style> + </headerTextFormat> + <contentTextFormat> + <text-style capitalization="0" namedStyle="" textOrientation="horizontal" textColor="0,0,0,255" blendMode="0" fontUnderline="0" fontItalic="0" fontStrikeout="0" fontSizeMapUnitScale="3x:0,0,0,0,0,0" fontWeight="50" fontSize="10" multilineHeight="1" previewBkgrdColor="255,255,255,255" fontKerning="1" allowHtml="0" textOpacity="1" fontWordSpacing="0" fontSizeUnit="Point" fontLetterSpacing="0" fontFamily="SimSun"> + <text-buffer bufferColor="255,255,255,255" bufferOpacity="1" bufferBlendMode="0" bufferSizeUnits="MM" bufferSize="1" bufferSizeMapUnitScale="3x:0,0,0,0,0,0" bufferNoFill="1" bufferDraw="0" bufferJoinStyle="128"/> + <text-mask maskedSymbolLayers="" maskSize="1.5" maskSizeUnits="MM" maskType="0" maskSizeMapUnitScale="3x:0,0,0,0,0,0" maskOpacity="1" maskEnabled="0" maskJoinStyle="128"/> + <background shapeRadiiMapUnitScale="3x:0,0,0,0,0,0" shapeBorderColor="128,128,128,255" shapeOpacity="1" shapeRotation="0" shapeDraw="0" shapeOffsetX="0" shapeBlendMode="0" shapeSizeType="0" shapeBorderWidthMapUnitScale="3x:0,0,0,0,0,0" shapeBorderWidth="0" shapeSizeMapUnitScale="3x:0,0,0,0,0,0" shapeOffsetUnit="MM" shapeSizeX="0" shapeBorderWidthUnit="MM" shapeSizeY="0" shapeJoinStyle="64" shapeRadiiX="0" shapeSizeUnit="MM" shapeOffsetY="0" shapeOffsetMapUnitScale="3x:0,0,0,0,0,0" shapeRadiiY="0" shapeRadiiUnit="MM" shapeType="0" shapeFillColor="255,255,255,255" shapeRotationType="0" shapeSVGFile=""/> + <shadow shadowRadius="1.5" shadowRadiusMapUnitScale="3x:0,0,0,0,0,0" shadowOpacity="0.7" shadowOffsetUnit="MM" shadowScale="100" shadowOffsetAngle="135" shadowRadiusUnit="MM" shadowOffsetMapUnitScale="3x:0,0,0,0,0,0" shadowOffsetGlobal="1" shadowRadiusAlphaOnly="0" shadowColor="0,0,0,255" shadowBlendMode="6" shadowOffsetDist="1" shadowUnder="0" shadowDraw="0"/> + <dd_properties> + <Option type="Map"> + <Option value="" name="name" type="QString"/> + <Option name="properties"/> + <Option value="collection" name="type" type="QString"/> + </Option> + </dd_properties> + </text-style> + </contentTextFormat> + <displayColumns> + <column sortOrder="0" width="0" hAlignment="1" attribute="" vAlignment="128" heading="" sortByRank="0"> + <backgroundColor green="0" blue="0" red="0" alpha="0"/> + </column> + <column sortOrder="0" width="0" hAlignment="1" attribute="" vAlignment="128" heading="璇存槑" sortByRank="0"> + <backgroundColor green="0" blue="0" red="0" alpha="0"/> + </column> + </displayColumns> + <sortColumns/> + <cellStyles> + <oddColumns enabled="0" cellBackgroundColor="255,255,255,255"/> + <evenColumns enabled="0" cellBackgroundColor="255,255,255,255"/> + <oddRows enabled="0" cellBackgroundColor="255,255,255,255"/> + <evenRows enabled="0" cellBackgroundColor="255,255,255,255"/> + <firstColumn enabled="0" cellBackgroundColor="255,255,255,255"/> + <lastColumn enabled="0" cellBackgroundColor="255,255,255,255"/> + <headerRow enabled="0" cellBackgroundColor="255,255,255,255"/> + <firstRow enabled="0" cellBackgroundColor="255,255,255,255"/> + <lastRow enabled="0" cellBackgroundColor="255,255,255,255"/> + </cellStyles> + <headers> + <header sortOrder="0" width="0" hAlignment="1" attribute="" vAlignment="128" heading="" sortByRank="0"> + <backgroundColor green="0" blue="0" red="0" alpha="0"/> + </header> + <header sortOrder="0" width="0" hAlignment="1" attribute="" vAlignment="128" heading="璇存槑" sortByRank="0"> + <backgroundColor green="0" blue="0" red="0" alpha="0"/> + </header> + </headers> + <contents> + <row> + <Option type="Map"> + <Option value="" name="background" type="color"/> + <Option value="璇�" name="content" type="QString"/> + <Option value="" name="foreground" type="color"/> + <Option value="2" name="halign" type="int"/> + <Option value="0" name="valign" type="int"/> + </Option> + <Option type="Map"> + <Option value="" name="background" type="color"/> + <Option value="鏄�" name="content" type="QString"/> + <Option value="" name="foreground" type="color"/> + <Option value="0" name="halign" type="int"/> + <Option value="0" name="valign" type="int"/> + </Option> + </row> + <row> + <Option type="Map"> + <Option value="" name="background" type="color"/> + <Option value="鐪佷唤锛�" name="content" type="QString"/> + <Option value="" name="foreground" type="color"/> + <Option value="2" name="halign" type="int"/> + <Option value="128" name="valign" type="int"/> + </Option> + <Option type="Map"> + <Option value="" name="background" type="color"/> + <Option value="娌冲寳鐪�" name="content" type="QString"/> + <Option value="" name="foreground" type="color"/> + <Option value="1" name="halign" type="int"/> + <Option value="128" name="valign" type="int"/> + </Option> + </row> + <row> + <Option type="Map"> + <Option value="" name="background" type="color"/> + <Option value="姣斾緥灏猴細" name="content" type="QString"/> + <Option value="" name="foreground" type="color"/> + <Option value="2" name="halign" type="int"/> + <Option value="128" name="valign" type="int"/> + </Option> + <Option type="Map"> + <Option value="" name="background" type="color"/> + <Option value="1锛�25涓�" name="content" type="QString"/> + <Option value="" name="foreground" type="color"/> + <Option value="1" name="halign" type="int"/> + <Option value="128" name="valign" type="int"/> + </Option> + </row> + <row> + <Option type="Map"> + <Option value="" name="background" type="color"/> + <Option value="褰卞儚鍒嗚鲸鐜囷細" name="content" type="QString"/> + <Option value="" name="foreground" type="color"/> + <Option value="0" name="halign" type="int"/> + <Option value="0" name="valign" type="int"/> + </Option> + <Option type="Map"> + <Option value="" name="background" type="color"/> + <Option value="20绫�" name="content" type="QString"/> + <Option value="" name="foreground" type="color"/> + <Option value="0" name="halign" type="int"/> + <Option value="0" name="valign" type="int"/> + </Option> + </row> + <row> + <Option type="Map"> + <Option value="" name="background" type="color"/> + <Option value="鍒跺浘鏃堕棿锛�" name="content" type="QString"/> + <Option value="" name="foreground" type="color"/> + <Option value="2" name="halign" type="int"/> + <Option value="0" name="valign" type="int"/> + </Option> + <Option type="Map"> + <Option value="" name="background" type="color"/> + <Option value="2022.11.06" name="content" type="QString"/> + <Option value="" name="foreground" type="color"/> + <Option value="0" name="halign" type="int"/> + <Option value="0" name="valign" type="int"/> + </Option> + </row> + </contents> + <rowHeights> + <row height="0"/> + <row height="0"/> + <row height="0"/> + <row height="0"/> + <row height="0"/> + </rowHeights> + <columnWidths> + <column width="0"/> + <column width="0"/> + </columnWidths> + </LayoutMultiFrame> + <customproperties> + <property value="png" key="atlasRasterFormat"/> + <property value="true" key="imageAntialias"/> + <property value="0" key="imageCropMarginBottom"/> + <property value="0" key="imageCropMarginLeft"/> + <property value="0" key="imageCropMarginRight"/> + <property value="0" key="imageCropMarginTop"/> + <property value="false" key="imageCropToContents"/> + <property value="true" key="singleFile"/> + <property key="layers" value="USA Population,楂樺痉褰卞儚娉ㄨ,楂樺痉褰卞儚"/> + <property key="imgPath" value="E:/terrait/TianJin/ExportMap/ExportMap/Sources/geo.png"/> + </customproperties> + <Atlas enabled="0" filenamePattern="'output_'||@atlas_featurenumber" filterFeatures="0" coverageLayer="" pageNameExpression="" sortFeatures="0" hideCoverage="0"/> +</Layout> diff --git a/ExportMap/Sources/geo_render.py b/ExportMap/Sources/geo_render.py new file mode 100644 index 0000000..fa44e00 --- /dev/null +++ b/ExportMap/Sources/geo_render.py @@ -0,0 +1,127 @@ +#!/usr/bin/env +# -*- coding: utf-8 -*- +import os +import sys +import math +import argparse +from qgis.core import * +from qgis.gui import * +from qgis.PyQt.QtGui import * +from qgis.PyQt.QtCore import * +from qgis.PyQt.QtWidgets import * +from qgis.PyQt.QtXml import * + + +# 鑾峰彇瀹屾暣璺緞 +def get_full_path(): + return os.path.split(sys.argv[0])[0] + + +# 鑾峰彇鍙傛暟 +def get_args(): + print("argv = ", sys.argv[1:]) + parser = argparse.ArgumentParser(description='ArgUtils') + parser.add_argument("-src", type=str, default=get_full_path(), required=False) + parser.add_argument("-qgz", type=str, default="geo.qgz", required=False) + parser.add_argument("-qpt", type=str, default="geo.qpt", required=False) + + return parser.parse_args() + + +# 璁剧疆鍥惧眰鍙敤鎬� +def set_layers_valid(prj, show_layers): + for layer in prj.mapLayers().values(): + flag = layer.name() in show_layers + print(layer.name() + ": " + str(flag)) + # if not flag: + # project.removeMapLayer(layer) + layer.setValid(flag) + + +# 璁剧疆鍥惧眰鍙鎬� +def set_item_visibility(root_node, show_layers): + print(root_node.name() + ': Group') + for node in root_node.children(): + # QgsLayerTreeLayer + if isinstance(node, QgsLayerTreeGroup): + set_item_visibility(node, show_layers) + # QgsRasterLayer, QgsVectorLayer + else: + name = node.layer().name() + flag = name in showLayers + print(name + ": " + str(flag)) + # if not flag: + # root_node.removeLayer(node.layer()) + # node.layer().setValid(False) + node.setItemVisibilityChecked(flag) + + +# 鍒濆鍖� +# QgsApplication.setPrefixPath(r"E:/terrait/TianJin/LFServer/QGIS/", True) +qgs = QgsApplication([], True) +qgs.initQgis() + +# 鍔犺浇宸ョ▼ +args = get_args() +project = QgsProject.instance() +# project.read(r'Test.qgz') +project.read(os.path.join(args.src, args.qgz)) +print("FileName: " + project.fileName()) + +# layout = QgsPrintLayout(project) +layout = QgsLayout(project) +# layout.initializeDefaults() + +# 鍔犺浇妯℃澘 +# with open(r'Test.qpt', 'r', encoding='utf-8') as f: +with open(os.path.join(args.src, args.qpt), 'r', encoding='utf-8') as f: + template_content = f.read() +doc = QDomDocument() +doc.setContent(template_content) +layout.loadFromTemplate(doc, QgsReadWriteContext(), True) + +# map = layout.itemById(r'鍦板浘') +map = layout.referenceMap() +map.zoomToExtent(map.extent()) +print('1:' + str(math.ceil(map.scale()))) + +size = map.sizeWithUnits() +print('size: ' + str(size.width()) + " * " + str(size.height()) + " mm") +if size.width() > 280 or size.height() > 174: + map.attemptResize(QgsLayoutSize(280, 174, QgsUnitTypes.LayoutMillimeters)) + print('size: ' + str(map.sizeWithUnits().width()) + " * " + str(map.sizeWithUnits().height()) + " mm") + +# 璁剧疆鍥惧眰 +# "闃�瀹�", "绔欏満", "绠¢亾涓績绾�", "鐭㈤噺娉ㄨ", "鐭㈤噺鍥�", "楂樺痉褰卞儚娉ㄨ", "楂樺痉褰卞儚", "褰卞儚娉ㄨ", "褰卞儚鍥�" +# showLayers = ["闃�瀹�", "绠¢亾涓績绾�", "鐭㈤噺娉ㄨ", "鐭㈤噺鍥�"] +showLayers = layout.customProperty("layers").split(',') +root = project.layerTreeRoot() +# set_layers_valid(project, showLayers) +set_item_visibility(root, showLayers) + +# collection = layout.pageCollection() +# page = collection.page(0) +# page.refreshItemSize() + +legend = layout.itemById(r'鍥句緥') +# legend.setLinkedMap(map) +# legend.setLegendFilterByMapEnabled(False) +# legend.setLegendFilterOutAtlas(True) +legend.updateFilterByMap(True) +legend.refreshFrame(True) +legend.updateLegend() +legend.refresh() + +# 鍒锋柊 +map.refresh() +layout.updateBounds() +layout.refresh() + +# 瀵煎嚭 +exporter = QgsLayoutExporter(layout) +# img_path = os.path.join(r"E:/terrait/TianJin/LFServer/QGIS", "render.png") +img_path = layout.customProperty("imgPath") +exporter.exportToImage(img_path, QgsLayoutExporter.ImageExportSettings()) + +# 閫�鍑� +qgs.exitQgis() diff --git a/JavaCode/App.config b/JavaCode/App.config new file mode 100644 index 0000000..e6c7397 --- /dev/null +++ b/JavaCode/App.config @@ -0,0 +1,12 @@ +锘�<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <appSettings> + <!-- 69701 --> + <add key="pgConn" value="Server=127.0.0.1;Port=5432;Database=langfang;User Id=postgres;Password=postgres;"/> + <!-- 20582 --> + <!--<add key="pgConn" value="Server=192.168.20.39;Port=5433;Database=langfang;User Id=postgres;Password=postgres;"/>--> + </appSettings> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> + </startup> +</configuration> \ No newline at end of file diff --git a/JavaCode/BsTemplate/Entity.java b/JavaCode/BsTemplate/Entity.java new file mode 100644 index 0000000..c6bdd66 --- /dev/null +++ b/JavaCode/BsTemplate/Entity.java @@ -0,0 +1,20 @@ +package {entityNS}; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.lf.server.entity.all.BaseEntity; +import lombok.*; + +import java.math.BigDecimal; +import java.sql.Timestamp; + +/** + * {bak} + * @author WWW + */ +@Data +@AllArgsConstructor +@TableName("{tabName}") +@EqualsAndHashCode(callSuper = false) +public class {entityName} extends BaseEntity { + private static final long serialVersionUID = {uid}L; diff --git a/JavaCode/BsTemplate/GeoEntity.java b/JavaCode/BsTemplate/GeoEntity.java new file mode 100644 index 0000000..b72f579 --- /dev/null +++ b/JavaCode/BsTemplate/GeoEntity.java @@ -0,0 +1,20 @@ +package {entityNS}; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.lf.server.entity.all.BaseGeoEntity; +import lombok.*; + +import java.math.BigDecimal; +import java.sql.Timestamp; + +/** + * {bak} + * @author WWW + */ +@Data +@AllArgsConstructor +@TableName("{tabName}") +@EqualsAndHashCode(callSuper = false) +public class {entityName} extends BaseGeoEntity { + private static final long serialVersionUID = {uid}L; diff --git a/JavaCode/BsTemplate/GeoMapper.java b/JavaCode/BsTemplate/GeoMapper.java new file mode 100644 index 0000000..3769593 --- /dev/null +++ b/JavaCode/BsTemplate/GeoMapper.java @@ -0,0 +1,15 @@ +package {mapperNS}; + +import {entityNS}.{entityName}; +import com.lf.server.mapper.all.GeomBaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +/** + * {bak} + * @author WWW + */ +@Mapper +@Repository +public interface {mapperName} extends GeomBaseMapper<{entityName}> { +} diff --git a/JavaCode/BsTemplate/Mapper.java b/JavaCode/BsTemplate/Mapper.java new file mode 100644 index 0000000..ee6e7d4 --- /dev/null +++ b/JavaCode/BsTemplate/Mapper.java @@ -0,0 +1,17 @@ +package {mapperNS}; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import {entityNS}.{entityName}; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +/** + * {bak} + * @author WWW + */ +@Mapper +@Repository +public interface {mapperName} extends BaseMapper<{entityName}> { +} diff --git a/JavaCode/DLL/Mono.Security.dll b/JavaCode/DLL/Mono.Security.dll new file mode 100644 index 0000000..62ae339 --- /dev/null +++ b/JavaCode/DLL/Mono.Security.dll Binary files differ diff --git a/JavaCode/DLL/Npgsql.dll b/JavaCode/DLL/Npgsql.dll new file mode 100644 index 0000000..53d9860 --- /dev/null +++ b/JavaCode/DLL/Npgsql.dll Binary files differ diff --git a/JavaCode/FrmMain.Designer.cs b/JavaCode/FrmMain.Designer.cs new file mode 100644 index 0000000..ccb57a1 --- /dev/null +++ b/JavaCode/FrmMain.Designer.cs @@ -0,0 +1,76 @@ +锘縩amespace JavaCode +{ + partial class FrmMain + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.btnSys = new System.Windows.Forms.Button(); + this.btnMybatis = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // btnSys + // + this.btnSys.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnSys.Location = new System.Drawing.Point(142, 63); + this.btnSys.Name = "btnSys"; + this.btnSys.Size = new System.Drawing.Size(183, 25); + this.btnSys.TabIndex = 13; + this.btnSys.Text = "鐢� 鎴� 绯� 缁� 琛�"; + this.btnSys.UseVisualStyleBackColor = true; + this.btnSys.Click += new System.EventHandler(this.btnSys_Click); + // + // btnMybatis + // + this.btnMybatis.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnMybatis.Location = new System.Drawing.Point(142, 134); + this.btnMybatis.Name = "btnMybatis"; + this.btnMybatis.Size = new System.Drawing.Size(183, 25); + this.btnMybatis.TabIndex = 14; + this.btnMybatis.Text = "鐢� 鎴� Mybatis Plus"; + this.btnMybatis.UseVisualStyleBackColor = true; + this.btnMybatis.Click += new System.EventHandler(this.btnMybatis_Click); + // + // FrmMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(484, 261); + this.Controls.Add(this.btnMybatis); + this.Controls.Add(this.btnSys); + this.Name = "FrmMain"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "FrmMain"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button btnSys; + private System.Windows.Forms.Button btnMybatis; + } +} \ No newline at end of file diff --git a/JavaCode/FrmMain.cs b/JavaCode/FrmMain.cs new file mode 100644 index 0000000..36ce72f --- /dev/null +++ b/JavaCode/FrmMain.cs @@ -0,0 +1,34 @@ +锘縰sing System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace JavaCode +{ + public partial class FrmMain : Form + { + + + public FrmMain() + { + InitializeComponent(); + } + + private void btnSys_Click(object sender, EventArgs e) + { + FrmSys frmSys = new FrmSys(); + frmSys.Show(); + } + + private void btnMybatis_Click(object sender, EventArgs e) + { + FrmMyBatisPlus mybatis = new FrmMyBatisPlus(); + mybatis.Show(); + } + } +} diff --git a/JavaCode/FrmMain.resx b/JavaCode/FrmMain.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/JavaCode/FrmMain.resx @@ -0,0 +1,120 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file diff --git a/JavaCode/FrmMyBatisPlus.Designer.cs b/JavaCode/FrmMyBatisPlus.Designer.cs new file mode 100644 index 0000000..4228738 --- /dev/null +++ b/JavaCode/FrmMyBatisPlus.Designer.cs @@ -0,0 +1,284 @@ +锘縩amespace JavaCode +{ + partial class FrmMyBatisPlus + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.txtNS = new System.Windows.Forms.TextBox(); + this.txtTabPre = new System.Windows.Forms.TextBox(); + this.btnReadTab = new System.Windows.Forms.Button(); + this.tabList = new System.Windows.Forms.ListBox(); + this.dgvTab = new System.Windows.Forms.DataGridView(); + this.txtEntityNS = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.txtMapperNS = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.btnGeneAll = new System.Windows.Forms.Button(); + this.btnAll = new System.Windows.Forms.Button(); + this.btnAnti = new System.Windows.Forms.Button(); + this.btnNone = new System.Windows.Forms.Button(); + this.btnGeneEntity = new System.Windows.Forms.Button(); + this.btnGeneMapper = new System.Windows.Forms.Button(); + this.txtTabNS = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.dgvTab)).BeginInit(); + this.SuspendLayout(); + // + // txtNS + // + this.txtNS.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtNS.Location = new System.Drawing.Point(12, 13); + this.txtNS.Name = "txtNS"; + this.txtNS.Size = new System.Drawing.Size(104, 26); + this.txtNS.TabIndex = 25; + this.txtNS.Text = "163875"; + // + // txtTabPre + // + this.txtTabPre.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtTabPre.Location = new System.Drawing.Point(136, 13); + this.txtTabPre.Name = "txtTabPre"; + this.txtTabPre.Size = new System.Drawing.Size(98, 26); + this.txtTabPre.TabIndex = 24; + // + // btnReadTab + // + this.btnReadTab.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnReadTab.Location = new System.Drawing.Point(247, 15); + this.btnReadTab.Name = "btnReadTab"; + this.btnReadTab.Size = new System.Drawing.Size(118, 23); + this.btnReadTab.TabIndex = 23; + this.btnReadTab.Text = "璇诲彇鏁版嵁搴撹〃"; + this.btnReadTab.UseVisualStyleBackColor = true; + this.btnReadTab.Click += new System.EventHandler(this.btnReadTab_Click); + // + // tabList + // + this.tabList.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.tabList.FormattingEnabled = true; + this.tabList.ItemHeight = 16; + this.tabList.Location = new System.Drawing.Point(12, 86); + this.tabList.Name = "tabList"; + this.tabList.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple; + this.tabList.Size = new System.Drawing.Size(353, 212); + this.tabList.TabIndex = 22; + this.tabList.SelectedIndexChanged += new System.EventHandler(this.tabList_SelectedIndexChanged); + // + // dgvTab + // + this.dgvTab.AllowUserToAddRows = false; + this.dgvTab.AllowUserToDeleteRows = false; + this.dgvTab.BackgroundColor = System.Drawing.SystemColors.ButtonFace; + this.dgvTab.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvTab.Location = new System.Drawing.Point(12, 312); + this.dgvTab.Margin = new System.Windows.Forms.Padding(0); + this.dgvTab.MultiSelect = false; + this.dgvTab.Name = "dgvTab"; + this.dgvTab.ReadOnly = true; + this.dgvTab.RowHeadersWidth = 40; + this.dgvTab.RowTemplate.Height = 23; + this.dgvTab.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.dgvTab.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgvTab.Size = new System.Drawing.Size(825, 300); + this.dgvTab.TabIndex = 26; + // + // txtEntityNS + // + this.txtEntityNS.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtEntityNS.Location = new System.Drawing.Point(525, 89); + this.txtEntityNS.Name = "txtEntityNS"; + this.txtEntityNS.Size = new System.Drawing.Size(312, 26); + this.txtEntityNS.TabIndex = 30; + this.txtEntityNS.Text = "com.lf.server.entity.bd"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label3.Location = new System.Drawing.Point(385, 94); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(136, 16); + this.label3.TabIndex = 29; + this.label3.Text = "Entity鍚嶇О绌洪棿锛�"; + // + // txtMapperNS + // + this.txtMapperNS.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtMapperNS.Location = new System.Drawing.Point(525, 53); + this.txtMapperNS.Name = "txtMapperNS"; + this.txtMapperNS.Size = new System.Drawing.Size(312, 26); + this.txtMapperNS.TabIndex = 32; + this.txtMapperNS.Text = "com.lf.server.mapper.bd"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(385, 58); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(136, 16); + this.label2.TabIndex = 31; + this.label2.Text = "Mapper鍚嶇О绌洪棿锛�"; + // + // btnGeneAll + // + this.btnGeneAll.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnGeneAll.Location = new System.Drawing.Point(525, 208); + this.btnGeneAll.Name = "btnGeneAll"; + this.btnGeneAll.Size = new System.Drawing.Size(312, 25); + this.btnGeneAll.TabIndex = 33; + this.btnGeneAll.Text = "鐢� 鎴� 鎵� 鏈� 鏂� 浠�"; + this.btnGeneAll.UseVisualStyleBackColor = true; + this.btnGeneAll.Click += new System.EventHandler(this.btnGeneAll_Click); + // + // btnAll + // + this.btnAll.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnAll.Location = new System.Drawing.Point(12, 53); + this.btnAll.Name = "btnAll"; + this.btnAll.Size = new System.Drawing.Size(104, 23); + this.btnAll.TabIndex = 34; + this.btnAll.Text = "鍏� 閫�"; + this.btnAll.UseVisualStyleBackColor = true; + this.btnAll.Click += new System.EventHandler(this.btnAll_Click); + // + // btnAnti + // + this.btnAnti.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnAnti.Location = new System.Drawing.Point(136, 52); + this.btnAnti.Name = "btnAnti"; + this.btnAnti.Size = new System.Drawing.Size(98, 23); + this.btnAnti.TabIndex = 35; + this.btnAnti.Text = "鍙� 閫�"; + this.btnAnti.UseVisualStyleBackColor = true; + this.btnAnti.Click += new System.EventHandler(this.btnAnti_Click); + // + // btnNone + // + this.btnNone.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnNone.Location = new System.Drawing.Point(247, 52); + this.btnNone.Name = "btnNone"; + this.btnNone.Size = new System.Drawing.Size(118, 23); + this.btnNone.TabIndex = 36; + this.btnNone.Text = "鍏� 涓� 閫�"; + this.btnNone.UseVisualStyleBackColor = true; + this.btnNone.Click += new System.EventHandler(this.btnNone_Click); + // + // btnGeneEntity + // + this.btnGeneEntity.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnGeneEntity.Location = new System.Drawing.Point(525, 169); + this.btnGeneEntity.Name = "btnGeneEntity"; + this.btnGeneEntity.Size = new System.Drawing.Size(312, 25); + this.btnGeneEntity.TabIndex = 38; + this.btnGeneEntity.Text = "鐢� 鎴� Entity.java"; + this.btnGeneEntity.UseVisualStyleBackColor = true; + this.btnGeneEntity.Click += new System.EventHandler(this.btnGeneEntity_Click); + // + // btnGeneMapper + // + this.btnGeneMapper.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnGeneMapper.Location = new System.Drawing.Point(525, 128); + this.btnGeneMapper.Name = "btnGeneMapper"; + this.btnGeneMapper.Size = new System.Drawing.Size(312, 25); + this.btnGeneMapper.TabIndex = 37; + this.btnGeneMapper.Text = "鐢� 鎴� Mapper.java"; + this.btnGeneMapper.UseVisualStyleBackColor = true; + this.btnGeneMapper.Click += new System.EventHandler(this.btnGeneMapper_Click); + // + // txtTabNS + // + this.txtTabNS.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtTabNS.Location = new System.Drawing.Point(525, 15); + this.txtTabNS.Name = "txtTabNS"; + this.txtTabNS.Size = new System.Drawing.Size(312, 26); + this.txtTabNS.TabIndex = 40; + this.txtTabNS.Text = "bd."; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(433, 20); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(88, 16); + this.label1.TabIndex = 39; + this.label1.Text = "琛ㄥ悕鍓嶇紑锛�"; + // + // FrmMyBatisPlus + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(852, 628); + this.Controls.Add(this.txtTabNS); + this.Controls.Add(this.label1); + this.Controls.Add(this.btnGeneEntity); + this.Controls.Add(this.btnGeneMapper); + this.Controls.Add(this.btnNone); + this.Controls.Add(this.btnAnti); + this.Controls.Add(this.btnAll); + this.Controls.Add(this.btnGeneAll); + this.Controls.Add(this.txtMapperNS); + this.Controls.Add(this.label2); + this.Controls.Add(this.txtEntityNS); + this.Controls.Add(this.label3); + this.Controls.Add(this.dgvTab); + this.Controls.Add(this.txtNS); + this.Controls.Add(this.txtTabPre); + this.Controls.Add(this.btnReadTab); + this.Controls.Add(this.tabList); + this.Name = "FrmMyBatisPlus"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "FrmMyBatisPlus"; + this.Load += new System.EventHandler(this.FrmMyBatisPlus_Load); + ((System.ComponentModel.ISupportInitialize)(this.dgvTab)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox txtNS; + private System.Windows.Forms.TextBox txtTabPre; + private System.Windows.Forms.Button btnReadTab; + private System.Windows.Forms.ListBox tabList; + private System.Windows.Forms.DataGridView dgvTab; + private System.Windows.Forms.TextBox txtEntityNS; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox txtMapperNS; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button btnGeneAll; + private System.Windows.Forms.Button btnAll; + private System.Windows.Forms.Button btnAnti; + private System.Windows.Forms.Button btnNone; + private System.Windows.Forms.Button btnGeneEntity; + private System.Windows.Forms.Button btnGeneMapper; + private System.Windows.Forms.TextBox txtTabNS; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/JavaCode/FrmMyBatisPlus.cs b/JavaCode/FrmMyBatisPlus.cs new file mode 100644 index 0000000..7ff7c13 --- /dev/null +++ b/JavaCode/FrmMyBatisPlus.cs @@ -0,0 +1,397 @@ +锘縰sing JavaCode.cs; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace JavaCode +{ + public partial class FrmMyBatisPlus : Form + { + #region 鎴愬憳鍙橀噺+鏋勯�犲嚱鏁� + private static List<string> excludes = new List<string>() { "gid", "objectid", "eventid", "dirid", "depid", "verid", "createtime", "createuser", "updateuser", "updatetime", "geom", "shape_leng", "shape_area" }; + + string baseDir = AppDomain.CurrentDomain.BaseDirectory; + + private PostgreHelper _dbHelper; + + private List<TabInfo> _list; + + public FrmMyBatisPlus() + { + InitializeComponent(); + } + + private void FrmMyBatisPlus_Load(object sender, EventArgs e) + { + _dbHelper = new PostgreHelper(DbEnum.langfang); + } + #endregion + + #region 鏌ヨ琛ㄧ粨鏋勶細163875,166056 29257,20582 + private void btnReadTab_Click(object sender, EventArgs e) + { + try + { + string tabName = this.txtTabPre.Text.Trim(); + string tabFilter = string.IsNullOrEmpty(tabName) ? "" : string.Format("and c.relname like '{0}%'", tabName); + + string sql = string.Format("select c.relname \"tab\", cast(obj_description(c.oid) as varchar) \"desc\", a.attnum \"num\", a.attname \"col\", t.typname \"type\", d.description \"bak\" from pg_attribute a left join pg_description d on d.objoid = a.attrelid and d.objsubid = a.attnum left join pg_class c on a.attrelid = c.oid left join pg_type t on a.atttypid = t.oid where a.attnum >= 0 and reltype>0 and relnamespace in ({0}) {1} order by c.relname desc, a.attnum asc", this.txtNS.Text.Trim(), tabFilter); + + DataTable dt = _dbHelper.GetDataTable(sql, null); + _list = ModelHandler.FillModel<TabInfo>(dt); + if (_list == null || _list.Count == 0) + { + MessageBox.Show("娌℃湁鏌ヨ鍒版暟鎹紒"); + return; + } + + List<string> tabList = new List<string>(); + foreach (TabInfo ti in _list) + { + if (!tabList.Contains(ti.tab)) + { + tabList.Add(ti.tab); + } + } + this.tabList.DataSource = tabList; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void btnAll_Click(object sender, EventArgs e) + { + for (int i = 0; i < this.tabList.Items.Count; i++) + { + this.tabList.SetSelected(i, true); + } + } + + private void btnAnti_Click(object sender, EventArgs e) + { + for (int i = 0; i < this.tabList.Items.Count; i++) + { + bool flag = this.tabList.GetSelected(i); + this.tabList.SetSelected(i, !flag); + } + } + + private void btnNone_Click(object sender, EventArgs e) + { + for (int i = 0; i < this.tabList.Items.Count; i++) + { + this.tabList.SetSelected(i, false); + } + } + + private void tabList_SelectedIndexChanged(object sender, EventArgs e) + { + string tab = this.tabList.SelectedItem as string; + List<TabInfo> tabs = (from p in _list where p.tab == tab orderby p.num select p).ToList<TabInfo>(); + + this.dgvTab.DataSource = new BindingList<TabInfo>(tabs); + if (tabs != null && tabs.Count > 1) + { + this.dgvTab.Rows[1].Selected = true; + this.dgvTab.CurrentCell = this.dgvTab.Rows[1].Cells[0]; + } + } + #endregion + + #region 鎸夐挳浜嬩欢 + private void btnGeneMapper_Click(object sender, EventArgs e) + { + try + { + string path = Path.Combine(baseDir, "BsGenerate\\Mapper"); + + List<string> names = GetTabList(); + foreach (string name in names) + { + List<TabInfo> tabs = GetTabInfo(name); + GenerateMapper(path, name, tabs); + } + + OpenFolder(path); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void btnGeneEntity_Click(object sender, EventArgs e) + { + try + { + string path = Path.Combine(baseDir, "BsGenerate\\Entity"); + + List<string> names = GetTabList(); + foreach (string name in names) + { + List<TabInfo> tabs = GetTabInfo(name); + GenerateEntity(path, name, tabs); + } + + OpenFolder(path); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void btnGeneAll_Click(object sender, EventArgs e) + { + try + { + string mapperPath = Path.Combine(baseDir, "BsGenerate\\Mapper"); + string entityPath = Path.Combine(baseDir, "BsGenerate\\Entity"); + + List<string> names = GetTabList(); + foreach (string name in names) + { + List<TabInfo> tabs = GetTabInfo(name); + GenerateMapper(mapperPath, name, tabs); + GenerateEntity(entityPath, name, tabs); + } + + string path = Path.Combine(baseDir, "BsGenerate"); + OpenFolder(path); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + #endregion + + #region 鐢熸垚 Mapper + private void GenerateMapper(string path, string name, List<TabInfo> tabs) + { + if (!Directory.Exists(path)) Directory.CreateDirectory(path); + + string tabName = this.txtTabNS.Text.Trim() + name; + //string shortName = NameConvert(name, true); + string shortName = GetEntityName(name, true); + + string mapperNS = this.txtMapperNS.Text.Trim(); + string mapperName = shortName + "Mapper"; + + string entityNS = this.txtEntityNS.Text.Trim(); + string entityName = shortName + "Entity"; + + string bak = string.IsNullOrWhiteSpace(tabs[0].desc) ? shortName : tabs[0].desc.Replace("琛�", ""); + + string javaFile = this.HasGeom(tabs) ? "GeoMapper.java" : "Mapper.java"; + string xml = File.ReadAllText(Path.Combine(baseDir, "BsTemplate\\" + javaFile)); + xml = xml + .Replace("{mapperNS}", mapperNS) + .Replace("{mapperName}", mapperName) + .Replace("{entityNS}", entityNS) + .Replace("{entityName}", entityName) + .Replace("{bak}", bak); + + string fileName = shortName + "Mapper.java"; + File.WriteAllText(Path.Combine(path, fileName), xml); + } + #endregion + + #region 鐢熸垚 Entity + private void GenerateEntity(string path, string name, List<TabInfo> tabs) + { + if (!Directory.Exists(path)) Directory.CreateDirectory(path); + + string tabName = this.txtTabNS.Text.Trim() + name; + //string shortName = NameConvert(name, true); + string shortName = GetEntityName(name, true); + + string entityNS = this.txtEntityNS.Text.Trim(); + string entityName = shortName + "Entity"; + + string bak = string.IsNullOrWhiteSpace(tabs[0].desc) ? shortName : tabs[0].desc.Replace("琛�", ""); + long uid = (long)Math.Floor((new Random()).NextDouble() * 1000000000000000000D); + + string javaFile = this.HasGeom(tabs) ? "GeoEntity.java" : "Entity.java"; + string xml = File.ReadAllText(Path.Combine(baseDir, "BsTemplate\\" + javaFile)); + xml = xml + .Replace("{entityNS}", entityNS) + .Replace("{entityName}", entityName) + .Replace("{bak}", bak) + .Replace("{tabName}", tabName) + .Replace("{uid}", uid.ToString()); + + StringBuilder sb = new StringBuilder(); + foreach (TabInfo ti in tabs) + { + string type = GetJavaType(ti); + //if (ti.col == "gid") sb.Append("\r\n @TableId(type = IdType.AUTO)"); + //if (ti.col == "geom" || ti.col == "shape_leng" || ti.col == "shape_area") + //{ + // sb.Append("\r\n @TableField(select = false)"); + //} + if (excludes.Contains(ti.col)) continue; + if (ti.col == "class") + { + //sb.Append("\r\n @TableField(value = \"class\")"); + //ti.col = "clazz"; + //ti.col = "classes"; + MessageBox.Show(ti.tab); + return; + } + + string colName = NameConvert(ti.col, false); + sb.Append("\r\n private " + type + " " + colName + ";\r\n"); + } + sb.Append("\r\n public " + entityName + "() {\r\n }\r\n"); + + foreach (TabInfo ti in tabs) + { + if (excludes.Contains(ti.col)) continue; + + string type = GetJavaType(ti); + string col1 = NameConvert(ti.col, true); + string col2 = NameConvert(ti.col, false); + + sb.Append("\r\n public " + type + " get" + col1 + "() {\r\n return " + col2 + ";\r\n }\r\n"); + sb.Append("\r\n public void set" + col1 + "(" + type + " " + col2 + ") {\r\n this." + col2 + " = " + col2 + ";\r\n }\r\n"); + } + sb.Append("}\r\n"); + sb.Insert(0, xml); + + string fileName = shortName + "Entity.java"; + File.WriteAllText(Path.Combine(path, fileName), sb.ToString()); + } + #endregion + + #region 鍏叡鏂规硶 + private List<string> GetTabList() + { + List<string> list = new List<string>(); + for (int i = 0, c = this.tabList.SelectedItems.Count; i < c; i++) + { + string item = this.tabList.SelectedItems[i] as String; + if (!string.IsNullOrEmpty(item)) + { + list.Add(item); + } + } + + return list; + } + + private List<TabInfo> GetTabInfo(string name) + { + List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); + + return tabs; + } + + private static string GetEntityName(string name, bool firstUpper) + { + return firstUpper ? ToUpperFirst(name.Replace("_", "")) : name.Replace("_", ""); + } + + private static string NameConvert(string name, bool firstUpper) + { + string[] strs = name.Split(new char[] { '_' }); + + string str = ""; + for (int i = 0, c = strs.Length; i < c; i++) + { + if (i == 0 && !firstUpper) + { + str += strs[i]; + continue; + } + + str += strs[i].Length == 1 ? strs[i] : ToUpperFirst(strs[i]); + } + + return str; + } + + public static string ToUpperFirst(string str) + { + return Regex.Replace(str, @"^\w", t => t.Value.ToUpper()); + } + + private string GetJavaType(TabInfo ti) + { + switch (ti.type) + { + case "timestamp": + return "Timestamp"; + case "float4": // float + return "Float"; + case "float8": // double + return "Double"; + case "bool": // boolean + return "Boolean"; + case "numeric": + return "BigDecimal"; + case "int8": // long + return "Long"; + case "int2": + case "int4": // int + return "Integer"; + default: + return "String"; + } + } + + private bool HasGeom(List<TabInfo> tabs) + { + foreach (TabInfo ti in tabs) + { + if (ti.col == "geom") return true; + } + + return false; + } + + private static void OpenFolder(string folderPath) + { + if (string.IsNullOrEmpty(folderPath)) return; + + Process process = new Process(); + ProcessStartInfo psi = new ProcessStartInfo("Explorer.exe"); + psi.Arguments = folderPath; + process.StartInfo = psi; + + try + { + process.Start(); + } + catch (Exception ex) + { + throw ex; + } + finally + { + process.Close(); + } + } + + private String QueryPrimaryKey(string tab) + { + string sql = string.Format("select pg_attribute.attname as colname from pg_constraint inner join pg_class on pg_constraint.conrelid = pg_class.oid inner join pg_attribute on pg_attribute.attrelid = pg_class.oid and pg_attribute.attnum = pg_constraint.conkey[1] inner join pg_type on pg_type.oid = pg_attribute.atttypid where pg_class.relname = '{0}' and pg_constraint.contype='p'", tab); + + object obj = _dbHelper.GetScalar(sql, null); + + return obj == null ? null : obj.ToString(); + } + #endregion + } +} diff --git a/JavaCode/FrmMyBatisPlus.resx b/JavaCode/FrmMyBatisPlus.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/JavaCode/FrmMyBatisPlus.resx @@ -0,0 +1,120 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file diff --git a/JavaCode/FrmSys.Designer.cs b/JavaCode/FrmSys.Designer.cs new file mode 100644 index 0000000..1f245e1 --- /dev/null +++ b/JavaCode/FrmSys.Designer.cs @@ -0,0 +1,410 @@ +锘縩amespace JavaCode +{ + partial class FrmSys + { + /// <summary> + /// 蹇呴渶鐨勮璁″櫒鍙橀噺銆� + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// 娓呯悊鎵�鏈夋鍦ㄤ娇鐢ㄧ殑璧勬簮銆� + /// </summary> + /// <param name="disposing">濡傛灉搴旈噴鏀炬墭绠¤祫婧愶紝涓� true锛涘惁鍒欎负 false銆�</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 绐椾綋璁捐鍣ㄧ敓鎴愮殑浠g爜 + + /// <summary> + /// 璁捐鍣ㄦ敮鎸佹墍闇�鐨勬柟娉� - 涓嶈 + /// 浣跨敤浠g爜缂栬緫鍣ㄤ慨鏀规鏂规硶鐨勫唴瀹广�� + /// </summary> + private void InitializeComponent() + { + this.tabList = new System.Windows.Forms.ListBox(); + this.btnReadTab = new System.Windows.Forms.Button(); + this.txtTabPre = new System.Windows.Forms.TextBox(); + this.txtMapperNS = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.txtEntityNS = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.button4 = new System.Windows.Forms.Button(); + this.dgvTab = new System.Windows.Forms.DataGridView(); + this.label4 = new System.Windows.Forms.Label(); + this.txtInsert = new System.Windows.Forms.TextBox(); + this.txtUpdate = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.button5 = new System.Windows.Forms.Button(); + this.button6 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.txtNS = new System.Windows.Forms.TextBox(); + this.button2 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.txtServiceNS = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.txtControllerNS = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.txtApiTag = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.txtTabNS = new System.Windows.Forms.TextBox(); + ((System.ComponentModel.ISupportInitialize)(this.dgvTab)).BeginInit(); + this.SuspendLayout(); + // + // tabList + // + this.tabList.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.tabList.FormattingEnabled = true; + this.tabList.ItemHeight = 16; + this.tabList.Location = new System.Drawing.Point(12, 49); + this.tabList.Name = "tabList"; + this.tabList.Size = new System.Drawing.Size(353, 244); + this.tabList.TabIndex = 0; + this.tabList.SelectedIndexChanged += new System.EventHandler(this.tabList_SelectedIndexChanged); + // + // btnReadTab + // + this.btnReadTab.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnReadTab.Location = new System.Drawing.Point(247, 13); + this.btnReadTab.Name = "btnReadTab"; + this.btnReadTab.Size = new System.Drawing.Size(118, 23); + this.btnReadTab.TabIndex = 1; + this.btnReadTab.Text = "璇诲彇鏁版嵁搴撹〃"; + this.btnReadTab.UseVisualStyleBackColor = true; + this.btnReadTab.Click += new System.EventHandler(this.btnReadTab_Click); + // + // txtTabPre + // + this.txtTabPre.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtTabPre.Location = new System.Drawing.Point(129, 10); + this.txtTabPre.Name = "txtTabPre"; + this.txtTabPre.Size = new System.Drawing.Size(100, 26); + this.txtTabPre.TabIndex = 2; + this.txtTabPre.Text = "sys_"; + // + // txtMapperNS + // + this.txtMapperNS.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtMapperNS.Location = new System.Drawing.Point(529, 51); + this.txtMapperNS.Name = "txtMapperNS"; + this.txtMapperNS.Size = new System.Drawing.Size(339, 26); + this.txtMapperNS.TabIndex = 9; + this.txtMapperNS.Text = "com.lf.server.mapper.sys"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(389, 56); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(136, 16); + this.label2.TabIndex = 8; + this.label2.Text = "Mapper鍚嶇О绌洪棿锛�"; + // + // txtEntityNS + // + this.txtEntityNS.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtEntityNS.Location = new System.Drawing.Point(529, 88); + this.txtEntityNS.Name = "txtEntityNS"; + this.txtEntityNS.Size = new System.Drawing.Size(339, 26); + this.txtEntityNS.TabIndex = 11; + this.txtEntityNS.Text = "com.lf.server.entity.sys"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label3.Location = new System.Drawing.Point(389, 93); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(136, 16); + this.label3.TabIndex = 10; + this.label3.Text = "Entity鍚嶇О绌洪棿锛�"; + // + // button4 + // + this.button4.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button4.Location = new System.Drawing.Point(885, 202); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(183, 25); + this.button4.TabIndex = 12; + this.button4.Text = "鐢� 鎴� 鎵� 鏈� 鏂� 浠�"; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.generateAll_Click); + // + // dgvTab + // + this.dgvTab.AllowUserToAddRows = false; + this.dgvTab.AllowUserToDeleteRows = false; + this.dgvTab.BackgroundColor = System.Drawing.SystemColors.ButtonFace; + this.dgvTab.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvTab.Location = new System.Drawing.Point(12, 312); + this.dgvTab.Margin = new System.Windows.Forms.Padding(0); + this.dgvTab.MultiSelect = false; + this.dgvTab.Name = "dgvTab"; + this.dgvTab.ReadOnly = true; + this.dgvTab.RowHeadersWidth = 40; + this.dgvTab.RowTemplate.Height = 23; + this.dgvTab.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.dgvTab.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgvTab.Size = new System.Drawing.Size(1056, 300); + this.dgvTab.TabIndex = 13; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label4.Location = new System.Drawing.Point(387, 241); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(136, 16); + this.label4.TabIndex = 14; + this.label4.Text = "鎻掑叆鏃舵帓闄ゅ瓧娈碉細"; + // + // txtInsert + // + this.txtInsert.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtInsert.Location = new System.Drawing.Point(529, 236); + this.txtInsert.Name = "txtInsert"; + this.txtInsert.Size = new System.Drawing.Size(339, 26); + this.txtInsert.TabIndex = 15; + this.txtInsert.Text = "id,update_user,update_time"; + // + // txtUpdate + // + this.txtUpdate.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtUpdate.Location = new System.Drawing.Point(529, 271); + this.txtUpdate.Name = "txtUpdate"; + this.txtUpdate.Size = new System.Drawing.Size(339, 26); + this.txtUpdate.TabIndex = 17; + this.txtUpdate.Text = "id,create_user,create_time"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label5.Location = new System.Drawing.Point(387, 276); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(136, 16); + this.label5.TabIndex = 16; + this.label5.Text = "鏇存柊鏃舵帓闄ゅ瓧娈碉細"; + // + // button5 + // + this.button5.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button5.Location = new System.Drawing.Point(885, 14); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(183, 25); + this.button5.TabIndex = 18; + this.button5.Text = "鐢� 鎴� Mapper.xml"; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.mapperXml_Click); + // + // button6 + // + this.button6.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button6.Location = new System.Drawing.Point(885, 52); + this.button6.Name = "button6"; + this.button6.Size = new System.Drawing.Size(183, 25); + this.button6.TabIndex = 19; + this.button6.Text = "鐢� 鎴� Mapper.java"; + this.button6.UseVisualStyleBackColor = true; + this.button6.Click += new System.EventHandler(this.mapperJava_Click); + // + // button1 + // + this.button1.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(885, 89); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(183, 25); + this.button1.TabIndex = 20; + this.button1.Text = "鐢� 鎴� Entity.java"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.entityJava_Click); + // + // txtNS + // + this.txtNS.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtNS.Location = new System.Drawing.Point(12, 10); + this.txtNS.Name = "txtNS"; + this.txtNS.Size = new System.Drawing.Size(100, 26); + this.txtNS.TabIndex = 21; + this.txtNS.Text = "20582"; + // + // button2 + // + this.button2.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button2.Location = new System.Drawing.Point(885, 127); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(183, 25); + this.button2.TabIndex = 22; + this.button2.Text = "鐢� 鎴� Service.java"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.serviceJava_Click); + // + // button3 + // + this.button3.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button3.Location = new System.Drawing.Point(885, 165); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(183, 25); + this.button3.TabIndex = 23; + this.button3.Text = "鐢熸垚 Controller.java"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.controllerJava_Click); + // + // txtServiceNS + // + this.txtServiceNS.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtServiceNS.Location = new System.Drawing.Point(529, 126); + this.txtServiceNS.Name = "txtServiceNS"; + this.txtServiceNS.Size = new System.Drawing.Size(339, 26); + this.txtServiceNS.TabIndex = 25; + this.txtServiceNS.Text = "com.lf.server.service.sys"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label6.Location = new System.Drawing.Point(381, 131); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(144, 16); + this.label6.TabIndex = 24; + this.label6.Text = "Service鍚嶇О绌洪棿锛�"; + // + // txtControllerNS + // + this.txtControllerNS.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtControllerNS.Location = new System.Drawing.Point(529, 164); + this.txtControllerNS.Name = "txtControllerNS"; + this.txtControllerNS.Size = new System.Drawing.Size(339, 26); + this.txtControllerNS.TabIndex = 27; + this.txtControllerNS.Text = "com.lf.server.controller.sys"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label7.Location = new System.Drawing.Point(365, 169); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(160, 16); + this.label7.TabIndex = 26; + this.label7.Text = "Controller鍚嶇О绌洪棿:"; + // + // txtApiTag + // + this.txtApiTag.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtApiTag.Location = new System.Drawing.Point(529, 201); + this.txtApiTag.Name = "txtApiTag"; + this.txtApiTag.Size = new System.Drawing.Size(339, 26); + this.txtApiTag.TabIndex = 29; + this.txtApiTag.Text = "杩愮淮绠$悊\\\\{bak}"; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label8.Location = new System.Drawing.Point(445, 206); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(80, 16); + this.label8.TabIndex = 28; + this.label8.Text = "Api鏍囪瘑锛�"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(437, 18); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(88, 16); + this.label1.TabIndex = 6; + this.label1.Text = "琛ㄥ悕鍓嶇紑锛�"; + // + // txtTabNS + // + this.txtTabNS.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtTabNS.Location = new System.Drawing.Point(529, 13); + this.txtTabNS.Name = "txtTabNS"; + this.txtTabNS.Size = new System.Drawing.Size(339, 26); + this.txtTabNS.TabIndex = 7; + this.txtTabNS.Text = "lf."; + // + // FrmSys + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1095, 630); + this.Controls.Add(this.txtApiTag); + this.Controls.Add(this.label8); + this.Controls.Add(this.txtControllerNS); + this.Controls.Add(this.label7); + this.Controls.Add(this.txtServiceNS); + this.Controls.Add(this.label6); + this.Controls.Add(this.button3); + this.Controls.Add(this.button2); + this.Controls.Add(this.txtNS); + this.Controls.Add(this.button1); + this.Controls.Add(this.button6); + this.Controls.Add(this.button5); + this.Controls.Add(this.txtUpdate); + this.Controls.Add(this.label5); + this.Controls.Add(this.txtInsert); + this.Controls.Add(this.label4); + this.Controls.Add(this.dgvTab); + this.Controls.Add(this.button4); + this.Controls.Add(this.txtEntityNS); + this.Controls.Add(this.label3); + this.Controls.Add(this.txtMapperNS); + this.Controls.Add(this.label2); + this.Controls.Add(this.txtTabNS); + this.Controls.Add(this.label1); + this.Controls.Add(this.txtTabPre); + this.Controls.Add(this.btnReadTab); + this.Controls.Add(this.tabList); + this.Name = "FrmSys"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "FrmSys"; + this.Load += new System.EventHandler(this.FrmMain_Load); + ((System.ComponentModel.ISupportInitialize)(this.dgvTab)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ListBox tabList; + private System.Windows.Forms.Button btnReadTab; + private System.Windows.Forms.TextBox txtTabPre; + private System.Windows.Forms.TextBox txtMapperNS; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox txtEntityNS; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.DataGridView dgvTab; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TextBox txtInsert; + private System.Windows.Forms.TextBox txtUpdate; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Button button6; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.TextBox txtNS; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.TextBox txtServiceNS; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.TextBox txtControllerNS; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox txtApiTag; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox txtTabNS; + } +} + diff --git a/JavaCode/FrmSys.cs b/JavaCode/FrmSys.cs new file mode 100644 index 0000000..a803972 --- /dev/null +++ b/JavaCode/FrmSys.cs @@ -0,0 +1,678 @@ +锘縰sing JavaCode.cs; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace JavaCode +{ + public partial class FrmSys : Form + { + #region 鎴愬憳鍙橀噺+鏋勯�犲嚱鏁� + string baseDir = AppDomain.CurrentDomain.BaseDirectory; + + private PostgreHelper _dbHelper; + + private List<TabInfo> _list; + + public FrmSys() + { + InitializeComponent(); + } + + private void FrmMain_Load(object sender, EventArgs e) + { + _dbHelper = new PostgreHelper(DbEnum.langfang); + } + #endregion + + #region 鏌ヨ琛ㄧ粨鏋� + private void btnReadTab_Click(object sender, EventArgs e) + { + string txtTab = this.txtTabPre.Text.Trim(); + string sql = "select c.relname \"tab\", cast(obj_description(c.oid) as varchar) \"desc\", a.attnum \"num\", a.attname \"col\", t.typname \"type\", d.description \"bak\" from pg_attribute a left join pg_description d on d.objoid = a.attrelid and d.objsubid = a.attnum left join pg_class c on a.attrelid = c.oid left join pg_type t on a.atttypid = t.oid where a.attnum >= 0 and c.relname like '" + txtTab + "%' and obj_description(c.oid) is not null and relnamespace=" + this.txtNS.Text.Trim() + " order by c.relname desc, a.attnum asc"; + + DataTable dt = _dbHelper.GetDataTable(sql, null); + + _list = ModelHandler.FillModel<TabInfo>(dt); + if (_list == null || _list.Count == 0) + { + MessageBox.Show("娌℃湁鏌ヨ鍒版暟鎹紒"); + return; + } + + List<string> tabList = new List<string>(); + foreach (TabInfo ti in _list) + { + if (!tabList.Contains(ti.tab)) + { + tabList.Add(ti.tab); + } + } + + this.tabList.DataSource = tabList; + } + + private void tabList_SelectedIndexChanged(object sender, EventArgs e) + { + string tab = this.tabList.SelectedItem as string; + List<TabInfo> tabs = (from p in _list where p.tab == tab orderby p.num select p).ToList<TabInfo>(); + + this.dgvTab.DataSource = new BindingList<TabInfo>(tabs); + if (tabs != null && tabs.Count > 1) + { + this.dgvTab.Rows[1].Selected = true; + this.dgvTab.CurrentCell = this.dgvTab.Rows[1].Cells[0]; + } + } + #endregion + + #region 鐢熸垚 Mapper.Xml + private void mapperXml_Click(object sender, EventArgs e) + { + try + { + string name = this.tabList.SelectedItem as string; + List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); + + GenerateMapperXml(name, tabs); + + string path = Path.Combine(baseDir, "SysGenerate"); + OpenFolder(path); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void GenerateMapperXml(string name, List<TabInfo> tabs) + { + string tabName = this.txtTabNS.Text.Trim() + name; + name = name.Replace(this.txtTabPre.Text, ""); + + string shortName = NameConvert(name, true); + string mapperNS = this.txtMapperNS.Text.Trim(); + string mapperName = shortName + "Mapper"; + string entityNS = this.txtEntityNS.Text.Trim(); + string entityName = shortName + "Entity"; + + int idx = this.dgvTab.CurrentRow.Index; + TabInfo selectTabInfo = tabs[idx]; + + string colType = GetJavaType(selectTabInfo); + string colName = NameConvert(selectTabInfo.col, false); + string testExpr = colName + " != null"; + string testWhere = selectTabInfo.col + (colType == "String" ? " like " : " = ") + "#{" + colName + "}"; + + string insertCols = GetInsertCols(tabs); + string insertVal = GetInsertVal(tabs); + string insertVals = GetInsertVals(tabs); + string updateVal = GetUpdateVal(tabs); + string updateVals = GetUpdateVals(tabs); + + string xml = File.ReadAllText(Path.Combine(baseDir, "SysTemplate\\Mapper.xml")); + xml = xml + .Replace("{mapperNS}", mapperNS) + .Replace("{mapperName}", mapperName) + .Replace("{tabName}", tabName) + .Replace("{testExpr}", testExpr) + .Replace("{testWhere}", testWhere) + .Replace("{entityNS}", entityNS) + .Replace("{entityName}", entityName) + .Replace("{insertCols}", insertCols) + .Replace("{insertVal}", insertVal) + .Replace("{insertVals}", insertVals) + .Replace("{updateVal}", updateVal) + .Replace("{updateVals}", updateVals); + + string path = Path.Combine(baseDir, "SysGenerate"); + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + + string fileName = shortName + "Mapper.xml"; + File.WriteAllText(Path.Combine(path, fileName), xml); + } + + private static string NameConvert(string name, bool firstUpper) + { + string[] strs = name.Split(new char[] { '_' }); + + string str = ""; + for (int i = 0, c = strs.Length; i < c; i++) + { + if (i == 0 && !firstUpper) + { + str += strs[i]; + continue; + } + str += ToUpperFirst(strs[i]); + } + + return str; + } + + public static string ToUpperFirst(string str) + { + return Regex.Replace(str, @"^\w", t => t.Value.ToUpper()); + } + + public string GetInsertCols(List<TabInfo> tabs) + { + List<string> excluds = this.txtInsert.Text.Trim().Split(new char[] { ',' }).ToList<string>(); + + StringBuilder sb = new StringBuilder(); + foreach (TabInfo ti in tabs) + { + if (excluds.Contains(ti.col)) + { + continue; + } + + sb.Append(ti.col + ","); + } + + if (sb.Length > 0) + { + sb.Remove(sb.Length - 1, 1); + } + + return sb.ToString(); + } + + public string GetInsertVal(List<TabInfo> tabs) + { + List<string> excluds = this.txtInsert.Text.Trim().Split(new char[] { ',' }).ToList<string>(); + + StringBuilder sb = new StringBuilder(); + foreach (TabInfo ti in tabs) + { + if (excluds.Contains(ti.col)) + { + continue; + } + if (ti.type == "timestamp") + { + sb.Append("now(),"); + continue; + } + + sb.Append("#{" + NameConvert(ti.col, false) + "},"); + } + + if (sb.Length > 0) + { + sb.Remove(sb.Length - 1, 1); + } + + return sb.ToString(); + } + + public string GetInsertVals(List<TabInfo> tabs) + { + List<string> excluds = this.txtInsert.Text.Trim().Split(new char[] { ',' }).ToList<string>(); + + StringBuilder sb = new StringBuilder(); + foreach (TabInfo ti in tabs) + { + if (excluds.Contains(ti.col)) + { + continue; + } + if (ti.type == "timestamp") + { + sb.Append("now(),"); + continue; + } + + sb.Append("#{item." + NameConvert(ti.col, false) + "},"); + } + + if (sb.Length > 0) + { + sb.Remove(sb.Length - 1, 1); + } + + return sb.ToString(); + } + + public string GetUpdateVal(List<TabInfo> tabs) + { + List<string> excluds = this.txtUpdate.Text.Trim().Split(new char[] { ',' }).ToList<string>(); + + StringBuilder sb = new StringBuilder(); + foreach (TabInfo ti in tabs) + { + if (excluds.Contains(ti.col)) + { + continue; + } + if (ti.type == "timestamp") + { + sb.Append(ti.col + "=now(),"); + continue; + } + + sb.Append(ti.col + "=#{" + NameConvert(ti.col, false) + "},"); + } + + if (sb.Length > 0) + { + sb.Remove(sb.Length - 1, 1); + } + + return sb.ToString(); + } + + public string GetUpdateVals(List<TabInfo> tabs) + { + List<string> excluds = this.txtUpdate.Text.Trim().Split(new char[] { ',' }).ToList<string>(); + + StringBuilder sb = new StringBuilder(); + foreach (TabInfo ti in tabs) + { + if (excluds.Contains(ti.col)) + { + continue; + } + if (ti.type == "timestamp") + { + sb.Append(ti.col + "=now(),"); + continue; + } + + sb.Append(ti.col + "=#{item." + NameConvert(ti.col, false) + "},"); + } + + if (sb.Length > 0) + { + sb.Remove(sb.Length - 1, 1); + } + + return sb.ToString(); + } + + private static void OpenFolder(string folderPath) + { + if (string.IsNullOrEmpty(folderPath)) return; + + Process process = new Process(); + ProcessStartInfo psi = new ProcessStartInfo("Explorer.exe"); + psi.Arguments = folderPath; + process.StartInfo = psi; + + try + { + process.Start(); + } + catch (Exception ex) + { + throw ex; + } + finally + { + process.Close(); + } + } + #endregion + + #region 鐢熸垚 Mapper.java + private void mapperJava_Click(object sender, EventArgs e) + { + try + { + string name = this.tabList.SelectedItem as string; + List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); + + GenerateMapperJava(name, tabs); + + string path = Path.Combine(baseDir, "SysGenerate"); + OpenFolder(path); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void GenerateMapperJava(string name, List<TabInfo> tabs) + { + name = name.Replace(this.txtTabPre.Text, ""); + + string shortName = NameConvert(name, true); + string mapperNS = this.txtMapperNS.Text.Trim(); + string entityNS = this.txtEntityNS.Text.Trim(); + string mapperName = shortName + "Mapper"; + string entityName = shortName + "Entity"; + string bak = tabs[0].desc.Replace("琛�", ""); + + int idx = this.dgvTab.CurrentRow.Index; + TabInfo selectTabInfo = tabs[idx]; + + string colType = GetJavaType(selectTabInfo); + string colName = NameConvert(selectTabInfo.col, false); + string queryCol = colType + " " + colName; + string colBak = selectTabInfo.bak; + + string xml = File.ReadAllText(Path.Combine(baseDir, "SysTemplate\\Mapper.java")); + xml = xml + .Replace("{mapperNS}", mapperNS) + .Replace("{mapperName}", mapperName) + .Replace("{entityNS}", entityNS) + .Replace("{entityName}", entityName) + .Replace("{colName}", colName) + .Replace("{colBak}", colBak) + .Replace("{bak}", bak) + .Replace("{queryCol}", queryCol); + + string path = Path.Combine(baseDir, "SysGenerate"); + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + + string fileName = shortName + "Mapper.java"; + File.WriteAllText(Path.Combine(path, fileName), xml); + } + + private string GetJavaType(TabInfo ti) + { + switch (ti.type) + { + case "timestamp": + return "Timestamp"; + case "float4": // float + return "Float"; + case "float8": // double + return "Double"; + case "bool": // boolean + return "Boolean"; + case "numeric": + return "BigDecimal"; + case "int8": // long + return "Long"; + case "int2": + case "int4": // int + return "Integer"; + default: + return "String"; + } + } + + private String GetType(TabInfo ti) + { + switch (ti.type) + { + case "timestamp": + return "Timestamp"; + case "float4": + return "float"; + case "float8": + return "double"; + case "bool": + return "boolean"; + case "numeric": + return "BigDecimal"; + case "int8": + return "long"; + case "int2": + case "int4": + return "int"; + default: + return "String"; + } + } + #endregion + + #region 鐢熸垚 Entity.java + private void entityJava_Click(object sender, EventArgs e) + { + try + { + string name = this.tabList.SelectedItem as string; + List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); + + GenerateEntityJava(name, tabs); + + string path = Path.Combine(baseDir, "SysGenerate"); + OpenFolder(path); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void GenerateEntityJava(string name, List<TabInfo> tabs) + { + name = name.Replace(this.txtTabPre.Text, ""); + + string shortName = NameConvert(name, true); + string entityNS = this.txtEntityNS.Text.Trim(); + string entityName = shortName + "Entity"; + string bak = tabs[0].desc.Replace("琛�", ""); + long uid = (long)Math.Floor((new Random()).NextDouble() * 1000000000000000000D); + + int idx = this.dgvTab.CurrentRow.Index; + TabInfo selectTabInfo = tabs[idx]; + + string xml = File.ReadAllText(Path.Combine(baseDir, "SysTemplate\\Entity.java")); + xml = xml + .Replace("{entityNS}", entityNS) + .Replace("{entityName}", entityName) + .Replace("{bak}", bak) + .Replace("{uid}", uid.ToString()); + + StringBuilder sb = new StringBuilder(); + foreach (TabInfo ti in tabs) + { + string type = GetType(ti); + string colName = NameConvert(ti.col, false); + sb.Append("\r\n private " + type + " " + colName + ";\r\n"); + } + + sb.Append("\r\n public " + entityName + "() {\r\n }\r\n"); + + foreach (TabInfo ti in tabs) + { + string type = GetType(ti); + string col1 = NameConvert(ti.col, true); + string col2 = NameConvert(ti.col, false); + + sb.Append("\r\n public " + type + " get" + col1 + "() {\r\n return " + col2 + ";\r\n }\r\n"); + sb.Append("\r\n public void set" + col1 + "(" + type + " " + col2 + ") {\r\n this." + col2 + " = " + col2 + ";\r\n }\r\n"); + } + sb.Append("}\r\n"); + + string path = Path.Combine(baseDir, "SysGenerate"); + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + + sb.Insert(0, xml); + + string fileName = shortName + "Entity.java"; + File.WriteAllText(Path.Combine(path, fileName), sb.ToString()); + } + #endregion + + #region 鐢熸垚 Service.java + private void serviceJava_Click(object sender, EventArgs e) + { + try + { + string name = this.tabList.SelectedItem as string; + List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); + + GenerateServiceJava(name, tabs); + + string path = Path.Combine(baseDir, "SysGenerate"); + OpenFolder(path); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void GenerateServiceJava(string name, List<TabInfo> tabs) + { + name = name.Replace(this.txtTabPre.Text, ""); + + string shortName = NameConvert(name, true); + string mapperNS = this.txtMapperNS.Text.Trim(); + string entityNS = this.txtEntityNS.Text.Trim(); + string serviceNS = this.txtServiceNS.Text.Trim(); + string mapperName = shortName + "Mapper"; + string minMapperName = NameConvert(name, false) + "Mapper"; + string entityName = shortName + "Entity"; + string serviceName = shortName + "Service"; + string bak = tabs[0].desc.Replace("琛�", ""); + + int idx = this.dgvTab.CurrentRow.Index; + TabInfo selectTabInfo = tabs[idx]; + + string colType = GetJavaType(selectTabInfo); + string colName = NameConvert(selectTabInfo.col, false); + string queryCol = colType + " " + colName; + + //string where = isString ? "\r\n " + colName + " = \"%\" + (StringHelper.isNull(" + colName + ") ? \"\" : " + colName + ".trim()) + \"%\";\r\n" : ""; + //string where = colType == "String" ? "\r\n " + colName + " = StringHelper.isNull(" + colName + ") ? null : \"%\" + " + colName + ".trim() + \"%\";\r\n" : ""; + string where = colType == "String" ? "\r\n " + colName + " = StringHelper.getLikeStr(" + colName + ");\r\n" : ""; + + string xml = File.ReadAllText(Path.Combine(baseDir, "SysTemplate\\Service.java")); + xml = xml + .Replace("{mapperNS}", mapperNS) + .Replace("{mapperName}", mapperName) + .Replace("{minMapperName}", minMapperName) + .Replace("{entityNS}", entityNS) + .Replace("{entityName}", entityName) + .Replace("{serviceNS}", serviceNS) + .Replace("{serviceName}", serviceName) + .Replace("{bak}", bak) + .Replace("{queryCol}", queryCol) + .Replace("{colName}", colName) + .Replace("{where}", where); + + string path = Path.Combine(baseDir, "SysGenerate"); + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + + string fileName = shortName + "Service.java"; + File.WriteAllText(Path.Combine(path, fileName), xml); + } + #endregion + + #region 鐢熸垚 Controller.java + private void controllerJava_Click(object sender, EventArgs e) + { + try + { + string name = this.tabList.SelectedItem as string; + List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); + + GenerateControllerJava(name, tabs); + + string path = Path.Combine(baseDir, "SysGenerate"); + OpenFolder(path); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void GenerateControllerJava(string name, List<TabInfo> tabs) + { + name = name.Replace(this.txtTabPre.Text, ""); + + string shortName = NameConvert(name, true); + string mapperNS = this.txtMapperNS.Text.Trim(); + string entityNS = this.txtEntityNS.Text.Trim(); + string serviceNS = this.txtServiceNS.Text.Trim(); + string controllerNS = this.txtControllerNS.Text.Trim(); + string apiTag = this.txtApiTag.Text.Trim(); + string mapperName = shortName + "Mapper"; + string entityName = shortName + "Entity"; + string serviceName = shortName + "Service"; + string minServiceName = NameConvert(name, false) + "Service"; + string controllerName = shortName + "Controller"; + string bak = tabs[0].desc.Replace("琛�", ""); + string apiName = NameConvert(name, false); + + int idx = this.dgvTab.CurrentRow.Index; + TabInfo selectTabInfo = tabs[idx]; + + string colType = GetJavaType(selectTabInfo); + string colName = NameConvert(selectTabInfo.col, false); + string queryCol = colType + " " + colName; + string colBak = selectTabInfo.bak; + + string xml = File.ReadAllText(Path.Combine(baseDir, "SysTemplate\\Controller.java")); + xml = xml + .Replace("{mapperNS}", mapperNS) + .Replace("{mapperName}", mapperName) + .Replace("{entityNS}", entityNS) + .Replace("{entityName}", entityName) + .Replace("{serviceNS}", serviceNS) + .Replace("{serviceName}", serviceName) + .Replace("{controllerNS}", controllerNS) + .Replace("{controllerName}", controllerName) + .Replace("{minServiceName}", minServiceName) + .Replace("{queryCol}", queryCol) + .Replace("{colName}", colName) + .Replace("{colBak}", colBak) + .Replace("{colType}", colType) + .Replace("{apiTag}", apiTag) + .Replace("{apiName}", apiName) + .Replace("{bak}", bak); + + string path = Path.Combine(baseDir, "SysGenerate"); + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + + string fileName = shortName + "Controller.java"; + File.WriteAllText(Path.Combine(path, fileName), xml); + } + #endregion + + #region 鐢熸垚鎵�鏈夋枃浠� + private void generateAll_Click(object sender, EventArgs e) + { + try + { + string name = this.tabList.SelectedItem as string; + List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); + + GenerateMapperXml(name, tabs); + GenerateMapperJava(name, tabs); + GenerateEntityJava(name, tabs); + GenerateServiceJava(name, tabs); + GenerateControllerJava(name, tabs); + + string path = Path.Combine(baseDir, "SysGenerate"); + OpenFolder(path); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + #endregion + } +} diff --git a/JavaCode/FrmSys.resx b/JavaCode/FrmSys.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/JavaCode/FrmSys.resx @@ -0,0 +1,120 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file diff --git a/JavaCode/JavaCode.csproj b/JavaCode/JavaCode.csproj new file mode 100644 index 0000000..66a1bc0 --- /dev/null +++ b/JavaCode/JavaCode.csproj @@ -0,0 +1,156 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{49F2AA44-7BF5-46B7-B08F-40AA1455F089}</ProjectGuid> + <OutputType>WinExe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>JavaCode</RootNamespace> + <AssemblyName>JavaCode</AssemblyName> + <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>DLL\Mono.Security.dll</HintPath> + </Reference> + <Reference Include="Npgsql, Version=2.2.3.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>DLL\Npgsql.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.configuration" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Deployment" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="cs\ModelHandler.cs" /> + <Compile Include="cs\PostgreHelper.cs" /> + <Compile Include="cs\TabInfo.cs" /> + <Compile Include="FrmMain.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="FrmMain.Designer.cs"> + <DependentUpon>FrmMain.cs</DependentUpon> + </Compile> + <Compile Include="FrmSys.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="FrmSys.Designer.cs"> + <DependentUpon>FrmSys.cs</DependentUpon> + </Compile> + <Compile Include="FrmMyBatisPlus.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="FrmMyBatisPlus.Designer.cs"> + <DependentUpon>FrmMyBatisPlus.cs</DependentUpon> + </Compile> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <EmbeddedResource Include="FrmMain.resx"> + <DependentUpon>FrmMain.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="FrmSys.resx"> + <DependentUpon>FrmSys.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="FrmMyBatisPlus.resx"> + <DependentUpon>FrmMyBatisPlus.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + <SubType>Designer</SubType> + </EmbeddedResource> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> + <None Include="Properties\Settings.settings"> + <Generator>SettingsSingleFileGenerator</Generator> + <LastGenOutput>Settings.Designer.cs</LastGenOutput> + </None> + <Compile Include="Properties\Settings.Designer.cs"> + <AutoGen>True</AutoGen> + <DependentUpon>Settings.settings</DependentUpon> + <DesignTimeSharedInput>True</DesignTimeSharedInput> + </Compile> + </ItemGroup> + <ItemGroup> + <None Include="App.config"> + <SubType>Designer</SubType> + </None> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="BsTemplate\Entity.java"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </EmbeddedResource> + <EmbeddedResource Include="BsTemplate\Mapper.java"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </EmbeddedResource> + <EmbeddedResource Include="BsTemplate\GeoMapper.java"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </EmbeddedResource> + <EmbeddedResource Include="BsTemplate\GeoEntity.java"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </EmbeddedResource> + <Content Include="DLL\Mono.Security.dll" /> + <Content Include="DLL\Npgsql.dll" /> + <Content Include="SysTemplate\pg.sql" /> + <EmbeddedResource Include="SysTemplate\Controller.java"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </EmbeddedResource> + <EmbeddedResource Include="SysTemplate\Entity.java"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </EmbeddedResource> + <EmbeddedResource Include="SysTemplate\Service.java"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </EmbeddedResource> + <EmbeddedResource Include="SysTemplate\Mapper.java"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </EmbeddedResource> + <EmbeddedResource Include="SysTemplate\Mapper.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + <SubType>Designer</SubType> + </EmbeddedResource> + </ItemGroup> + <ItemGroup /> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file diff --git a/JavaCode/Program.cs b/JavaCode/Program.cs new file mode 100644 index 0000000..2c037d8 --- /dev/null +++ b/JavaCode/Program.cs @@ -0,0 +1,22 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace JavaCode +{ + static class Program + { + /// <summary> + /// 搴旂敤绋嬪簭鐨勪富鍏ュ彛鐐广�� + /// </summary> + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new FrmMain()); + } + } +} diff --git a/JavaCode/Properties/AssemblyInfo.cs b/JavaCode/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..209f97a --- /dev/null +++ b/JavaCode/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +锘縰sing System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 鏈夊叧绋嬪簭闆嗙殑甯歌淇℃伅閫氳繃浠ヤ笅 +// 鐗规�ч泦鎺у埗銆傛洿鏀硅繖浜涚壒鎬у�煎彲淇敼 +// 涓庣▼搴忛泦鍏宠仈鐨勪俊鎭�� +[assembly: AssemblyTitle("JavaCode")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("JavaCode")] +[assembly: AssemblyCopyright("Copyright 漏 HP Inc. 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 灏� ComVisible 璁剧疆涓� false 浣挎绋嬪簭闆嗕腑鐨勭被鍨� +// 瀵� COM 缁勪欢涓嶅彲瑙併�傚鏋滈渶瑕佷粠 COM 璁块棶姝ょ▼搴忛泦涓殑绫诲瀷锛� +// 鍒欏皢璇ョ被鍨嬩笂鐨� ComVisible 鐗规�ц缃负 true銆� +[assembly: ComVisible(false)] + +// 濡傛灉姝ら」鐩悜 COM 鍏紑锛屽垯涓嬪垪 GUID 鐢ㄤ簬绫诲瀷搴撶殑 ID +[assembly: Guid("bab5d8a8-948d-46c1-aa49-97e6bebeab0a")] + +// 绋嬪簭闆嗙殑鐗堟湰淇℃伅鐢变笅闈㈠洓涓�肩粍鎴�: +// +// 涓荤増鏈� +// 娆$増鏈� +// 鐢熸垚鍙� +// 淇鍙� +// +// 鍙互鎸囧畾鎵�鏈夎繖浜涘�硷紝涔熷彲浠ヤ娇鐢ㄢ�滅敓鎴愬彿鈥濆拰鈥滀慨璁㈠彿鈥濈殑榛樿鍊硷紝 +// 鏂规硶鏄寜濡備笅鎵�绀轰娇鐢ㄢ��*鈥�: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/JavaCode/Properties/Resources.Designer.cs b/JavaCode/Properties/Resources.Designer.cs new file mode 100644 index 0000000..15b44f7 --- /dev/null +++ b/JavaCode/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +锘�//------------------------------------------------------------------------------ +// <auto-generated> +// 姝や唬鐮佺敱宸ュ叿鐢熸垚銆� +// 杩愯鏃剁増鏈�: 4.0.30319.42000 +// +// 瀵规鏂囦欢鐨勬洿鏀瑰彲鑳戒細瀵艰嚧涓嶆纭殑琛屼负锛屽苟涓斿鏋� +// 閲嶆柊鐢熸垚浠g爜锛岃繖浜涙洿鏀瑰皢涓㈠け銆� +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace JavaCode.Properties +{ + + + /// <summary> + /// 涓�涓己绫诲瀷鐨勮祫婧愮被锛岀敤浜庢煡鎵炬湰鍦板寲鐨勫瓧绗︿覆绛夈�� + /// </summary> + // 姝ょ被鏄敱 StronglyTypedResourceBuilder + // 绫婚�氳繃绫讳技浜� ResGen 鎴� Visual Studio 鐨勫伐鍏疯嚜鍔ㄧ敓鎴愮殑銆� + // 鑻ヨ娣诲姞鎴栫Щ闄ゆ垚鍛橈紝璇风紪杈� .ResX 鏂囦欢锛岀劧鍚庨噸鏂拌繍琛� ResGen + // (浠� /str 浣滀负鍛戒护閫夐」)锛屾垨閲嶆柊鐢熸垚 VS 椤圭洰銆� + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// <summary> + /// 杩斿洖姝ょ被浣跨敤鐨勩�佺紦瀛樼殑 ResourceManager 瀹炰緥銆� + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("JavaCode.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// <summary> + /// 涓烘墍鏈夎祫婧愭煡鎵鹃噸鍐欏綋鍓嶇嚎绋嬬殑 CurrentUICulture 灞炴�э紝 + /// 鏂规硶鏄娇鐢ㄦ寮虹被鍨嬭祫婧愮被銆� + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/JavaCode/Properties/Resources.resx b/JavaCode/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/JavaCode/Properties/Resources.resx @@ -0,0 +1,117 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file diff --git a/JavaCode/Properties/Settings.Designer.cs b/JavaCode/Properties/Settings.Designer.cs new file mode 100644 index 0000000..1a75312 --- /dev/null +++ b/JavaCode/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +锘�//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace JavaCode.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/JavaCode/Properties/Settings.settings b/JavaCode/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/JavaCode/Properties/Settings.settings @@ -0,0 +1,7 @@ +锘�<?xml version='1.0' encoding='utf-8'?> +<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> + <Profiles> + <Profile Name="(Default)" /> + </Profiles> + <Settings /> +</SettingsFile> diff --git a/JavaCode/SysTemplate/Controller.java b/JavaCode/SysTemplate/Controller.java new file mode 100644 index 0000000..dabec4f --- /dev/null +++ b/JavaCode/SysTemplate/Controller.java @@ -0,0 +1,253 @@ +package {controllerNS}; + +import com.lf.server.annotation.SysLog; +import com.lf.server.controller.all.BaseController; +import com.lf.server.entity.all.ResponseMsg; +import {entityNS}.{entityName}; +import com.lf.server.entity.sys.UserEntity; +import {serviceNS}.{serviceName}; +import com.lf.server.service.sys.TokenService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** + * {bak} + * @author WWW + */ +@Api(tags = "{apiTag}") +@RestController +@RequestMapping("/{apiName}") +public class {controllerName} extends BaseController { + @Autowired + {serviceName} {minServiceName}; + + @Autowired + TokenService tokenService; + + @SysLog() + @ApiOperation(value = "鏌ヨ璁板綍鏁�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "{colName}", value = "{colBak}", dataType = "{colType}", paramType = "query", required = false, example = "") + }) + @GetMapping({"/selectCount"}) + public ResponseMsg<Integer> selectCount({queryCol}) { + try { + int count = {minServiceName}.selectCount({colName}); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @SysLog() + @ApiOperation(value = "鍒嗛〉鏌ヨ") + @ApiImplicitParams({ + @ApiImplicitParam(name = "{colName}", value = "{colBak}", dataType = "{colType}", paramType = "query", example = ""), + @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"), + @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/selectByPage") + public ResponseMsg<List<{entityName}>> selectByPage({queryCol}, Integer pageSize, Integer pageIndex) { + try { + if (pageSize < 1 || pageIndex < 1) { + return fail("姣忛〉椤垫暟鎴栧垎椤垫暟灏忎簬1", null); + } + + List<{entityName}> rs = {minServiceName}.selectByPage({colName}, pageSize, pageSize * (pageIndex - 1)); + + return success(rs); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } + } + + @SysLog() + @ApiOperation(value = "鍒嗛〉鏌ヨ骞惰繑鍥炶褰曟暟") + @ApiImplicitParams({ + @ApiImplicitParam(name = "{colName}", value = "{colBak}", dataType = "{colType}", paramType = "query", example = ""), + @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"), + @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/selectByPageAndCount") + public ResponseMsg<List<{entityName}>> selectByPageAndCount({queryCol}, Integer pageSize, Integer pageIndex) { + try { + if (pageSize < 1 || pageIndex < 1) { + return fail("姣忛〉椤垫暟鎴栧垎椤垫暟灏忎簬1", null); + } + + int count = {minServiceName}.selectCount({colName}); + if (count == 0) { + return success(0, null); + } + + List<{entityName}> rs = {minServiceName}.selectByPage({colName}, pageSize, pageSize * (pageIndex - 1)); + + return success(count, rs); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } + } + + @SysLog() + @ApiOperation(value = "鏌ヨ鎵�鏈�") + @GetMapping(value = "/selectAll") + public ResponseMsg<List<{entityName}>> selectAll() { + try { + List<{entityName}> list = {minServiceName}.selectAll(); + + return success(list); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } + } + + @SysLog() + @ApiOperation(value = "鏍规嵁ID鏌ヨ") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "ID", dataType = "int", paramType = "query", example = "1") + }) + @GetMapping(value = "/selectById") + public ResponseMsg<{entityName}> selectById(int id) { + try { + {entityName} entity = {minServiceName}.selectById(id); + + return success(entity); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } + } + + @SysLog() + @ApiOperation(value = "鎻掑叆涓�鏉�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "{entityName}", paramType = "body") + }) + @PostMapping(value = "/insert", produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> insert(@RequestBody {entityName} entity, HttpServletRequest req) { + try { + UserEntity ue = tokenService.getCurrentUser(req); + if (ue != null) { + entity.setCreateUser(ue.getId()); + } + + int count = {minServiceName}.insert(entity); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @SysLog() + @ApiOperation(value = "鎻掑叆澶氭潯") + @ApiImplicitParams({ + @ApiImplicitParam(name = "list", value = "瀹炰綋绫婚泦鍚�", dataType = "{entityName}", paramType = "body") + }) + @PostMapping(value = "/inserts", produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> inserts(@RequestBody List<{entityName}> list, HttpServletRequest req) { + try { + UserEntity ue = tokenService.getCurrentUser(req); + if (ue != null) { + for ({entityName} entity : list) { + entity.setCreateUser(ue.getId()); + } + } + + int count = {minServiceName}.inserts(list); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @SysLog() + @ApiOperation(value = "鍒犻櫎涓�鏉�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/delete") + public ResponseMsg<Integer> delete(int id) { + try { + int count = {minServiceName}.delete(id); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @SysLog() + @ApiOperation(value = "鍒犻櫎澶氭潯") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ids", value = "ID鏁扮粍", dataType = "Integer", paramType = "query", example = "1,2") + }) + @GetMapping(value = "/deletes") + public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids) { + try { + if (ids == null || ids.isEmpty()) { + return fail("id鏁扮粍涓嶈兘涓虹┖", -1); + } + + int count = {minServiceName}.deletes(ids); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @SysLog() + @ApiOperation(value = "鏇存柊涓�鏉�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "{entityName}", paramType = "body") + }) + @ResponseBody + @PostMapping(value = "/update", produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> update(@RequestBody {entityName} entity, HttpServletRequest req) { + try { + UserEntity ue = tokenService.getCurrentUser(req); + if (ue != null) { + entity.setUpdateUser(ue.getId()); + } + + int count = {minServiceName}.update(entity); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @SysLog() + @ApiOperation(value = "鏇存柊澶氭潯") + @ApiImplicitParams({ + @ApiImplicitParam(name = "list", value = "瀹炰綋绫婚泦鍚�", dataType = "{entityName}", paramType = "body") + }) + @ResponseBody + @PostMapping(value = "/updates", produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> updates(@RequestBody List<{entityName}> list, HttpServletRequest req) { + try { + UserEntity ue = tokenService.getCurrentUser(req); + if (ue != null) { + for ({entityName} entity : list) { + entity.setUpdateUser(ue.getId()); + } + } + + int count = {minServiceName}.updates(list); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } +} diff --git a/JavaCode/SysTemplate/Entity.java b/JavaCode/SysTemplate/Entity.java new file mode 100644 index 0000000..0d30a98 --- /dev/null +++ b/JavaCode/SysTemplate/Entity.java @@ -0,0 +1,11 @@ +package {entityNS}; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * {bak} + * @author WWW + */ +public class {entityName} implements Serializable { + private static final long serialVersionUID = -{uid}L; diff --git a/JavaCode/SysTemplate/Mapper.java b/JavaCode/SysTemplate/Mapper.java new file mode 100644 index 0000000..480f765 --- /dev/null +++ b/JavaCode/SysTemplate/Mapper.java @@ -0,0 +1,96 @@ +package {mapperNS}; + +import {entityNS}.{entityName}; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * {bak} + * @author WWW + */ +@Mapper +@Repository +public interface {mapperName} { + /** + * 鏌ヨ璁板綍鏁� + * + * @param {colName} {colBak} + * @return 璁板綍鏁� + */ + public Integer selectCount({queryCol}); + + /** + * 鍒嗛〉鏌ヨ + * + * @param {colName} {colBak} + * @param limit 璁板綍琛� + * @param offset 鍋忕Щ閲� + * @return 鍒楄〃 + */ + public List<{entityName}> selectByPage({queryCol}, Integer limit, Integer offset); + + /** + * 鏌ヨ鎵�鏈� + * + * @return + */ + public List<{entityName}> selectAll(); + + /** + * 鏍规嵁ID鏌ヨ + * + * @param id + * @return + */ + public {entityName} selectById(int id); + + /** + * 鎻掑叆涓�鏉� + * + * @param entity + * @return + */ + public Integer insert({entityName} entity); + + /** + * 鎻掑叆澶氭潯 + * + * @param list + * @return + */ + public Integer inserts(List<{entityName}> list); + + /** + * 鍒犻櫎涓�鏉� + * + * @param id + * @return + */ + public Integer delete(int id); + + /** + * 鍒犻櫎澶氭潯 + * + * @param ids + * @return + */ + public Integer deletes(List<Integer> ids); + + /** + * 鏇存柊涓�鏉� + * + * @param entity + * @return + */ + public Integer update({entityName} entity); + + /** + * 鏇存柊澶氭潯 + * + * @param list + * @return + */ + public Integer updates(List<{entityName}> list); +} diff --git a/JavaCode/SysTemplate/Mapper.xml b/JavaCode/SysTemplate/Mapper.xml new file mode 100644 index 0000000..6f0d6ee --- /dev/null +++ b/JavaCode/SysTemplate/Mapper.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="{mapperNS}.{mapperName}"> + <select id="selectCount" resultType="java.lang.Integer"> + select count(*) from {tabName} + <where> + <if test="{testExpr}"> + {testWhere} + </if> + </where> + </select> + + <select id="selectByPage" resultType="{entityNS}.{entityName}"> + select * from {tabName} + <where> + <if test="{testExpr}"> + {testWhere} + </if> + </where> + order by id + limit #{limit} offset #{offset} + </select> + + <select id="selectAll" resultType="{entityNS}.{entityName}"> + select * from {tabName} order by id; + </select> + + <select id="selectById" resultType="{entityNS}.{entityName}"> + select * from {tabName} where id = #{id} + </select> + + <insert id="insert" parameterType="{entityNS}.{entityName}"> + insert into {tabName} + ({insertCols}) + values + ({insertVal}) + </insert> + + <insert id="inserts"> + insert into {tabName} + ({insertCols}) + values + <foreach collection="list" item="item" index="index" separator=","> + ({insertVals}) + </foreach> + </insert> + + <delete id="delete"> + delete from {tabName} where id = #{id} + </delete> + + <delete id="deletes"> + delete from {tabName} where id in + <foreach item="id" collection="ids" index="index" open="(" separator="," close=")"> + #{id} + </foreach> + </delete> + + <update id="update"> + update {tabName} + set {updateVal} + where id=#{id} + </update> + + <update id="updates"> + <foreach collection="list" item="item" index="index" separator=";"> + update {tabName} + <set> + {updateVals} + </set> + where id = #{item.id} + </foreach> + </update> +</mapper> \ No newline at end of file diff --git a/JavaCode/SysTemplate/Service.java b/JavaCode/SysTemplate/Service.java new file mode 100644 index 0000000..6e9185a --- /dev/null +++ b/JavaCode/SysTemplate/Service.java @@ -0,0 +1,69 @@ +package {serviceNS}; + +import {entityNS}.{entityName}; +import com.lf.server.helper.StringHelper; +import {mapperNS}.{mapperName}; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * {bak} + * @author WWW + */ +@Service +public class {serviceName} implements {mapperName} { + @Autowired + {mapperName} {minMapperName}; + + @Override + public Integer selectCount({queryCol}) {{where} + return {minMapperName}.selectCount({colName}); + } + + @Override + public List<{entityName}> selectByPage({queryCol}, Integer limit, Integer offset) {{where} + return {minMapperName}.selectByPage({colName}, limit, offset); + } + + @Override + public List<{entityName}> selectAll() { + return {minMapperName}.selectAll(); + } + + @Override + public {entityName} selectById(int id) { + return {minMapperName}.selectById(id); + } + + @Override + public Integer insert({entityName} entity) { + return {minMapperName}.insert(entity); + } + + @Override + public Integer inserts(List<{entityName}> list) { + return {minMapperName}.inserts(list); + } + + @Override + public Integer delete(int id) { + return {minMapperName}.delete(id); + } + + @Override + public Integer deletes(List<Integer> ids) { + return {minMapperName}.deletes(ids); + } + + @Override + public Integer update({entityName} entity) { + return {minMapperName}.update(entity); + } + + @Override + public Integer updates(List<{entityName}> list) { + return {minMapperName}.updates(list); + } +} diff --git a/JavaCode/SysTemplate/pg.sql b/JavaCode/SysTemplate/pg.sql new file mode 100644 index 0000000..f9880ed --- /dev/null +++ b/JavaCode/SysTemplate/pg.sql @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + +select * from stationseries; +select * from sitepoint order by gid; +update sitepoint set sitename='杞崡棣栫珯' where gid=55; +------------------------------------------------------------------------------ SQL璇彞 +select * from data_dir; +select * from meta_data; +select table_name as name from data_dictionary group by table_name; +update meta_data set create_time=CURRENT_TIMESTAMP,create_user='admin' where 1=1; -- CURRENT_TIME锛孋URRENT_DATE + +select * from data_files; +select * from style_data; commit; +delete from style_data where id > 22; +select * from data_dictionary order by id; +select *,queryLevel(path_id) as path from meta_data; +select queryLevel(2005); + +select count(*) from meta_data where Upper(name) like '%A%'; +select *,queryLevel(path_id) path from meta_data where Upper(name) like '%A%' order by id limit 2 offset 0; + +alter table style_data add column path varchar(255); comment on column style_data.path is '瀛樺偍璺緞'; +alter table style_data add column img varchar(255); comment on column style_data.img is '棰勮鍥剧墖'; + +INSERT INTO public.meta_data( + name, path_id, create_time, create_user, type, format, up_unit, status, version, x_min, y_min, x_max, y_max, coor_sys, accuracy, operation, remarks, s_url) + VALUES ('SITEPOINT.shp',2007, CURRENT_TIMESTAMP, 'admin', 'SHP', '.shp','璁捐闄�/鍕樺療瀹�','姝e父', 'v1.0', 0, 0, 0, 0, 'CGCS200', '1:2000', 'upload', '', ''); +------------------------------------------------------------------------------ 鏁版嵁鐩綍 +DROP TABLE IF EXISTS public.data_dir; + +CREATE TABLE public.data_dir +( + id integer, + name character varying(60), + pid integer NOT NULL, + oid integer DEFAULT 1, + PRIMARY KEY (id) +); + +COMMENT ON TABLE public.data_dir IS '鏁版嵁鐩綍'; +COMMENT ON COLUMN public.data_dir.id IS 'ID'; +COMMENT ON COLUMN public.data_dir.name IS '鍚嶇О'; +COMMENT ON COLUMN public.data_dir.pid IS '鐖惰妭鐐�'; +COMMENT ON COLUMN public.data_dir.oid IS '搴忓彿'; + +SELECT COALESCE(MAX(id),1) FROM public.data_dir; +select * from public.data_dir; + +DELETE FROM public.data_dir where id<1000; +SELECT id,name,pid,oid FROM public.data_dir order by id; +------------------------------------------------------------------------------ 涓婁紶鏂囦欢 +DROP TABLE IF EXISTS public.data_files; + +create table public.data_files +( + id serial primary key, + mid integer, + guid varchar(40), + name varchar(255), + ext varchar(10), + path varchar(1024), + subs varchar(1024), + remark varchar(1024) +); + +COMMENT ON TABLE public.data_files IS '涓婁紶鏂囦欢'; +COMMENT ON COLUMN public.data_files.id IS 'ID'; +COMMENT ON COLUMN public.data_files.mid IS '鍏冩暟鎹甀D'; +COMMENT ON COLUMN public.data_files.guid IS 'GUID'; +COMMENT ON COLUMN public.data_files.name IS '鍚嶇О'; +COMMENT ON COLUMN public.data_files.ext IS '鎵╁睍鍚�'; +COMMENT ON COLUMN public.data_files.path IS '璺緞'; +COMMENT ON COLUMN public.data_files.subs IS '瀛愭枃浠�'; +COMMENT ON COLUMN public.data_files.remark IS '澶囨敞'; + +select * from data_files; +------------------------------------------------------------------------------ 鏌ヨ灞傜骇 +with recursive rs as( + select id,name,pid,oid from public.data_dir where id = 2005 + union + select a.id,a.name,a.pid,a.oid from public.data_dir a, rs b where a.id=b.pid +) select id,name,pid,oid FROM rs order by id,oid; + + +CREATE OR REPLACE FUNCTION queryLevel(id INTEGER) +RETURNS VARCHAR as $$ + declare + str varchar=''; + rec varchar; -- public.data_dir%ROWTYPE; + begin + for rec in execute 'with recursive rs as(' || + 'select id,name,pid,oid from public.data_dir where id=' || id || + ' union select a.id,a.name,a.pid,a.oid from public.data_dir a, rs b where a.id=b.pid '|| + ') select name FROM rs order by id,oid' + loop + str = str || '\' || rec; -- rec.name; + end loop; + + if (char_length(str) > 1) then + str = SUBSTRING(str, 2); + end if; + + return str; + end; +$$ LANGUAGE PLPGSQL; + +-- 涓縿涓滅嚎绠¢亾宸ョ▼鍗楁\鍕樺療鏁版嵁\鍩虹鍦拌川\鍖哄煙鍦拌川 +select queryLevel(2005); + +select id,name,pid,oid,queryLevel(id) from data_dir where 1=1 order by id limit 10; + +------------------------------------------------------------------------------ 鏌ヨ灞傜骇ID +--drop function queryDir(id INTEGER); +CREATE OR REPLACE FUNCTION queryDir(id INTEGER) +RETURNS integer[] as $$ + declare + ids integer[]; + sid integer; + begin + for sid in execute 'with recursive rs as(' || + 'select id,pid from public.data_dir where id=' || id || + ' union select a.id,a.pid from public.data_dir a, rs b where a.pid=b.id '|| + ') select id FROM rs order by id' + loop + select array_append(ids, sid) into ids; + end loop; + + return ids; + end; +$$ LANGUAGE PLPGSQL; + +-- {2003,2004,2005,2006,2007,2008,2009} +select queryDir(2003); + +select * from data_dir order by id; +select * from meta_data where (path_id = ANY(array[2001,2002,2003,2005])); +select * from meta_data where (path_id = ANY((select queryDir(2005))::integer[])) order by id; +select * from meta_data where path_id=ANY(queryDir(2005)) order by id; +------------------------------------------------------------------------------ diff --git a/JavaCode/cs/ModelHandler.cs b/JavaCode/cs/ModelHandler.cs new file mode 100644 index 0000000..6f2a4e8 --- /dev/null +++ b/JavaCode/cs/ModelHandler.cs @@ -0,0 +1,83 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace JavaCode.cs +{ + public class ModelHandler + { + /// <summary> + /// 濉厖瀵硅薄鍒楄〃 + /// </summary> + public static List<T> FillModel<T>(DataTable dt) where T : new() + { + if (dt == null || dt.Rows.Count == 0) + { + return null; + } + + List<T> list = new List<T>(); + BindingFlags flag = BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance; + PropertyInfo[] pis = typeof(T).GetProperties(); + + foreach (DataRow dr in dt.Rows) + { + T t = new T(); + foreach (PropertyInfo pi in pis) + { + object val = dr[pi.Name] == DBNull.Value ? null : dr[pi.Name]; + t.GetType().GetProperty(pi.Name, flag).SetValue(t, val, null); + } + + list.Add(t); + } + + return list; + } + + /// <summary> + /// 濉厖DataTable + /// </summary> + public static DataTable FillDataTable<T>(List<T> list) where T : new() + { + if (list == null || list.Count == 0) + { + return null; + } + + DataTable dt = CreateDataTable<T>(); + PropertyInfo[] pis = typeof(T).GetProperties(); + + foreach (T t in list) + { + DataRow dr = dt.NewRow(); + foreach (PropertyInfo pi in pis) + { + dr[pi.Name] = pi.GetValue(t, null); + } + } + + return dt; + } + + /// <summary> + /// 鍒涘缓DataTable + /// </summary> + public static DataTable CreateDataTable<T>() where T : new() + { + DataTable dt = new DataTable(typeof(T).Name); + + PropertyInfo[] pis = typeof(T).GetProperties(); + foreach (PropertyInfo pi in pis) + { + dt.Columns.Add(new DataColumn(pi.Name, pi.PropertyType)); + } + + return dt; + } + } +} diff --git a/JavaCode/cs/PostgreHelper.cs b/JavaCode/cs/PostgreHelper.cs new file mode 100644 index 0000000..ef88f93 --- /dev/null +++ b/JavaCode/cs/PostgreHelper.cs @@ -0,0 +1,174 @@ +锘縰sing Npgsql; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Data.Common; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace JavaCode.cs +{ + public enum DbEnum + { + langfang = 0, + + postgis = 1, + + postgres = 2 + } + + /// <summary> + /// Postgre甯姪绫� + /// </summary> + public class PostgreHelper + { + private const string StrRegex = @"<[^>]+?style=[\w]+?:expression\(|\b(alert|confirm|prompt)\b|^\+/v(8|9)|<[^>]*?=[^>]*?&#[^>]*?>|\b(and|or)\b.{1,6}?(=|>|<|\bin\b|\blike\b)|/\*.+?\*/|<\s*script\b|<\s*img\b|\bEXEC\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\s+(TABLE|DATABASE)"; + + private string conStr = null; + + public PostgreHelper(DbEnum db) + { + string str = ConfigurationManager.AppSettings["pgConn"]; + + this.conStr = string.Format(str, db.ToString()); + } + + /// <summary> + /// 杩炴帴瀛楃涓� + /// </summary> + public String ConStr + { + get + { + return this.conStr; + } + } + + /// <summary> + /// 鑾峰彇DataTable + /// </summary> + public DataTable GetDataTable(string sql, params DbParameter[] args) + { + using (NpgsqlConnection con = new NpgsqlConnection(ConStr)) + { + if (con.State != ConnectionState.Open) + { + con.Open(); + } + + using (NpgsqlCommand cmd = new NpgsqlCommand(sql, con)) + { + if (args != null) + { + foreach (DbParameter arg in args) + { + //arg.ParameterName = arg.ParameterName.Replace("@", ":"); + cmd.Parameters.Add(arg); + } + } + + using (NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(cmd)) + { + DataTable dt = new DataTable(); + adapter.Fill(dt); + + return dt; + } + } + } + } + + /// <summary> + /// 鑾峰彇璁板綍鏁� + /// </summary> + public int GetCount(string sql, params DbParameter[] args) + { + using (NpgsqlConnection con = new NpgsqlConnection(ConStr)) + { + if (con.State != ConnectionState.Open) + { + con.Open(); + } + + using (NpgsqlCommand cmd = new NpgsqlCommand(sql, con)) + { + if (args != null) + { + foreach (DbParameter arg in args) + { + //arg.ParameterName = arg.ParameterName.Replace("@", ":"); + cmd.Parameters.Add(arg); + } + } + + object obj = cmd.ExecuteScalar(); + + return obj == null ? 0 : Convert.ToInt32(obj); + } + } + } + + public Object GetScalar(string sql, params DbParameter[] args) + { + using (NpgsqlConnection con = new NpgsqlConnection(ConStr)) + { + if (con.State != ConnectionState.Open) + { + con.Open(); + } + + using (NpgsqlCommand cmd = new NpgsqlCommand(sql, con)) + { + if (args != null) + { + foreach (DbParameter arg in args) + { + cmd.Parameters.Add(arg); + } + } + + return cmd.ExecuteScalar(); + } + } + } + + /// <summary> + /// 鎵цSQL锛岃繑鍥炲奖鍝嶈鏁� + /// </summary> + public int ExecuteNonQuery(string sql, params DbParameter[] args) + { + using (NpgsqlConnection con = new NpgsqlConnection(ConStr)) + { + if (con.State != ConnectionState.Open) + { + con.Open(); + } + + using (NpgsqlCommand cmd = new NpgsqlCommand(sql, con)) + { + if (args != null) + { + foreach (DbParameter arg in args) + { + //arg.ParameterName = arg.ParameterName.Replace("@", ":"); + cmd.Parameters.Add(arg); + } + } + + return cmd.ExecuteNonQuery(); + } + } + } + + /// <summary> + /// 妫�鏌ュ瓧绗︿覆 + /// </summary> + public static bool CheckStr(string input) + { + return Regex.IsMatch(input, StrRegex, RegexOptions.IgnoreCase); + } + } +} diff --git a/JavaCode/cs/TabInfo.cs b/JavaCode/cs/TabInfo.cs new file mode 100644 index 0000000..8def01a --- /dev/null +++ b/JavaCode/cs/TabInfo.cs @@ -0,0 +1,23 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JavaCode.cs +{ + public class TabInfo + { + public string tab { set; get; } + + public string desc { set; get; } + + public int num { set; get; } + + public string col { set; get; } + + public string type { set; get; } + + public string bak { set; get; } + } +} -- Gitblit v1.9.3