Browse Source

动态表格

v1.0
Yen 2 years ago
parent
commit
1b036fbccb
  1. 1
      src/main/java/com/qs/serve/modules/exl/common/ExlConst.java
  2. 29
      src/main/java/com/qs/serve/modules/exl/common/TableCreateSqlUtil.java
  3. 14
      src/main/java/com/qs/serve/modules/exl/controller/ExlTableConfController.java
  4. 52
      src/main/java/com/qs/serve/modules/exl/controller/ExlTableDataController.java
  5. 5
      src/main/java/com/qs/serve/modules/exl/entity/ExlColumnConf.java
  6. 6
      src/main/java/com/qs/serve/modules/exl/service/impl/ExlTableConfServiceImpl.java
  7. 2
      src/main/java/com/qs/serve/modules/tbs/common/TbsBudgetCheckState.java
  8. 7
      src/main/java/com/qs/serve/modules/tbs/controller/TbsBudgetChangeController.java
  9. 10
      src/main/java/com/qs/serve/modules/tbs/controller/TbsBudgetCheckController.java
  10. 2
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsBudgetChangeOperationServiceImpl.java
  11. 5
      src/main/java/com/qs/serve/task/TbsTask.java

1
src/main/java/com/qs/serve/modules/exl/common/ExlConst.java

