| | |
| | | select * from lf.sys_meta_file a where metaid in (113,120,121,122); |
| | | alter sequence bd.dlg_agnp_gid_seq restart with 4000; |
| | | select max(gid) from bd.dlg_agnp; |
| | | |
| | | ---------------------------------------------------------------------------------------------- |
| | | select * from bd.dlg_25w_boul where gid<11; -- delete from bd.dlg_25w_boul where gid>10; alter sequence bd.dlg_25w_boul_gid_seq restart with 20; |
| | | select * from bd.dlg_25w_resa where gid<12; -- delete from bd.dlg_25w_resa where gid>11; alter sequence bd.dlg_25w_resa_gid_seq restart with 20; |
| | | select * from bd.dlg_agnp where gid<13; -- delete from bd.dlg_agnp where gid>12; alter sequence bd.dlg_agnp_gid_seq restart with 20; |
| | | select gb,name,classes,pinyin,pac,bsm,geom,eventid,dirid,depid,verid,createtime,createuser,updateuser,updatetime from bd.dlg_agnp |
| | | |
| | | select * from lf.sys_user |
| | | select * from lf.sys_download where guid='5ce046cc05b186332775c03ac6792caf' |
| | | select * from bs.bs_project; |
| | | |
| | | select * from bd.dlg_agnp order by gid desc; |
| | | insert into bd.dlg_agnp(gb,name) values('01','A01'); |
| | | insert into bd.dlg_agnp(gb,name) values('02','A02'); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | comment on column lf.sys_domain.bak is '夿³¨'; |
| | | |
| | | select * from lf.sys_domain order by dom_name,orderid; |
| | | ----------------------------------------------------------------------------------------------------- 27.项ç®è¡¨ |
| | | -- drop table if exists lf.sys_project; |
| | | create table if not exists lf.sys_project ( |
| | | id serial primary key, |
| | | dirid integer default 0, |
| | | depid integer default 0, |
| | | projname varchar(200), |
| | | projtype varchar(50), |
| | | location varchar(200), |
| | | province varchar(50), |
| | | country varchar(50), |
| | | corpname varchar(200), |
| | | department varchar(200), |
| | | conperiod varchar(20), |
| | | contents varchar(500), |
| | | projstate varchar(50), |
| | | remarks varchar(250), |
| | | belongsid varchar(100), |
| | | datastatus varchar(10), |
| | | create_user integer default 1, |
| | | create_time timestamp(6) without time zone default now(), |
| | | update_user integer, |
| | | update_time timestamp(6) without time zone, |
| | | geom geometry(Point, 4490) |
| | | ); -- drop index index_sys_project_geom; |
| | | create index index_sys_project_geom on lf.sys_project using gist (geom); |
| | | comment on table lf.sys_project is '项ç®è¡¨'; |
| | | comment on column lf.sys_project.id is '主é®id'; |
| | | comment on column lf.sys_project.dirid is 'ç®å½id'; |
| | | comment on column lf.sys_project.depid is 'åä½id'; |
| | | comment on column lf.sys_project.projname is '项ç®åç§°'; |
| | | comment on column lf.sys_project.projtype is '项ç®ç±»å'; |
| | | comment on column lf.sys_project.location is 'å°çä½ç½®'; |
| | | comment on column lf.sys_project.province is 'æå±ç份'; |
| | | comment on column lf.sys_project.country is 'æå±å½å®¶'; |
| | | comment on column lf.sys_project.corpname is '建设åä½åç§°'; |
| | | comment on column lf.sys_project.department is '主管é¨é¨'; |
| | | comment on column lf.sys_project.conperiod is '建设工æ'; |
| | | comment on column lf.sys_project.contents is 'å·¥ç¨å
容'; |
| | | comment on column lf.sys_project.projstate is '项ç®ç¶æ'; |
| | | comment on column lf.sys_project.remarks is '夿³¨'; |
| | | comment on column lf.sys_project.belongsid is 'æé代ç '; |
| | | comment on column lf.sys_project.datastatus is 'æ°æ®ç¶æ'; |
| | | comment on column lf.sys_project.create_user is 'å建人id'; |
| | | comment on column lf.sys_project.create_time is 'å建æ¶é´'; |
| | | comment on column lf.sys_project.update_user is 'æ´æ°äººid'; |
| | | comment on column lf.sys_project.update_time is 'æ´æ°æ¶é´'; |
| | | comment on column lf.sys_project.geom is '空é´ä½ç½®'; |
| | | |
| | | select * from lf.sys_project; |
| | | ----------------------------------------------------------------------------------------------------- å
æ°æ®æµè¯è¡¨ * |
| | | -- drop table if exists md.md_zxcg; |
| | | create table md.md_zxcg( |
| | |
| | | //testBlacklist(); |
| | | //FloatServerController.test(); |
| | | //testReadExcel(); |
| | | //testBatchUpdate(); |
| | | |
| | | //boolean f1 = ZipHelper.unzip("D:\\LF\\data\\resources.zip", "D:\\LF\\data\\unzip"); |
| | | //boolean f2 = ZipHelper.zip("D:\\LF\\data\\res.zip", "D:\\LF\\data\\unzip\\resources"); |
| | |
| | | } |
| | | } |
| | | |
| | | private void testBatchUpdate() { |
| | | DlgagnpEntity d1 = new DlgagnpEntity(); |
| | | d1.setGid(56); |
| | | d1.setGb("10"); |
| | | d1.setName("a01"); |
| | | DlgagnpEntity d2 = new DlgagnpEntity(); |
| | | d2.setGid(57); |
| | | d2.setGb("20"); |
| | | d2.setName("a02"); |
| | | |
| | | List<DlgagnpEntity> list = new ArrayList<>(); |
| | | list.add(d1); |
| | | list.add(d2); |
| | | |
| | | int rows = dlgagnpMapper.updateBatch(list); |
| | | } |
| | | |
| | | private void testMybatisPlus() { |
| | | String s1 = locateService.selectWktById(1); |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.lf.server.controller.data; |
| | | |
| | | import com.lf.server.annotation.SysLog; |
| | | import com.lf.server.controller.all.BaseQueryController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.bs.BsprojectEntity; |
| | | import com.lf.server.entity.data.DirEntity; |
| | | import com.lf.server.entity.sys.DepEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.mapper.bs.BsprojectMapper; |
| | | import com.lf.server.service.data.DirService; |
| | | import com.lf.server.service.sys.DepService; |
| | | 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.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * æ°æ®æ£ç´¢ |
| | | * @author WWW |
| | | */ |
| | | @Api(tags = "æ°æ®ç®¡ç\\项ç®ç®¡ç") |
| | | @RestController |
| | | @RequestMapping("/project") |
| | | public class ProjectController extends BaseQueryController { |
| | | @Autowired |
| | | DepService depService; |
| | | |
| | | @Autowired |
| | | DirService dirService; |
| | | |
| | | @Autowired |
| | | TokenService tokenService; |
| | | |
| | | @Autowired |
| | | BsprojectMapper bsprojectMapper; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ¥è¯¢ææå使°æ®") |
| | | @GetMapping(value = "/selectDepAll") |
| | | public ResponseMsg<List<DepEntity>> selectDepAll() { |
| | | try { |
| | | List<DepEntity> list = depService.selectDepAll(); |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ¥è¯¢ææç®å½æ°æ®") |
| | | @GetMapping(value = "/selectDirAll") |
| | | public ResponseMsg<List<DirEntity>> selectDirAll() { |
| | | try { |
| | | List<DirEntity> list = dirService.selectDirAll(); |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ ¹æ®ç®å½IDæ¥è¯¢") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "dirid", value = "ç®å½ID", dataType = "int", paramType = "query", example = "0") |
| | | }) |
| | | @GetMapping(value = "/selectByDirid") |
| | | public ResponseMsg<BsprojectEntity> selectByDirid(int dirid) { |
| | | try { |
| | | Map<String, Object> map = new HashMap<>(1); |
| | | map.put("dirid", dirid); |
| | | |
| | | List<BsprojectEntity> list = bsprojectMapper.selectByMap(map); |
| | | if (null == list || list.isEmpty()) { |
| | | return success(null); |
| | | } |
| | | |
| | | return success(list.get(0)); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "å é¤ä¸æ¡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "gid", value = "ID", dataType = "int", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/delete") |
| | | public ResponseMsg<Integer> delete(int gid) { |
| | | try { |
| | | int rows = bsprojectMapper.deleteById(gid); |
| | | |
| | | return success(rows); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æå
¥ä¸æ¡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "å®ä½ç±»", dataType = "DictEntity", paramType = "body") |
| | | }) |
| | | @PostMapping(value = "/insert", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insert(@RequestBody BsprojectEntity entity, HttpServletRequest req) { |
| | | try { |
| | | if (null == entity) { |
| | | return fail("å®ä½ç±»ä¸è½ä¸ºç©º", 0); |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | entity.setCreateuser(ue.getId()); |
| | | entity.setCreatetime(WebHelper.getCurrentTimestamp()); |
| | | entity.setGeom(StringHelper.getGeomWKT(entity.getGeom())); |
| | | |
| | | List<BsprojectEntity> list = new ArrayList<>(); |
| | | list.add(entity); |
| | | |
| | | int rows = bsprojectMapper.insertBatch(list); |
| | | |
| | | return success(rows); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æ´æ°ä¸æ¡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "å®ä½ç±»", dataType = "DictEntity", paramType = "body") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/update", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> update(@RequestBody BsprojectEntity entity, HttpServletRequest req) { |
| | | try { |
| | | if (null == entity) { |
| | | return fail("å®ä½ç±»ä¸è½ä¸ºç©º", 0); |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | entity.setUpdateuser(ue.getId()); |
| | | entity.setUpdatetime(WebHelper.getCurrentTimestamp()); |
| | | entity.setGeom(StringHelper.getGeomWKT(entity.getGeom())); |
| | | |
| | | List<BsprojectEntity> list = new ArrayList<>(); |
| | | list.add(entity); |
| | | |
| | | int rows = bsprojectMapper.updateBatch(list); |
| | | |
| | | return success(rows); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.lf.server.entity.bs; |
| | | |
| | | 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; |
| | | |
| | | /** |
| | | * Bsproject |
| | | * @author WWW |
| | | */ |
| | | @Data |
| | | @AllArgsConstructor |
| | | @TableName("bs.bs_project") |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class BsprojectEntity extends BaseGeoEntity { |
| | | private static final long serialVersionUID = 39899152256501448L; |
| | | |
| | | private String projname; |
| | | |
| | | private String projtype; |
| | | |
| | | private String location; |
| | | |
| | | private String province; |
| | | |
| | | private String country; |
| | | |
| | | private String corpname; |
| | | |
| | | private String department; |
| | | |
| | | private String conperiod; |
| | | |
| | | private String contents; |
| | | |
| | | private String projstate; |
| | | |
| | | private String remarks; |
| | | |
| | | private String belongsid; |
| | | |
| | | private String datastatus; |
| | | |
| | | public BsprojectEntity() { |
| | | } |
| | | |
| | | public String getProjname() { |
| | | return projname; |
| | | } |
| | | |
| | | public void setProjname(String projname) { |
| | | this.projname = projname; |
| | | } |
| | | |
| | | public String getProjtype() { |
| | | return projtype; |
| | | } |
| | | |
| | | public void setProjtype(String projtype) { |
| | | this.projtype = projtype; |
| | | } |
| | | |
| | | public String getLocation() { |
| | | return location; |
| | | } |
| | | |
| | | public void setLocation(String location) { |
| | | this.location = location; |
| | | } |
| | | |
| | | public String getProvince() { |
| | | return province; |
| | | } |
| | | |
| | | public void setProvince(String province) { |
| | | this.province = province; |
| | | } |
| | | |
| | | public String getCountry() { |
| | | return country; |
| | | } |
| | | |
| | | public void setCountry(String country) { |
| | | this.country = country; |
| | | } |
| | | |
| | | public String getCorpname() { |
| | | return corpname; |
| | | } |
| | | |
| | | public void setCorpname(String corpname) { |
| | | this.corpname = corpname; |
| | | } |
| | | |
| | | public String getDepartment() { |
| | | return department; |
| | | } |
| | | |
| | | public void setDepartment(String department) { |
| | | this.department = department; |
| | | } |
| | | |
| | | public String getConperiod() { |
| | | return conperiod; |
| | | } |
| | | |
| | | public void setConperiod(String conperiod) { |
| | | this.conperiod = conperiod; |
| | | } |
| | | |
| | | public String getContents() { |
| | | return contents; |
| | | } |
| | | |
| | | public void setContents(String contents) { |
| | | this.contents = contents; |
| | | } |
| | | |
| | | public String getProjstate() { |
| | | return projstate; |
| | | } |
| | | |
| | | public void setProjstate(String projstate) { |
| | | this.projstate = projstate; |
| | | } |
| | | |
| | | public String getRemarks() { |
| | | return remarks; |
| | | } |
| | | |
| | | public void setRemarks(String remarks) { |
| | | this.remarks = remarks; |
| | | } |
| | | |
| | | public String getBelongsid() { |
| | | return belongsid; |
| | | } |
| | | |
| | | public void setBelongsid(String belongsid) { |
| | | this.belongsid = belongsid; |
| | | } |
| | | |
| | | public String getDatastatus() { |
| | | return datastatus; |
| | | } |
| | | |
| | | public void setDatastatus(String datastatus) { |
| | | this.datastatus = datastatus; |
| | | } |
| | | } |
| | |
| | | package com.lf.server.extend; |
| | | |
| | | import com.baomidou.mybatisplus.core.injector.AbstractMethod; |
| | | import com.baomidou.mybatisplus.core.metadata.TableFieldInfo; |
| | | import com.baomidou.mybatisplus.core.metadata.TableInfo; |
| | | import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils; |
| | | import org.apache.ibatis.mapping.MappedStatement; |
| | | import org.apache.ibatis.mapping.SqlSource; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * æ¹éæ´æ°æ¹æ³ |
| | |
| | | */ |
| | | @SuppressWarnings("ALL") |
| | | public class UpdateBatchMethod extends AbstractMethod { |
| | | private static List<String> excludeFields = new ArrayList<>(Arrays.asList("objectid", "createuser", "createtime", "shape_leng", "shape_area")); |
| | | |
| | | /** |
| | | * update user set name = "a", age = 17 where id = 1; |
| | | * update user set name = "b", age = 18 where id = 2; |
| | |
| | | public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) { |
| | | String sql = "<script>\n<foreach collection=\"list\" item=\"item\" separator=\";\">\nupdate %s %s where %s=#{%s} %s\n</foreach>\n</script>"; |
| | | String additional = tableInfo.isWithVersion() ? tableInfo.getVersionFieldInfo().getVersionOli("item", "item.") : "" + tableInfo.getLogicDeleteSql(true, true); |
| | | String setSql = sqlSet(tableInfo.isWithLogicDelete(), false, tableInfo, false, "item", "item."); |
| | | //String setSql = sqlSet(tableInfo.isWithLogicDelete(), false, tableInfo, false, "item", "item."); |
| | | String setSql = getSqlSet(tableInfo.isWithLogicDelete(), false, tableInfo, false, "item", "item."); |
| | | String sqlResult = String.format(sql, tableInfo.getTableName(), setSql, tableInfo.getKeyColumn(), "item." + tableInfo.getKeyProperty(), additional); |
| | | |
| | | // update %s %s where %s=#{%s} %s |
| | | // update tab set a=#{a} where gid=1 |
| | | |
| | | SqlSource sqlSource = languageDriver.createSqlSource(configuration, sqlResult, modelClass); |
| | | |
| | | // 第ä¸ä¸ªåæ°å¿
é¡»åRootMapperçèªå®ä¹æ¹æ³åä¸è´ |
| | | return this.addUpdateMappedStatement(mapperClass, modelClass, "updateBatch", sqlSource); |
| | | } |
| | | |
| | | private String getSqlSet(boolean logic, boolean ew, TableInfo table, boolean judgeAliasNull, final String alias, final String prefix) { |
| | | // String sqlScript = table.getAllSqlSet(logic, prefix); |
| | | String sqlScript = getSqlSet(table); |
| | | if (judgeAliasNull) { |
| | | sqlScript = SqlScriptUtils.convertIf(sqlScript, String.format("%s != null", alias), true); |
| | | } |
| | | if (ew) { |
| | | sqlScript = sqlScript + "\n"; |
| | | sqlScript = sqlScript + this.convertIfEwParam("ew.sqlSet", false); |
| | | } |
| | | |
| | | sqlScript = SqlScriptUtils.convertSet(sqlScript); |
| | | |
| | | return sqlScript; |
| | | } |
| | | |
| | | private String getSqlSet(TableInfo tableInfo) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (TableFieldInfo f : tableInfo.getFieldList()) { |
| | | if (excludeFields.contains(f.getColumn())) { |
| | | continue; |
| | | } |
| | | |
| | | if ("geom".equals(f.getColumn())) { |
| | | sb.append("<if test=\"item['geom'] != null\">geom=${item.geom},</if>\n"); |
| | | continue; |
| | | } |
| | | |
| | | sb.append(String.format("<if test=\"item['%s'] != null\">%s=#{item.%s},</if>\n", f.getColumn(), f.getColumn(), f.getColumn())); |
| | | } |
| | | sb.deleteCharAt(sb.length() - 1); |
| | | |
| | | return sb.toString(); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * è·åå¾å½¢çWKTå符串 |
| | | * |
| | | * @param wkt |
| | | * @return |
| | | */ |
| | | public static String getGeomWKT(String wkt) { |
| | | if (StringHelper.isEmpty(wkt)) { |
| | | return "null"; |
| | | } |
| | | |
| | | return String.format("ST_GeomFromText('%s')", wkt); |
| | | } |
| | | |
| | | /** |
| | | * é¦åæ¯å¤§å |
| | | */ |
| | | public static String firstCharToUpperCase(String str) { |
| | |
| | | |
| | | /** |
| | | * è¿æ¥Listéå |
| | | * |
| | | * @param list æ´æ°éå |
| | | * @param join è¿æ¥å符 |
| | | * @return |
| | |
| | | } |
| | | |
| | | if (sb.length() > 0 && sb.lastIndexOf(join) == sb.length() - 1) { |
| | | sb.deleteCharAt(sb.length() -1 ); |
| | | sb.deleteCharAt(sb.length() - 1); |
| | | } |
| | | |
| | | return sb.toString(); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.lf.server.mapper.bs; |
| | | |
| | | import com.lf.server.entity.bs.BsprojectEntity; |
| | | import com.lf.server.mapper.all.GeomBaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | /** |
| | | * Bsproject |
| | | * @author WWW |
| | | */ |
| | | @Mapper |
| | | @Repository |
| | | public interface BsprojectMapper extends GeomBaseMapper<BsprojectEntity> { |
| | | } |