| | |
| | | import com.product.admin.service.UpdateLoginUserInfoService; |
| | | import com.product.common.lang.StringUtils; |
| | | import com.product.core.cache.DataPoolCacheImpl; |
| | | import com.product.core.config.CoreConst; |
| | | import com.product.core.dao.BaseDao; |
| | | import com.product.core.entity.DataTableEntity; |
| | | import com.product.core.entity.FieldSetEntity; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.xml.crypto.Data; |
| | | import java.util.*; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Component |
| | | public class ReportConfigService extends AbstractBaseService implements IReportConfigService { |
| | | @Autowired |
| | | BaseDao baseDao; |
| | | @Autowired |
| | | CodeService codeService; |
| | | @Autowired |
| | | public QueryFilterService queryFilterService; |
| | | @Autowired |
| | | public DataListReportService dataListReportService; |
| | | @Autowired |
| | | BaseDao baseDao; |
| | | @Autowired |
| | | CodeService codeService; |
| | | @Autowired |
| | | public QueryFilterService queryFilterService; |
| | | @Autowired |
| | | public DataListReportService dataListReportService; |
| | | |
| | | /** |
| | | * 报表列表 |
| | | * |
| | | * @param cpage |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public DataTableEntity listReportConfig(Integer cpage, Integer pageSize, FieldSetEntity fse) { |
| | | cpage = cpage == null ? 1 : cpage; |
| | | pageSize = pageSize == null ? 20 : pageSize; |
| | | /** |
| | | * 报表列表 |
| | | * |
| | | * @param cpage |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public DataTableEntity listReportConfig(Integer cpage, Integer pageSize, FieldSetEntity fse) { |
| | | cpage = cpage == null ? 1 : cpage; |
| | | pageSize = pageSize == null ? 20 : pageSize; |
| | | |
| | | List<Object> paramList = Lists.newArrayList(); |
| | | StringBuilder sql = new StringBuilder(512); |
| | | String queryFilter = " "; |
| | | if(!BaseUtil.dataTableIsEmpty(fse.getSubDataTable("systemSeniorQueryString"))){ |
| | | queryFilter ="AND"+ queryFilterService.getQueryFilter(fse); |
| | | } |
| | | sql.append("\nSELECT a.uuid,a.type_uuid,a.is_valid,a.org_level_uuid,a.report_name,b.type_name,b.type_group") |
| | | .append("\nFROM product_sys_report_config a") |
| | | .append("\nLEFT JOIN product_sys_report_type_config b ON a.type_uuid = b.uuid") |
| | | .append("\nwhere (function_uuid is null or function_uuid='') ") |
| | | .append(queryFilter); |
| | | List<Object> paramList = Lists.newArrayList(); |
| | | StringBuilder sql = new StringBuilder(512); |
| | | sql.append("\nSELECT a.uuid,a.type_uuid,a.is_valid,a.org_level_uuid,a.report_name,b.type_name,b.type_group") |
| | | .append("\nFROM product_sys_report_config a") |
| | | .append("\nLEFT JOIN product_sys_report_type_config b ON a.type_uuid = b.uuid") |
| | | .append("\nwhere (function_uuid is null or function_uuid='') "); |
| | | if (!StringUtils.isEmpty(fse.getString(CmnConst.TYPE_UUID))) { |
| | | sql.append("\nand b.type_group=?"); |
| | | paramList.add(fse.getString(CmnConst.TYPE_UUID)); |
| | | } |
| | | return baseDao.listTable(sql.toString(), paramList.toArray(), pageSize, cpage); |
| | | } |
| | | |
| | | if (!StringUtils.isEmpty(fse.getString(CmnConst.TYPE_UUID))) { |
| | | sql.append("\nand b.type_group=? "); |
| | | paramList.add(fse.getString(CmnConst.TYPE_UUID)); |
| | | } |
| | | return baseDao.listTable(sql.toString(), paramList.toArray(), pageSize, cpage); |
| | | } |
| | | /** |
| | | * 报表详情 |
| | | * |
| | | * @param uuid |
| | | * @return |
| | | */ |
| | | public FieldSetEntity findReportConfig(String uuid) { |
| | | StringBuilder sql = new StringBuilder(256); |
| | | sql.append("\nselect report_area,cell_position_y,cell_position_x,attribute_name,report_type_attr_value") |
| | | .append("\nfrom (") |
| | | .append("\n select report_area,cell_position_y,cell_position_x,report_type_attr_value,report_type_attr FROM product_sys_report_config_attribute ca") |
| | | .append("\n where report_config_uuid=?") |
| | | .append("\n) ca") |
| | | .append("\nleft join (") |
| | | .append("\n select uuid,attribute_name FROM product_sys_report_type_attribute where type_group='DataList'") |
| | | .append("\n) ta on ca.report_type_attr=ta.uuid") |
| | | .append("\nwhere attribute_name is not null ") |
| | | .append("\norder by report_area,cell_position_y,cell_position_x"); |
| | | DataTableEntity tempDte = baseDao.listTable(sql.toString(), new Object[]{uuid}); |
| | | DataTableEntity reportConfigAttrDte = new DataTableEntity(); |
| | | FieldSetEntity tempFse; |
| | | FieldSetEntity reportConfigAttrFse = new FieldSetEntity(); |
| | | String curReportArea; |
| | | String curX; |
| | | String curY; |
| | | String preReportArea = ""; |
| | | String preX = ""; |
| | | String preY = ""; |
| | | for (int i = 0; i < tempDte.getRows(); i++) { |
| | | tempFse = tempDte.getFieldSetEntity(i); |
| | | curReportArea = tempFse.getString(CmnConst.ATTR_REPORT_AREA); |
| | | curX = tempFse.getString(CmnConst.CELL_POSITION_X); |
| | | curY = tempFse.getString(CmnConst.CELL_POSITION_Y); |
| | | if (curReportArea == null || curX == null || curY == null) { |
| | | continue; |
| | | } |
| | | if (!preReportArea.equals(curReportArea) || !preX.equals(curX) || !preY.equals(curY)) { |
| | | reportConfigAttrFse = new FieldSetEntity(); |
| | | reportConfigAttrDte.addFieldSetEntity(reportConfigAttrFse); |
| | | reportConfigAttrFse.setTableName(CmnConst.PRODUCT_SYS_REPORT_CONFIG_ATTRIBUTE); |
| | | reportConfigAttrFse.setValue(CmnConst.ATTR_X, curX); |
| | | reportConfigAttrFse.setValue(CmnConst.ATTR_Y, curY); |
| | | reportConfigAttrFse.setValue(CmnConst.ATTR_REPORT_AREA, curReportArea); |
| | | } |
| | | reportConfigAttrFse.setValue(tempFse.getString(CmnConst.ATTRIBUTE_NAME), tempFse.getString(CmnConst.REPORT_TYPE_ATTR_VALUE)); |
| | | preReportArea = curReportArea; |
| | | preX = curX; |
| | | preY = curY; |
| | | } |
| | | |
| | | /** |
| | | * 报表详情 |
| | | * |
| | | * @param uuid |
| | | * @return |
| | | */ |
| | | public FieldSetEntity findReportConfig(String uuid) { |
| | | StringBuilder sql = new StringBuilder(256); |
| | | sql.append("\nselect report_area,cell_position_y,cell_position_x,attribute_name,report_type_attr_value") |
| | | .append("\nfrom (") |
| | | .append("\n select report_area,cell_position_y,cell_position_x,report_type_attr_value,report_type_attr FROM product_sys_report_config_attribute ca") |
| | | .append("\n where report_config_uuid=?") |
| | | .append("\n) ca") |
| | | .append("\nleft join (") |
| | | .append("\n select uuid,attribute_name FROM product_sys_report_type_attribute where type_group='DataList'") |
| | | .append("\n) ta on ca.report_type_attr=ta.uuid") |
| | | .append("\nwhere attribute_name is not null ") |
| | | .append("\norder by report_area,cell_position_y,cell_position_x"); |
| | | DataTableEntity tempDte = baseDao.listTable(sql.toString(), new Object[]{uuid}); |
| | | DataTableEntity reportConfigAttrDte = new DataTableEntity(); |
| | | FieldSetEntity tempFse; |
| | | FieldSetEntity reportConfigAttrFse = new FieldSetEntity(); |
| | | String curReportArea; |
| | | String curX; |
| | | String curY; |
| | | String preReportArea = ""; |
| | | String preX = ""; |
| | | String preY = ""; |
| | | for (int i = 0; i < tempDte.getRows(); i++) { |
| | | tempFse = tempDte.getFieldSetEntity(i); |
| | | curReportArea = tempFse.getString(CmnConst.ATTR_REPORT_AREA); |
| | | curX = tempFse.getString(CmnConst.CELL_POSITION_X); |
| | | curY = tempFse.getString(CmnConst.CELL_POSITION_Y); |
| | | if (curReportArea == null || curX == null || curY == null) { |
| | | continue; |
| | | } |
| | | if (!preReportArea.equals(curReportArea) || !preX.equals(curX) || !preY.equals(curY)) { |
| | | reportConfigAttrFse = new FieldSetEntity(); |
| | | reportConfigAttrDte.addFieldSetEntity(reportConfigAttrFse); |
| | | reportConfigAttrFse.setTableName(CmnConst.PRODUCT_SYS_REPORT_CONFIG_ATTRIBUTE); |
| | | reportConfigAttrFse.setValue(CmnConst.ATTR_X, curX); |
| | | reportConfigAttrFse.setValue(CmnConst.ATTR_Y, curY); |
| | | reportConfigAttrFse.setValue(CmnConst.ATTR_REPORT_AREA, curReportArea); |
| | | } |
| | | reportConfigAttrFse.setValue(tempFse.getString(CmnConst.ATTRIBUTE_NAME), tempFse.getString(CmnConst.REPORT_TYPE_ATTR_VALUE)); |
| | | preReportArea = curReportArea; |
| | | preX = curX; |
| | | preY = curY; |
| | | } |
| | | FieldSetEntity reportConfigFse = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_REPORT_CONFIG, uuid, false); |
| | | reportConfigFse.addSubDataTable(reportConfigAttrDte); |
| | | |
| | | FieldSetEntity reportConfigFse = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_REPORT_CONFIG, uuid, false); |
| | | reportConfigFse.addSubDataTable(reportConfigAttrDte); |
| | | return reportConfigFse; |
| | | } |
| | | |
| | | return reportConfigFse; |
| | | } |
| | | /** |
| | | * 报表新增 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | public String addReportConfig(FieldSetEntity fse) { |
| | | fse.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUserId()); |
| | | fse.setValue(CmnConst.CREATED_UTC_DATETIME, new Date()); |
| | | fse.setValue(CmnConst.IS_VALID, 1); |
| | | |
| | | /** |
| | | * 报表新增 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | public String addReportConfig(FieldSetEntity fse) { |
| | | fse.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUserId()); |
| | | fse.setValue(CmnConst.CREATED_UTC_DATETIME, new Date()); |
| | | fse.setValue(CmnConst.IS_VALID, 1); |
| | | replaceAttrName2UUID(fse); |
| | | |
| | | replaceAttrName2UUID(fse); |
| | | if (StringUtils.isEmpty(fse.getString(CmnConst.PAGE_SIZE))) { |
| | | fse.setValue(CmnConst.PAGE_SIZE, null); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(fse.getString(CmnConst.PAGE_SIZE))) { |
| | | fse.setValue(CmnConst.PAGE_SIZE, null); |
| | | } |
| | | System.out.println(System.currentTimeMillis()); |
| | | String uuid = baseDao.add(fse); |
| | | System.out.println(System.currentTimeMillis()); |
| | | String uuid = baseDao.add(fse); |
| | | |
| | | if ("1".equals(fse.getString(CmnConst.RELATE_FLAG))) { |
| | | // 重新设置缓存 |
| | | dataListReportService.setConfig(fse.getUUID()); |
| | | } |
| | | if ("1".equals(fse.getString(CmnConst.RELATE_FLAG))) { |
| | | // 重新设置缓存 |
| | | dataListReportService.setConfig(fse.getUUID()); |
| | | } |
| | | |
| | | return uuid; |
| | | } |
| | | return uuid; |
| | | } |
| | | |
| | | /** |
| | | * 报表修改 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | public boolean updateReportConfig(FieldSetEntity fse) { |
| | | fse.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUserId()); |
| | | fse.setValue(CmnConst.UPDATED_UTC_DATETIME, new Date()); |
| | | /** |
| | | * 报表修改 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | public boolean updateReportConfig(FieldSetEntity fse) { |
| | | fse.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUserId()); |
| | | fse.setValue(CmnConst.UPDATED_UTC_DATETIME, new Date()); |
| | | |
| | | replaceAttrName2UUID(fse); |
| | | replaceAttrName2UUID(fse); |
| | | |
| | | if (StringUtils.isEmpty(fse.getString(CmnConst.PAGE_SIZE))) { |
| | | fse.setValue(CmnConst.PAGE_SIZE, null); |
| | | } |
| | | if (StringUtils.isEmpty(fse.getString(CmnConst.PAGE_SIZE))) { |
| | | fse.setValue(CmnConst.PAGE_SIZE, null); |
| | | } |
| | | |
| | | boolean result = baseDao.update(fse); |
| | | boolean result = baseDao.update(fse); |
| | | |
| | | if ("1".equals(fse.getString(CmnConst.RELATE_FLAG)) || !StringUtils.isEmpty(fse.getString(CmnConst.FUNCTION_UUID))) { |
| | | // 重新设置缓存 |
| | | dataListReportService.setConfig(fse.getUUID()); |
| | | } |
| | | if ("1".equals(fse.getString(CmnConst.RELATE_FLAG)) || !StringUtils.isEmpty(fse.getString(CmnConst.FUNCTION_UUID))) { |
| | | // 重新设置缓存 |
| | | dataListReportService.setConfig(fse.getUUID()); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 替换属性名称为uuid |
| | | * |
| | | * @param fse |
| | | */ |
| | | private void replaceAttrName2UUID(FieldSetEntity fse) { |
| | | DataTableEntity reportTypeAttrDte = baseDao.listTable(CmnConst.PRODUCT_SYS_REPORT_TYPE_ATTRIBUTE, "type_group='DataList'", new Object[]{}, new Object[]{CmnConst.ATTRIBUTE_NAME, CmnConst.UUID}); |
| | | if (!BaseUtil.dataTableIsEmpty(reportTypeAttrDte)) { |
| | | Map<String, String> reportTypeAttrMap = Maps.newHashMap(); |
| | | FieldSetEntity tempFse; |
| | | for (int i = 0; i < reportTypeAttrDte.getRows(); i++) { |
| | | tempFse = reportTypeAttrDte.getFieldSetEntity(i); |
| | | reportTypeAttrMap.put(tempFse.getString(CmnConst.ATTRIBUTE_NAME), tempFse.getUUID()); |
| | | } |
| | | DataTableEntity preReportAttrDte = baseDao.listTable(CmnConst.PRODUCT_SYS_REPORT_CONFIG_ATTRIBUTE, "report_config_uuid=?", new Object[]{fse.getUUID()}); |
| | | Map<JSONObject, String> preReportAttrMap = Maps.newHashMap(); |
| | | JSONObject tempObj; |
| | | if (!BaseUtil.dataTableIsEmpty(preReportAttrDte)) { |
| | | for (int i = 0; i < preReportAttrDte.getRows(); i++) { |
| | | tempFse = preReportAttrDte.getFieldSetEntity(i); |
| | | tempObj = new JSONObject(); |
| | | tempObj.put(CmnConst.ATTR_REPORT_AREA, tempFse.getString(CmnConst.ATTR_REPORT_AREA)); |
| | | tempObj.put(CmnConst.CELL_POSITION_X, tempFse.getString(CmnConst.CELL_POSITION_X)); |
| | | tempObj.put(CmnConst.CELL_POSITION_Y, tempFse.getString(CmnConst.CELL_POSITION_Y)); |
| | | tempObj.put(CmnConst.REPORT_TYPE_ATTR, tempFse.getString(CmnConst.REPORT_TYPE_ATTR)); |
| | | preReportAttrMap.put(tempObj, tempFse.getUUID()); |
| | | } |
| | | } |
| | | DataTableEntity reportAttrDte = fse.getSubDataTable(CmnConst.PRODUCT_SYS_REPORT_CONFIG_ATTRIBUTE); |
| | | if (!BaseUtil.dataTableIsEmpty(reportAttrDte)) { |
| | | String tempUUID; |
| | | for (int i = 0; i < reportAttrDte.getRows(); i++) { |
| | | tempFse = reportAttrDte.getFieldSetEntity(i); |
| | | tempFse.setValue("report_type_attr_show_name", tempFse.getString(CmnConst.REPORT_TYPE_ATTR)); |
| | | tempFse.setValue(CmnConst.REPORT_TYPE_ATTR, reportTypeAttrMap.get(tempFse.getString(CmnConst.REPORT_TYPE_ATTR))); |
| | | tempFse.setValue(CmnConst.CELL_POSITION_X, tempFse.getString(CmnConst.ATTR_X)); |
| | | tempFse.setValue(CmnConst.CELL_POSITION_Y, tempFse.getString(CmnConst.ATTR_Y)); |
| | | String x = tempFse.getString(CmnConst.ATTR_X); |
| | | tempObj = new JSONObject(); |
| | | tempObj.put(CmnConst.ATTR_REPORT_AREA, tempFse.getString(CmnConst.ATTR_REPORT_AREA)); |
| | | tempObj.put(CmnConst.CELL_POSITION_X, tempFse.getString(CmnConst.CELL_POSITION_X)); |
| | | tempObj.put(CmnConst.CELL_POSITION_Y, tempFse.getString(CmnConst.CELL_POSITION_Y)); |
| | | tempObj.put(CmnConst.REPORT_TYPE_ATTR, tempFse.getString(CmnConst.REPORT_TYPE_ATTR)); |
| | | /** |
| | | * 替换属性名称为uuid |
| | | * |
| | | * @param fse |
| | | */ |
| | | private void replaceAttrName2UUID(FieldSetEntity fse) { |
| | | DataTableEntity reportTypeAttrDte = baseDao.listTable(CmnConst.PRODUCT_SYS_REPORT_TYPE_ATTRIBUTE, "type_group='DataList'", new Object[]{}, new Object[]{CmnConst.ATTRIBUTE_NAME, CmnConst.UUID}); |
| | | if (!BaseUtil.dataTableIsEmpty(reportTypeAttrDte)) { |
| | | Map<String, String> reportTypeAttrMap = Maps.newHashMap(); |
| | | FieldSetEntity tempFse; |
| | | for (int i = 0; i < reportTypeAttrDte.getRows(); i++) { |
| | | tempFse = reportTypeAttrDte.getFieldSetEntity(i); |
| | | reportTypeAttrMap.put(tempFse.getString(CmnConst.ATTRIBUTE_NAME), tempFse.getUUID()); |
| | | } |
| | | DataTableEntity preReportAttrDte = baseDao.listTable(CmnConst.PRODUCT_SYS_REPORT_CONFIG_ATTRIBUTE, "report_config_uuid=?", new Object[]{fse.getUUID()}); |
| | | Map<JSONObject, String> preReportAttrMap = Maps.newHashMap(); |
| | | JSONObject tempObj; |
| | | if (!BaseUtil.dataTableIsEmpty(preReportAttrDte)) { |
| | | for (int i = 0; i < preReportAttrDte.getRows(); i++) { |
| | | tempFse = preReportAttrDte.getFieldSetEntity(i); |
| | | tempObj = new JSONObject(); |
| | | tempObj.put(CmnConst.ATTR_REPORT_AREA, tempFse.getString(CmnConst.ATTR_REPORT_AREA)); |
| | | tempObj.put(CmnConst.CELL_POSITION_X, tempFse.getString(CmnConst.CELL_POSITION_X)); |
| | | tempObj.put(CmnConst.CELL_POSITION_Y, tempFse.getString(CmnConst.CELL_POSITION_Y)); |
| | | tempObj.put(CmnConst.REPORT_TYPE_ATTR, tempFse.getString(CmnConst.REPORT_TYPE_ATTR)); |
| | | preReportAttrMap.put(tempObj, tempFse.getUUID()); |
| | | } |
| | | } |
| | | DataTableEntity reportAttrDte = fse.getSubDataTable(CmnConst.PRODUCT_SYS_REPORT_CONFIG_ATTRIBUTE); |
| | | if (!BaseUtil.dataTableIsEmpty(reportAttrDte)) { |
| | | String tempUUID; |
| | | for (int i = 0; i < reportAttrDte.getRows(); i++) { |
| | | tempFse = reportAttrDte.getFieldSetEntity(i); |
| | | tempFse.setValue(CmnConst.REPORT_TYPE_ATTR, reportTypeAttrMap.get(tempFse.getString(CmnConst.REPORT_TYPE_ATTR))); |
| | | tempFse.setValue(CmnConst.CELL_POSITION_X, tempFse.getString(CmnConst.ATTR_X)); |
| | | tempFse.setValue(CmnConst.CELL_POSITION_Y, tempFse.getString(CmnConst.ATTR_Y)); |
| | | |
| | | tempUUID = preReportAttrMap.get(tempObj); |
| | | if (!StringUtils.isEmpty(tempUUID)) { |
| | | tempFse.setValue(CmnConst.UUID, tempUUID); |
| | | } |
| | | if (StringUtils.isEmpty(tempFse.getString(CmnConst.REPORT_TYPE_ATTR_VALUE))) { |
| | | //属性值是否为空 |
| | | if (StringUtils.isEmpty(tempFse.getUUID())) { |
| | | //没有保存过的属性 |
| | | reportAttrDte.removeFieldSetEntity(i); |
| | | i--; |
| | | } else { |
| | | //标记为删除 |
| | | tempFse.setValue(CoreConst.SYSTEM_DATA_OPERATE_TYPE, "del"); |
| | | } |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | tempObj = new JSONObject(); |
| | | tempObj.put(CmnConst.ATTR_REPORT_AREA, tempFse.getString(CmnConst.ATTR_REPORT_AREA)); |
| | | tempObj.put(CmnConst.CELL_POSITION_X, tempFse.getString(CmnConst.CELL_POSITION_X)); |
| | | tempObj.put(CmnConst.CELL_POSITION_Y, tempFse.getString(CmnConst.CELL_POSITION_Y)); |
| | | tempObj.put(CmnConst.REPORT_TYPE_ATTR, tempFse.getString(CmnConst.REPORT_TYPE_ATTR)); |
| | | |
| | | /** |
| | | * 报表删除 |
| | | * |
| | | * @param uuid |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | public boolean deleteReportConfig(String uuid) { |
| | | return baseDao.delete(CmnConst.PRODUCT_SYS_REPORT_CONFIG, "uuid=?", new Object[]{uuid}); |
| | | } |
| | | tempUUID = preReportAttrMap.get(tempObj); |
| | | if (!StringUtils.isEmpty(tempUUID)) { |
| | | tempFse.setValue(CmnConst.UUID, tempUUID); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Autowired |
| | | UpdateLoginUserInfoService updateLoginUserInfoService; |
| | | /** |
| | | * 报表删除 |
| | | * |
| | | * @param uuid |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | public boolean deleteReportConfig(String uuid) { |
| | | return baseDao.delete(CmnConst.PRODUCT_SYS_REPORT_CONFIG, "uuid=?", new Object[]{uuid}); |
| | | } |
| | | |
| | | /** |
| | | * 取消报表发布 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | public boolean cancelRelease(FieldSetEntity fse) { |
| | | DataTableEntity reportConfigDte = DataPoolCacheImpl.getInstance().getCacheData(CmnConst.CACHE_REPORT_CONFIG, new String[]{fse.getUUID()}); |
| | | if (BaseUtil.dataTableIsEmpty(reportConfigDte)) { |
| | | throw new BaseException(ReportCode.GET_REPORT_CONFIG_FIAL.getValue(), ReportCode.GET_REPORT_CONFIG_FIAL.getText()); |
| | | } |
| | | FieldSetEntity reportConfigFse = reportConfigDte.getFieldSetEntity(0); |
| | | String functionUUID = reportConfigFse.getString(CmnConst.FUNCTION_UUID); |
| | | if (StringUtils.isEmpty(functionUUID)) { |
| | | return false; |
| | | } |
| | | @Autowired |
| | | UpdateLoginUserInfoService updateLoginUserInfoService; |
| | | |
| | | DataTableEntity dt = baseDao.listTable(CmnConst.PRODUCT_SYS_FUNCTION_PERMISSION, "function_uuid=?", new Object[]{functionUUID}, new Object[]{"role_uuid uuid"}); |
| | | //从角色权限中移除 |
| | | baseDao.delete(CmnConst.PRODUCT_SYS_FUNCTION_PERMISSION, "function_uuid=?", new Object[]{functionUUID}); |
| | | //删除连线 |
| | | baseDao.delete(CmnConst.PRODUCT_SYS_LINK, "function_uuid=?", new Object[]{functionUUID}); |
| | | //删除按钮 |
| | | baseDao.delete(CmnConst.PRODUCT_SYS_FUNCTION_BUTTONS, "function_uuid=?", new Object[]{functionUUID}); |
| | | //删除页面 |
| | | baseDao.delete(CmnConst.PRODUCT_SYS_MVC_PAGE, "function_uuid=?", new Object[]{functionUUID}); |
| | | /** |
| | | * 取消报表发布 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | public boolean cancelRelease(FieldSetEntity fse) { |
| | | DataTableEntity reportConfigDte = DataPoolCacheImpl.getInstance().getCacheData(CmnConst.CACHE_REPORT_CONFIG, new String[]{fse.getUUID()}); |
| | | if (BaseUtil.dataTableIsEmpty(reportConfigDte)) { |
| | | throw new BaseException(ReportCode.GET_REPORT_CONFIG_FIAL.getValue(), ReportCode.GET_REPORT_CONFIG_FIAL.getText()); |
| | | } |
| | | FieldSetEntity reportConfigFse = reportConfigDte.getFieldSetEntity(0); |
| | | String functionUUID = reportConfigFse.getString(CmnConst.FUNCTION_UUID); |
| | | if (StringUtils.isEmpty(functionUUID)) { |
| | | return false; |
| | | } |
| | | |
| | | //删除菜单 |
| | | baseDao.delete(CmnConst.PRODUCT_SYS_MENUS, "function_uuid=?", new Object[]{functionUUID}); |
| | | //删除功能 |
| | | baseDao.delete(CmnConst.PRODUCT_SYS_FUNCTIONS, "uuid=?", new Object[]{functionUUID}); |
| | | DataTableEntity dt = baseDao.listTable(CmnConst.PRODUCT_SYS_FUNCTION_PERMISSION, "function_uuid=?", new Object[]{functionUUID}, new Object[]{"role_uuid uuid"}); |
| | | //从角色权限中移除 |
| | | baseDao.delete(CmnConst.PRODUCT_SYS_FUNCTION_PERMISSION, "function_uuid=?", new Object[]{functionUUID}); |
| | | //删除连线 |
| | | baseDao.delete(CmnConst.PRODUCT_SYS_LINK, "function_uuid=?", new Object[]{functionUUID}); |
| | | //删除按钮 |
| | | baseDao.delete(CmnConst.PRODUCT_SYS_FUNCTION_BUTTONS, "function_uuid=?", new Object[]{functionUUID}); |
| | | //删除页面 |
| | | baseDao.delete(CmnConst.PRODUCT_SYS_MVC_PAGE, "function_uuid=?", new Object[]{functionUUID}); |
| | | |
| | | //数据回写 |
| | | fse.setValue(CmnConst.FUNCTION_UUID, ""); |
| | | //删除菜单 |
| | | baseDao.delete(CmnConst.PRODUCT_SYS_MENUS, "function_uuid=?", new Object[]{functionUUID}); |
| | | //删除功能 |
| | | baseDao.delete(CmnConst.PRODUCT_SYS_FUNCTIONS, "uuid=?", new Object[]{functionUUID}); |
| | | |
| | | if (!DataTableEntity.isEmpty(dt)) { |
| | | updateLoginUserInfoService.updateUserInfoByUpdateRole(dt.getUuids(), true); |
| | | } |
| | | return baseDao.update(fse); |
| | | } |
| | | //数据回写 |
| | | fse.setValue(CmnConst.FUNCTION_UUID, ""); |
| | | |
| | | /** |
| | | * 报表发布 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | public boolean releaseConfig(FieldSetEntity fse) { |
| | | if (!DataTableEntity.isEmpty(dt)) { |
| | | updateLoginUserInfoService.updateUserInfoByUpdateRole(dt.getUuids(), true); |
| | | } |
| | | return baseDao.update(fse); |
| | | } |
| | | |
| | | FieldSetEntity fseReport = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_REPORT_CONFIG, fse.getUUID(), false); |
| | | /** |
| | | * 报表发布 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | public boolean releaseConfig(FieldSetEntity fse) { |
| | | |
| | | //创建MVCC保存对象 |
| | | FieldSetEntity fseFunction = new FieldSetEntity(); |
| | | //1.创建MVC(系统MVC目录下) |
| | | //生成功能编码 |
| | | String defaultCode = "001-005"; |
| | | fseFunction.setTableName(CmnConst.PRODUCT_SYS_FUNCTIONS); |
| | | codeService.createCode(fseFunction, CmnConst.PRODUCT_SYS_FUNCTIONS, CmnConst.TRICODE, defaultCode); |
| | | fseFunction.setValue(CmnConst.TABLE_UUID, CmnConst.PRODUCT_SYS_REPORT_CONFIG); //功能关联表 |
| | | fseFunction.setValue(CmnConst.FUNCTION_NAME, fseReport.getString(CmnConst.REPORT_NAME)); //功能名称 |
| | | fseFunction.setValue(CmnConst.FUNCTION_DESCRIPTION, fseReport.getString(CmnConst.REPORT_NAME)); //功能描述 |
| | | fseFunction.setValue(CmnConst.STATUS_UUID, 1); //是否启用 |
| | | fseFunction.setValue(CmnConst.FUNCTION_TYPE_UUID, 5); //功能类型-业务后台管理 管理员和普通用户都能分配该报表的权限 |
| | | fseFunction.setValue(CmnConst.CLIENT_TYPE_UUID, "Web"); //客户端类型 |
| | | fseFunction.setValue(CmnConst.VERSION_UUID, "001"); |
| | | fseFunction.setValue(CmnConst.DATA_TYPE, 1);// 数据类型 |
| | | fseFunction.setValue(CmnConst.TRICODE_PARENT, defaultCode);// 上级模块code |
| | | fseFunction.setValue("terminal_type", 1); |
| | | BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), fseFunction); |
| | | FieldSetEntity fseReport = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_REPORT_CONFIG, fse.getUUID(), false); |
| | | |
| | | //创建按钮保存对象 |
| | | DataTableEntity dtButton = new DataTableEntity(); |
| | | FieldSetEntity fseButton = new FieldSetEntity(); |
| | | fseButton.setTableName(CmnConst.PRODUCT_SYS_FUNCTION_BUTTONS); |
| | | fseButton.setValue(CmnConst.IS_MAIN, 1); //是否入口 |
| | | fseButton.setValue(CmnConst.STATUS_UUID, 1); //是否启用 |
| | | fseButton.setValue(CmnConst.CLIENT_TYPE_UUID, "Web"); //客户端类型 |
| | | fseButton.setValue(CmnConst.BUTTON_NAME, "入口"); //按钮名称 |
| | | fseButton.setValue(CmnConst.BUTTON_TITLE, "entrance"); //按钮标题 |
| | | fseButton.setValue(CmnConst.BUTTON_TYPE, 1); //按钮类型 |
| | | fseButton.setValue(CmnConst.BUTTON_CATEGORY_UUID, "main"); //按钮分类 |
| | | fseButton.setValue(CmnConst.ROUTE_NAME, BaseUtil.getPageCode()); //路由名称 |
| | | fseButton.setValue(CmnConst.UPLOAD_API_URL, CmnConst.ADDRESS_INIT_INTERFENCE);// 入口接口地址 |
| | | fseButton.setValue("terminal_type", 1); |
| | | JSONObject paramObj = new JSONObject(); |
| | | paramObj.put(CmnConst.UUID, fse.getUUID()); |
| | | fseButton.setValue(CmnConst.PARAMS, paramObj.toString());// 接口参数 |
| | | fseButton.setValue(CmnConst.TOP_LOCATION, "100px"); |
| | | fseButton.setValue(CmnConst.LEFT_LOCATION, "100px"); |
| | | dtButton.setMeta(fseButton.getMeta()); |
| | | dtButton.addFieldSetEntity(fseButton); |
| | | //创建MVCC保存对象 |
| | | FieldSetEntity fseFunction = new FieldSetEntity(); |
| | | //1.创建MVC(系统MVC目录下) |
| | | //生成功能编码 |
| | | String defaultCode = "001-005"; |
| | | fseFunction.setTableName(CmnConst.PRODUCT_SYS_FUNCTIONS); |
| | | codeService.createCode(fseFunction, CmnConst.PRODUCT_SYS_FUNCTIONS, CmnConst.TRICODE, defaultCode); |
| | | fseFunction.setValue(CmnConst.TABLE_UUID, CmnConst.PRODUCT_SYS_REPORT_CONFIG); //功能关联表 |
| | | fseFunction.setValue(CmnConst.FUNCTION_NAME, fseReport.getString(CmnConst.REPORT_NAME)); //功能名称 |
| | | fseFunction.setValue(CmnConst.FUNCTION_DESCRIPTION, fseReport.getString(CmnConst.REPORT_NAME)); //功能描述 |
| | | fseFunction.setValue(CmnConst.STATUS_UUID, 1); //是否启用 |
| | | fseFunction.setValue(CmnConst.FUNCTION_TYPE_UUID, 5); //功能类型-业务后台管理 管理员和普通用户都能分配该报表的权限 |
| | | fseFunction.setValue(CmnConst.CLIENT_TYPE_UUID, "Web"); //客户端类型 |
| | | fseFunction.setValue(CmnConst.VERSION_UUID, "001"); |
| | | fseFunction.setValue(CmnConst.DATA_TYPE, 1);// 数据类型 |
| | | fseFunction.setValue(CmnConst.TRICODE_PARENT, defaultCode);// 上级模块code |
| | | fseFunction.setValue("terminal_type", 1); |
| | | BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), fseFunction); |
| | | |
| | | //创建页面保存对象 |
| | | DataTableEntity dtPage = new DataTableEntity(); |
| | | FieldSetEntity fsePage = new FieldSetEntity(); |
| | | fsePage.setTableName(CmnConst.PRODUCT_SYS_MVC_PAGE); |
| | | //创建按钮保存对象 |
| | | DataTableEntity dtButton = new DataTableEntity(); |
| | | FieldSetEntity fseButton = new FieldSetEntity(); |
| | | fseButton.setTableName(CmnConst.PRODUCT_SYS_FUNCTION_BUTTONS); |
| | | fseButton.setValue(CmnConst.IS_MAIN, 1); //是否入口 |
| | | fseButton.setValue(CmnConst.STATUS_UUID, 1); //是否启用 |
| | | fseButton.setValue(CmnConst.CLIENT_TYPE_UUID, "Web"); //客户端类型 |
| | | fseButton.setValue(CmnConst.BUTTON_NAME, "入口"); //按钮名称 |
| | | fseButton.setValue(CmnConst.BUTTON_TITLE, "entrance"); //按钮标题 |
| | | fseButton.setValue(CmnConst.BUTTON_TYPE, 1); //按钮类型 |
| | | fseButton.setValue(CmnConst.BUTTON_CATEGORY_UUID, "main"); //按钮分类 |
| | | fseButton.setValue(CmnConst.ROUTE_NAME, BaseUtil.getPageCode()); //路由名称 |
| | | fseButton.setValue(CmnConst.UPLOAD_API_URL, CmnConst.ADDRESS_INIT_INTERFENCE);// 入口接口地址 |
| | | fseButton.setValue("terminal_type", 1); |
| | | JSONObject paramObj = new JSONObject(); |
| | | paramObj.put(CmnConst.UUID, fse.getUUID()); |
| | | fseButton.setValue(CmnConst.PARAMS, paramObj.toString());// 接口参数 |
| | | fseButton.setValue(CmnConst.TOP_LOCATION, "100px"); |
| | | fseButton.setValue(CmnConst.LEFT_LOCATION, "100px"); |
| | | dtButton.setMeta(fseButton.getMeta()); |
| | | dtButton.addFieldSetEntity(fseButton); |
| | | |
| | | //创建页面保存对象 |
| | | DataTableEntity dtPage = new DataTableEntity(); |
| | | FieldSetEntity fsePage = new FieldSetEntity(); |
| | | fsePage.setTableName(CmnConst.PRODUCT_SYS_MVC_PAGE); |
| | | // fsePage.setValue(CmnConst.PAGE_NAME, "报表展示"); |
| | | fsePage.setValue(CmnConst.PAGE_NAME, fse.getString(CmnConst.MENU_NAME)); |
| | | fsePage.setValue(CmnConst.PAGE_TYPE, 2); |
| | | fsePage.setValue(CmnConst.PAGE_URL, CmnConst.ADDRESS_REPORT_SHOW); |
| | | fsePage.setValue(CmnConst.TOP_LOCATION, "300px"); |
| | | fsePage.setValue(CmnConst.LEFT_LOCATION, "100px"); |
| | | fsePage.setValue(CmnConst.PAGE_OPEN_WITH, 0); |
| | | fsePage.setValue(CmnConst.PAGE_TYPE, 0); |
| | | fsePage.setValue("terminal_type", 1); |
| | | dtPage.addFieldSetEntity(fsePage); |
| | | fsePage.setValue(CmnConst.PAGE_NAME, fse.getString(CmnConst.MENU_NAME)); |
| | | fsePage.setValue(CmnConst.PAGE_TYPE, 2); |
| | | fsePage.setValue(CmnConst.PAGE_URL, CmnConst.ADDRESS_REPORT_SHOW); |
| | | fsePage.setValue(CmnConst.TOP_LOCATION, "300px"); |
| | | fsePage.setValue(CmnConst.LEFT_LOCATION, "100px"); |
| | | fsePage.setValue(CmnConst.PAGE_OPEN_WITH, 0); |
| | | fsePage.setValue(CmnConst.PAGE_TYPE, 0); |
| | | fsePage.setValue("terminal_type", 1); |
| | | dtPage.addFieldSetEntity(fsePage); |
| | | |
| | | fseFunction.addSubDataTable(dtButton); |
| | | fseFunction.addSubDataTable(dtPage); |
| | | fseFunction.addSubDataTable(dtButton); |
| | | fseFunction.addSubDataTable(dtPage); |
| | | |
| | | String functionUUID = baseDao.add(fseFunction); |
| | | String functionUUID = baseDao.add(fseFunction); |
| | | |
| | | //创建连线保存对象 |
| | | FieldSetEntity fseLink = new FieldSetEntity(); |
| | | fseLink.setTableName(CmnConst.PRODUCT_SYS_LINK); |
| | | fseLink.setValue(CmnConst.LINK_TYPE, 0); //连线类型 |
| | | fseLink.setValue(CmnConst.FUNCTION_UUID, functionUUID); //所属功能UUID |
| | | fseLink.setValue(CmnConst.LINE_FROM, fseButton.getUUID()); //起始端 |
| | | fseLink.setValue(CmnConst.FROM_TYPE, 0); //起始端类型 |
| | | fseLink.setValue(CmnConst.LINE_TO, fsePage.getUUID()); //结束端 |
| | | fseLink.setValue(CmnConst.TO_TYPE, 2); //结束端类型 |
| | | fseLink.setValue("terminal_type", 1); |
| | | BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), fseLink); |
| | | //创建连线保存对象 |
| | | FieldSetEntity fseLink = new FieldSetEntity(); |
| | | fseLink.setTableName(CmnConst.PRODUCT_SYS_LINK); |
| | | fseLink.setValue(CmnConst.LINK_TYPE, 0); //连线类型 |
| | | fseLink.setValue(CmnConst.FUNCTION_UUID, functionUUID); //所属功能UUID |
| | | fseLink.setValue(CmnConst.LINE_FROM, fseButton.getUUID()); //起始端 |
| | | fseLink.setValue(CmnConst.FROM_TYPE, 0); //起始端类型 |
| | | fseLink.setValue(CmnConst.LINE_TO, fsePage.getUUID()); //结束端 |
| | | fseLink.setValue(CmnConst.TO_TYPE, 2); //结束端类型 |
| | | fseLink.setValue("terminal_type", 1); |
| | | BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), fseLink); |
| | | |
| | | baseDao.add(fseLink); |
| | | baseDao.add(fseLink); |
| | | |
| | | // 提取发布的角色相关数据 |
| | | List<String> roleUUIDList = Lists.newArrayList(); |
| | | List<String> clientUUIDList = Lists.newArrayList(); |
| | | clientUUIDList.add(SpringMVCContextHolder.getCurrentUser().getClientUuid()); |
| | | // String[] singleRoleInfoArr; |
| | | for (String singleRoleInfo : fse.getString(CmnConst.ROLE_UUID).split("#")) { |
| | | // singleRoleInfoArr = singleRoleInfo.split(","); |
| | | roleUUIDList.add(singleRoleInfo); |
| | | } |
| | | // 提取发布的角色相关数据 |
| | | List<String> roleUUIDList = Lists.newArrayList(); |
| | | List<String> clientUUIDList = Lists.newArrayList(); |
| | | clientUUIDList.add(SpringMVCContextHolder.getCurrentUser().getClientUuid()); |
| | | // String[] singleRoleInfoArr; |
| | | for (String singleRoleInfo : fse.getString(CmnConst.ROLE_UUID).split("#")) { |
| | | // singleRoleInfoArr = singleRoleInfo.split(","); |
| | | roleUUIDList.add(singleRoleInfo); |
| | | } |
| | | |
| | | // 2.绑定角色(给某一角色赋予该功能) |
| | | for (String roleUUID : roleUUIDList) { |
| | | FieldSetEntity fseFunctionButton = new FieldSetEntity(); |
| | | fseFunctionButton.setTableName(CmnConst.PRODUCT_SYS_FUNCTION_PERMISSION); |
| | | fseFunctionButton.setValue(CmnConst.FUNCTION_UUID, functionUUID);// 所属功能UUID |
| | | fseFunctionButton.setValue(CmnConst.BUTTON_UUID, fseButton.getUUID());// 按钮UUID |
| | | fseFunctionButton.setValue(CmnConst.ROLE_UUID, roleUUID);// 所属角色UUID |
| | | baseDao.add(fseFunctionButton); |
| | | } |
| | | // 2.绑定角色(给某一角色赋予该功能) |
| | | for (String roleUUID : roleUUIDList) { |
| | | FieldSetEntity fseFunctionButton = new FieldSetEntity(); |
| | | fseFunctionButton.setTableName(CmnConst.PRODUCT_SYS_FUNCTION_PERMISSION); |
| | | fseFunctionButton.setValue(CmnConst.FUNCTION_UUID, functionUUID);// 所属功能UUID |
| | | fseFunctionButton.setValue(CmnConst.BUTTON_UUID, fseButton.getUUID());// 按钮UUID |
| | | fseFunctionButton.setValue(CmnConst.ROLE_UUID, roleUUID);// 所属角色UUID |
| | | baseDao.add(fseFunctionButton); |
| | | } |
| | | |
| | | // 3.绑定客户角色(给某一客户角色赋予该功能) |
| | | for (String clientUUID : clientUUIDList) { |
| | | DataTableEntity clientDte = DataPoolCacheImpl.getInstance().getCacheData("客户信息", new String[]{clientUUID}); |
| | | if (BaseUtil.dataTableIsEmpty(clientDte)) { |
| | | continue; |
| | | } |
| | | FieldSetEntity clientFse = clientDte.getFieldSetEntity(0); |
| | | FieldSetEntity fseClientFunctionButton = new FieldSetEntity(); |
| | | fseClientFunctionButton.setTableName(CmnConst.PRODUCT_SYS_FUNCTION_PERMISSION); |
| | | fseClientFunctionButton.setValue(CmnConst.FUNCTION_UUID, functionUUID);// 所属功能UUID |
| | | fseClientFunctionButton.setValue(CmnConst.BUTTON_UUID, fseButton.getUUID());// 按钮UUID |
| | | fseClientFunctionButton.setValue(CmnConst.ROLE_UUID, clientFse.getString(CmnConst.ROLE_UUID));// 所属角色UUID |
| | | baseDao.add(fseClientFunctionButton); |
| | | } |
| | | // 3.绑定客户角色(给某一客户角色赋予该功能) |
| | | for (String clientUUID : clientUUIDList) { |
| | | DataTableEntity clientDte = DataPoolCacheImpl.getInstance().getCacheData("客户信息", new String[]{clientUUID}); |
| | | if (BaseUtil.dataTableIsEmpty(clientDte)) { |
| | | continue; |
| | | } |
| | | FieldSetEntity clientFse = clientDte.getFieldSetEntity(0); |
| | | FieldSetEntity fseClientFunctionButton = new FieldSetEntity(); |
| | | fseClientFunctionButton.setTableName(CmnConst.PRODUCT_SYS_FUNCTION_PERMISSION); |
| | | fseClientFunctionButton.setValue(CmnConst.FUNCTION_UUID, functionUUID);// 所属功能UUID |
| | | fseClientFunctionButton.setValue(CmnConst.BUTTON_UUID, fseButton.getUUID());// 按钮UUID |
| | | fseClientFunctionButton.setValue(CmnConst.ROLE_UUID, clientFse.getString(CmnConst.ROLE_UUID));// 所属角色UUID |
| | | baseDao.add(fseClientFunctionButton); |
| | | } |
| | | |
| | | //4.创建菜单(根据前端所选父级菜单) |
| | | FieldSetEntity fseMenu = new FieldSetEntity(); |
| | | fseMenu.setTableName(CmnConst.PRODUCT_SYS_MENUS); |
| | | codeService.createCode(fseMenu, CmnConst.PRODUCT_SYS_MENUS, CmnConst.TRICODE, fse.getString(CmnConst.TRICODE_PARENT)); |
| | | fseMenu.setValue(CmnConst.TRICODE_PARENT, fse.getString(CmnConst.TRICODE_PARENT)); |
| | | fseMenu.setValue(CmnConst.MENU_NAME, fse.getString(CmnConst.MENU_NAME)); |
| | | fseMenu.setValue(CmnConst.FUNCTION_UUID, functionUUID); |
| | | fseMenu.setValue(CmnConst.SEQUENCE, fse.getString(CmnConst.SEQUENCE)); |
| | | fseMenu.setValue(CmnConst.IS_CATALOG, 0); |
| | | fseMenu.setValue(CmnConst.IS_SHOW, StringUtils.isEmpty(fse.getString(CmnConst.IS_SHOW)) ? 1 : fse.getString(CmnConst.IS_SHOW)); |
| | | fseMenu.setValue(CmnConst.MENU_ICON, fse.getString(CmnConst.MENU_ICON)); |
| | | BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), fseMenu); |
| | | //4.创建菜单(根据前端所选父级菜单) |
| | | FieldSetEntity fseMenu = new FieldSetEntity(); |
| | | fseMenu.setTableName(CmnConst.PRODUCT_SYS_MENUS); |
| | | codeService.createCode(fseMenu, CmnConst.PRODUCT_SYS_MENUS, CmnConst.TRICODE, fse.getString(CmnConst.TRICODE_PARENT)); |
| | | fseMenu.setValue(CmnConst.TRICODE_PARENT, fse.getString(CmnConst.TRICODE_PARENT)); |
| | | fseMenu.setValue(CmnConst.MENU_NAME, fse.getString(CmnConst.MENU_NAME)); |
| | | fseMenu.setValue(CmnConst.FUNCTION_UUID, functionUUID); |
| | | fseMenu.setValue(CmnConst.SEQUENCE, fse.getString(CmnConst.SEQUENCE)); |
| | | fseMenu.setValue(CmnConst.IS_CATALOG, 0); |
| | | fseMenu.setValue(CmnConst.IS_SHOW, StringUtils.isEmpty(fse.getString(CmnConst.IS_SHOW)) ? 1 : fse.getString(CmnConst.IS_SHOW)); |
| | | fseMenu.setValue(CmnConst.MENU_ICON, fse.getString(CmnConst.MENU_ICON)); |
| | | BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), fseMenu); |
| | | |
| | | baseDao.add(fseMenu); |
| | | baseDao.add(fseMenu); |
| | | |
| | | //数据回写 |
| | | fseReport.setValue(CmnConst.FUNCTION_UUID, functionUUID); |
| | | //数据回写 |
| | | fseReport.setValue(CmnConst.FUNCTION_UUID, functionUUID); |
| | | |
| | | boolean result = baseDao.update(fseReport); |
| | | boolean result = baseDao.update(fseReport); |
| | | |
| | | // 重新设置缓存 |
| | | dataListReportService.setConfig(fseReport.getUUID()); |
| | | // 重新设置缓存 |
| | | dataListReportService.setConfig(fseReport.getUUID()); |
| | | |
| | | return result; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 报表copy |
| | | * |
| | | * @param uuid |
| | | * @return |
| | | */ |
| | | public String copyConfig(String uuid) { |
| | | FieldSetEntity fse = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_REPORT_CONFIG, uuid, true); |
| | | FieldSetEntity fseCopy = fse; |
| | | fseCopy.remove(CmnConst.ID); |
| | | fseCopy.remove(CmnConst.UUID); |
| | | DataTableEntity dtSub = fseCopy.getSubDataTable(CmnConst.PRODUCT_SYS_REPORT_CONFIG_ATTRIBUTE); |
| | | if (dtSub != null && dtSub.getRows() > 0) { |
| | | for (int i = 0; i < dtSub.getRows(); i++) { |
| | | FieldSetEntity fseSub = dtSub.getFieldSetEntity(i); |
| | | fseSub.remove(CmnConst.ID); |
| | | fseSub.remove(CmnConst.UUID); |
| | | } |
| | | } |
| | | return baseDao.add(fseCopy, true); |
| | | } |
| | | /** |
| | | * 报表copy |
| | | * |
| | | * @param uuid |
| | | * @return |
| | | */ |
| | | public String copyConfig(String uuid) { |
| | | FieldSetEntity fse = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_REPORT_CONFIG, uuid, true); |
| | | FieldSetEntity fseCopy = fse; |
| | | fseCopy.remove(CmnConst.ID); |
| | | fseCopy.remove(CmnConst.UUID); |
| | | DataTableEntity dtSub = fseCopy.getSubDataTable(CmnConst.PRODUCT_SYS_REPORT_CONFIG_ATTRIBUTE); |
| | | if (dtSub != null && dtSub.getRows() > 0) { |
| | | for (int i = 0; i < dtSub.getRows(); i++) { |
| | | FieldSetEntity fseSub = dtSub.getFieldSetEntity(i); |
| | | fseSub.remove(CmnConst.ID); |
| | | fseSub.remove(CmnConst.UUID); |
| | | } |
| | | } |
| | | return baseDao.add(fseCopy, true); |
| | | } |
| | | |
| | | /** |
| | | * 配置报表-引用 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | public FieldSetEntity quoteReportConfig(FieldSetEntity fse) { |
| | | FieldSetEntity sourceFse = findReportConfig(fse.getUUID()); |
| | | sourceFse.setValue(CmnConst.DATASOURCE_UUID, fse.getString(CmnConst.DATASOURCE_UUID)); |
| | | sourceFse.remove(new String[]{CmnConst.ID, CmnConst.UUID, CmnConst.CREATED_BY, CmnConst.CREATED_UTC_DATETIME, CmnConst.UPDATED_BY, CmnConst.CREATED_UTC_DATETIME, CmnConst.REPORT_NAME}); |
| | | DataTableEntity subDte = sourceFse.getSubDataTable(CmnConst.PRODUCT_SYS_REPORT_CONFIG_ATTRIBUTE); |
| | | FieldSetEntity subFse; |
| | | for (int i = 0; i < subDte.getRows(); i++) { |
| | | subFse = subDte.getFieldSetEntity(i); |
| | | subFse.remove(new String[]{CmnConst.ID, CmnConst.UUID, CmnConst.CREATED_BY, CmnConst.CREATED_UTC_DATETIME, CmnConst.UPDATED_BY, CmnConst.CREATED_UTC_DATETIME}); |
| | | } |
| | | return sourceFse; |
| | | } |
| | | /** |
| | | * 配置报表-引用 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | public FieldSetEntity quoteReportConfig(FieldSetEntity fse) { |
| | | FieldSetEntity sourceFse = findReportConfig(fse.getUUID()); |
| | | sourceFse.setValue(CmnConst.DATASOURCE_UUID, fse.getString(CmnConst.DATASOURCE_UUID)); |
| | | sourceFse.remove(new String[]{CmnConst.ID, CmnConst.UUID, CmnConst.CREATED_BY, CmnConst.CREATED_UTC_DATETIME, CmnConst.UPDATED_BY, CmnConst.CREATED_UTC_DATETIME, CmnConst.REPORT_NAME}); |
| | | DataTableEntity subDte = sourceFse.getSubDataTable(CmnConst.PRODUCT_SYS_REPORT_CONFIG_ATTRIBUTE); |
| | | FieldSetEntity subFse; |
| | | for (int i = 0; i < subDte.getRows(); i++) { |
| | | subFse = subDte.getFieldSetEntity(i); |
| | | subFse.remove(new String[]{CmnConst.ID, CmnConst.UUID, CmnConst.CREATED_BY, CmnConst.CREATED_UTC_DATETIME, CmnConst.UPDATED_BY, CmnConst.CREATED_UTC_DATETIME}); |
| | | } |
| | | return sourceFse; |
| | | } |
| | | |
| | | /** |
| | | * 获取报表发布信息-发布 |
| | | * |
| | | * @return |
| | | */ |
| | | public JSONArray getReportReleaseInfo() { |
| | | StringBuilder sql = new StringBuilder(256); |
| | | DataTableEntity aimDte = new DataTableEntity(); |
| | | DataTableEntity dte; |
| | | Object[] arr; |
| | | String filter; |
| | | sql.append("select distinct null pid,uuid sid,client_name name FROM product_sys_clients c") |
| | | .append("\ninner join (") |
| | | .append("\n select client_uuid pid,uuid sid,org_level_name FROM product_sys_org_levels where org_level_status=0 order by org_level_code") |
| | | .append("\n) o on o.pid=c.uuid") |
| | | .append("\ninner join (") |
| | | .append("\n select org_level_uuid pid,uuid sid,role_name FROM product_sys_role where is_used=1") |
| | | .append("\n) r on r.pid=o.sid"); |
| | | // 去掉admin所属客户 |
| | | /** |
| | | * 获取报表发布信息-发布 |
| | | * |
| | | * @return |
| | | */ |
| | | public JSONArray getReportReleaseInfo() { |
| | | StringBuilder sql = new StringBuilder(256); |
| | | DataTableEntity aimDte = new DataTableEntity(); |
| | | DataTableEntity dte; |
| | | Object[] arr; |
| | | String filter; |
| | | sql.append("select distinct null pid,uuid sid,client_name name FROM product_sys_clients c") |
| | | .append("\ninner join (") |
| | | .append("\n select client_uuid pid,uuid sid,org_level_name FROM product_sys_org_levels where org_level_status=0 order by org_level_code") |
| | | .append("\n) o on o.pid=c.uuid") |
| | | .append("\ninner join (") |
| | | .append("\n select org_level_uuid pid,uuid sid,role_name FROM product_sys_role where is_used=1") |
| | | .append("\n) r on r.pid=o.sid"); |
| | | // 去掉admin所属客户 |
| | | // .append("\nwhere c.uuid!='4d4679ed-c4c3-41b8-abfe-451a66fd4043'"); |
| | | dte = baseDao.listTable(sql.toString(), new Object[]{}); |
| | | dte = baseDao.listTable(sql.toString(), new Object[]{}); |
| | | |
| | | aimDte.addFieldSetEntity(dte); |
| | | aimDte.addFieldSetEntity(dte); |
| | | |
| | | arr = dte.getFieldAllValues("sid"); |
| | | filter = BaseUtil.buildQuestionMarkFilter("client_uuid", arr.length, true); |
| | | sql.setLength(0); |
| | | sql.append("\nselect distinct o.* from (") |
| | | .append("\n select client_uuid pid,uuid sid,org_level_name name FROM product_sys_org_levels where org_level_status=0") |
| | | .append("\n and ").append(filter) |
| | | .append("\n order by org_level_code") |
| | | .append("\n) o") |
| | | .append("\ninner join (") |
| | | .append("\n select org_level_uuid pid,uuid sid,role_name FROM product_sys_role where is_used=1") |
| | | .append("\n) r on r.pid=o.sid"); |
| | | dte = baseDao.listTable(sql.toString(), arr); |
| | | aimDte.addFieldSetEntity(dte); |
| | | arr = dte.getFieldAllValues("sid"); |
| | | filter = BaseUtil.buildQuestionMarkFilter("client_uuid", arr.length, true); |
| | | sql.setLength(0); |
| | | sql.append("\nselect distinct o.* from (") |
| | | .append("\n select client_uuid pid,uuid sid,org_level_name name FROM product_sys_org_levels where org_level_status=0") |
| | | .append("\n and ").append(filter) |
| | | .append("\n order by org_level_code") |
| | | .append("\n) o") |
| | | .append("\ninner join (") |
| | | .append("\n select org_level_uuid pid,uuid sid,role_name FROM product_sys_role where is_used=1") |
| | | .append("\n) r on r.pid=o.sid"); |
| | | dte = baseDao.listTable(sql.toString(), arr); |
| | | aimDte.addFieldSetEntity(dte); |
| | | |
| | | arr = dte.getFieldAllValues("sid"); |
| | | filter = BaseUtil.buildQuestionMarkFilter("org_level_uuid", arr.length, true); |
| | | sql.setLength(0); |
| | | sql.append("\nselect org_level_uuid pid,uuid sid,role_name name FROM product_sys_role where is_used=1").append(" and ").append(filter); |
| | | dte = baseDao.listTable(sql.toString(), arr); |
| | | aimDte.addFieldSetEntity(dte); |
| | | arr = dte.getFieldAllValues("sid"); |
| | | filter = BaseUtil.buildQuestionMarkFilter("org_level_uuid", arr.length, true); |
| | | sql.setLength(0); |
| | | sql.append("\nselect org_level_uuid pid,uuid sid,role_name name FROM product_sys_role where is_used=1").append(" and ").append(filter); |
| | | dte = baseDao.listTable(sql.toString(), arr); |
| | | aimDte.addFieldSetEntity(dte); |
| | | |
| | | return BaseUtil.dataTableToTreeData(aimDte, "sid", "pid", null, false); |
| | | } |
| | | return BaseUtil.dataTableToTreeData(aimDte, "sid", "pid", null, false); |
| | | } |
| | | |
| | | /** |
| | | * 获取报表发布信息-发布后查看信息 |
| | | * |
| | | * @return |
| | | */ |
| | | public JSONObject viewReportReleaseInfo(FieldSetEntity fse) { |
| | | DataTableEntity reportConfigDte = DataPoolCacheImpl.getInstance().getCacheData(CmnConst.CACHE_REPORT_CONFIG, new String[]{fse.getUUID()}); |
| | | if (BaseUtil.dataTableIsEmpty(reportConfigDte)) { |
| | | throw new BaseException(ReportCode.GET_REPORT_RELEASE_INFO_FAIL.getValue(), ReportCode.GET_REPORT_RELEASE_INFO_FAIL.getText()); |
| | | } |
| | | FieldSetEntity reportConfigFse = reportConfigDte.getFieldSetEntity(0); |
| | | StringBuilder sql = new StringBuilder(256); |
| | | sql.append("\nselect group_concat(single_role_uuid separator '#') role_uuid") |
| | | .append("\nfrom (") |
| | | .append("\n select concat(client_uuid,',',uuid,',',role_uuid) single_role_uuid") |
| | | .append("\n FROM product_sys_org_levels o") |
| | | .append("\n inner join (") |
| | | .append("\n select org_level_uuid,uuid role_uuid,role_name") |
| | | .append("\n FROM product_sys_role r") |
| | | .append("\n inner join (") |
| | | .append("\n select role_uuid FROM product_sys_function_permission where function_uuid=?") |
| | | .append("\n ) p on r.uuid=p.role_uuid") |
| | | .append("\n ) r1 on o.uuid=r1.org_level_uuid") |
| | | .append("\n) t"); |
| | | String functionUUID = reportConfigFse.getString(CmnConst.FUNCTION_UUID); |
| | | DataTableEntity dte = baseDao.listTable(sql.toString(), new Object[]{functionUUID}); |
| | | /** |
| | | * 获取报表发布信息-发布后查看信息 |
| | | * |
| | | * @return |
| | | */ |
| | | public JSONObject viewReportReleaseInfo(FieldSetEntity fse) { |
| | | DataTableEntity reportConfigDte = DataPoolCacheImpl.getInstance().getCacheData(CmnConst.CACHE_REPORT_CONFIG, new String[]{fse.getUUID()}); |
| | | if (BaseUtil.dataTableIsEmpty(reportConfigDte)) { |
| | | throw new BaseException(ReportCode.GET_REPORT_RELEASE_INFO_FAIL.getValue(), ReportCode.GET_REPORT_RELEASE_INFO_FAIL.getText()); |
| | | } |
| | | FieldSetEntity reportConfigFse = reportConfigDte.getFieldSetEntity(0); |
| | | StringBuilder sql = new StringBuilder(256); |
| | | sql.append("\nselect group_concat(single_role_uuid separator '#') role_uuid") |
| | | .append("\nfrom (") |
| | | .append("\n select concat(client_uuid,',',uuid,',',role_uuid) single_role_uuid") |
| | | .append("\n FROM product_sys_org_levels o") |
| | | .append("\n inner join (") |
| | | .append("\n select org_level_uuid,uuid role_uuid,role_name") |
| | | .append("\n FROM product_sys_role r") |
| | | .append("\n inner join (") |
| | | .append("\n select role_uuid FROM product_sys_function_permission where function_uuid=?") |
| | | .append("\n ) p on r.uuid=p.role_uuid") |
| | | .append("\n ) r1 on o.uuid=r1.org_level_uuid") |
| | | .append("\n) t"); |
| | | String functionUUID = reportConfigFse.getString(CmnConst.FUNCTION_UUID); |
| | | DataTableEntity dte = baseDao.listTable(sql.toString(), new Object[]{functionUUID}); |
| | | |
| | | FieldSetEntity menuFse = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_MENUS, "function_uuid=?", new Object[]{functionUUID}, false); |
| | | FieldSetEntity menuFse = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_MENUS, "function_uuid=?", new Object[]{functionUUID}, false); |
| | | |
| | | JSONObject resultObj = new JSONObject(); |
| | | resultObj.put(CmnConst.UUID, fse.getUUID()); |
| | | resultObj.put(CmnConst.ROLE_UUID, dte.getFieldSetEntity(0).getString(CmnConst.ROLE_UUID)); |
| | | resultObj.put(CmnConst.TRICODE_PARENT, menuFse.getString(CmnConst.TRICODE_PARENT)); |
| | | resultObj.put(CmnConst.MENU_ICON, menuFse.getString(CmnConst.MENU_ICON)); |
| | | resultObj.put(CmnConst.MENU_NAME, menuFse.getString(CmnConst.MENU_NAME)); |
| | | JSONObject resultObj = new JSONObject(); |
| | | resultObj.put(CmnConst.UUID, fse.getUUID()); |
| | | resultObj.put(CmnConst.ROLE_UUID, dte.getFieldSetEntity(0).getString(CmnConst.ROLE_UUID)); |
| | | resultObj.put(CmnConst.TRICODE_PARENT, menuFse.getString(CmnConst.TRICODE_PARENT)); |
| | | resultObj.put(CmnConst.MENU_ICON, menuFse.getString(CmnConst.MENU_ICON)); |
| | | resultObj.put(CmnConst.MENU_NAME, menuFse.getString(CmnConst.MENU_NAME)); |
| | | |
| | | return resultObj; |
| | | } |
| | | return resultObj; |
| | | } |
| | | |
| | | /** |
| | | * 已发布列表界面 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | public DataTableEntity releasedListReportConfig(FieldSetEntity fse) { |
| | | String filter = queryFilterService.getQueryFilter(fse); |
| | | StringBuilder sql = new StringBuilder(256); |
| | | /** |
| | | * 已发布列表界面 |
| | | * |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | public DataTableEntity releasedListReportConfig(FieldSetEntity fse) { |
| | | String filter = queryFilterService.getQueryFilter(fse); |
| | | StringBuilder sql = new StringBuilder(256); |
| | | // sql.append("select * from ( "); |
| | | sql.append("\n select rc.uuid,rc.report_name,rtc.type_name,t1.role_info,mp.menu_name tricode_parent,m.menu_icon,m.menu_name "); |
| | | sql.append("\n FROM product_sys_report_config rc "); |
| | | sql.append("\n inner join ( "); |
| | | sql.append("\n select function_uuid,group_concat(role_info separator ',') role_info "); |
| | | sql.append("\n from ( "); |
| | | sql.append("\n select function_uuid,concat(c.client_name,'/',o.org_level_name,'/',role_name) role_info "); |
| | | sql.append("\n FROM product_sys_clients c "); |
| | | sql.append("\n inner join product_sys_org_levels o on o.client_uuid=c.uuid "); |
| | | sql.append("\n inner join ( "); |
| | | sql.append("\n select function_uuid,org_level_uuid,uuid role_uuid,role_name "); |
| | | sql.append("\n FROM product_sys_role r "); |
| | | sql.append("\n inner join ( "); |
| | | sql.append("\n select function_uuid,role_uuid FROM product_sys_function_permission "); |
| | | sql.append("\n ) p on r.uuid=p.role_uuid "); |
| | | sql.append("\n ) r1 on o.uuid=r1.org_level_uuid "); |
| | | sql.append("\n ) t "); |
| | | sql.append("\n group by function_uuid "); |
| | | sql.append("\n ) t1 on rc.function_uuid=t1.function_uuid "); |
| | | sql.append("\n inner join product_sys_menus m on rc.function_uuid=m.function_uuid "); |
| | | sql.append("\n inner join product_sys_report_type_config rtc on rc.type_uuid=rtc.uuid "); |
| | | sql.append("\n inner join product_sys_menus mp on m.tricode_parent=mp.tricode "); |
| | | sql.append("\n select rc.uuid,rc.report_name,rtc.type_name,t1.role_info,mp.menu_name tricode_parent,m.menu_icon,m.menu_name "); |
| | | sql.append("\n FROM product_sys_report_config rc "); |
| | | sql.append("\n inner join ( "); |
| | | sql.append("\n select function_uuid,group_concat(role_info separator ',') role_info "); |
| | | sql.append("\n from ( "); |
| | | sql.append("\n select function_uuid,concat(c.client_name,'/',o.org_level_name,'/',role_name) role_info "); |
| | | sql.append("\n FROM product_sys_clients c "); |
| | | sql.append("\n inner join product_sys_org_levels o on o.client_uuid=c.uuid "); |
| | | sql.append("\n inner join ( "); |
| | | sql.append("\n select function_uuid,org_level_uuid,uuid role_uuid,role_name "); |
| | | sql.append("\n FROM product_sys_role r "); |
| | | sql.append("\n inner join ( "); |
| | | sql.append("\n select function_uuid,role_uuid FROM product_sys_function_permission "); |
| | | sql.append("\n ) p on r.uuid=p.role_uuid "); |
| | | sql.append("\n ) r1 on o.uuid=r1.org_level_uuid "); |
| | | sql.append("\n ) t "); |
| | | sql.append("\n group by function_uuid "); |
| | | sql.append("\n ) t1 on rc.function_uuid=t1.function_uuid "); |
| | | sql.append("\n inner join product_sys_menus m on rc.function_uuid=m.function_uuid "); |
| | | sql.append("\n inner join product_sys_report_type_config rtc on rc.type_uuid=rtc.uuid "); |
| | | sql.append("\n inner join product_sys_menus mp on m.tricode_parent=mp.tricode "); |
| | | // sql.append("\n) t2 "); |
| | | if (!StringUtils.isEmpty(filter)) { |
| | | sql.append(" WHERE " + filter); |
| | | } |
| | | Integer curPage = fse.getInteger(CmnConst.CPAGE); |
| | | Integer pageSize = fse.getInteger(CmnConst.PAGESIZE); |
| | | return baseDao.listTable(sql.toString(), new Object[]{}, pageSize == null ? Integer.MAX_VALUE : pageSize, curPage == null ? 1 : curPage); |
| | | } |
| | | if (!StringUtils.isEmpty(filter)) { |
| | | sql.append(" WHERE " + filter); |
| | | } |
| | | Integer curPage = fse.getInteger(CmnConst.CPAGE); |
| | | Integer pageSize = fse.getInteger(CmnConst.PAGESIZE); |
| | | return baseDao.listTable(sql.toString(), new Object[]{}, pageSize == null ? Integer.MAX_VALUE : pageSize, curPage == null ? 1 : curPage); |
| | | } |
| | | } |