| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.Cache; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | * |
| | | * @param baseModelDTO 数据传输对象 |
| | | */ |
| | | @Transactional |
| | | @Override |
| | | public void changeStatus(BaseModelDTO baseModelDTO) { |
| | | VciBaseUtil.alertNotNull(baseModelDTO, "数据信息", baseModelDTO.getOid(), "主键", baseModelDTO.getBtmname(), "业务类型", baseModelDTO.getLcStatus(), "目标状态"); |
| | | List<String> oids = VciBaseUtil.str2List(baseModelDTO.getOid()); |
| | | // List<ClientBusinessObject> cboList = boService.selectCBOByOidCollection(oids, baseModelDTO.getBtmname()); |
| | | //插个点 业务类型完成后需要修改 |
| | | QueryWrapper<BtmTypeVO> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("BTMNAME",baseModelDTO.getBtmname()); |
| | | wrapper.in("OID",oids); |
| | | // QueryWrapper<BtmTypeVO> wrapper = new QueryWrapper<>(); |
| | | List<BaseModel> baseModels = new ArrayList<>(); |
| | | baseModels = selectByTypeAndOid(baseModelDTO.getBtmname(), baseModelDTO.getOid()); |
| | | if(baseModels.size() == 0){ |
| | | throw new VciBaseException("未查询到相关数据。"); |
| | | } |
| | | // 待完善 |
| | | List<BtmTypeVO> cboList = null; // btmTypeClient.selectList(wrapper); |
| | | //还需要修改allCode的生命周期 |
| | |
| | | // List<ClientBusinessObject> codeCbos = boService.queryCBO(MdmBtmTypeConstant.CODE_ALL_CODE, conditionMap); |
| | | // 回收需要业务数据删除 |
| | | if (CodeDefaultLC.TASK_BACK.getValue().equals(baseModelDTO.getLcStatus())) { |
| | | R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(baseModelDTO.getBtmname())); |
| | | // String referTable = listR.getData().get(0).getTableName(); |
| | | commonsMapper.deleteByTaleAndOid(listR.getData().get(0).getTableName(),VciBaseUtil.toInSql(baseModelDTO.getOid())); |
| | | // BatchCBO batchCBO = new BatchCBO(); |
| | | // batchCBO.getDeleteCbos().addAll(cboList); |
| | | |
| | | // 待完善 |
| | | //btmTypeClient.deleteBatchIds(cboList); |
| | | |
| | | //boService.persistenceBatch(batchCBO); |
| | | } else { |
| | | for (BaseModel baseModel : baseModels) { |
| | | baseModel.setLcStatus(baseModelDTO.getLcStatus()); |
| | | } |
| | | updateBatchByBaseModel(baseModelDTO.getBtmname(),baseModels); |
| | | // lifeCycleService.transCboStatus(cboList, baseModelDTO.getLcStatus()); |
| | | } |
| | | for (CodeAllCode codeCbo : codeCbos) { |
| | | codeCbo.setLcStatus(baseModelDTO.getLcStatus()); |
| | | } |
| | | codeAllCodeService.updateBatchById(codeCbos); |
| | | // lifeCycleService.transCboStatus(codeCbos, baseModelDTO.getLcStatus()); |
| | | } |
| | | |
| | |
| | | |
| | | DataGrid<Map<String, String>> dataGrid = new DataGrid<>(); |
| | | List<Map<String, String>> dataList = new ArrayList<>(); |
| | | // if (!CollectionUtils.isEmpty(maps)) { |
| | | // maps.stream().forEach(map -> { |
| | | // Map<String, String> data = new HashMap<>(); |
| | | // map.forEach((key, value) -> { |
| | | // data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value)); |
| | | // }); |
| | | // dataList.add(data); |
| | | // }); |
| | | // } |
| | | // dataGrid.setData(dataList); |
| | | if (!CollectionUtils.isEmpty(maps)) { |
| | | wrapperData(maps, templateVO, sqlBO.getSelectFieldList(), false); |
| | | maps.stream().forEach(map -> { |
| | | Map<String, String> data = new HashMap<>(); |
| | | for (String s : map.keySet()) { |
| | | data.put(s.toLowerCase(Locale.ROOT), String.valueOf(map.get(s))); |
| | | } |
| | | // map.forEach((key, value) -> { |
| | | // data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value)); |
| | | // }); |
| | | for (String s : map.keySet()) { |
| | | data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s))); |
| | | } |
| | | dataList.add(data); |
| | | }); |
| | | dataGrid.setData(dataList); |
| | | dataGrid.setTotal(Long.parseLong(commonsMapper.selectBySql(sqlBO.getSqlCount()).get(0).values().toArray()[0].toString())); |
| | | wrapperData(dataList, templateVO, sqlBO.getSelectFieldList(), false); |
| | | // maps.stream().forEach(map -> { |
| | | // Map<String, String> data = new HashMap<>(); |
| | | //// map.forEach((key, value) -> { |
| | | //// data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value)); |
| | | //// }); |
| | | // for (String s : map.keySet()) { |
| | | // data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s))); |
| | | // } |
| | | // dataList.add(data); |
| | | // }); |
| | | } |
| | | // dataGrid.setData(dataList); |
| | | // if (!CollectionUtils.isEmpty(maps)) { |
| | | // wrapperData(maps, templateVO, sqlBO.getSelectFieldList(), false); |
| | | // maps.stream().forEach(map -> { |
| | | // Map<String, String> data = new HashMap<>(); |
| | | //// map.forEach((key, value) -> { |
| | | //// data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value)); |
| | | //// }); |
| | | // for (String s : map.keySet()) { |
| | | // data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s))); |
| | | // } |
| | | // dataList.add(data); |
| | | // }); |
| | | dataGrid.setData(dataList); |
| | | dataGrid.setTotal(Long.parseLong(commonsMapper.selectBySql(sqlBO.getSqlCount()).get(0).values().toArray()[0].toString())); |
| | | // } |
| | | return dataGrid; |
| | | } |
| | | |
| | |
| | | //pageHelper.addDefaultDesc("createTime"); |
| | | pageHelper.addDefaultDesc("id"); |
| | | if (!classifyService.checkHasChild(codeClassifyOid)) { |
| | | conditionMap.put(CODE_CLASSIFY_OID_FIELD, codeClassifyOid); |
| | | conditionMap.put("t."+CODE_CLASSIFY_OID_FIELD, codeClassifyOid); |
| | | } else { |
| | | //表需要改 |
| | | // conditionMap.put(CODE_CLASSIFY_OID_FIELD, QueryOptionConstant.IN + "(select oid from " + VciBaseUtil.getTableName(MdmBtmTypeConstant.CODE_CLASSIFY) |
| | | conditionMap.put(CODE_CLASSIFY_OID_FIELD, QueryOptionConstant.IN + "(select oid from pl_code_classify where lcstatus='" + FrameWorkDefaultValueConstant.FRAMEWORK_DATA_ENABLED + |
| | | conditionMap.put("t."+CODE_CLASSIFY_OID_FIELD, QueryOptionConstant.IN + "(select oid from pl_code_classify where lcstatus='" + FrameWorkDefaultValueConstant.FRAMEWORK_DATA_ENABLED + |
| | | "' start with parentCodeClassifyOid = '" + codeClassifyOid + "' CONNECT BY PRIOR OID = parentCodeClassifyOid )"); |
| | | } |
| | | conditionMap.put("lastr", "1"); |
| | | conditionMap.put("lastv", "1"); |
| | | conditionMap.put("t.lastr", "1"); |
| | | conditionMap.put("t.lastv", "1"); |
| | | return queryGrid(btmTypeId, templateVO, conditionMap, pageHelper); |
| | | // List<String> selectFieldList = templateVO.getAttributes().stream().map(CodeClassifyTemplateAttrVO::getId).collect(Collectors.toList()); |
| | | // //参照让平台直接查询就行 |
| | |
| | | * @return 处理成功数据条数 |
| | | */ |
| | | @Override |
| | | public Integer insertBatchByType(String btmType, List<BaseModel> baseModels) throws Exception { |
| | | public Integer insertBatchByType(String btmType, List<BaseModel> baseModels) { |
| | | //使用传入的业务类型查询表 |
| | | R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType)); |
| | | if(listR.getData().size() == 0){ |
| | |
| | | * @return 查询出的数据 |
| | | */ |
| | | @Override |
| | | public List<BaseModel> selectByTypeAndOid(String btmType, String oids) throws IllegalAccessException, NoSuchFieldException, InstantiationException, InvocationTargetException, IntrospectionException, SQLException { |
| | | public List<BaseModel> selectByTypeAndOid(String btmType, String oids) { |
| | | |
| | | //使用传入的业务类型查询表 |
| | | R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType)); |
| | |
| | | |
| | | List<BaseModel> baseModels = new ArrayList<>(); |
| | | //将查询到的数据转换为basemodel,使用的反射方式来进行创建的 |
| | | for (Map map : maps) { |
| | | Object obj = BaseModel.class.newInstance(); |
| | | BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass()); |
| | | PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); |
| | | for (PropertyDescriptor property : propertyDescriptors) { |
| | | Method setter = property.getWriteMethod(); |
| | | if (setter != null) { |
| | | //oracle的时间为TIMESTAMP的,需要进行转换成data,否则将报错 |
| | | if(map.get(property.getName().toUpperCase()) instanceof TIMESTAMP){ |
| | | LocalDateTime localDateTime = ((TIMESTAMP) map.get(property.getName().toUpperCase())).toLocalDateTime(); |
| | | ZoneId zoneId = ZoneId.systemDefault(); |
| | | ZonedDateTime zdt = localDateTime.atZone(zoneId); |
| | | Date date = Date.from(zdt.toInstant()); |
| | | setter.invoke(obj,date); |
| | | map.remove(property.getName().toUpperCase()); |
| | | } //oracle的数字为BigDecimal的,需要进行转换成Integer,否则将报错 |
| | | else if (map.get(property.getName().toUpperCase()) instanceof BigDecimal |
| | | && ("Integer").equals(setter.getParameterTypes()[0].getSimpleName())){ |
| | | setter.invoke(obj, ((BigDecimal)map.get(property.getName().toUpperCase())).intValue()); |
| | | map.remove(property.getName().toUpperCase()); |
| | | }else if(map.get(property.getName().toUpperCase()) != null){ |
| | | setter.invoke(obj, map.get(property.getName().toUpperCase())); |
| | | map.remove(property.getName().toUpperCase()); |
| | | try{ |
| | | for (Map map : maps) { |
| | | Object obj = BaseModel.class.newInstance(); |
| | | BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass()); |
| | | PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); |
| | | for (PropertyDescriptor property : propertyDescriptors) { |
| | | Method setter = property.getWriteMethod(); |
| | | if (setter != null) { |
| | | //oracle的时间为TIMESTAMP的,需要进行转换成data,否则将报错 |
| | | if(map.get(property.getName().toUpperCase()) instanceof TIMESTAMP){ |
| | | LocalDateTime localDateTime = ((TIMESTAMP) map.get(property.getName().toUpperCase())).toLocalDateTime(); |
| | | ZoneId zoneId = ZoneId.systemDefault(); |
| | | ZonedDateTime zdt = localDateTime.atZone(zoneId); |
| | | Date date = Date.from(zdt.toInstant()); |
| | | setter.invoke(obj,date); |
| | | map.remove(property.getName().toUpperCase()); |
| | | } //oracle的数字为BigDecimal的,需要进行转换成Integer,否则将报错 |
| | | else if (map.get(property.getName().toUpperCase()) instanceof BigDecimal |
| | | && ("Integer").equals(setter.getParameterTypes()[0].getSimpleName())){ |
| | | setter.invoke(obj, ((BigDecimal)map.get(property.getName().toUpperCase())).intValue()); |
| | | map.remove(property.getName().toUpperCase()); |
| | | }else if(map.get(property.getName().toUpperCase()) != null){ |
| | | setter.invoke(obj, map.get(property.getName().toUpperCase())); |
| | | map.remove(property.getName().toUpperCase()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | for (Object key : map.keySet()) { |
| | | map.put(key,String.valueOf(map.get(key))); |
| | | } |
| | | for (Object key : map.keySet()) { |
| | | map.put(key,String.valueOf(map.get(key))); |
| | | } |
| | | |
| | | ((BaseModel) obj).setData(map); |
| | | baseModels.add((BaseModel) obj); |
| | | ((BaseModel) obj).setData(map); |
| | | baseModels.add((BaseModel) obj); |
| | | } |
| | | }catch (Exception e){ |
| | | throw new VciBaseException("查询失败:" + e.getMessage()); |
| | | } |
| | | return baseModels; |
| | | } |
| | |
| | | * @return 处理状态 |
| | | */ |
| | | @Override |
| | | public R updateBatchByBaseModel(String btmType, List<BaseModel> baseModels) throws Exception { |
| | | public R updateBatchByBaseModel(String btmType, List<BaseModel> baseModels) { |
| | | //使用传入的业务类型查询表 |
| | | R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType)); |
| | | if(listR.getData().size() == 0){ |