| | |
| | | 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; |
| | |
| | | |
| | | 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 参照的配置 |