@ -7,6 +7,7 @@ package com.qs.serve.modules.exl.common;
public interface ExlConst { public interface ExlConst {
String TABLE_NAME_PRE = "exd_"; String TABLE_NAME_PRE = "exd_";
String TABLE_COMMENT_PRE = "excel数据-";
String DATE_TYPE = "date"; String DATE_TYPE = "date";
String TYPE_INT = "int"; String TYPE_INT = "int";

29
src/main/java/com/qs/serve/modules/exl/common/TableCreateSqlUtil.java

@ -13,27 +13,32 @@ import java.util.Map;
public class TableCreateSqlUtil { public class TableCreateSqlUtil {
public static final Map<String,String> MYSQL_DATA_MAP = new HashMap<>(); public static final Map<String,String> MYSQL_DATA_MAP = new HashMap<>();
static {
MYSQL_DATA_MAP.put("int","bigint");
MYSQL_DATA_MAP.put("string","varchar(300)");
MYSQL_DATA_MAP.put("date","date");
MYSQL_DATA_MAP.put("money","decimal(11, 2)");
MYSQL_DATA_MAP.put("datetime","datetime");
}
public static final String COLUMN_NULL = " null "; public static final String COLUMN_NULL = " null ";
public static final String COLUMN_NOT_NULL = " not null "; public static final String COLUMN_NOT_NULL = " not null ";
public static final String COLUMN_COMMENT = "COMMENT"; public static final String COLUMN_COMMENT = "COMMENT";
public static String createMysqlTableSql(String tableName, List<ExlColumnConf> columnList){ public static String createMysqlTableSql(String tableName,String tableRemark, List<ExlColumnConf> columnList){
StringBuffer result = new StringBuffer("CREATE TABLE `"+tableName+"` ("); StringBuffer result = new StringBuffer("CREATE TABLE `"+tableName+"` (");
result.append(" `union_id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',"); result.append(" `union_row_id` varchar(255) NOT NULL AUTO_INCREMENT COMMENT 'union_row_id',");
for (ExlColumnConf column : columnList) { for (ExlColumnConf column : columnList) {
String columnType = column.getColumnType(); String columnType = MYSQL_DATA_MAP.get(column.getColumnType())==null?column.getColumnType():MYSQL_DATA_MAP.get(column.getColumnType());
String nullValue = column.getNotNullFlag().equals(1) ? COLUMN_NOT_NULL:COLUMN_NULL; String nullValue = column.getNotNullFlag().equals(1) ? COLUMN_NOT_NULL:COLUMN_NULL;
if(columnType.equals("int")){ result.append("`"+column.getColumnName()+"` "+
result.append("`"+column.getColumnName()+"` "+ columnType +
MYSQL_DATA_MAP.get(columnType) + nullValue +
nullValue + COLUMN_COMMENT + " '"+
COLUMN_COMMENT + " '"+ column.getColumnHeader()+"',");
column.getColumnHeader()+"',");
}
} }
result.append(" PRIMARY KEY (`union_id`) USING BTREE "); result.append(" PRIMARY KEY (`union_row_id`) USING BTREE ");
return result.append(")").toString(); return result.append(") COMMENT = '"+tableRemark+"' ").toString();
} }
} }

14
src/main/java/com/qs/serve/modules/exl/controller/ExlTableConfController.java

@ -61,13 +61,6 @@ public class ExlTableConfController {
List<ExlTableConf> list = exlTableConfService.list(lqw); List<ExlTableConf> list = exlTableConfService.list(lqw);
return R.ok(list); return R.ok(list);
} }
//测试传参
@GetMapping("/test")
public R<?> test(@RequestParam Map<String,String> map){
return R.ok(map);
}
/** /**
* 翻页 * 翻页
* @param param * @param param
@ -167,8 +160,11 @@ public class ExlTableConfController {
columnLqw.eq(ExlColumnConf::getTableConfId,tableId); columnLqw.eq(ExlColumnConf::getTableConfId,tableId);
List<ExlColumnConf> columnConfList = exlColumnConfService.list(columnLqw); List<ExlColumnConf> columnConfList = exlColumnConfService.list(columnLqw);
if(tableConf.getEnableFlag().equals(0)){ if(tableConf.getEnableFlag().equals(0)){
String sql = TableCreateSqlUtil.createMysqlTableSql(ExlConst.TABLE_NAME_PRE String sql = TableCreateSqlUtil.createMysqlTableSql(
+ tableConf.getTableName(),columnConfList); ExlConst.TABLE_NAME_PRE + tableConf.getTableName(),
ExlConst.TABLE_COMMENT_PRE + tableConf.getExcelTitle(),
columnConfList);
log.debug(sql);
boolean result = QsSqlSessionUtil.executeSql(sql,sqlSessionTemplate); boolean result = QsSqlSessionUtil.executeSql(sql,sqlSessionTemplate);
if(result){ if(result){
tableConf.setEnableFlag(1); tableConf.setEnableFlag(1);

52
src/main/java/com/qs/serve/modules/exl/controller/ExlTableDataController.java

@ -49,7 +49,7 @@ public class ExlTableDataController {
* test * test
* @return * @return
*/ */
@GetMapping("/test/{tableConfigId}") @GetMapping("/page/{tableConfigId}")
public R<?> test(@PathVariable("tableConfigId") Long tableConfigId,@RequestParam Map<String,String> map){ public R<?> test(@PathVariable("tableConfigId") Long tableConfigId,@RequestParam Map<String,String> map){
// table // table
ExlTableConf tableConf = exlTableConfService.getById(tableConfigId); ExlTableConf tableConf = exlTableConfService.getById(tableConfigId);
@ -103,59 +103,19 @@ public class ExlTableDataController {
} }
/**
* 翻页
* @param param
* @return
*/
@GetMapping("/page")
public R<PageVo<ExlTableConf>> getPage(ExlTableConf param){
LambdaQueryWrapper<ExlTableConf> lqw = new LambdaQueryWrapper<>(param);
PageUtil.startPage();
List<ExlTableConf> list = exlTableConfService.list(lqw);
return R.byPageHelperList(list);
}
/**
* 更新
* @param param
* @return
*/
//@PostMapping("/updateById")
public R<?> updateById(@RequestBody @Valid ExlTableBo param){
return R.ok();
}
/** /**
* 新增 * 新增
* @param param * @param param
* @return * @return
*/ */
//@PostMapping("/save") @PostMapping("/batchSave/{tableConfigId}")
public R<?> save(@RequestBody @Valid ExlTableBo param){ public R<?> batchSave(@RequestBody List<Object> param){
return R.ok(); for (Object obj : param) {
}
/**
* 删除
* @param ids
* @return
*/
//@DeleteMapping("/deleteById/{ids}")
@SysLog(module = SystemModule.Excel, title = "表配置", biz = BizType.DELETE)
public R<?> deleteById(@PathVariable("ids") String ids){
List<Long> idsLong = StringUtils.splitIdLong(ids);
LambdaQueryWrapper<ExlTableConf> lqw = new LambdaQueryWrapper<>();
lqw.in(ExlTableConf::getId,ids);
lqw.eq(ExlTableConf::getEnableFlag,1);
Long count = exlTableConfService.count(lqw);
if(count>0){
return R.error("已启用的配置不可删除");
} }
boolean result = exlTableConfService.removeByIds(idsLong); return R.ok(param);
return R.isTrue(result);
} }
} }

5
src/main/java/com/qs/serve/modules/exl/entity/ExlColumnConf.java

