| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.generator.config.querys.AbstractDbQuery; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.mdm.entity.Flows; |
| | | import com.highdatas.mdm.entity.Maintain; |
| | | import com.highdatas.mdm.entity.MaintainDetail; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.MaintainDetailMapper; |
| | | import com.highdatas.mdm.mapper.MaintainMapper; |
| | | import com.highdatas.mdm.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.pojo.*; |
| | |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author kimi |
| | |
| | | |
| | | @Autowired |
| | | IFlowsService flowsService; |
| | | @Autowired |
| | | MaintainDetailMapper maintainDetailMapper; |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | |
| | | @Override |
| | | public HashMap<Operate, Object> compare(String maintainId, String maintainId2) { |
| | | public JSONObject compare(String maintainId, String maintainId2, Operate operate, int pageNo, int pageSize) { |
| | | Maintain baseMaintain = selectById(maintainId); |
| | | Maintain compareMaintain = selectById(maintainId2); |
| | | |
| | | HashMap<Operate, Object> operateIntegerMap = new HashMap<Operate, Object>(); |
| | | |
| | | List<Map<String, Object>> maps; |
| | | Page page; |
| | | List<SysField> fieldByMaintain; |
| | | if (DbUtils.compareVersion(baseMaintain, compareMaintain) > 0) { |
| | | addCompareInfo(baseMaintain, compareMaintain, operateIntegerMap); |
| | | operateIntegerMap.put(Operate.common, MessageFormat.format("{0} 对比 {1}", baseMaintain.getVersion(), compareMaintain.getVersion())); |
| | | }else { |
| | | addCompareInfo(compareMaintain, baseMaintain, operateIntegerMap); |
| | | operateIntegerMap.put(Operate.common, MessageFormat.format("{0} 对比 {1}", compareMaintain.getVersion(), baseMaintain.getVersion())); |
| | | String maintainTableName = baseMaintain.getTableName(); |
| | | String tempName = baseMaintain.getTableName() + Constant.RECORD; |
| | | fieldByMaintain = fieldService.getFieldByMaintain(baseMaintain.getId()); |
| | | String collect = fieldByMaintain.stream().map(sysField -> sysField.getField()).collect(Collectors.joining(Constant.COMMA)); |
| | | maps = maintainDetailMapper.selectOperateDatas("count(*) as cnt", tempName, operate.name(), maintainTableName, compareMaintain.getOrderNo(), baseMaintain.getOrderNo(), null, null); |
| | | Object cnt = maps.get(0).get("cnt"); |
| | | page = new Page(Integer.valueOf(cnt.toString())); |
| | | page.setPageNo(pageNo); |
| | | page.setPageSize(pageSize); |
| | | maps = maintainDetailMapper.selectOperateDatas(collect, tempName, operate.name(), maintainTableName, compareMaintain.getOrderNo(), baseMaintain.getOrderNo(), "desc", page.getLimitSQL()); |
| | | |
| | | } else { |
| | | if (operate.equals(Operate.create)) { |
| | | operate = Operate.delete; |
| | | } else if (operate.equals(Operate.delete)) { |
| | | operate = Operate.create; |
| | | } |
| | | String maintainTableName = compareMaintain.getTableName(); |
| | | String tempName = compareMaintain.getTableName() + Constant.RECORD; |
| | | fieldByMaintain = fieldService.getFieldByMaintain(compareMaintain.getId()); |
| | | String collect = fieldByMaintain.stream().map(sysField -> sysField.getField()).collect(Collectors.joining(Constant.COMMA)); |
| | | maps = maintainDetailMapper.selectOperateDatas("count(*) as cnt", tempName, operate.name(), maintainTableName, baseMaintain.getOrderNo(), compareMaintain.getOrderNo(), null, null); |
| | | Object cnt = maps.get(0).get("cnt"); |
| | | page = new Page(Integer.valueOf(cnt.toString())); |
| | | page.setPageNo(pageNo); |
| | | page.setPageSize(pageSize); |
| | | maps = maintainDetailMapper.selectOperateDatas(collect, tempName, operate.name(), maintainTableName, baseMaintain.getOrderNo(), compareMaintain.getOrderNo(), null, page.getLimitSQL()); |
| | | } |
| | | |
| | | return operateIntegerMap; |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("total", page.getRecordCount()); |
| | | object.fluentPut("size", page.getPageSize()); |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | object.fluentPut("records", maps); |
| | | object.fluentPut("fields", fieldByMaintain); |
| | | |
| | | return object; |
| | | } |
| | | |
| | | private void addCompareInfo(Maintain baseMaintain, Maintain compareMaintain, HashMap<Operate, Object> operateIntegerMap) { |
| | |
| | | |
| | | @Override |
| | | public void dealFlow(String maintainId, ActivitiStatus status) { |
| | | Maintain maintain = selectById(maintainId); |
| | | String tableName = maintain.getTableName(); |
| | | List<MaintainDetail> maintainDetailList = maintainDetailService.selectList(new EntityWrapper<MaintainDetail>().eq("parent_id", maintainId)); |
| | | if (status.equals(ActivitiStatus.close)) { |
| | | String collect = maintainDetailList.stream().map(detail -> DbUtils.quotedStr(detail.getPreMergeId())).collect(Collectors.joining(Constant.COMMA)); |
| | | //delete temp |
| | | if (!StringUtils.isEmpty(collect)) { |
| | | masterDataService.delete(tableName + Constant.RECORD, "id in (" +collect+ ")"); |
| | | try { |
| | | Maintain maintain = selectById(maintainId); |
| | | String tableName = maintain.getTableName(); |
| | | List<MaintainDetail> maintainDetailList = maintainDetailService.selectList(new EntityWrapper<MaintainDetail>().eq("parent_id", maintainId)); |
| | | if (status.equals(ActivitiStatus.close)) { |
| | | String collect = maintainDetailList.stream().map(detail -> DbUtils.quotedStr(detail.getPreMergeId())).collect(Collectors.joining(Constant.COMMA)); |
| | | //delete temp |
| | | if (!StringUtils.isEmpty(collect)) { |
| | | masterDataService.delete(tableName + Constant.RECORD, "id in (" + collect + ")"); |
| | | } |
| | | |
| | | //delete detail |
| | | for (MaintainDetail maintainDetail : maintainDetailList) { |
| | | maintainDetail.deleteById(); |
| | | } |
| | | //delete maintain |
| | | maintain.deleteById(); |
| | | return; |
| | | } |
| | | String fields = masterDataService.getTempFields(null, tableName); |
| | | String tempFields = masterDataService.getFields(tableName + Constant.RECORD); |
| | | |
| | | //delete detail |
| | | for (MaintainDetail maintainDetail : maintainDetailList) { |
| | | maintainDetail.deleteById(); |
| | | String tableTempName = tableName + Constant.RECORD; |
| | | // insert 2 std |
| | | tableInfoMapper.tempCreate2std(tableName, fields, tableTempName, DbUtils.quotedStr(maintainId)); |
| | | |
| | | |
| | | // update |
| | | List<Map<String, Object>> updeateDatas = tableInfoMapper.tempByOperate(DbUtils.quotedStr(Operate.update.name()), tempFields, tableTempName, DbUtils.quotedStr(maintainId)); |
| | | for (Map<String, Object> updeateData : updeateDatas) { |
| | | String stdId = updeateData.get(Constant.STD_ID).toString(); |
| | | String id = updeateData.get(Constant.ID).toString(); |
| | | Result result = masterDataService.selectById(tableName, stdId); |
| | | Object tempData = result.getData(); |
| | | String datas = JSON.toJSONString(tempData); |
| | | JSONObject object = JSON.parseObject(datas); |
| | | Object grid = object.get("grid"); |
| | | object = JSON.parseObject(JSON.toJSONString(grid)); |
| | | |
| | | object.put(Constant.STD_ID, stdId); |
| | | object.put(Constant.ID, id); |
| | | |
| | | datas = JSON.toJSONString(object); |
| | | |
| | | masterDataService.updateById(tableTempName, datas, id, true); |
| | | |
| | | updeateData.put(Constant.STD_ID, null); |
| | | updeateData.put(Constant.ID, stdId); |
| | | |
| | | masterDataService.updateById(tableName, JSON.toJSONString(updeateData), stdId, true); |
| | | } |
| | | //delete maintain |
| | | maintain.deleteById(); |
| | | return; |
| | | //delete |
| | | List<Map<String, Object>> delDatas = tableInfoMapper.tempByOperate(DbUtils.quotedStr(Operate.delete.name()), tempFields, tableTempName, DbUtils.quotedStr(maintainId)); |
| | | for (Map<String, Object> delData : delDatas) { |
| | | Object id = delData.get(Constant.STD_ID); |
| | | masterDataService.deleteById(tableName, id.toString()); |
| | | } |
| | | // update deal |
| | | tableInfoMapper.tempDeal(tableTempName, DbUtils.quotedStr(maintainId)); |
| | | } |
| | | String fields = masterDataService.getTempFields(tableName); |
| | | String tempFields = masterDataService.getFields(tableName + Constant.RECORD); |
| | | |
| | | String tableTempName = tableName + Constant.RECORD; |
| | | // insert 2 std |
| | | tableInfoMapper.tempCreate2std(tableName, fields, tableTempName, DbUtils.quotedStr(maintainId)); |
| | | |
| | | |
| | | // update |
| | | List<Map<String, Object>> updeateDatas = tableInfoMapper.tempByOperate(DbUtils.quotedStr(Operate.update.name()), tempFields, tableTempName, DbUtils.quotedStr(maintainId)); |
| | | for (Map<String, Object> updeateData : updeateDatas) { |
| | | String stdId = updeateData.get(Constant.STD_ID).toString(); |
| | | String id = updeateData.get(Constant.ID).toString(); |
| | | Result result = masterDataService.selectById(tableName, stdId); |
| | | Object tempData = result.getData(); |
| | | String datas = JSON.toJSONString(tempData); |
| | | JSONObject object = JSON.parseObject(datas); |
| | | Object grid = object.get("grid"); |
| | | object = JSON.parseObject(JSON.toJSONString(grid)); |
| | | |
| | | object.put(Constant.STD_ID, stdId); |
| | | object.put(Constant.ID, id); |
| | | |
| | | datas = JSON.toJSONString(object); |
| | | |
| | | masterDataService.updateById(tableTempName,datas, id,true); |
| | | |
| | | updeateData.put(Constant.STD_ID, null); |
| | | updeateData.put(Constant.ID, stdId); |
| | | |
| | | masterDataService.updateById(tableName,JSON.toJSONString(updeateData), stdId,true); |
| | | catch (Exception e ){ |
| | | e.printStackTrace(); |
| | | } |
| | | //delete |
| | | List<Map<String, Object>> delDatas = tableInfoMapper.tempByOperate(DbUtils.quotedStr(Operate.delete.name()), tempFields, tableTempName, DbUtils.quotedStr(maintainId)); |
| | | for (Map<String, Object> delData : delDatas) { |
| | | Object id = delData.get(Constant.STD_ID); |
| | | masterDataService.deleteById(tableName, id.toString()); |
| | | } |
| | | // update deal |
| | | tableInfoMapper.tempDeal(tableTempName, DbUtils.quotedStr(maintainId)); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public boolean checkNowVersion(String maintainId) { |
| | | Maintain maintain = selectById(maintainId); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result getUnSubmitData(String tableName, Integer pageNo, String pageSize, String whereSegment) { |
| | | public Long getUnSubmitDataCnt(TUser user, String tableName, String whereSegment) { |
| | | Wrapper<Maintain> versionWrapper = new EntityWrapper<Maintain>().eq("table_name", tableName).isNull("flow_id").orderBy("order_no desc"); |
| | | Maintain maintain = selectOne(versionWrapper); |
| | | if (maintain == null) { |
| | | return null; |
| | | } |
| | | String maintainId = maintain.getId(); |
| | | String tempName = tableName + Constant.RECORD; |
| | | Long aLong = maintainMapper.countUnSubmitData(tempName, whereSegment, DbUtils.quotedStr(maintainId)); |
| | | return aLong; |
| | | } |
| | | @Override |
| | | public Result getUnSubmitData(TUser user, String tableName, Integer pageNo, String pageSize, String whereSegment) { |
| | | Wrapper<Maintain> versionWrapper = new EntityWrapper<Maintain>().eq("table_name", tableName).isNull("flow_id").orderBy("order_no desc"); |
| | | Maintain maintain = selectOne(versionWrapper); |
| | | if (maintain == null) { |
| | |
| | | if (!StringUtils.isEmpty(pageSize)) { |
| | | page.setPageSize(Integer.valueOf(pageSize)); |
| | | } |
| | | String tempFields = masterDataService.getTempFields(tableName); |
| | | String tempFields = masterDataService.getTempFields(user, tableName); |
| | | List<Map<String, Object>> maps = maintainMapper.selectUnSubmitData(tempName, tempFields, whereSegment, DbUtils.quotedStr(maintainId), page.getLimitSQL()); |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("records", maps); |
| | |
| | | |
| | | nowMaintain.setChargeId(userId); |
| | | String maintainId = nowMaintain.getId(); |
| | | if(StringUtils.isEmpty(maintainId)) { |
| | | if (StringUtils.isEmpty(maintainId)) { |
| | | nowMaintain.setId(DbUtils.getUUID()); |
| | | } |
| | | return nowMaintain; |
| | | } |
| | | |
| | | @Override |
| | | public JSONObject compareField(String maintainId1, String maintainId2) { |
| | | Maintain baseMaintain = selectById(maintainId1); |
| | | Maintain compareMaintain = selectById(maintainId2); |
| | | boolean pre = false; |
| | | if (DbUtils.compareVersion(baseMaintain, compareMaintain) > 0) { |
| | | pre = true; |
| | | } |
| | | |
| | | List<SysField> baseFieldList = fieldService.getFieldByMaintain(maintainId1); |
| | | List<SysField> compareFieldList = fieldService.getFieldByMaintain(maintainId2); |
| | | List<String> baseFieldStrList = baseFieldList.stream().map(sysField -> sysField.getField()).collect(Collectors.toList()); |
| | | List<String> compareFieldStrList = compareFieldList.stream().map(sysField -> sysField.getField()).collect(Collectors.toList()); |
| | | |
| | | List<String> baseExportList = baseFieldStrList.stream().filter(s -> !compareFieldStrList.contains(s)).collect(Collectors.toList()); |
| | | List<SysField> baseExprotFieldList = baseFieldList.stream().filter(sysField -> baseExportList.contains(sysField.getField())).collect(Collectors.toList()); |
| | | List<String> compareExportList = compareFieldStrList.stream().filter(s -> !baseFieldStrList.contains(s)).collect(Collectors.toList()); |
| | | List<SysField> compareExprotFieldList = compareFieldList.stream().filter(sysField -> compareExportList.contains(sysField.getField())).collect(Collectors.toList()); |
| | | |
| | | List<String> collect = baseFieldStrList.stream().filter(s -> compareFieldList.contains(s)).collect(Collectors.toList()); |
| | | List<SysField> changedList = new ArrayList<>(); |
| | | for (String s : collect) { |
| | | List<SysField> baseCol = baseFieldList.stream().filter(sysField -> sysField.getField().equalsIgnoreCase(s)).collect(Collectors.toList()); |
| | | List<SysField> compareCol = compareFieldList.stream().filter(sysField -> sysField.getField().equalsIgnoreCase(s)).collect(Collectors.toList()); |
| | | SysField baseField = baseCol.get(0); |
| | | SysField sysField = compareCol.get(0); |
| | | if (!baseField.equals(sysField)) { |
| | | if (pre) { |
| | | //base 大 |
| | | changedList.add(baseField); |
| | | } else { |
| | | changedList.add(sysField); |
| | | } |
| | | } |
| | | } |
| | | JSONObject object = new JSONObject(); |
| | | if (pre) { |
| | | object.fluentPut("create", baseExprotFieldList); |
| | | object.fluentPut("delete", compareExprotFieldList); |
| | | object.fluentPut("update", changedList); |
| | | } else { |
| | | object.fluentPut("create", compareExprotFieldList); |
| | | object.fluentPut("delete", baseExprotFieldList); |
| | | object.fluentPut("update", changedList); |
| | | } |
| | | return object; |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result getInvalidVerionData(String tableName, String where, Integer pageNo, Integer pageSize) { |
| | | public Long getInvalidVerionDataCnt(TUser user, String tableName, String where) { |
| | | Maintain invalidVersion = getInvalidMaxVersion(tableName); |
| | | if (invalidVersion == null) { |
| | | return null; |
| | | } |
| | | String tableTempName = tableName + Constant.RECORD; |
| | | String tempFields = masterDataService.getTempFields(user, tableName); |
| | | Long count = maintainMapper.countInvalidVersionData(tableTempName, where, invalidVersion.getOrderNo()); |
| | | return count; |
| | | } |
| | | @Override |
| | | public Result getInvalidVerionData(TUser user, String tableName, String where, Integer pageNo, Integer pageSize) { |
| | | Maintain invalidVersion = getInvalidMaxVersion(tableName); |
| | | if (invalidVersion == null) { |
| | | return Result.success(null); |
| | | } |
| | | String tableTempName = tableName + Constant.RECORD; |
| | | String tempFields = masterDataService.getTempFields(tableName); |
| | | String tempFields = masterDataService.getTempFields(user, tableName); |
| | | Long count = maintainMapper.countInvalidVersionData(tableTempName, where, invalidVersion.getOrderNo()); |
| | | Page page = new Page(count); |
| | | page.setPageNo(pageNo); |
| | |
| | | List<Maintain> maintains = selectList(versionWrapper); |
| | | for (Maintain maintain : maintains) { |
| | | Flows flows = flowsService.selectById(maintain.getFlowId()); |
| | | if (flows == null){ |
| | | if (flows == null) { |
| | | continue; |
| | | } |
| | | ActivitiStatus status = flows.getStatus(); |
| | |
| | | //return selectOne(new EntityWrapper<Maintain>().eq("table_name", tableName).orderBy("version desc")); |
| | | } |
| | | |
| | | @Override |
| | | public Maintain getRecentHistoryVersion(String tableName) { |
| | | Maintain nowMaintain = null; |
| | | Wrapper<Maintain> versionWrapper = new EntityWrapper<Maintain>().eq("table_name", tableName).isNotNull("flow_id").orderBy("order_no desc"); |
| | | List<Maintain> maintains = selectList(versionWrapper); |
| | | for (Maintain maintain : maintains) { |
| | | Flows flows = flowsService.selectById(maintain.getFlowId()); |
| | | if (flows == null){ |
| | | continue; |
| | | } |
| | | ActivitiStatus status = flows.getStatus(); |
| | | if (status.equals(ActivitiStatus.open) && nowMaintain == null) { |
| | | nowMaintain = maintain; |
| | | continue; |
| | | } |
| | | if (!status.equals(ActivitiStatus.open) && nowMaintain != null){ |
| | | nowMaintain = null; |
| | | } |
| | | } |
| | | if (nowMaintain == null) { |
| | | nowMaintain = selectOne(new EntityWrapper<Maintain>().eq("table_name", tableName).orderBy("order_no desc")); |
| | | } |
| | | int orderNo = nowMaintain.getOrderNo(); |
| | | Maintain nowVersion = getNowVersion(tableName); |
| | | if (nowVersion != null && nowVersion.getOrderNo() == orderNo) { |
| | | orderNo--; |
| | | } |
| | | Maintain maintain = selectOne(new EntityWrapper<Maintain>().eq("table_name", nowMaintain.getTableName()).eq("order_no", orderNo)); |
| | | return maintain; |
| | | } |
| | | |
| | | @Override |
| | | public Maintain getMaintainFromVersion(String tableName, String verison) { |
| | |
| | | return maxVersion; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectVersionOperator(String tableTempName, String maintaInId, String where) { |
| | | return maintainMapper.selectVersionOperator(tableTempName, where, maintaInId); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectVersionOperator(String tableTempName, String maintaInId) { |
| | | return maintainMapper.selectVersionOperator(tableTempName, Constant.WHERE_DEFAULT, maintaInId); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectVersionOperatorByType(String tableTempName, String maintaInId, Operate operate, String where) { |
| | | return maintainMapper.selectVersionOperatorByType(tableTempName, where, maintaInId, operate.name()); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectVersionOperatorByType(String tableTempName, String maintaInId, Operate operate) { |
| | | return maintainMapper.selectVersionOperatorByType(tableTempName, Constant.WHERE_DEFAULT, maintaInId, operate.name()); |
| | | } |
| | | |
| | | @Override |
| | | public long countVersionOperator(String tableTempName, String maintaInId, String whereSegment) { |
| | | return maintainMapper.countVersionOperator(tableTempName, maintaInId, whereSegment); |
| | | } |
| | | |
| | | @Override |
| | | public long countVersionOperator(String tableTempName, String maintaInId) { |
| | | return maintainMapper.countVersionOperator(tableTempName, maintaInId, Constant.WHERE_DEFAULT); |
| | | return maintainMapper.selectVersionOperatorByType(tableTempName, Constant.WHERE_DEFAULT, maintaInId, operate.name()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public long countVersionOperatorByType(String tableTempName, String filterSegment, String maintaInId, Operate operate) { |
| | | return maintainMapper.countVersionOperatorByType(tableTempName,filterSegment, maintaInId,operate.name()); |
| | | return maintainMapper.countVersionOperatorByType(tableTempName, filterSegment, maintaInId, operate.name()); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectVersionOperatorByPage(String tableTempName, String maintaInId, String limit, String where) { |
| | | return maintainMapper.selectVersionOperatorByPage(tableTempName, maintaInId, limit, where); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectVersionOperatorByPage(String tableTempName, String maintaInId, String limit) { |
| | | return maintainMapper.selectVersionOperatorByPage(tableTempName, Constant.WHERE_DEFAULT, maintaInId, limit); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectVersionOperatorByTypeByPage(String tableTempName, String maintaInId, Operate operate, String limit) { |
| | | return maintainMapper.selectVersionOperatorByTypeByPage(tableTempName, Constant.WHERE_DEFAULT, maintaInId, operate.name(), limit); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectVersionOperatorByTypeByPage(String tableTempName, String maintaInId, Operate operate, String limit, String where) { |
| | | return maintainMapper.selectVersionOperatorByTypeByPage(tableTempName, where, maintaInId, operate.name(), limit); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getCompareVersionMaintains(Maintain unFlowMaxVersion, Maintain maintainFromVersion) { |
| | | Integer compare = DbUtils.compareVersion(unFlowMaxVersion, maintainFromVersion); |
| | | ArrayList<String> ids = new ArrayList<>(); |
| | | if (compare > 0) { |
| | | getVerionMatintains(unFlowMaxVersion,maintainFromVersion, ids); |
| | | }else if(compare == 0) { |
| | | getVerionMatintains(unFlowMaxVersion, maintainFromVersion, ids); |
| | | } else if (compare == 0) { |
| | | ids.add(unFlowMaxVersion.getId()); |
| | | }else { |
| | | getVerionMatintains(maintainFromVersion,unFlowMaxVersion, ids); |
| | | } else { |
| | | getVerionMatintains(maintainFromVersion, unFlowMaxVersion, ids); |
| | | } |
| | | return ids; |
| | | } |
| | | |
| | | @Override |
| | | public Result tempDataByVersionByFlow(String flowId, String whereSegment, Integer pageNo, Integer pageSize) { |
| | | public Result tempDataByVersionByFlow(TUser user, String flowId, String whereSegment, Integer pageNo, Integer pageSize) { |
| | | Flows flows = flowsService.selectById(flowId); |
| | | if (flows == null) { |
| | | return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND); |
| | |
| | | if (maintain == null) { |
| | | return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND); |
| | | } |
| | | String fields = masterDataService.getTempFields(maintain.getTableName()); |
| | | String fields = masterDataService.getTempFields(user, maintain.getTableName()); |
| | | String tableTempName = maintain.getTableName() + Constant.RECORD; |
| | | long total = maintainMapper.countTempDataByVersionByFlow(tableTempName, flowId, whereSegment); |
| | | |
| | |
| | | return Result.success(object); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getPreInfo(Maintain maintain, String id) { |
| | | String maintainTableName = maintain.getTableName(); |
| | | String recordTableName = maintainTableName + Constant.RECORD; |
| | | List<Map<String, Object>> maps = maintainDetailMapper.seleMaintainDetailByDataId(recordTableName, maintain.getId(), id); |
| | | |
| | | if (maps == null) { |
| | | return null; |
| | | } |
| | | if (maps == null || maps.isEmpty()) { |
| | | return null; |
| | | } |
| | | Map<String, Object> stringObjectMap = maps.get(0); |
| | | String createTime = stringObjectMap.get("createTime").toString(); |
| | | List<SysField> fieldByMaintain = fieldService.getFieldByMaintain(maintain.getId()); |
| | | String fields = fieldByMaintain.stream().map(sysField -> sysField.getField()) |
| | | .map(s -> s.equalsIgnoreCase(Constant.ID) ? MessageFormat.format("{0} as id", Constant.STD_ID) : s) |
| | | .collect(Collectors.joining(Constant.COMMA)); |
| | | |
| | | List<Map<String, Object>> preData = maintainDetailMapper.getPreData(fields, recordTableName, id, createTime); |
| | | if (preData == null || preData.isEmpty()) { |
| | | return null; |
| | | } |
| | | Map<String, Object> result = preData.get(0); |
| | | String maintainId = result.get("maintainId").toString(); |
| | | Maintain preMaintain = selectById(maintainId); |
| | | if (preMaintain != null) { |
| | | String chargeId = preMaintain.getChargeId(); |
| | | TUser userById = DbUtils.getUserById(chargeId); |
| | | if (userById != null) { |
| | | result.put("userName", userById.getUserName()); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | private void getVerionMatintains(Maintain firstVersion, Maintain secondVersion, List<String> ids) { |