|
@@ -1,23 +1,25 @@
|
|
package com.management.platform.service.impl;
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
-import com.management.platform.entity.BusObject;
|
|
|
|
-import com.management.platform.entity.CusTableColumn;
|
|
|
|
-import com.management.platform.entity.User;
|
|
|
|
-import com.management.platform.mapper.BusObjectMapper;
|
|
|
|
-import com.management.platform.mapper.CusTableColumnMapper;
|
|
|
|
-import com.management.platform.mapper.UserMapper;
|
|
|
|
|
|
+import com.management.platform.entity.*;
|
|
|
|
+import com.management.platform.entity.bo.FormStorePageBO;
|
|
|
|
+import com.management.platform.entity.bo.PageBO;
|
|
|
|
+import com.management.platform.entity.vo.SysRichFunction;
|
|
|
|
+import com.management.platform.mapper.*;
|
|
import com.management.platform.service.CusTableColumnService;
|
|
import com.management.platform.service.CusTableColumnService;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.MessageUtils;
|
|
import com.management.platform.util.MessageUtils;
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper, CusTableColumn> implements CusTableColumnService {
|
|
public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper, CusTableColumn> implements CusTableColumnService {
|
|
@@ -31,6 +33,23 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
@Resource
|
|
@Resource
|
|
private BusObjectMapper busObjectMapper;
|
|
private BusObjectMapper busObjectMapper;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private BusObjRelationMapper busObjRelationMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private BusReportStoreMapper busReportStoreMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private CusReportFormMapper cusReportFormMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private ReportFormAccessMapper reportFormAccessMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private SysFunctionMapper sysFunctionMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private SysRoleFunctionMapper sysRoleFunctionMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg getStructByTableName(String tableName, HttpServletRequest request) {
|
|
public HttpRespMsg getStructByTableName(String tableName, HttpServletRequest request) {
|
|
@@ -55,4 +74,228 @@ public class CusTableColumnServiceImpl extends ServiceImpl<CusTableColumnMapper,
|
|
msg.setData(resMap);
|
|
msg.setData(resMap);
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg getAllBusTable(HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ List<BusObject> busObjects = busObjectMapper.selectList(null);
|
|
|
|
+ msg.setData(busObjects);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg getRelateTableByFromColumn(String tableName,String columnName, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ List<BusObjRelation> busObjRelations = busObjRelationMapper.selectList(new LambdaQueryWrapper<BusObjRelation>()
|
|
|
|
+ .eq(BusObjRelation::getFromTbl, tableName)
|
|
|
|
+ .eq(BusObjRelation::getFromCol, columnName));
|
|
|
|
+ msg.setData(busObjRelations);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg getRelateBusTableByFromTable(String tableName, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ List<BusObjRelation> relationList = busObjRelationMapper.selectList(new LambdaQueryWrapper<BusObjRelation>()
|
|
|
|
+ .select(BusObjRelation::getToTbl, BusObjRelation::getFromColBusName)
|
|
|
|
+ .eq(BusObjRelation::getFromTbl, tableName)
|
|
|
|
+ );
|
|
|
|
+ msg.setData(relationList);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg getFormStorePage(PageBO<FormStorePageBO> queryBO,HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+ IPage<BusReportStore> page =new Page<>();
|
|
|
|
+ page.setCurrent(queryBO.getPageIndex());
|
|
|
|
+ page.setSize(queryBO.getPageSize());
|
|
|
|
+ FormStorePageBO pageQueryBO = queryBO.getData();
|
|
|
|
+ pageQueryBO.setUserId(user.getId());
|
|
|
|
+ pageQueryBO.setDepartmentId(user.getDepartmentId());
|
|
|
|
+ pageQueryBO.setCompanyId(user.getCompanyId());
|
|
|
|
+ page = busReportStoreMapper.getPrivilegedFormStore(page,queryBO.getData());
|
|
|
|
+ List<BusReportStore> records = page.getRecords();
|
|
|
|
+ if(CollectionUtils.isNotEmpty(records)){
|
|
|
|
+ List<Integer> formIds = records.stream().filter(t -> null != t.getRelateFormId()).map(BusReportStore::getRelateFormId)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ if(CollectionUtils.isNotEmpty(formIds)){
|
|
|
|
+ List<CusReportForm> cusReportForms = cusReportFormMapper.selectList(new LambdaQueryWrapper<CusReportForm>()
|
|
|
|
+ .in(CusReportForm::getId, formIds)
|
|
|
|
+ );
|
|
|
|
+ List<ReportFormAccess> reportFormAccesses = reportFormAccessMapper.getAccessesByFormIds(user.getCompanyId(),formIds);
|
|
|
|
+ Map<Integer, List<ReportFormAccess>> accessGroupMap = reportFormAccesses.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(ReportFormAccess::getRelateFormId));
|
|
|
|
+ for (CusReportForm cusReportForm : cusReportForms) {
|
|
|
|
+ List<ReportFormAccess> accesses = accessGroupMap.get(cusReportForm.getId());
|
|
|
|
+ if(CollectionUtils.isNotEmpty(accesses)){
|
|
|
|
+ List<ReportFormAccess> userAccesses = accesses.stream().filter(t -> 1 == t.getAccessType()).collect(Collectors.toList());
|
|
|
|
+ List<ReportFormAccess> deptAccesses = accesses.stream().filter(t -> 2 == t.getAccessType()).collect(Collectors.toList());
|
|
|
|
+ cusReportForm.setUserAccessList(userAccesses);
|
|
|
|
+ cusReportForm.setDeptAccessList(deptAccesses);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ page.setRecords(records);
|
|
|
|
+ }
|
|
|
|
+ msg.setData(page);
|
|
|
|
+
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public HttpRespMsg addOrUpdateFormStore(BusReportStore busReportStore, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+
|
|
|
|
+ List<SysRichFunction> sysFunctions = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "分类文件夹管理");
|
|
|
|
+ if(CollectionUtils.isEmpty(sysFunctions)){
|
|
|
|
+ msg.setError("角色无操作权限");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(null == busReportStore.getId()){
|
|
|
|
+ busReportStore.setCreateBy(user.getId());
|
|
|
|
+ busReportStore.setCompanyId(user.getCompanyId());
|
|
|
|
+ busReportStoreMapper.insert(busReportStore);
|
|
|
|
+ }else{
|
|
|
|
+ busReportStore.setUpdateBy(user.getId());
|
|
|
|
+ busReportStore.setUpdateTime(new Date());
|
|
|
|
+
|
|
|
|
+ busReportStoreMapper.updateById(busReportStore);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg addOrUpdateReportForm(CusReportForm cusReportForm, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+ if(null == cusReportForm.getId()){
|
|
|
|
+ BusReportStore busReportStore = new BusReportStore();
|
|
|
|
+ busReportStore.setStoreName(cusReportForm.getReportFormName());
|
|
|
|
+ busReportStore.setCreateBy(user.getId());
|
|
|
|
+ busReportStore.setStoreType(2);
|
|
|
|
+ busReportStore.setOrderItem(cusReportForm.getOrderItem());
|
|
|
|
+ busReportStore.setParentStoreId(cusReportForm.getParentStoreId());
|
|
|
|
+ busReportStore.setDescription(cusReportForm.getDescription());
|
|
|
|
+ busReportStore.setCompanyId(user.getCompanyId());
|
|
|
|
+ busReportStoreMapper.insert(busReportStore);
|
|
|
|
+
|
|
|
|
+ cusReportForm.setCreateBy(user.getId());
|
|
|
|
+ cusReportForm.setCompanyId(user.getCompanyId());
|
|
|
|
+ cusReportFormMapper.insert(cusReportForm);
|
|
|
|
+
|
|
|
|
+ List<ReportFormAccess> toAddList = new ArrayList<>();
|
|
|
|
+ List<ReportFormAccess> deptAccessList = cusReportForm.getDeptAccessList();
|
|
|
|
+ if(CollectionUtils.isNotEmpty(deptAccessList)){
|
|
|
|
+ for (ReportFormAccess reportFormAccess : deptAccessList) {
|
|
|
|
+ reportFormAccess.setRelateFormId(cusReportForm.getId());
|
|
|
|
+ reportFormAccess.setCompanyId(user.getCompanyId());
|
|
|
|
+ reportFormAccess.setAccessType(2);
|
|
|
|
+ toAddList.add(reportFormAccess);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<ReportFormAccess> userAccessList = cusReportForm.getUserAccessList();
|
|
|
|
+ if(CollectionUtils.isNotEmpty(userAccessList)){
|
|
|
|
+ for (ReportFormAccess reportFormAccess : userAccessList) {
|
|
|
|
+ reportFormAccess.setRelateFormId(cusReportForm.getId());
|
|
|
|
+ reportFormAccess.setCompanyId(user.getCompanyId());
|
|
|
|
+ reportFormAccess.setAccessType(1);
|
|
|
|
+ toAddList.add(reportFormAccess);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ reportFormAccessMapper.batchInsert(toAddList);
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ BusReportStore busReportStore = busReportStoreMapper.selectOne(new LambdaQueryWrapper<BusReportStore>()
|
|
|
|
+ .eq(BusReportStore::getRelateFormId, cusReportForm.getId())
|
|
|
|
+ );
|
|
|
|
+ if(null != busReportStore){
|
|
|
|
+ busReportStore.setStoreName(cusReportForm.getReportFormName());
|
|
|
|
+ busReportStore.setUpdateBy(user.getId());
|
|
|
|
+ busReportStore.setUpdateTime(new Date());
|
|
|
|
+ busReportStore.setOrderItem(cusReportForm.getOrderItem());
|
|
|
|
+ busReportStore.setParentStoreId(cusReportForm.getParentStoreId());
|
|
|
|
+ busReportStore.setDescription(cusReportForm.getDescription());
|
|
|
|
+ busReportStoreMapper.updateById(busReportStore);
|
|
|
|
+
|
|
|
|
+ cusReportFormMapper.updateById(cusReportForm);
|
|
|
|
+
|
|
|
|
+ List<ReportFormAccess> toAddList = new ArrayList<>();
|
|
|
|
+ List<ReportFormAccess> deptAccessList = cusReportForm.getDeptAccessList();
|
|
|
|
+ if(CollectionUtils.isNotEmpty(deptAccessList)){
|
|
|
|
+ for (ReportFormAccess reportFormAccess : deptAccessList) {
|
|
|
|
+ reportFormAccess.setRelateFormId(cusReportForm.getId());
|
|
|
|
+ reportFormAccess.setCompanyId(user.getCompanyId());
|
|
|
|
+ reportFormAccess.setAccessType(2);
|
|
|
|
+ toAddList.add(reportFormAccess);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<ReportFormAccess> userAccessList = cusReportForm.getUserAccessList();
|
|
|
|
+ if(CollectionUtils.isNotEmpty(userAccessList)){
|
|
|
|
+ for (ReportFormAccess reportFormAccess : userAccessList) {
|
|
|
|
+ reportFormAccess.setRelateFormId(cusReportForm.getId());
|
|
|
|
+ reportFormAccess.setCompanyId(user.getCompanyId());
|
|
|
|
+ reportFormAccess.setAccessType(1);
|
|
|
|
+ toAddList.add(reportFormAccess);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ reportFormAccessMapper.delete(new LambdaQueryWrapper<ReportFormAccess>()
|
|
|
|
+ .eq(ReportFormAccess::getRelateFormId, cusReportForm.getId())
|
|
|
|
+ );
|
|
|
|
+ reportFormAccessMapper.batchInsert(toAddList);
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ msg.setError("未找到对应报表");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public HttpRespMsg deleteFormStore(Integer storeId,HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+ List<SysRichFunction> sysFunctions = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "分类文件夹管理");
|
|
|
|
+ if(CollectionUtils.isEmpty(sysFunctions)){
|
|
|
|
+ msg.setError("角色无操作权限");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ BusReportStore busReportStore = busReportStoreMapper.selectById(storeId);
|
|
|
|
+ if(busReportStore.getCreateBy() != user.getId()){
|
|
|
|
+ msg.setError("非创建人无法删除");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //删除下级报表
|
|
|
|
+ //删除该目录
|
|
|
|
+ busReportStoreMapper.delete(new LambdaQueryWrapper<BusReportStore>()
|
|
|
|
+ .and(tmp->tmp.eq(BusReportStore::getId,storeId).or().in(BusReportStore::getParentStoreId,storeId))
|
|
|
|
+ );
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public HttpRespMsg deleteReportForm(Integer formId, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+ CusReportForm cusReportForm = cusReportFormMapper.selectById(formId);
|
|
|
|
+ if(cusReportForm.getCreateBy() != user.getId()){
|
|
|
|
+ msg.setError("非创建人不能删除");
|
|
|
|
+ }
|
|
|
|
+ cusReportFormMapper.deleteById(formId);
|
|
|
|
+ reportFormAccessMapper.delete(new LambdaQueryWrapper<ReportFormAccess>()
|
|
|
|
+ .eq(ReportFormAccess::getCompanyId,user.getCompanyId())
|
|
|
|
+ .in(ReportFormAccess::getRelateFormId,formId)
|
|
|
|
+ );
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
}
|
|
}
|