@ -32,6 +32,8 @@ public class ExlColumnConf implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Long id; private Long id;
/** 非必传 */
@JsonIgnore
private Long tableConfId; private Long tableConfId;
/** 列名 */ /** 列名 */
@ -55,6 +57,9 @@ public class ExlColumnConf implements Serializable {
/** 空值标识 */ /** 空值标识 */
private Integer notNullFlag; private Integer notNullFlag;
/** 空值标识 */
private Integer keyFlag;
/** 创建时间 */ /** 创建时间 */
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")

6
src/main/java/com/qs/serve/modules/exl/service/impl/ExlTableConfServiceImpl.java

@ -3,6 +3,7 @@ package com.qs.serve.modules.exl.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qs.serve.common.util.Assert; import com.qs.serve.common.util.Assert;
import com.qs.serve.modules.exl.common.ExlConst;
import com.qs.serve.modules.exl.entity.ExlColumnConf; import com.qs.serve.modules.exl.entity.ExlColumnConf;
import com.qs.serve.modules.exl.entity.dto.ExlTableBo; import com.qs.serve.modules.exl.entity.dto.ExlTableBo;
import com.qs.serve.modules.exl.service.ExlColumnConfService; import com.qs.serve.modules.exl.service.ExlColumnConfService;
@ -12,6 +13,7 @@ import org.springframework.stereotype.Service;
import com.qs.serve.modules.exl.entity.ExlTableConf; import com.qs.serve.modules.exl.entity.ExlTableConf;
import com.qs.serve.modules.exl.service.ExlTableConfService; import com.qs.serve.modules.exl.service.ExlTableConfService;
import com.qs.serve.modules.exl.mapper.ExlTableConfMapper; import com.qs.serve.modules.exl.mapper.ExlTableConfMapper;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
@ -28,6 +30,7 @@ public class ExlTableConfServiceImpl extends ServiceImpl<ExlTableConfMapper,ExlT
private final ExlColumnConfService columnConfService; private final ExlColumnConfService columnConfService;
@Override @Override
@Transactional(rollbackFor = Exception.class)
public ExlTableConf modify(ExlTableBo param) { public ExlTableConf modify(ExlTableBo param) {
ExlTableConf tableConf = new ExlTableConf(); ExlTableConf tableConf = new ExlTableConf();
if(param.getId()==null){ if(param.getId()==null){
@ -62,6 +65,9 @@ public class ExlTableConfServiceImpl extends ServiceImpl<ExlTableConfMapper,ExlT
List<ExlColumnConf> columnList = param.getColumnList(); List<ExlColumnConf> columnList = param.getColumnList();
columnList.forEach(a->{ columnList.forEach(a->{
a.setTableConfId(tableId); a.setTableConfId(tableId);
if(a.getColumnType().equals(ExlConst.TYPE_MONEY)){
a.setConditionFlag(0);
}
a.setId(null); a.setId(null);
}); });
columnConfService.saveBatch(columnList); columnConfService.saveBatch(columnList);

2
src/main/java/com/qs/serve/modules/tbs/common/TbsBudgetCheckState.java

@ -14,6 +14,6 @@ public interface TbsBudgetCheckState {
int State_2_finished = 2; int State_2_finished = 2;
int State_3_setback = 3; int State_3_setback = 3;
int State_4_stop = 4; int State_4_stop = 4;
int State_5_close = 4; int State_5_close = 5;
} }

7
src/main/java/com/qs/serve/modules/tbs/controller/TbsBudgetChangeController.java

@ -1,6 +1,8 @@
package com.qs.serve.modules.tbs.controller; package com.qs.serve.modules.tbs.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qs.serve.common.framework.manager.AsyncFactory;
import com.qs.serve.common.framework.manager.AsyncManager;
import com.qs.serve.common.model.annotation.SysLog; import com.qs.serve.common.model.annotation.SysLog;
import com.qs.serve.common.model.dto.PageVo; import com.qs.serve.common.model.dto.PageVo;
import com.qs.serve.common.model.dto.R; import com.qs.serve.common.model.dto.R;
@ -11,10 +13,12 @@ import com.qs.serve.common.util.PageUtil;
import com.qs.serve.common.util.CopierUtil; import com.qs.serve.common.util.CopierUtil;
import com.qs.serve.common.util.StringUtils; import com.qs.serve.common.util.StringUtils;
import com.qs.serve.modules.sys.service.SysAttachService; import com.qs.serve.modules.sys.service.SysAttachService;
import com.qs.serve.modules.tbs.common.TbsBudgetCheckState;
import com.qs.serve.modules.tbs.common.dto.TbsBudgetChangeVo; import com.qs.serve.modules.tbs.common.dto.TbsBudgetChangeVo;
import com.qs.serve.modules.tbs.entity.*; import com.qs.serve.modules.tbs.entity.*;
import com.qs.serve.modules.tbs.entity.so.TbsBudgetChangeSo; import com.qs.serve.modules.tbs.entity.so.TbsBudgetChangeSo;
import com.qs.serve.modules.tbs.service.*; import com.qs.serve.modules.tbs.service.*;
import com.qs.serve.modules.tbs.service.impl.TbsBudgetChangeOperationServiceImpl;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@ -82,6 +86,9 @@ public class TbsBudgetChangeController {
if(budgetChange.getOrgAttachIds()!=null&&budgetChange.getOrgAttachIds().length>0){ if(budgetChange.getOrgAttachIds()!=null&&budgetChange.getOrgAttachIds().length>0){
budgetChange.setOrgAttachInfos(sysAttachService.listByIds(Arrays.asList(budgetChange.getOrgAttachIds()))); budgetChange.setOrgAttachInfos(sysAttachService.listByIds(Arrays.asList(budgetChange.getOrgAttachIds())));
} }
if (budgetChange.getBudgetCheckState().equals(TbsBudgetCheckState.State_1_apply)){
AsyncManager.me().execute(AsyncFactory.submitBudgetChange(budgetChange.getId()+""));
}
return R.ok(budgetChange); return R.ok(budgetChange);
} }

10
src/main/java/com/qs/serve/modules/tbs/controller/TbsBudgetCheckController.java

@ -39,6 +39,16 @@ public class TbsBudgetCheckController {
private final TbsBudgetApplyOperationServiceImpl tbsBudgetApplyOperationService; private final TbsBudgetApplyOperationServiceImpl tbsBudgetApplyOperationService;
private final TbsBudgetChangeOperationServiceImpl tbsBudgetChangeOperationService; private final TbsBudgetChangeOperationServiceImpl tbsBudgetChangeOperationService;
//测试
@PostMapping("test/{id}")
public R<?> test(@PathVariable String id){
TbsAffairCommitBo param = new TbsAffairCommitBo();
param.setTargetId(id);
tbsBudgetChangeOperationService.doFinished(param);
return R.ok();
}
/** /**
* 提交申请 * 提交申请
* @return * @return

2
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsBudgetChangeOperationServiceImpl.java

@ -85,7 +85,7 @@ public class TbsBudgetChangeOperationServiceImpl implements SeeYonOperationServi
budgetChangeMapper.updateById(budgetChange); budgetChangeMapper.updateById(budgetChange);
} }
TbsBudget tbsBudget = budgetMapper.selectById(budgetChange.getBudgetId()); TbsBudget tbsBudget = budgetMapper.selectById(budgetChange.getBudgetId());
SysUser sysUser = getSysUserService().getBySyId(budgetChange.getUserId()); SysUser sysUser = getSysUserService().getById(budgetChange.getUserId());
//更新条件 //更新条件
List<TbsBudgetChangeCondition> allChangeConditionList = tbsBudgetChangeConditionService.listByChangeId(budgetChange.getId()); List<TbsBudgetChangeCondition> allChangeConditionList = tbsBudgetChangeConditionService.listByChangeId(budgetChange.getId());
Map<Integer,List<TbsBudgetChangeCondition>> map = allChangeConditionList.stream().collect(Collectors.groupingBy(TbsBudgetChangeCondition::getSourceFlag)); Map<Integer,List<TbsBudgetChangeCondition>> map = allChangeConditionList.stream().collect(Collectors.groupingBy(TbsBudgetChangeCondition::getSourceFlag));

5
src/main/java/com/qs/serve/task/TbsTask.java

@ -45,10 +45,11 @@ public class TbsTask {
List<TbsCostApply> costApplyList = tbsCostApplyService.list(lqwApply); List<TbsCostApply> costApplyList = tbsCostApplyService.list(lqwApply);
List<Long> costApplyIds = costApplyList.stream().map(a->a.getId()).collect(Collectors.toList()); List<Long> costApplyIds = costApplyList.stream().map(a->a.getId()).collect(Collectors.toList());
//只更新审批完成的申请活动状态 //只更新审批完成的申请活动状态
LocalDate now = LocalDate.now();
LocalDate lastDay = now.plusDays(-1);
LambdaQueryWrapper<TbsActivity> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TbsActivity> lqw = new LambdaQueryWrapper<>();
lqw.in(TbsActivity::getCostApplyId,costApplyIds); lqw.in(TbsActivity::getCostApplyId,costApplyIds);
lqw.le(TbsActivity::getPreCheckDate, LocalDate.now()); lqw.le(TbsActivity::getPreCheckDate, lastDay);
lqw.eq(TbsActivity::getReopenFlag,0); lqw.eq(TbsActivity::getReopenFlag,0);
// 2-完成;4-已释放;5-已关闭 表流程已完结,冻结无意义 // 2-完成;4-已释放;5-已关闭 表流程已完结,冻结无意义
lqw.eq(TbsActivity::getActivityState,TbsActivityState.STATE_0_Todo); lqw.eq(TbsActivity::getActivityState,TbsActivityState.STATE_0_Todo);

Loading…
Cancel
Save