| | |
| | | import com.vci.ubcs.code.enumpack.*; |
| | | import com.vci.ubcs.code.mapper.CommonsMapper; |
| | | import com.vci.ubcs.code.service.*; |
| | | import com.vci.ubcs.code.util.ClientBusinessObject; |
| | | import com.vci.ubcs.code.vo.CodeKeyAttrRepeatVO; |
| | | import com.vci.ubcs.code.vo.CodeReferConfigVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.UITableFieldVO; |
| | |
| | | import com.vci.ubcs.system.user.feign.IUserClient; |
| | | import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils; |
| | | import oracle.sql.TIMESTAMP; |
| | | import org.aspectj.apache.bcel.classfile.Code; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | |
| | | cbo.setNameOid(VciBaseUtil.getPk()); |
| | | cbo.setCreateTime(new Date()); |
| | | cbo.setLastModifyTime(new Date()); |
| | | cbo.setCreator(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | //cbo.setCreator(String.valueOf(AuthUtil.getUser().getUserId()));、 |
| | | // 要求显示账号,所以做了更改 |
| | | cbo.setCreator(String.valueOf(AuthUtil.getUser().getAccount())); |
| | | cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | cbo.setTenantId(AuthUtil.getTenantId()); |
| | | if(StringUtils.isNotBlank(orderDTO.getLcStatus())||StringUtils.isNotBlank(orderDTO.getData().get("lcStatus"))){ |
| | |
| | | } |
| | | final String[] sql = {"select * from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "}; |
| | | conditionMap.forEach((key, value) -> { |
| | | sql[0] += " and " + key + " = " + value; |
| | | if(StringUtils.isBlank(value)||value.equals(QueryOptionConstant.ISNULL)) { |
| | | sql[0] += " and " + key + " is null"; |
| | | }else{ |
| | | sql[0] += " and " + key + " = " + value; |
| | | } |
| | | }); |
| | | if (StringUtils.isNotBlank(orderDTO.getOid())) { |
| | | //修改的时候,需要排除自己 |
| | |
| | | */ |
| | | @Override |
| | | public R checkGroupCode(Map<String, String> parameter) { |
| | | List<CodeClassify> codeClassifyList = classifyService.selectAllLevelParents(parameter.get("oid")); |
| | | List<CodeClassify> codeClassifyList = classifyService.selectAllLevelParentByOid(parameter.get("oid")); |
| | | Set<String> configGroupCode = Arrays.stream(parameter.get("classifyGroupCode").split("#")).collect(Collectors.toSet()); |
| | | // Boolean checkGroupFlag = false;//是否查询到配置的顶层分类中 |
| | | for (int i = codeClassifyList.size()-1; i >= 0; i--) { |
| | |
| | | uiTableConfigVO.setQueryColumns(queryColumns); |
| | | //set给表格配置属性 |
| | | uiFormReferVO.setTableConfig(uiTableConfigVO); |
| | | //字段名不一致,需要手动set |
| | | |
| | | uiFormReferVO.setMuti(StringUtils.isBlank(codeReferConfig.getIsMuti())?false:true); |
| | | uiFormReferVO.setInitSort(new UIFieldSortVO(codeReferConfig.getSortField(),codeReferConfig.getSortType())); |
| | | // 筛选条件 |
| | | HashMap<String, String> whereMap = new HashMap<>(); |
| | | if(!CollectionUtils.isEmpty(codeReferConfig.getCodeSrchCondConfigVOS())){ |
| | |
| | | //说明还是参照里面的,我们默认这种情况下都是字符串吧,因为参照的属性不一定用的平台的属性池里的,所以大部分情况下,显示的属性都是字符串吧 |
| | | return referFieldMap.get(field) + SPACE + "LIKE" + SPACE + "'%" + value + "%'" + SPACE; |
| | | } else { |
| | | return (field.contains(".") ? "" : "t.") + field + SPACE + "LIKE " + "'%" + getStringValueInWhere(field, value, attrVOMap) + "%'" + SPACE; |
| | | return (field.contains(".") ? "" : "t.") + field + SPACE + "LIKE " + "'%" + value + "%'" + SPACE; |
| | | } |
| | | } else if (key.endsWith("_notequal")) { |
| | | String field = UBCSSqlKeyword.getColumn(key, "_notequal"); |
| | |
| | | if (referFieldMap.containsKey(field)) { |
| | | return referFieldMap.get(field) + SPACE + " >= " + value + SPACE; |
| | | } else { |
| | | return (field.contains(".") ? "" : "t.") + field + SPACE + " >= " + getStringValueInWhere(value, field, attrVOMap) + SPACE; |
| | | return (field.contains(".") ? "" : "t.") + field + SPACE + " >= " + getStringValueInWhere(field, value, attrVOMap) + SPACE; |
| | | } |
| | | } else if (key.endsWith("_le")) { |
| | | //说明是<=的。我们需要先获取一下 |
| | |
| | | if (referFieldMap.containsKey(field)) { |
| | | return referFieldMap.get(field) + SPACE + "= '" + value + "'" + SPACE; |
| | | } else { |
| | | return (field.contains(".") ? "" : "t.") + field + SPACE + "= '" + getStringValueInWhere(field, value, attrVOMap) + "'" + SPACE; |
| | | return (field.contains(".") ? "" : "t.") + field + SPACE + "= " + getStringValueInWhere(field, value, attrVOMap) + "" + SPACE; |
| | | } |
| | | } else { |
| | | // if (referFieldMap.containsKey(key)) { |
| | |
| | | // cbo.getData().putAll(orderDTO.getData()); |
| | | cbo.setLastModifyTime(new Date()); |
| | | cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | updateBatchByBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), Collections.singletonList(cbo)); |
| | | batchSaveSelectChar(templateVO, Collections.singletonList(cbo)); |
| | | R r = updateBatchByBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), Collections.singletonList(cbo)); |
| | | if(!r.isSuccess()){ |
| | | throw new ServiceException(r.getMsg()); |
| | | } |
| | | batchSaveSelectChar(templateVO, Collections.singletonList(cbo)); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | //只能删除自己创建的数据 |
| | | String userId = String.valueOf(AuthUtil.getUser().getUserId()); |
| | | String userId = String.valueOf(AuthUtil.getUser().getAccount()); |
| | | for (BaseModel clientBusinessObject : cboList) { |
| | | String creator = clientBusinessObject.getCreator(); |
| | | if (!userId.equalsIgnoreCase(creator)) { |
| | |
| | | // 日期码段设置默认值 |
| | | if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) { |
| | | try { |
| | | secVO.setCodeDateFormatStr(Func.format(new Date(),secVO.getCodeDateFormatStr())); |
| | | secVO.setCodeDateValue(Func.format(new Date(),secVO.getCodeDateFormatStr())); |
| | | }catch (Exception e){ |
| | | throw new ServiceException("日期码段日期格式配置有误,导致转换出错:"+e.getMessage()); |
| | | } |
| | |
| | | // 日期码段设置默认值 |
| | | if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) { |
| | | try { |
| | | secVO.setCodeDateFormatStr(Func.format(new Date(),secVO.getCodeDateFormatStr())); |
| | | secVO.setCodeDateValue(Func.format(new Date(),secVO.getCodeDateFormatStr())); |
| | | }catch (Exception e){ |
| | | throw new ServiceException("日期码段日期格式配置有误,导致转换出错:"+e.getMessage()); |
| | | } |
| | |
| | | // 日期码段设置默认值 |
| | | if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) { |
| | | try { |
| | | secVO.setCodeDateFormatStr(Func.format(new Date(),secVO.getCodeDateFormatStr())); |
| | | secVO.setCodeDateValue(Func.format(new Date(),secVO.getCodeDateFormatStr())); |
| | | }catch (Exception e){ |
| | | throw new ServiceException("日期码段日期格式配置有误,导致转换出错:"+e.getMessage()); |
| | | } |
| | |
| | | }); |
| | | return commonsMapper.insertByBaseModel(listR.getData().get(0).getTableName(), maps.get(0), maps); |
| | | } |
| | | /** |
| | | * 传入业务类型以及ID查询业务表数据是否重复 |
| | | * |
| | | * @param btmType 业务类型 |
| | | * @param ids 处理数据 |
| | | * @return 查询到数据的总数 |
| | | */ |
| | | @Override |
| | | public Integer selectIdsCounts(String btmType, List<String> ids) { |
| | | //使用传入的业务类型查询表 |
| | | R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType)); |
| | | if (!listR.isSuccess() || listR.getData().size() == 0) { |
| | | throw new VciBaseException("传入业务类型未查询到相应表单,请检查!"); |
| | | } |
| | | return commonsMapper.queryCountBySql("select count(*) from " + |
| | | listR.getData().get(0).getTableName() + " where id in ("+ ids.stream().map(s -> "'" + s + "'").collect(Collectors.joining(",")) +")"); |
| | | } |
| | | |
| | | /** |
| | | * 传入业务类型以及ID、OID查询业务表数据是否重复 |
| | | * |
| | | * @param btmType 业务类型 |
| | | * @param id 处理数据id |
| | | * @param oid 处理数据oid |
| | | * @return 查询到数据的总数 |
| | | */ |
| | | @Override |
| | | public Integer selectIdAndOidCounts(String btmType, String id, String oid) { |
| | | //使用传入的业务类型查询表 |
| | | R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType)); |
| | | if (!listR.isSuccess() || listR.getData().size() == 0) { |
| | | throw new VciBaseException("传入业务类型未查询到相应表单,请检查!"); |
| | | } |
| | | return commonsMapper.queryCountBySql("select count(*) from " + |
| | | listR.getData().get(0).getTableName() + " where id ='" + id + "' and oid <> '" + oid + "'"); |
| | | } |
| | | |
| | | /** |
| | | * 传入业务类型以及相oid集合查询数据进行返回 |
| | |
| | | |
| | | return R.success("更新成功!"); |
| | | } |
| | | /** |
| | | * 更新业务数据同时对码值表数据操作接口 |
| | | * |
| | | * @param btmType 业务类型 |
| | | * @param baseModels 处理数据 |
| | | * @return 处理状态 |
| | | */ |
| | | @Transactional(rollbackFor = VciBaseException.class) |
| | | @Override |
| | | public R<Integer> updateBatchBtypeDatas(String btmType, List<BaseModel> baseModels) { |
| | | |
| | | /** |
| | | //使用传入的业务类型查询表 |
| | | R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType)); |
| | | if (!listR.isSuccess() || listR.getData().size() == 0) { |
| | | throw new VciBaseException("传入业务类型未查询到相应表单,请检查!"); |
| | | } |
| | | //获取当前业务类型所有字段用来做对比 |
| | | R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getAllAttributeByBtmId(btmType); |
| | | if (!allAttributeByBtmId.isSuccess() || allAttributeByBtmId.getData().getAttributes().size() == 0) { |
| | | throw new VciBaseException("传入业务类型未查询到相应字段信息,请检查!"); |
| | | } |
| | | Set<String> existFild = allAttributeByBtmId.getData().getAttributes().stream().map(btmTypeAttributeVO -> { |
| | | return btmTypeAttributeVO.getId(); |
| | | }).collect(Collectors.toSet()); |
| | | if(!CollectionUtils.isEmpty(baseModels)){ |
| | | List<String> oidList=baseModels.stream().filter(data-> com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(data.getOid())).map(BaseModel::getOid).distinct().collect(Collectors.toList()); |
| | | LambdaQueryWrapper<CodeAllCode> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.in(CodeAllCode::getCreateCodeOid,oidList); |
| | | List<CodeAllCode> codeAllCodeList= codeAllCodeService.selectByWrapper(lqw); |
| | | Map<String, CodeAllCode> cboMap = codeAllCodeList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getCreateCodeOid(), t -> t)); |
| | | List<CodeAllCode> newCodeAllCodeList=new ArrayList<>(); |
| | | //将bean转为map,mybatis统一处理 |
| | | List<Map<String, String>> maps = new ArrayList<>(); |
| | | try { |
| | | baseModels.stream().forEach(baseModel->{ |
| | | String oid=baseModel.getOid(); |
| | | try { |
| | | maps.add(VciBaseUtil.convertBean2Map(baseModel,existFild)); |
| | | } catch (Exception e) { |
| | | throw new VciBaseException("类型转换错误:" + e.getMessage()); |
| | | } |
| | | if(cboMap.containsKey(oid)){ |
| | | CodeAllCode codeAllCode= cboMap.get(oid); |
| | | codeAllCode.setId(baseModel.getId()); |
| | | codeAllCode.setLastModifier(AuthUtil.getUser().getUserName()); |
| | | codeAllCode.setLastModifyTime(new Date()); |
| | | codeAllCode.setLcStatus(baseModel.getLcStatus()); |
| | | newCodeAllCodeList.add(codeAllCode); |
| | | } |
| | | }); |
| | | commonsMapper.updateBatchByBaseModel(listR.getData().get(0).getTableName(), maps); |
| | | codeAllCodeService.saveOrUpdateBatch(newCodeAllCodeList); |
| | | } catch (Exception e) { |
| | | throw new VciBaseException("类型转换错误:" + e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | return R.success("更新成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 获取参照的信息 |
| | | * |
| | | * @param referConfigVO 参照的配置 |