@@ -0,0 +1,45 @@ | |||
package com.qmrz.generator; | |||
import com.qmrz.service.TableService; | |||
import com.qmrz.utils.CGHelper; | |||
import com.qmrz.utils.Fn; | |||
import com.qmrz.utils.SpringContextUtil; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
/** | |||
* Controller生成 | |||
*/ | |||
public class ControllerFPGenerator { | |||
private TableService tableService; | |||
private String dbName; | |||
public ControllerFPGenerator(String dbName) { | |||
tableService = SpringContextUtil.getBean(TableService.class); | |||
this.dbName = dbName; | |||
} | |||
public void generator() { | |||
List<Map> tableList = tableService.getTableList(dbName); | |||
List<Map> columnList = tableService.getColumnList(dbName); | |||
GeneratorUtil.setColumnShowName(columnList); | |||
Map result = columnList.stream().collect(Collectors.groupingBy(map -> map.get("table_name"), Collectors.toList())); | |||
CGHelper cgHelper = new CGHelper("controller_fp.ftl", dbName); | |||
tableList.forEach(item -> { | |||
String table_name = item.get("table_name").toString(); | |||
String table_name2 = Fn.firstUpperCase(table_name); | |||
item.put("columnList", result.get(table_name)); | |||
item.put("dbname", dbName); | |||
item.put("table_name2", table_name2);//首字母大写 | |||
cgHelper.generator("controller_fp", table_name2 + "Controller.java", item); | |||
}); | |||
} | |||
} |
@@ -0,0 +1,42 @@ | |||
package com.qmrz.generator; | |||
import com.qmrz.service.TableService; | |||
import com.qmrz.utils.CGHelper; | |||
import com.qmrz.utils.Fn; | |||
import com.qmrz.utils.SpringContextUtil; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
/** | |||
* Service生成 | |||
*/ | |||
public class ServiceFPGenerator { | |||
private TableService tableService; | |||
private String dbName; | |||
public ServiceFPGenerator(String dbName) { | |||
tableService = SpringContextUtil.getBean(TableService.class); | |||
this.dbName = dbName; | |||
} | |||
public void generator() { | |||
List<Map> tableList = tableService.getTableList(dbName); | |||
List<Map> columnList = tableService.getColumnList(dbName); | |||
Map result = columnList.stream().collect(Collectors.groupingBy(map -> map.get("table_name"), Collectors.toList())); | |||
CGHelper cgHelper = new CGHelper("service_fp.ftl", dbName); | |||
tableList.forEach(item -> { | |||
String table_name = item.get("table_name").toString(); | |||
String table_name2 = Fn.firstUpperCase(table_name); | |||
item.put("columnList", result.get(table_name)); | |||
item.put("dbname", dbName); | |||
item.put("table_name2",table_name2);//首字母大写 | |||
cgHelper.generator("service_fp", table_name2 + "Service.java", item); | |||
}); | |||
} | |||
} |
@@ -0,0 +1,42 @@ | |||
package com.qmrz.generator; | |||
import com.qmrz.service.TableService; | |||
import com.qmrz.utils.CGHelper; | |||
import com.qmrz.utils.Fn; | |||
import com.qmrz.utils.SpringContextUtil; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
/** | |||
* ServiceImpl生成 | |||
*/ | |||
public class ServiceImplFPGenerator { | |||
private TableService tableService; | |||
private String dbName; | |||
public ServiceImplFPGenerator(String dbName) { | |||
tableService = SpringContextUtil.getBean(TableService.class); | |||
this.dbName = dbName; | |||
} | |||
public void generator() { | |||
List<Map> tableList = tableService.getTableList(dbName); | |||
List<Map> columnList = tableService.getColumnList(dbName); | |||
Map result = columnList.stream().collect(Collectors.groupingBy(map -> map.get("table_name"), Collectors.toList())); | |||
CGHelper cgHelper = new CGHelper("serviceImpl_fp.ftl", dbName); | |||
tableList.forEach(item -> { | |||
String table_name = item.get("table_name").toString(); | |||
String table_name2 = Fn.firstUpperCase(table_name); | |||
item.put("columnList", result.get(table_name)); | |||
item.put("dbname", dbName); | |||
item.put("table_name2",table_name2);//首字母大写 | |||
cgHelper.generator("serviceImpl_fp", table_name2 + "ServiceImpl.java", item); | |||
}); | |||
} | |||
} |
@@ -0,0 +1,42 @@ | |||
package com.qmrz.generator; | |||
import com.qmrz.service.TableService; | |||
import com.qmrz.utils.CGHelper; | |||
import com.qmrz.utils.Fn; | |||
import com.qmrz.utils.SpringContextUtil; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
/** | |||
* ServiceImpl生成 | |||
*/ | |||
public class ServiceImplFPRGenerator { | |||
private TableService tableService; | |||
private String dbName; | |||
public ServiceImplFPRGenerator(String dbName) { | |||
tableService = SpringContextUtil.getBean(TableService.class); | |||
this.dbName = dbName; | |||
} | |||
public void generator() { | |||
List<Map> tableList = tableService.getTableList(dbName); | |||
List<Map> columnList = tableService.getColumnList(dbName); | |||
Map result = columnList.stream().collect(Collectors.groupingBy(map -> map.get("table_name"), Collectors.toList())); | |||
CGHelper cgHelper = new CGHelper("serviceImpl_fpr.ftl", dbName); | |||
tableList.forEach(item -> { | |||
String table_name = item.get("table_name").toString(); | |||
String table_name2 = Fn.firstUpperCase(table_name); | |||
item.put("columnList", result.get(table_name)); | |||
item.put("dbname", dbName); | |||
item.put("table_name2",table_name2);//首字母大写 | |||
cgHelper.generator("serviceImpl_fpr", table_name2 + "ServiceImpl.java", item); | |||
}); | |||
} | |||
} |
@@ -0,0 +1,35 @@ | |||
package com.qmrz.controller.mj; | |||
import com.qmrz.dto.PageMapDTO; | |||
import com.qmrz.service.${table_name2}Service; | |||
import com.qmrz.utils.RD; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import java.util.Map; | |||
/** | |||
* ${table_name},${table_comment} | |||
* Automatic generation | |||
*/ | |||
@Slf4j | |||
@RequestMapping("/mj/${table_name}") | |||
@RestController | |||
public class ${table_name2}Controller { | |||
@Autowired | |||
${table_name2}Service ${table_name}Service; | |||
@RequestMapping("selPage") | |||
public RD selPage(@RequestBody PageMapDTO where) { | |||
return RD.success(this.${table_name}Service.pageList(where)); | |||
} | |||
@RequestMapping("export") | |||
public void export(@RequestBody Map where) { | |||
this.${table_name}Service.export(where); | |||
} | |||
} |
@@ -31,6 +31,9 @@ ${table_name}(${table_comment}) | |||
<!-- 已反馈 --> | |||
<if test='where_status=="4"'> | |||
,th.fppoliceid,fpP_2.fullname fppolicename | |||
,th.jspoliceid,jsP_2.fullname jspolicename | |||
,th.fptime | |||
,th.currpoliceid fkpoliceid,p.fullname fkpolicename | |||
,th.operationtime fktime | |||
,if(th.chpoliceid,1,0) chstatus, if(th.thpoliceid,1,0) thstatus | |||
@@ -60,6 +63,8 @@ ${table_name}(${table_comment}) | |||
<!-- 已反馈 --> | |||
<if test='where_status=="4"'> | |||
left join police fpP_2 on fpP_2.id=th.fppoliceid | |||
left join police jsP_2 on jsP_2.id=th.jspoliceid | |||
left join zonepubinfo fkzp2 on fkzp2.pubcode = th.gldw and th.memo=4 | |||
</if> | |||
@@ -77,6 +82,20 @@ ${table_name}(${table_comment}) | |||
</otherwise> | |||
</choose> | |||
<!-- 5级 行政区划搜索 --> | |||
<if test="_parameter.containsKey('where_xzqhGrade5List')"> | |||
and t.xzqh in ( | |||
<foreach item="item" index="index" collection="where_xzqhGrade5List" separator=","> | |||
${'#'}{item} | |||
</foreach> | |||
) | |||
</if> | |||
<!--remarks 模糊搜索--> | |||
<if test="_parameter.containsKey('like_remarks')"> | |||
and th.remarks like concat('%', ${'#'}{like_remarks} ,'%') | |||
</if> | |||
<!--app模糊搜索 --> | |||
<if test="_parameter.containsKey('like_appkeyword')"> | |||
<!-- TODO 需处理 | |||
@@ -88,11 +107,11 @@ ${table_name}(${table_comment}) | |||
<if test="_parameter.containsKey('where_historytype')"> | |||
<!--当日--> | |||
<if test=" where_historytype == 1 "> | |||
and DATEDIFF(th.operationtime,now())=0 | |||
and DATEDIFF(th.operationtime,${'#'}{where_nowtime})=0 | |||
</if> | |||
<!--历史--> | |||
<if test=" where_historytype == 2 "> | |||
<![CDATA[ and DATEDIFF(th.operationtime,now())<0 ]]> | |||
<![CDATA[ and DATEDIFF(th.operationtime,${'#'}{where_nowtime})<0 ]]> | |||
</if> | |||
</if> | |||
@@ -0,0 +1,115 @@ | |||
package com.qmrz.service.impl; | |||
import com.github.pagehelper.PageHelper; | |||
import com.qmrz.constants.AppConstant; | |||
import com.qmrz.dto.PageMapDTO; | |||
import com.qmrz.login.PoliceLogin; | |||
import com.qmrz.service.${table_name2}Service; | |||
import com.qmrz.service.XzqhService; | |||
import com.qmrz.utils.*; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.io.IOException; | |||
import java.util.LinkedHashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* ${table_name},${table_comment} | |||
*/ | |||
@Slf4j | |||
@Service | |||
public class ${table_name2}ServiceImpl extends BaseServiceImpl implements ${table_name2}Service { | |||
public ${table_name2}ServiceImpl() { | |||
super("${table_name}"); | |||
} | |||
@Autowired | |||
XzqhService xzqhService; | |||
public void export(Map where) { | |||
//清除map value 为空 | |||
MapUtil.clearEmpty(where); | |||
List<String> xzqhGrade5List = xzqhService.getGrade5CodeBy5Name(Fn.toString(where.get("like_xzqhname"))); | |||
if(!ConvertUtil.isEmpty(xzqhGrade5List)){ | |||
where.put("where_xzqhGrade5List", xzqhGrade5List); | |||
} | |||
String statusList = Fn.clearNotInteger(Fn.toString(where.get("where_status"))); | |||
CheckUtil.isEmpty(statusList, "where_status参数有误"); | |||
where.put("where_status", statusList); | |||
//数据权限限制 | |||
where.putAll(PoliceLogin.getWhereMap(Fn.toString(where.get("where_gldwsearch")))); | |||
where.put("where_nowtime",DateTimeUtil.currentStr()); | |||
List<Map> dataList = dbHelper.selectList(getMapperName("getList"), where); | |||
if ("4".equals(statusList)) | |||
dataList.forEach(i -> i.put("memoname", AppConstant.getMemoValue(Fn.toInt(i.get("memo"))))); | |||
DateTimeUtil.formatByObj(dataList); | |||
Map<String, String> colMap = new LinkedHashMap<>(); | |||
//===============TODO 待处理===============// | |||
// colMap.put("ownername", "房东姓名"); | |||
// colMap.put("ownerphone", "联系电话"); | |||
// colMap.put("houseaddr", "房屋地址"); | |||
// colMap.put("housenumber", "房间号"); | |||
// colMap.put("xzqhname", "行政区划"); | |||
// colMap.put("gldwname", "管辖单位"); | |||
// colMap.put("peoplecount", "当前在住人数"); | |||
// | |||
// if ("1".equals(statusList)) { | |||
// colMap.put("fppolicename", "分派人"); | |||
// colMap.put("jspolicename", "接收人"); | |||
// colMap.put("fptime", "分派时间"); | |||
// } else if (statusList.contains("2") || statusList.contains("3")) { | |||
// colMap.put("chthpolicename", "撤回/退回人"); | |||
// colMap.put("chthtime", "撤回/退回时间"); | |||
// } else if ("4".equals(statusList)) { | |||
// colMap.put("fkpolicename", "反馈人"); | |||
// colMap.put("fktime", "反馈时间"); | |||
// colMap.put("memoname", "反馈结果"); | |||
// }else if ("5".equals(statusList)) { | |||
// colMap.put("wxclpolicename", "处理人"); | |||
// colMap.put("wxcltime", "处理时间"); | |||
// colMap.put("remarks", "处理意见"); | |||
// } | |||
try { | |||
ExportPOIUtils.start_download(Web.getResponse(), DateTimeUtil.format("yyyyMMddHHmmss"), dataList | |||
, colMap.values().toArray(new String[]{}) | |||
, colMap.keySet().toArray(new String[]{}) | |||
); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
public PageData<Map> pageList(PageMapDTO where) { | |||
//清除map value 为空 | |||
MapUtil.clearEmpty(where); | |||
List<String> xzqhGrade5List = xzqhService.getGrade5CodeBy5Name(Fn.toString(where.get("like_xzqhname"))); | |||
if(!ConvertUtil.isEmpty(xzqhGrade5List)){ | |||
where.put("where_xzqhGrade5List", xzqhGrade5List); | |||
} | |||
String statusList = Fn.clearNotInteger(Fn.toString(where.get("where_status"))); | |||
CheckUtil.isEmpty(statusList, "where_status参数有误"); | |||
where.put("where_status", statusList); | |||
//数据权限限制 | |||
where.putAll(PoliceLogin.getWhereMap(Fn.toString(where.get("where_gldwsearch")))); | |||
where.put("where_nowtime",DateTimeUtil.currentStr()); | |||
List<Map> result = PageHelper.startPage(where.getPageIndex(), where.getPageSize()).doSelectPage( | |||
() -> dbHelper.selectList(getMapperName("getList"), where) | |||
); | |||
if ("4".equals(statusList)) | |||
result.forEach( i -> i.put("memoname", AppConstant.getMemoValue(Fn.toInt(i.get("memo"))))); | |||
return PageData.newobj(result); | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
package com.qmrz.service.impl; | |||
import com.qmrz.service.${table_name2}Service; | |||
import com.qmrz.service.impl.relation.BaseRelationImpl; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* ${table_name},${table_comment} | |||
*/ | |||
@Slf4j | |||
@Service | |||
public class ${table_name2}ServiceImpl extends BaseRelationImpl implements ${table_name2}Service { | |||
public ${table_name2}ServiceImpl() { | |||
super("${table_name}"); | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
package com.qmrz.service; | |||
import com.qmrz.dto.PageMapDTO; | |||
import com.qmrz.utils.PageData; | |||
import java.util.Map; | |||
/** | |||
* ${table_name},${table_comment} | |||
*/ | |||
public interface ${table_name2}Service extends BaseService { | |||
PageData<Map> pageList(PageMapDTO where); | |||
void export(Map where); | |||
} |
@@ -28,9 +28,14 @@ private String dbname="qmrz"; | |||
javaSync(); | |||
// service(); | |||
service2(); | |||
serviceFP(); | |||
serviceImplFp(); | |||
serviceImplFpr(); | |||
// serviceImpl(); | |||
service2Impl(); | |||
controller(); | |||
controllerFP(); | |||
interface2(); | |||
} | |||
@@ -102,6 +107,15 @@ private String dbname="qmrz"; | |||
generator.generator(); | |||
} | |||
/** | |||
* service 生成 | |||
*/ | |||
@Test | |||
public void serviceFP() { | |||
ServiceFPGenerator generator = new ServiceFPGenerator(dbname); | |||
generator.generator(); | |||
} | |||
/** | |||
* serviceImpl 生成 | |||
*/ | |||
@@ -111,6 +125,22 @@ private String dbname="qmrz"; | |||
generator.generator(); | |||
} | |||
/** | |||
* serviceFpImpl 生成 | |||
*/ | |||
@Test | |||
public void serviceImplFp() { | |||
ServiceImplFPGenerator generator = new ServiceImplFPGenerator(dbname); | |||
generator.generator(); | |||
} | |||
@Test | |||
public void serviceImplFpr() { | |||
ServiceImplFPRGenerator generator = new ServiceImplFPRGenerator(dbname); | |||
generator.generator(); | |||
} | |||
/** | |||
* serviceImpl 生成 | |||
*/ | |||
@@ -129,6 +159,16 @@ private String dbname="qmrz"; | |||
generator.generator(); | |||
} | |||
/** | |||
* controller 生成 | |||
*/ | |||
@Test | |||
public void controllerFP() { | |||
ControllerFPGenerator generator = new ControllerFPGenerator(dbname); | |||
generator.generator(); | |||
} | |||
/** | |||
* api_sync 同步 | |||
*/ | |||