|
@@ -125,7 +125,7 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
|
public HttpRespMsg getRelateBusTableByFromTable(String tableName, HttpServletRequest request) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
List<BusObjRelation> relationList = busObjRelationMapper.selectList(new LambdaQueryWrapper<BusObjRelation>()
|
|
|
- .select(BusObjRelation::getToTbl, BusObjRelation::getFromColBusName)
|
|
|
+// .select(BusObjRelation::getToTbl, BusObjRelation::getFromColBusName)
|
|
|
.eq(BusObjRelation::getFromTbl, tableName)
|
|
|
);
|
|
|
msg.setData(relationList);
|
|
@@ -231,7 +231,7 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
|
cusReportForm.setExecuteSql(s);
|
|
|
if(null == cusReportForm.getId()){
|
|
|
|
|
|
- Company company = companyMapper.selectById(user.getId());
|
|
|
+ Company company = companyMapper.selectById(user.getCompanyId());
|
|
|
if(1 == company.getVersionControl()){
|
|
|
Integer count = busReportStoreMapper.selectCount(new LambdaQueryWrapper<BusReportStore>()
|
|
|
.eq(BusReportStore::getCompanyId, user.getCompanyId())
|
|
@@ -242,6 +242,10 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ cusReportForm.setCreateBy(user.getId());
|
|
|
+ cusReportForm.setCompanyId(user.getCompanyId());
|
|
|
+ cusReportFormMapper.insert(cusReportForm);
|
|
|
+
|
|
|
BusReportStore lastStore = busReportStoreMapper.selectOne(new LambdaQueryWrapper<BusReportStore>()
|
|
|
.eq(BusReportStore::getCompanyId, user.getCompanyId())
|
|
|
.eq(BusReportStore::getParentStoreId, cusReportForm.getParentStoreId())
|
|
@@ -249,6 +253,7 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
|
.last(" limit 1")
|
|
|
);
|
|
|
BusReportStore busReportStore = new BusReportStore();
|
|
|
+ busReportStore.setRelateFormId(cusReportForm.getId());
|
|
|
busReportStore.setStoreName(cusReportForm.getReportFormName());
|
|
|
busReportStore.setCreateBy(user.getId());
|
|
|
busReportStore.setStoreType(2);
|
|
@@ -262,27 +267,46 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
|
}
|
|
|
busReportStoreMapper.insert(busReportStore);
|
|
|
|
|
|
- cusReportForm.setCreateBy(user.getId());
|
|
|
- cusReportForm.setCompanyId(user.getCompanyId());
|
|
|
- cusReportFormMapper.insert(cusReportForm);
|
|
|
-
|
|
|
List<ReportFormAccess> toAddList = new ArrayList<>();
|
|
|
// List<ReportFormAccess> deptAccessList = cusReportForm.getDeptAccessList();
|
|
|
- List<Integer> departmentIds = cusReportForm.getDepartmentIds();
|
|
|
- if(CollectionUtils.isNotEmpty(departmentIds)){
|
|
|
- for (Integer deptId: departmentIds) {
|
|
|
+ if(StringUtils.isNotBlank(cusReportForm.getDepartmentIds())){
|
|
|
+ String[] departmentIds = cusReportForm.getDepartmentIds().split(",");
|
|
|
+ for (String deptId: departmentIds) {
|
|
|
ReportFormAccess reportFormAccess = new ReportFormAccess();
|
|
|
reportFormAccess.setRelateFormId(cusReportForm.getId());
|
|
|
reportFormAccess.setCompanyId(user.getCompanyId());
|
|
|
reportFormAccess.setAccessType(2);
|
|
|
- reportFormAccess.setDepartmentId(deptId);
|
|
|
+ reportFormAccess.setDepartmentId(Integer.parseInt(deptId));
|
|
|
toAddList.add(reportFormAccess);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// List<Integer> departmentIds = cusReportForm.getDepartmentIds();
|
|
|
+// if(CollectionUtils.isNotEmpty(departmentIds)){
|
|
|
+// for (Integer deptId: departmentIds) {
|
|
|
+// ReportFormAccess reportFormAccess = new ReportFormAccess();
|
|
|
+// reportFormAccess.setRelateFormId(cusReportForm.getId());
|
|
|
+// reportFormAccess.setCompanyId(user.getCompanyId());
|
|
|
+// reportFormAccess.setAccessType(2);
|
|
|
+// reportFormAccess.setDepartmentId(deptId);
|
|
|
+// toAddList.add(reportFormAccess);
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
// List<ReportFormAccess> userAccessList = cusReportForm.getUserAccessList();
|
|
|
- List<String> userIds = cusReportForm.getUserIds();
|
|
|
- if(CollectionUtils.isNotEmpty(userIds)){
|
|
|
+// List<String> userIds = cusReportForm.getUserIds();
|
|
|
+// if(CollectionUtils.isNotEmpty(userIds)){
|
|
|
+// for (String userId: userIds) {
|
|
|
+// ReportFormAccess reportFormAccess = new ReportFormAccess();
|
|
|
+// reportFormAccess.setRelateFormId(cusReportForm.getId());
|
|
|
+// reportFormAccess.setCompanyId(user.getCompanyId());
|
|
|
+// reportFormAccess.setAccessType(1);
|
|
|
+// reportFormAccess.setUserId(userId);
|
|
|
+// toAddList.add(reportFormAccess);
|
|
|
+// }
|
|
|
+// }
|
|
|
+ if(StringUtils.isNotBlank(cusReportForm.getUserIds())){
|
|
|
+ String[] userIds = cusReportForm.getUserIds().split(",");
|
|
|
for (String userId: userIds) {
|
|
|
ReportFormAccess reportFormAccess = new ReportFormAccess();
|
|
|
reportFormAccess.setRelateFormId(cusReportForm.getId());
|
|
@@ -292,7 +316,29 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
|
toAddList.add(reportFormAccess);
|
|
|
}
|
|
|
}
|
|
|
- reportFormAccessMapper.batchInsert(toAddList);
|
|
|
+// List<List<ReportFormAccess>> all = new ArrayList<>();
|
|
|
+// if (toAddList.size() > 500) {
|
|
|
+// int i = 0;
|
|
|
+// while (i < toAddList.size()) {
|
|
|
+// List<ReportFormAccess> subList;
|
|
|
+// if (i + 500 > toAddList.size()) {
|
|
|
+// subList = toAddList.subList(i, toAddList.size());
|
|
|
+// } else {
|
|
|
+// subList = toAddList.subList(i, i + 500);
|
|
|
+// }
|
|
|
+// i = i + 500;
|
|
|
+// all.add(subList);
|
|
|
+// }
|
|
|
+// for (List<ReportFormAccess> reportFormAccesses : all) {
|
|
|
+// reportFormAccessMapper.batchInsert(reportFormAccesses);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// reportFormAccessMapper.batchInsert(toAddList);
|
|
|
+// }
|
|
|
+ for (ReportFormAccess reportFormAccess : toAddList) {
|
|
|
+ reportFormAccessMapper.insert(reportFormAccess);
|
|
|
+ }
|
|
|
+// reportFormAccessMapper.batchInsert(toAddList);
|
|
|
|
|
|
}else{
|
|
|
BusReportStore busReportStore = busReportStoreMapper.selectOne(new LambdaQueryWrapper<BusReportStore>()
|
|
@@ -300,6 +346,7 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
|
);
|
|
|
if(null != busReportStore){
|
|
|
busReportStore.setStoreName(cusReportForm.getReportFormName());
|
|
|
+ busReportStore.setRelateFormId(cusReportForm.getId());
|
|
|
busReportStore.setUpdateBy(user.getId());
|
|
|
busReportStore.setUpdateTime(new Date());
|
|
|
busReportStore.setParentStoreId(cusReportForm.getParentStoreId());
|
|
@@ -331,7 +378,31 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
|
reportFormAccessMapper.delete(new LambdaQueryWrapper<ReportFormAccess>()
|
|
|
.eq(ReportFormAccess::getRelateFormId, cusReportForm.getId())
|
|
|
);
|
|
|
- reportFormAccessMapper.batchInsert(toAddList);
|
|
|
+
|
|
|
+// List<List<ReportFormAccess>> all = new ArrayList<>();
|
|
|
+// if (toAddList.size() > 500) {
|
|
|
+// int i = 0;
|
|
|
+// while (i < toAddList.size()) {
|
|
|
+// List<ReportFormAccess> subList;
|
|
|
+// if (i + 500 > toAddList.size()) {
|
|
|
+// subList = toAddList.subList(i, toAddList.size());
|
|
|
+// } else {
|
|
|
+// subList = toAddList.subList(i, i + 500);
|
|
|
+// }
|
|
|
+// i = i + 500;
|
|
|
+// all.add(subList);
|
|
|
+// }
|
|
|
+// for (List<ReportFormAccess> reportFormAccesses : all) {
|
|
|
+// reportFormAccessMapper.batchInsert(reportFormAccesses);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// reportFormAccessMapper.batchInsert(toAddList);
|
|
|
+// }
|
|
|
+
|
|
|
+ for (ReportFormAccess reportFormAccess : toAddList) {
|
|
|
+ reportFormAccessMapper.insert(reportFormAccess);
|
|
|
+ }
|
|
|
+// reportFormAccessMapper.batchInsert(toAddList);
|
|
|
|
|
|
}else{
|
|
|
msg.setError("未找到对应报表");
|
|
@@ -444,12 +515,48 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
|
List<BusReportStore> busReportStores = busReportStoreMapper.selectList(new LambdaQueryWrapper<BusReportStore>()
|
|
|
.eq(BusReportStore::getCompanyId, user.getCompanyId())
|
|
|
+ .ne(BusReportStore::getStoreType,2)
|
|
|
);
|
|
|
List<BusReportStore> listTree = this.listToTree(busReportStores);
|
|
|
msg.setData(listTree);
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getResByFormJson(String formJson, HttpServletRequest request) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ List<Map<String,Object>> columnList = new ArrayList<>();
|
|
|
+ Matcher deleteMatcher = DELETE_SGIN_PATTERN.matcher(formJson);
|
|
|
+ Matcher updateMatcher = UPDATE_SIGN_PATTERN.matcher(formJson);
|
|
|
+ Matcher insertMatcher = INSERT_SIGN_PATTERN.matcher(formJson);
|
|
|
+ if (deleteMatcher.find() || updateMatcher.find() || insertMatcher.find()) {
|
|
|
+ msg.setError("包含非法字符,无法执行");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ try (Connection connection = dataSource.getConnection()) {
|
|
|
+ PreparedStatement preparedStatement = connection.prepareStatement(formJson);
|
|
|
+ ResultSet resultSet = preparedStatement.executeQuery();
|
|
|
+ columnList = this.convertList(resultSet);
|
|
|
+ }catch (SQLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ msg.setError("SQL语句有误,请联系管理员");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ msg.setData(columnList);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getFormJsonByFormId(Integer formId, HttpServletRequest request) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ CusReportForm cusReportForm = cusReportFormMapper.selectById(formId);
|
|
|
+// Map<String,Object> map = new HashMap<>();
|
|
|
+// map.put("formJson",cusReportForm.getFormJson());
|
|
|
+// map.put("formFieldHead",cusReportForm.getFormFieldHead());
|
|
|
+ msg.setData(cusReportForm.getFormJson());
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
private List<BusReportStore> listToTree(List<BusReportStore> treeNodeList){
|
|
|
if(null == treeNodeList){
|
|
|
return null;
|
|
@@ -481,7 +588,7 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
|
while (rs.next()) {
|
|
|
Map<String, Object> rowData = new HashMap<String, Object>();
|
|
|
for (int i = 1; i <= columnCount; i++) {
|
|
|
- rowData.put(md.getColumnName(i), rs.getObject(i));
|
|
|
+ rowData.put(md.getTableName(i)+"_"+md.getColumnName(i), rs.getObject(i));
|
|
|
}
|
|
|
list.add(rowData);
|
|
|
}
|