| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; |
| | | import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO; |
| | | import com.vci.ubcs.code.bo.CodeTemplateAttrSqlBO; |
| | | import com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant; |
| | |
| | | import com.vci.ubcs.code.dto.datapush.BaseModelDTO; |
| | | import com.vci.ubcs.code.entity.*; |
| | | import com.vci.ubcs.code.enumpack.*; |
| | | import com.vci.ubcs.code.mapper.CodeAllCodeMapper; |
| | | import com.vci.ubcs.code.mapper.CodeOsbtmtypeMapper; |
| | | import com.vci.ubcs.code.mapper.CodeWupinMapper; |
| | | import com.vci.ubcs.code.mapper.CommonsMapper; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.stream.Collectors; |
| | |
| | | * @date 2022-2-22 |
| | | */ |
| | | @Service |
| | | public class MdmEngineServiceImpl extends ServiceImpl<CodeWupinMapper, CodeWupinEntity> implements MdmEngineService { |
| | | public class MdmEngineServiceImpl extends ServiceImpl<CodeWupinMapper, CodeWupin> implements MdmEngineService { |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Autowired |
| | | private ICodeClassifyTemplateButtonService templateButtonService; |
| | | |
| | | @Autowired |
| | | private ICodeClassifyTemplateAttrService codeClassifyTemplateAttrService; |
| | | // /** |
| | | // * 用户查询的服务,需要问一下是否需要重写,使用查询此平台的用户表 |
| | | // */ |
| | |
| | | switchDateAttrOnOrder(templateVO, orderDTO); |
| | | //9.生成编码的信息 |
| | | // ClientBusinessObject cbo = boService.createCBOByBtmName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()); |
| | | CodeWupinEntity cbo = createCBOByBtmName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()); |
| | | CodeWupin cbo = createCBOByBtmName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()); |
| | | // //默认的属性都不用从前端拷贝 |
| | | // //设置编码需要的默认属性的内容 |
| | | copyValueToCBO(classifyFullInfo, cbo, orderDTO, templateVO, false); |
| | | // //TODO:因为默认的属性都不拷贝,目前集团码叫name,并没有从DTO拷贝到cbo里。增加一个单独处理,以后再看要不要调整 |
| | | cbo.setName(orderDTO.getName() == null ? "" : orderDTO.getName()); |
| | | // //end -- modify by lihang @20220407 |
| | | List<CodeWupinEntity> cboList = new ArrayList<>(); |
| | | List<CodeWupin> cboList = new ArrayList<>(); |
| | | |
| | | //备注 |
| | | cbo.setDescription(orderDTO.getDescription()); |
| | |
| | | |
| | | |
| | | List<String> charList = new ArrayList<>(); |
| | | for (CodeWupinEntity wupinEntity : cboList) { |
| | | for (CodeWupin wupinEntity : cboList) { |
| | | charList.add(wupinEntity.getId()); |
| | | } |
| | | batchSaveSelectChar(templateVO, charList); |
| | |
| | | * @param templateVO 模板的显示对象 |
| | | * @param edit 是否为修改 |
| | | */ |
| | | private void copyValueToCBO(CodeClassifyFullInfoBO classifyFullInfo, CodeWupinEntity cbo, |
| | | private void copyValueToCBO(CodeClassifyFullInfoBO classifyFullInfo, CodeWupin cbo, |
| | | CodeOrderDTO orderDTO, CodeClassifyTemplateVO templateVO, |
| | | boolean edit) { |
| | | String fullPath = ""; |
| | |
| | | * @throws VciBaseException 初始化出错的是会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeWupinEntity createCBOByBtmName(String btmName) |
| | | public CodeWupin createCBOByBtmName(String btmName) |
| | | throws VciBaseException { |
| | | if(btmName!=null){ |
| | | btmName = btmName.trim().toLowerCase(); |
| | |
| | | CodeOsbtmtypeEntity btmTypeVO = codeOsbtmtypeMapper.selectOne(btmWrapper); |
| | | // OsBtmTypeVO btmTypeVO = btmService.getBtmById(boName); |
| | | String userName = AuthUtil.getUser().getUserName(); |
| | | CodeWupinEntity wupinEntity = new CodeWupinEntity(); |
| | | CodeWupin wupinEntity = new CodeWupin(); |
| | | wupinEntity.setOid(null); |
| | | // bo.setRevisionid((new ObjectUtility()).getNewObjectID36()); |
| | | // bo.setNameoid((new ObjectUtility()).getNewObjectID36()); |
| | |
| | | //找业务类型,然后使用主键去获取数据库里的数据 |
| | | // List<ClientBusinessObject> cbos = boService.queryCBO(classifyFullInfo.getTopClassifyVO().getBtmtypeid(), WebUtil.getOidQuery(orderDTO.getOid())); |
| | | |
| | | QueryWrapper<CodeWupinEntity> btmWrapper = new QueryWrapper<>(); |
| | | QueryWrapper<CodeWupin> btmWrapper = new QueryWrapper<>(); |
| | | btmWrapper.eq("OID",orderDTO.getOid()); |
| | | CodeWupinEntity cbo = codeWupinMapper.selectOne(btmWrapper); |
| | | CodeWupin cbo = codeWupinMapper.selectOne(btmWrapper); |
| | | |
| | | // CodeClstemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid()); |
| | | // CodeRuleVO ruleVO = ruleService.getObjectHasSecByOid(orderDTO.getCodeRuleOid()); |
| | |
| | | oidCollection.addAll(strings); |
| | | } |
| | | |
| | | List<CodeWupinEntity> cboList = codeWupinMapper.selectBatchIds(oidCollection); |
| | | List<CodeWupin> cboList = codeWupinMapper.selectBatchIds(oidCollection); |
| | | // List<ClientBusinessObject> cboList = new ArrayList<>(); |
| | | // oidCollection.stream().forEach(oids -> { |
| | | // Map<String, String> conditionMap = new HashMap<>(); |
| | |
| | | if (CollectionUtils.isEmpty(cboList)) { |
| | | throw new VciBaseException("数据全部在系统中不存在"); |
| | | } |
| | | List<CodeWupinEntity> editCBOs = cboList.stream().filter(s -> !CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(s.getLcStatus())).collect(Collectors.toList()); |
| | | List<CodeWupin> editCBOs = cboList.stream().filter(s -> !CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(s.getLcStatus())).collect(Collectors.toList()); |
| | | if (!CollectionUtils.isEmpty(editCBOs)) { |
| | | CodeWupinEntity cbo = editCBOs.get(0); |
| | | CodeWupin cbo = editCBOs.get(0); |
| | | throw new VciBaseException("编码为{0}等共{1}条数据的状态不是[{2}],不允许删除", new String[]{cbo.getId(), String.valueOf(editCBOs.size()), CodeDefaultLC.EDITING.getText()}); |
| | | } |
| | | |
| | | //只能删除自己创建的数据 |
| | | String userId = AuthUtil.getUser().getUserName(); |
| | | for (CodeWupinEntity clientBusinessObject:cboList){ |
| | | for (CodeWupin clientBusinessObject:cboList){ |
| | | String creator = clientBusinessObject.getCreator(); |
| | | if(!userId.equalsIgnoreCase(creator)){ |
| | | throw new VciBaseException("编码为"+clientBusinessObject.getId()+"的数据不是当前用户创建,不能删除!"); |
| | |
| | | public R markDataPassing(String oid, String btmName, Boolean pass) { |
| | | VciBaseUtil.alertNotNull(oid, "业务数据主键", btmName, "业务类型", pass, "标记类型"); |
| | | boolean flag = false; |
| | | // try { |
| | | // ClientBusinessObjectOperation operation = new ClientBusinessObjectOperation(); |
| | | try { |
| | | // QueryWrapper<CodeWupinEntity> wrapper = new QueryWrapper<>(); |
| | | // wrapper.eq("oid",oid); |
| | | CodeWupin data = baseMapper.selectById(oid); |
| | | // ClientBusinessObjectOperation operation = new ClientBusinessObjectOperation(); |
| | | // ClientBusinessObject data = operation.readBusinessObjectById(oid, btmName); |
| | | // if (data == null || StringUtils.isBlank(data.getOid())) { |
| | | // return BaseResult.fail(DATA_OID_NOT_EXIST); |
| | | // } |
| | | // data.setAttributeValue("passing", String.valueOf(pass)); |
| | | if (data == null || StringUtils.isBlank(data.getOid())) { |
| | | return R.fail(DATA_OID_NOT_EXIST); |
| | | } |
| | | data.setPassing(String.valueOf(pass)); |
| | | flag = SqlHelper.retBool(baseMapper.updateById(data)); |
| | | // flag = operation.updateBuinessObject(data); |
| | | // } catch (VCIError e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (flag) { |
| | | return R.success("标记成功!"); |
| | | } else { |
| | |
| | | } |
| | | List<String> oidList = VciBaseUtil.str2List(conditionMap.get("oid")); |
| | | Map<String, String> oidMap = new HashMap<>(); |
| | | QueryWrapper<CodeWupin> wrapper = new QueryWrapper(); |
| | | if (conditionMap.get("oid").contains(",")) { |
| | | oidMap.put("oid", QueryOptionConstant.IN +"("+ VciBaseUtil.toInSql(oidList.toArray(new String[0])) + ")"); |
| | | // oidMap.put("oid", QueryOptionConstant.IN +"("+ VciBaseUtil.toInSql(oidList.toArray(new String[0])) + ")"); |
| | | wrapper.in("oid",oidList); |
| | | } else { |
| | | oidMap.put("oid", conditionMap.get("oid")); |
| | | // oidMap.put("oid", conditionMap.get("oid")); |
| | | wrapper.in("oid",conditionMap.get("oid")); |
| | | } |
| | | if (CollectionUtils.isEmpty(oidMap)) { |
| | | throw new VciBaseException("业务数据主键不能为空"); |
| | | } |
| | | // List<ClientBusinessObject> cbos = boService.queryCBO(btmType, oidMap); |
| | | // if (CollectionUtils.isEmpty(cbos)) { |
| | | // throw new VciBaseException("未找到业务数据"); |
| | | // } |
| | | // ClientBusinessObject cbo = cbos.get(0); |
| | | // String templateOid = cbo.getAttributeValue("CODETEMPLATEOID"); |
| | | List<CodeWupin> cbos = baseMapper.selectList(wrapper); |
| | | if (CollectionUtils.isEmpty(cbos)) { |
| | | throw new VciBaseException("未找到业务数据"); |
| | | } |
| | | CodeWupin cbo = cbos.get(0); |
| | | String templateOid = cbo.getCodetemplateoid(); |
| | | // Map<String, String> templateOidMap = new HashMap<>(); |
| | | // templateOidMap.put("oid", templateOid); |
| | | |
| | | QueryWrapper<CodeClassifyTemplate> codeClassifyTemplateWrapper = new QueryWrapper<>(); |
| | | codeClassifyTemplateWrapper.eq("oid", templateOid); |
| | | List<CodeClassifyTemplate> templateDOList = templateService.list(codeClassifyTemplateWrapper); |
| | | |
| | | // List<CodeClassifyTemplate> templateDOList = boService.queryObject(CodeClassifyTemplate.class, templateOidMap); |
| | | QueryWrapper<CodeClassifyTemplateAttr> codeClassifyTemplateAttrWrapper = new QueryWrapper<>(); |
| | | codeClassifyTemplateAttrWrapper.eq("CLASSIFYTEMPLATEOID", templateOid); |
| | | // templateOidMap.clear(); |
| | | // templateOidMap.put("CLASSIFYTEMPLATEOID",templateOid); |
| | | // List<CodeClassifyTemplateAttr> attrDOList = boService.queryObject(CodeClassifyTemplateAttr.class, templateOidMap); |
| | | // if (CollectionUtils.isEmpty(templateDOList)) { |
| | | // logger.error("找不到业务数据关联的模板,模板主键:" + templateOid); |
| | | // throw new VciBaseException("找不到业务数据关联的模板"); |
| | | // } |
| | | // CodeClassifyTemplateVO templateVO = templateService.codeClassifyTemplateDO2VO(templateDOList.get(0)); |
| | | // templateVO.setAttributes(templateAttrService.codeClassifyTemplateAttrDO2VOs(attrDOList)); |
| | | // try { |
| | | // if (oidList.size() > 1){ |
| | | // DataGrid<Map<String,String>> allDataGrid = new DataGrid<>(); |
| | | // List<Map<String,String>> allData = new ArrayList<>(); |
| | | // oidList.forEach(oid -> { |
| | | // Map<String,String> condition = new HashMap<>(); |
| | | // condition.put("oid",oid); |
| | | // DataGrid<Map<String, String>> dataGrid = queryGrid(btmType, templateVO, condition, pageHelper); |
| | | // allData.addAll(dataGrid.getData()); |
| | | // }); |
| | | // allDataGrid.setData(allData); |
| | | // return allDataGrid; |
| | | // }else { |
| | | // return queryGrid(btmType, templateVO, conditionMap, pageHelper); |
| | | // } |
| | | // } catch (Exception e) { |
| | | // System.out.println(e.getMessage()); |
| | | List<CodeClassifyTemplateAttr> attrDOList = codeClassifyTemplateAttrService.list(codeClassifyTemplateAttrWrapper); |
| | | // boService.queryObject(CodeClassifyTemplateAttr.class, templateOidMap); |
| | | if (CollectionUtils.isEmpty(templateDOList)) { |
| | | logger.error("找不到业务数据关联的模板,模板主键:" + templateOid); |
| | | throw new VciBaseException("找不到业务数据关联的模板"); |
| | | } |
| | | CodeClassifyTemplateVO templateVO = templateService.codeClassifyTemplateDO2VO(templateDOList.get(0)); |
| | | templateVO.setAttributes(codeClassifyTemplateAttrService.codeClassifyTemplateAttrDO2VOs(attrDOList)); |
| | | try { |
| | | if (oidList.size() > 1){ |
| | | DataGrid<Map<String,String>> allDataGrid = new DataGrid<>(); |
| | | List<Map<String,String>> allData = new ArrayList<>(); |
| | | oidList.forEach(oid -> { |
| | | Map<String,String> condition = new HashMap<>(); |
| | | condition.put("oid",oid); |
| | | DataGrid<Map<String, String>> dataGrid = queryGrid(btmType, templateVO, condition, pageHelper); |
| | | allData.addAll(dataGrid.getData()); |
| | | }); |
| | | allDataGrid.setData(allData); |
| | | return allDataGrid; |
| | | }else { |
| | | return queryGrid(btmType, templateVO, conditionMap, pageHelper); |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println(e.getMessage()); |
| | | return null; |
| | | // } |
| | | } |
| | | } |
| | | /** |
| | | * 使用分类的主键获取表格的定义 |
| | |
| | | kv.setValue(buttonVO.getClassifyButtonOidName()); |
| | | kv.setAttributes(VciBaseUtil.objectToMap(buttonVO)); |
| | | buttons.add(kv); |
| | | optionJsMap.put(buttonVO.getId(), buttonVO.getButtonVO().getExecutejs()); |
| | | optionJsMap.put(buttonVO.getId(), buttonVO.getButtonVO().getExecuteJs()); |
| | | }); |
| | | optionFieldVO.setOptionJsMap(optionJsMap); |
| | | uiInfoVO.getTableDefineVO().getCols().get(0).add(optionFieldVO); |