| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vci.ubcs.code.entity.DockingPreAttrMapping; |
| | | import com.vci.ubcs.code.entity.DockingPreAttrRange; |
| | | import com.vci.ubcs.code.entity.DockingPreMetaAttr; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.vci.ubcs.code.constant.MdmBtmTypeConstant; |
| | | import com.vci.ubcs.code.entity.*; |
| | | import com.vci.ubcs.code.feign.IMdmInterJtClient; |
| | | import com.vci.ubcs.code.mapper.DockingPreAttrMappingMapper; |
| | | import com.vci.ubcs.code.service.IDockingPreAttrMappingService; |
| | | import com.vci.ubcs.code.service.IDockingPreAttrRangeService; |
| | | import com.vci.ubcs.code.service.IDockingPreMetaAttrService; |
| | | import com.vci.ubcs.code.service.*; |
| | | import com.vci.ubcs.code.vo.pagemodel.BaseModelVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.DockingPreAttrMappingVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.DockingPreAttrRangeVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.group.DockingGroupDataVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.group.DockingMainData; |
| | | import com.vci.ubcs.code.vo.webserviceModel.group.DockingViewVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.group.ResultDataVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.group.result.DataObjectVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.group.result.DataVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.group.result.ResultDataObject; |
| | | import com.vci.ubcs.code.wrapper.DockingPreAttrMappingWrapper; |
| | | import com.vci.ubcs.code.wrapper.DockingPreAttrRangeWrapper; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.revision.model.BaseModel; |
| | | import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; |
| | | import com.vci.ubcs.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /*** |
| | |
| | | */ |
| | | @Service |
| | | public class DockingPreAttrMappingServiceImpl extends ServiceImpl<DockingPreAttrMappingMapper, DockingPreAttrMapping> implements IDockingPreAttrMappingService { |
| | | |
| | | |
| | | |
| | | @Value("${docking.apply.unitCode:410-MDM}") |
| | | public String dockingApplyUnitCode; |
| | | @Autowired(required = false) |
| | | private IMdmInterJtClient mdmInterJtClient; |
| | | |
| | | /*** |
| | | * 集团分类属性属性映射配置服务 |
| | | */ |
| | | @Autowired(required = false) |
| | | DockingPreAttrMappingMapper dockingPreAttrMappingMapper; |
| | | private DockingPreAttrMappingMapper dockingPreAttrMappingMapper; |
| | | |
| | | /*** |
| | | * 业务数据属性服务 |
| | | */ |
| | | @Autowired(required = false) |
| | | private MdmEngineService mdmEngineService; |
| | | |
| | | /*** |
| | | * 集团属性服务 |
| | | */ |
| | | @Autowired(required = false) |
| | | IDockingPreMetaAttrService dockingPreMetaAttrService; |
| | | private IDockingPreMetaAttrService dockingPreMetaAttrService; |
| | | /*** |
| | | * 属性取值范围服务 |
| | | */ |
| | | @Autowired(required = false) |
| | | IDockingPreAttrRangeService dockingPreAttrRangeService; |
| | | private IDockingPreAttrRangeService dockingPreAttrRangeService; |
| | | |
| | | |
| | | /*** |
| | | * 集团分类服务 |
| | | */ |
| | | @Autowired(required = false) |
| | | private IDockingPreClassifyService dockingPreClassifyService; |
| | | |
| | | /*** |
| | | * 申请单服务 |
| | | */ |
| | | @Autowired(required = false) |
| | | private IDockingPreApplyFormService dockingPreApplyFormService; |
| | | |
| | | |
| | | /*** |
| | | * 模型视图单服务 |
| | | */ |
| | | @Autowired(required = false) |
| | | private IDockingPreViewModelService dockingPreViewModelService; |
| | | |
| | | |
| | | /*** |
| | | * 根据主数据分类主键获取分类信息配置 |
| | | * @param codeClassifyId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DockingPreAttrMappingVO> getdockingAttrMappingsByCodeclassId(String codeClassifyId) { |
| | | public List<DockingPreAttrMappingVO> getDockingAttrMappingsByCodeClassifyId(String codeClassifyId,String sourceClassifyId) { |
| | | VciBaseUtil.alertNotNull(codeClassifyId,"主数据分类主键"); |
| | | //VciBaseUtil.alertNotNull(sourceClassifyId,"集团分类主键"); |
| | | //首先获取分类模板属性,然后与属性配置坐比较,以防被有增删属性的可能 |
| | | List<DockingPreMetaAttr> dockingPreMetaAttrList= dockingPreMetaAttrService.selectByWrapper(Wrappers.<DockingPreMetaAttr>query().lambda().eq(DockingPreMetaAttr::getSourceClassifyId,codeClassifyId)); |
| | | List<DockingPreAttrMapping> dockingPreAttrMappings=this.selectByWrapper(Wrappers.<DockingPreAttrMapping>query().lambda().eq(DockingPreAttrMapping::getSourceClassifyId, codeClassifyId)); |
| | | List<DockingPreMetaAttr> dockingPreMetaAttrList= dockingPreMetaAttrService.selectByWrapper(Wrappers.<DockingPreMetaAttr>query().lambda().eq(DockingPreMetaAttr::getSourceClassifyId,sourceClassifyId)); |
| | | List<DockingPreAttrMapping> dockingPreAttrMappings=this.selectByWrapper(Wrappers.<DockingPreAttrMapping>query().lambda().eq(DockingPreAttrMapping::getSourceClassifyId, sourceClassifyId).eq(DockingPreAttrMapping::getTargetClassifyId, codeClassifyId)); |
| | | Map<String/**属性主键**/, DockingPreAttrMapping> dockingPreAttrMappingMap = dockingPreAttrMappings.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getMetaListId(), t -> t)); |
| | | |
| | | List<DockingPreAttrMapping> newDockingPreAttrMappingList=new ArrayList<>(); |
| | |
| | | if(dockingPreAttrMappingMap.containsKey(attrOid)){ |
| | | dockingPreAttrMapping= dockingPreAttrMappingMap.get(attrOid); |
| | | }else{ |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(dockingPreAttrMapping, MdmBtmTypeConstant.DOCKING_PRE_JAPPLYFORM); |
| | | dockingPreAttrMapping.setMetaListId(dockingPreMetaAttr.getOid());//属性主键 |
| | | dockingPreAttrMapping.setSourceAttrKey(dockingPreMetaAttr.getEnglishName());//英文名称 |
| | | dockingPreAttrMapping.setSourceAttrName(dockingPreMetaAttr.getChineseName());//中文名称 |
| | |
| | | } |
| | | return dockingPreAttrMappingVOList; |
| | | } |
| | | private String code=""; |
| | | |
| | | private String msg=""; |
| | | |
| | | /*** |
| | | * 像集团申请集团码 |
| | | * @param oids |
| | | * @param btmName |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public R applyGroupCode(String oids, String btmName) throws VciBaseException { |
| | | List<BaseModel> updateCbos=new ArrayList<BaseModel>(); |
| | | List<DockingPreApplyForm> dockingPreAttrMappings=new ArrayList<>(); |
| | | VciBaseUtil.alertNotNull(oids,"选择的数据"); |
| | | VciBaseUtil.alertNotNull(btmName,"业务类型"); |
| | | //List<BaseModelVO> codeWupins=mdmEngineService.listByIds(VciBaseUtil.str2List(oids)); |
| | | List<BaseModelVO> dataModelList = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(dataModelList)) { |
| | | DockingGroupDataVO dockingGroupDataVO = new DockingGroupDataVO(); |
| | | //申请单和申请单对象关系 |
| | | Map<String, DockingPreApplyForm> addDockingPreApplyFormMap = new HashMap<String, DockingPreApplyForm>(); |
| | | Map<String, DockingPreApplyForm> editDockingPreApplyFormMap = new HashMap<String, DockingPreApplyForm>(); |
| | | Map<String, BaseModelVO> baseModelVOMap = new HashMap<String, BaseModelVO>(); |
| | | //组织数据 |
| | | dockingGroupDataVO = queryApplycodeDataObjects(dataModelList, addDockingPreApplyFormMap, editDockingPreApplyFormMap, baseModelVOMap); |
| | | ResultDataObject resultDataObject = mdmInterJtClient.receiveAddApply(dockingGroupDataVO); |
| | | code = resultDataObject.getCode(); |
| | | msg = resultDataObject.getMsg(); |
| | | if ("1".equals(resultDataObject.getCode())) {//结果正确的情况 |
| | | List<DataObjectVO> dataObjectVOList = resultDataObject.getData(); |
| | | dataObjectVOList.stream().forEach(dataObject -> { |
| | | boolean isEditDatas = false; |
| | | String code2 = dataObject.getCode(); |
| | | DataVO data2 = dataObject.getData(); |
| | | String applyId = data2.getApplyId();//申请单id |
| | | String customCoding = StringUtils.isBlank(data2.getCustomCoding()) ? "" : data2.getCustomCoding();//集团码段 |
| | | msg = dataObject.getMsg(); |
| | | if (code2.equals("1")) {//结果正确的情况 |
| | | if (!"".equals(customCoding)) { |
| | | isEditDatas = true; |
| | | } |
| | | } |
| | | //需要修改的申请单数据 |
| | | if (editDockingPreApplyFormMap.containsKey(applyId)) { |
| | | DockingPreApplyForm dockingPreApplyForm = editDockingPreApplyFormMap.get(applyId); |
| | | dockingPreApplyForm.setCode(code2); |
| | | dockingPreApplyForm.setMsg("申请:" + msg); |
| | | dockingPreApplyForm.setGroupCode(customCoding); |
| | | ObjectMapper mp = new ObjectMapper(); |
| | | String writeValueAsString = null; |
| | | try { |
| | | writeValueAsString = mp.writeValueAsString(dataObject); |
| | | dockingPreApplyForm.setContent(writeValueAsString); |
| | | } catch (JsonProcessingException e) { |
| | | } |
| | | } |
| | | //新增的申请单数据 |
| | | if (addDockingPreApplyFormMap.containsKey(applyId)) { |
| | | DockingPreApplyForm dockingPreApplyForm = addDockingPreApplyFormMap.get(applyId); |
| | | dockingPreApplyForm.setCode(code2); |
| | | dockingPreApplyForm.setMsg("申请:" + msg); |
| | | dockingPreApplyForm.setGroupCode(customCoding); |
| | | ObjectMapper mp = new ObjectMapper(); |
| | | String writeValueAsString = null; |
| | | try { |
| | | writeValueAsString = mp.writeValueAsString(dataObject); |
| | | dockingPreApplyForm.setContent(writeValueAsString); |
| | | } catch (JsonProcessingException e) { |
| | | } |
| | | } |
| | | //如果有集团码则更新数据 |
| | | if (isEditDatas) { |
| | | if (baseModelVOMap.containsKey(applyId)) { |
| | | BaseModelVO baseModelVO = baseModelVOMap.get(applyId); |
| | | BaseModel baseModel = new BaseModel(); |
| | | BeanUtilForVCI.copyDeclaredIgnoreCase(baseModelVO, baseModel); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(baseModel); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(baseModel); |
| | | baseModelVO.setId(customCoding); |
| | | updateCbos.add(baseModel);//更新数据集团code |
| | | } |
| | | } |
| | | }); |
| | | } else { |
| | | editDockingPreApplyFormMap.forEach((key, dockingPreApplyForm) -> { |
| | | dockingPreApplyForm.setCode("2"); |
| | | dockingPreApplyForm.setMsg("申请:" + msg); |
| | | dockingPreApplyForm.setContent(""); |
| | | dockingPreApplyForm.setGroupCode(""); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(dockingPreApplyForm); |
| | | }); |
| | | addDockingPreApplyFormMap.forEach((key, dockingPreApplyForm) -> { |
| | | dockingPreApplyForm.setCode("2"); |
| | | dockingPreApplyForm.setMsg("申请:" + msg); |
| | | dockingPreApplyForm.setContent(""); |
| | | dockingPreApplyForm.setGroupCode(""); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(dockingPreApplyForm, MdmBtmTypeConstant.DOCKING_PRE_JAPPLYFORM); |
| | | }); |
| | | } |
| | | if (editDockingPreApplyFormMap.size() > 0) { |
| | | dockingPreAttrMappings.addAll(editDockingPreApplyFormMap.values());//添加申请单数据 |
| | | } |
| | | if (addDockingPreApplyFormMap.size() > 0) { |
| | | dockingPreAttrMappings.addAll(addDockingPreApplyFormMap.values());//需要修改的申请单数据 |
| | | } |
| | | //保存表单数据 |
| | | dockingPreApplyFormService.saveOrUpdateBatch(dockingPreAttrMappings); |
| | | //mdmEngineService.saveBatch(updateCbos);//保存数据 |
| | | } |
| | | return R.success("申请接口调用成功"); |
| | | } |
| | | |
| | | /*** |
| | | * 对象转换 |
| | |
| | | } |
| | | return dockingPreAttrMappingVOList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 组织数据 |
| | | * */ |
| | | private DockingGroupDataVO queryApplycodeDataObjects(List<BaseModelVO> codeWupins,Map<String,DockingPreApplyForm> addDockingPreApplyFormMap,Map<String,DockingPreApplyForm> editDockingPreApplyFormMap,Map<String,BaseModelVO> codeWupinMap) throws VciBaseException{ |
| | | try { |
| | | String curUserName = AuthUtil.getUser().getUserName(); |
| | | //申请的数据 |
| | | List<DockingMainData> mainDataList=new ArrayList<DockingMainData>(); |
| | | for (BaseModelVO dataBusinessObject : codeWupins) { |
| | | String format = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()); |
| | | String codeclsfid = dataBusinessObject.getData().getOrDefault("codeclsfid",""); |
| | | String btmName = dataBusinessObject.getBtmname(); |
| | | String oid = dataBusinessObject.getOid(); |
| | | |
| | | DockingPreApplyForm dockingPreApplyForm = new DockingPreApplyForm(); |
| | | |
| | | String dataOid = dataBusinessObject.getOid(); |
| | | Map<String, String> conditionsMap = new HashMap<String, String>(); |
| | | List<DockingPreApplyForm> applyFormObjects = dockingPreApplyFormService.list(Wrappers.<DockingPreApplyForm>query().lambda().eq(DockingPreApplyForm::getDataOid, dataOid).eq(DockingPreApplyForm::getOperationType, "1")); |
| | | String apllyCode = ""; |
| | | if (!CollectionUtils.isEmpty(applyFormObjects)) { |
| | | dockingPreApplyForm = applyFormObjects.get(0); |
| | | apllyCode = dockingPreApplyForm.getId(); |
| | | editDockingPreApplyFormMap.put(apllyCode, dockingPreApplyForm);//申请单和申请单对象关系 |
| | | } else { |
| | | apllyCode = dockingApplyUnitCode + "-" + format; |
| | | dockingPreApplyForm.setId(apllyCode); |
| | | dockingPreApplyForm.setName(""); |
| | | dockingPreApplyForm.setOperationType("2"); |
| | | dockingPreApplyForm.setDescription(dataBusinessObject.getDescription());//获取数据描述信息 |
| | | dockingPreApplyForm.setDataOid(oid); |
| | | dockingPreApplyForm.setDataBtmName(btmName); |
| | | addDockingPreApplyFormMap.put(apllyCode, dockingPreApplyForm);//申请单和申请单对象关系 |
| | | } |
| | | |
| | | codeWupinMap.put(apllyCode, dataBusinessObject);//申请单和对应数据关系 |
| | | conditionsMap = new HashMap<String, String>(); |
| | | conditionsMap.put("jtargetclsfid", codeclsfid);//视图oid |
| | | |
| | | List<DockingPreAttrMapping> dockingPreAttrMappingList = this.selectByWrapper(Wrappers.<DockingPreAttrMapping>query().lambda().eq(DockingPreAttrMapping::getTargetClassifyId, codeclsfid)); |
| | | if (CollectionUtils.isEmpty(dockingPreAttrMappingList)) { |
| | | throw new Exception("根据所选的数据,没有找到对应的集团分类设置,请核对!"); |
| | | } |
| | | String jsourceclsfid = dockingPreAttrMappingList.get(0).getSourceClassifyId(); |
| | | //获取数据模型分类信息 |
| | | DockingPreClassify dockingPreClassify = dockingPreClassifyService.getById(jsourceclsfid); |
| | | DockingMainData mainData = new DockingMainData(); |
| | | mainData.setApplyEntId(dockingApplyUnitCode);//申请单位代码 |
| | | mainData.setApplyId(apllyCode);//申请单号 |
| | | mainData.setClassName(dockingPreClassify.getGetNodeLinkName());//分类名称 |
| | | mainData.setCreateBy(curUserName);// |
| | | mainData.setSecretLevel("内部");//密级,默认为内部 |
| | | mainData.setViewInfos(getviewInfos(dockingPreClassify, dataBusinessObject));//获取视图模型 |
| | | mainDataList.add(mainData); |
| | | } |
| | | //根据数据模型,组织所需要数据 |
| | | DockingGroupDataVO postParameters=new DockingGroupDataVO(); |
| | | postParameters.setSysName("420-CODE");//系统标识 |
| | | postParameters.setMainData(mainDataList);// |
| | | return postParameters; |
| | | } catch (Throwable e) { |
| | | // TODO Auto-generated catch block |
| | | throw new VciBaseException("查询数据出错"+e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取模型视图 |
| | | * @param dockingPreClassify |
| | | * @param dataBusinessObject |
| | | * @throws VciBaseException |
| | | */ |
| | | private List<DockingViewVO>getviewInfos(DockingPreClassify dockingPreClassify,BaseModelVO dataBusinessObject) throws Throwable{ |
| | | List<DockingViewVO> viewInfoList=new ArrayList<>(); |
| | | String jclassOid= dockingPreClassify.getOid(); |
| | | Map<String,String>conditionsMap=new HashMap<String, String>(); |
| | | conditionsMap.put("jsourceclsfid",jclassOid); |
| | | conditionsMap.put("jviewname","编码视图");//申请只传编码视图 |
| | | //根据分类查询模型视图对象 |
| | | List<DockingPreViewModel> dockingPreViewModels= dockingPreViewModelService.list(Wrappers.<DockingPreViewModel>query().lambda().eq(DockingPreViewModel::getSourceClassifyId,jclassOid).eq(DockingPreViewModel::getViewName,"编码视图")); |
| | | for (DockingPreViewModel dockingPreViewModel : dockingPreViewModels) { |
| | | //组织数据属性信息 |
| | | DockingViewVO viewInfo=new DockingViewVO(); |
| | | viewInfo.setViewName(dockingPreViewModel.getViewName());//视图名称 |
| | | viewInfo.setViewValue(getViewValueList(dockingPreViewModel,jclassOid,dataBusinessObject));//视图 |
| | | viewInfoList.add(viewInfo); |
| | | } |
| | | return viewInfoList; |
| | | } |
| | | |
| | | /*** |
| | | * 获取配置信息 |
| | | * @param dockingPreViewModel |
| | | * @param jclassOid |
| | | * @param dataBusinessObject |
| | | * @return |
| | | * @throws VciBaseException |
| | | */ |
| | | private List<Map<String, Object>> getViewValueList(DockingPreViewModel dockingPreViewModel,String jclassOid,BaseModelVO dataBusinessObject) throws Throwable{ |
| | | //构造模型视图数据 |
| | | List<Map<String, Object>> viewValueList=new ArrayList<Map<String,Object>>(); |
| | | String oid = dockingPreViewModel.getOid(); |
| | | Map<String,String> dataValueMap=dataBusinessObject.getData(); |
| | | String codeClassifyId=dataValueMap.get("codeclsfid"); |
| | | Map<String,String>conditionsMap=new HashMap<String, String>(); |
| | | |
| | | |
| | | |
| | | List<DockingPreAttrMapping> dockingPreAttrMappingList = this.selectByWrapper(Wrappers.<DockingPreAttrMapping>query().lambda() |
| | | .eq(DockingPreAttrMapping::getSourceClassifyId, jclassOid).eq(DockingPreAttrMapping::getTargetClassifyId, codeClassifyId)); |
| | | if(CollectionUtils.isEmpty(dockingPreAttrMappingList)) { |
| | | return viewValueList; |
| | | } |
| | | |
| | | Map<String,DockingPreAttrMapping> jintegmappconfigMap=new HashMap<String, DockingPreAttrMapping>(); |
| | | for (DockingPreAttrMapping businessObject : dockingPreAttrMappingList) { |
| | | jintegmappconfigMap.put(businessObject.getSourceAttrKey(), businessObject); |
| | | } |
| | | List<DockingPreMetaAttr> dockingPreMetaAttrList= dockingPreMetaAttrService.selectByWrapper( |
| | | Wrappers.<DockingPreMetaAttr>query().lambda().eq(DockingPreMetaAttr::getViewModelId,dockingPreViewModel.getOid()) |
| | | .eq(DockingPreMetaAttr::getSourceClassifyId,dockingPreViewModel.getSourceClassifyId())); |
| | | |
| | | Map<String,Object> viewValueMap=new HashMap<String,Object>(); |
| | | for (DockingPreMetaAttr dockingPreMetaAttr : dockingPreMetaAttrList) { |
| | | String jenglishname=dockingPreMetaAttr.getEnglishName();////集团配置属性 |
| | | if(jintegmappconfigMap.containsKey(jenglishname)){ |
| | | DockingPreAttrMapping dockingPreAttrMapping=jintegmappconfigMap.get(jenglishname); |
| | | String attrId = dockingPreAttrMapping.getTargetAttrId();//编码属性id |
| | | String jtargetattrkey = dockingPreAttrMapping.getTargetAttrKey();//编码属性id |
| | | Object newVaue=null; |
| | | if(StringUtils.isNotBlank(jtargetattrkey)){ |
| | | getAttrRange(dockingPreMetaAttr);//获取字段取值范围 |
| | | String value=dataValueMap.get(jtargetattrkey)==null?"":dataValueMap.getOrDefault(jtargetattrkey,""); |
| | | newVaue = getVaue(dockingPreMetaAttr, value); |
| | | }else{ |
| | | newVaue = getVaue(dockingPreMetaAttr, ""); |
| | | } |
| | | if(newVaue==null||"".equals(newVaue)){ |
| | | newVaue= dockingPreMetaAttr.getDefaultValue(); |
| | | } |
| | | viewValueMap.put(jenglishname, newVaue); |
| | | } |
| | | } |
| | | |
| | | viewValueList.add(viewValueMap); |
| | | return viewValueList; |
| | | } |
| | | |
| | | /*** |
| | | * 获取属性枚举映射配置 |
| | | */ |
| | | Map<String,Map<String,DockingPreAttrRange>> attrRangeMap=new HashMap<String, Map<String,DockingPreAttrRange>>(); |
| | | private void getAttrRange(DockingPreMetaAttr jmetaatter) throws Throwable{ |
| | | |
| | | String jmetalistoid = jmetaatter.getOid(); |
| | | if(attrRangeMap.containsKey(jmetalistoid)) { |
| | | return; |
| | | } |
| | | Map<String,String>conditionsMap=new HashMap<String, String>(); |
| | | conditionsMap.put("jmetalistid", jmetalistoid);//视图oid |
| | | List<DockingPreAttrRange> dockingPreAttrRangeList = dockingPreAttrRangeService.selectByWrapper(Wrappers.<DockingPreAttrRange>query().lambda().eq(DockingPreAttrRange::getMetaListId, jmetalistoid)); |
| | | if (CollectionUtils.isEmpty(dockingPreAttrRangeList)) { |
| | | return; |
| | | } |
| | | Map<String, DockingPreAttrRange> rangeMap = new HashMap<String, DockingPreAttrRange>(); |
| | | rangeMap = dockingPreAttrRangeList.stream().collect(Collectors.toMap(s -> s.getNumTextValue(), t -> t, (o1, o2) -> o2)); |
| | | attrRangeMap.put(jmetalistoid, rangeMap); |
| | | |
| | | } |
| | | /**** |
| | | * 值类型转换 |
| | | * @param jmetaatter |
| | | * @param value |
| | | * @return |
| | | * @throws Throwable |
| | | */ |
| | | private Object getVaue(DockingPreMetaAttr jmetaatter,String value) throws Throwable{ |
| | | //jmetadatatype 元数据类型(1 字符型, 2 整型, 3 长整型, 4 单精度, 5 双精度,6 日期型, 7 时间型, 8 布尔型, 9 文件, 10复合型) |
| | | int jmetadatatype = jmetaatter.getMetaDataType(); |
| | | String jmetalistoid = jmetaatter.getOid(); |
| | | Map<String, DockingPreAttrRange> rangeMap=new HashMap<String, DockingPreAttrRange>(); |
| | | if(attrRangeMap.containsKey(jmetalistoid)){ |
| | | rangeMap = attrRangeMap.get(jmetalistoid); |
| | | if(rangeMap.containsKey(value)){ |
| | | DockingPreAttrRange dockingPreAttrRange = rangeMap.get(value); |
| | | value=dockingPreAttrRange.getNumText();//将编码属性域值转换成集团对应的域值 |
| | | } |
| | | } |
| | | |
| | | if(jmetadatatype==1){//1 字符型 |
| | | return StringUtils.isBlank(value)?"":value; |
| | | }else if(jmetadatatype==2){//2 整型 |
| | | return StringUtils.isBlank(value)?null:Integer.parseInt(value); |
| | | }else if(jmetadatatype==3){//3 长整型 |
| | | return StringUtils.isBlank(value)?null:Long.parseLong(value); |
| | | }else if(jmetadatatype==4){//4 单精度, |
| | | return StringUtils.isBlank(value)?null:Float.parseFloat(value); |
| | | }else if(jmetadatatype==5){// 5 双精度 |
| | | return StringUtils.isBlank(value)?null:Double.parseDouble(value); |
| | | }else if(jmetadatatype==6){//6 日期型 |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd"); |
| | | if(StringUtils.isBlank(value)) { |
| | | return null; |
| | | }else { |
| | | try { |
| | | return simpleDateFormat.parse(value); |
| | | } catch (ParseException e) { |
| | | throw new VciBaseException("date", new String[]{"日期格式转换错误"}); |
| | | } |
| | | } |
| | | }else if(jmetadatatype==7){//7 时间型 |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss"); |
| | | if(StringUtils.isBlank(value)) { |
| | | return null; |
| | | }else{ |
| | | try { |
| | | return simpleDateFormat.parse(value); |
| | | } catch (ParseException e) { |
| | | throw new VciBaseException("date", new String[]{"日期格式转换错误"}); |
| | | } |
| | | } |
| | | }else if(jmetadatatype==8){//8 布尔型 |
| | | return value; |
| | | }else if(jmetadatatype==9){//9 文件, |
| | | return value; |
| | | }else if(jmetadatatype==10){//10复合型 |
| | | return value;//符合型是什么东东如何处理 |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | } |