1428594221
2023-06-27 35ad24a24e91e1996ef9e97c2714bfbc7a32cdfa
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java
@@ -26,11 +26,13 @@
import com.vci.ubcs.code.wrapper.CodeBasicSecWrapper;
import com.vci.ubcs.omd.cache.EnumCache;
import com.vci.ubcs.omd.enums.EnumEnum;
import com.vci.ubcs.starter.enumpack.CodeTableNameEnum;
import com.vci.ubcs.starter.exception.VciBaseException;
import com.vci.ubcs.starter.revision.service.RevisionModelUtil;
import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil;
import com.vci.ubcs.starter.util.UBCSCondition;
import com.vci.ubcs.starter.util.UBCSSqlKeyword;
import com.vci.ubcs.starter.web.enumpck.NewAppConstantEnum;
import com.vci.ubcs.starter.web.enumpck.OsCodeFillTypeEnum;
import com.vci.ubcs.starter.web.pagemodel.BladeQueryObject;
import com.vci.ubcs.starter.web.pagemodel.KeyValue;
@@ -40,6 +42,7 @@
import com.vci.ubcs.starter.web.util.WebUtil;
import com.vci.ubcs.system.entity.DictBiz;
import com.vci.ubcs.system.feign.IDictBizClient;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
@@ -120,15 +123,19 @@
    * @throws VciBaseException 查询条件和分页出错的时候会抛出异常
    */
   @Override
   public IPage<CodeBasicSecVO> gridCodeBasicSec(Query query, Map<String,Object> conditionMap) throws VciBaseException {
      if(Func.isEmpty(conditionMap.get("pkCodeRule")) && Func.isEmpty(conditionMap.get("t.pkCodeRule_equal")) ){
   public IPage<CodeBasicSecVO> gridCodeBasicSec(Query query, Map<String,Object> conditionMap) throws ServiceException {
      if(Func.isEmpty(Func.isEmpty(conditionMap.get(CodeTableNameEnum.PL_CODE_BASICSEC.getText()+".pkCodeRule")))){
         return null;
      }
      // 联表查询
      MPJLambdaWrapper<CodeBasicSec> mpjLambdaWrapper = UBCSCondition.getMPJLambdaWrapper(conditionMap, CodeBasicSec.class)
      // 联表查询 ,设置表别名,表别名默认就采用表名小写,配置高级查询的时候就需要根据这个来对where条件进行配置
      MPJLambdaWrapper<CodeBasicSec> mpjLambdaWrapper = new MPJLambdaWrapper<>(CodeBasicSec.class, CodeTableNameEnum.PL_CODE_BASICSEC.getText())
         .selectAll(CodeBasicSec.class)
         .selectAs(CodeClassify::getName, CodeBasicSec::getReferCodeClassifyOidName)
         .leftJoin(CodeClassify.class, CodeClassify::getOid, CodeBasicSec::getReferCodeClassifyOid);
         .leftJoin(CodeClassify.class, CodeTableNameEnum.PL_CODE_CLASSIFY.getText(), CodeClassify::getOid, CodeBasicSec::getReferCodeClassifyOid)
         .leftJoin(CodeBasicSec.class,CodeTableNameEnum.PL_CODE_BASICSEC.getText()+1,CodeBasicSec::getOid,CodeBasicSec::getParentClassifySecOid
            ,ext->ext.selectAs(CodeBasicSec::getName,CodeBasicSec::getParentClassifySecText));
      // 添加where条件
      UBCSSqlKeyword.buildConditionByAs(conditionMap,mpjLambdaWrapper,CodeTableNameEnum.PL_CODE_BASICSEC.getText());
      IPage<CodeBasicSec> codeBasicSecIPage = codeBasicSecMapper.selectPage(UBCSCondition.getPage(query), mpjLambdaWrapper);
      return CodeBasicSecWrapper.build().pageVO(codeBasicSecIPage);
   }
@@ -140,7 +147,7 @@
    */
   @Override
   @Transactional(rollbackFor = Exception.class)
   public boolean batchDeleteSecByCodeRuleOid(String codeRuleOid) {
   public boolean batchDeleteSecByCodeRuleOid(String codeRuleOid) throws ServiceException {
      VciBaseUtil.alertNotNull(codeRuleOid,"编码规则主键");
      // 1、通过pkcoderule作为条件,先查询要删除基础码段
      List<CodeBasicSec> deleteList = this.codeBasicSecMapper.selectList(Wrappers.<CodeBasicSec>query().eq("pkcoderule", codeRuleOid));
@@ -183,7 +190,7 @@
    * @return 有空的则传key-属性名 value-字段含义,没有空的则传 key-success value-true
    */
   @Override
   public KeyValue checkAttrNullableBySecType(CodeBasicSecDTO codeBasicSecDTO) {
   public KeyValue checkAttrNullableBySecType(CodeBasicSecDTO codeBasicSecDTO) throws ServiceException {
      VciBaseUtil.alertNotNull(codeBasicSecDTO.getSecType(), "码段分类");
      String secType = codeBasicSecDTO.getSecType();
      HashMap<String, String> attrMap = JSONObject.parseObject(JSONObject.toJSONString(codeBasicSecDTO), HashMap.class);
@@ -346,7 +353,7 @@
    * @param secType 码段类型
    * @return 不可为空的字段集合
    */
   private Map<String, String> getNotNullableAttr(String secType) {
   private Map<String, String> getNotNullableAttr(String secType) throws ServiceException {
      Map<String, String> attrMap = new HashMap<>();
      if (CodeSecTypeEnum.CODE_ATTR_SEC.getValue().equalsIgnoreCase(secType)) {
         attrMap.put("name", "属性码段名称");
@@ -496,27 +503,30 @@
    */
   @Override
   @Transactional(rollbackFor = Exception.class)
   public R cloneCodeBasicSec(List<String> oidList, String pkCodeRule) {
   public R cloneCodeBasicSec(List<String> oidList, String pkCodeRule) throws ServiceException {
      boolean isLinked = checkIsLinked(pkCodeRule,null);
      if (isLinked) {
         return R.fail("编码规则已被引用,不允许编辑或删除");
      }
      List<CodeBasicSec> createList = new ArrayList<>();
      List<CodeBasicSec> basicSecDOS = codeBasicSecMapper.selectBatchIds(oidList);
      if(basicSecDOS.isEmpty()){
         return R.fail("克隆的码段信息不存在!");
      }
      basicSecDOS.forEach(sec -> {
         CodeBasicSec newSecDO = new CodeBasicSec();
         BeanUtilForVCI.copyPropertiesIgnoreCase(sec,newSecDO);
         newSecDO.setOid("");
         newSecDO.setNameOid("");
         newSecDO.setRevisionOid("");
         newSecDO.setOid(VciBaseUtil.getPk());
         newSecDO.setNameOid(VciBaseUtil.getPk());
         newSecDO.setRevisionOid(VciBaseUtil.getPk());
         newSecDO.setId(newSecDO.getId() + "_copy");
         newSecDO.setName(newSecDO.getName() + "_copy");
         newSecDO.setPkCodeRule(pkCodeRule);
         createList.add(newSecDO);
      });
      boolean b = saveBatch(createList);
      boolean resBoolean = saveBatch(createList);
      //codeBasicSecMapper.insertBatch(createList);
      return R.data(b,"克隆码段信息成功");
      return resBoolean ? R.data(resBoolean,"克隆码段信息成功"):R.fail("克隆码段信息失败!");
   }
   /**
@@ -560,7 +570,7 @@
    */
   @Override
   @Transactional(rollbackFor = Exception.class)
   public boolean upOrderNum(String oid) {
   public boolean upOrderNum(String oid) throws ServiceException{
      CodeBasicSec secDO = selectByOid(oid);
      if(secDO.getOrderNum() > 1){
         //等于1的时候不能上移了
@@ -591,7 +601,7 @@
    */
   @Override
   @Transactional(rollbackFor = Exception.class)
   public boolean downOrderNum(String oid) {
   public boolean downOrderNum(String oid) throws ServiceException {
      CodeBasicSec secDO = selectByOid(oid);
      Long total = codeBasicSecMapper.selectCount(Wrappers.<CodeBasicSec>query()
         .lambda().eq(CodeBasicSec::getPkCodeRule,secDO.getPkCodeRule())
@@ -623,7 +633,7 @@
    * @return
    */
   @Override
   public List<String> getOidByCodeclassifysecOid(String codeClassifySecOid) {
   public List<String> getOidByCodeclassifysecOid(String codeClassifySecOid)throws ServiceException {
      return codeBasicSecMapper.getOidByCodeclassifysecOid(codeClassifySecOid.trim());
   }
@@ -703,7 +713,7 @@
    * @return 码段的内容
    */
   @Override
   public List<CodeBasicSecVO> listCodeBasicSecByRuleOid(String ruleOid) {
   public List<CodeBasicSecVO> listCodeBasicSecByRuleOid(String ruleOid)throws ServiceException {
      if(StringUtils.isBlank(ruleOid)){
         return new ArrayList<>();
      }
@@ -782,12 +792,22 @@
   public CodeBasicSecVO codeBasicSecDO2VO(CodeBasicSec codeBasicSecDO) throws VciBaseException {
      CodeBasicSecVO codeBasicSecVO = new CodeBasicSecVO();
      if (codeBasicSecDO != null) {
         BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecVO, codeBasicSecVO);
         codeBasicSecVO.setSecTypeText(CodeSecTypeEnum.getTextByValue(codeBasicSecVO.getSecType()));
         codeBasicSecVO.setCodeLevelTypeText(CodeLevelTypeEnum.getTextByValue(codeBasicSecVO.getCodeLevelType()));
         codeBasicSecVO.setCodeSecLengthTypeText(CodeSecLengthTypeEnum.getTextByValue(codeBasicSecVO.getCodeSecLengthType()));
         codeBasicSecVO.setValueCutTypeText(CodeCutTypeEnum.getValueByText(codeBasicSecVO.getValueCutType()));
         codeBasicSecVO.setCodeGetValueTypeText(CodeGetValueTypeEnum.getValueByText(codeBasicSecVO.getCodeGetValueType()));
         BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDO, codeBasicSecVO);
         if(StringUtils.isNotBlank(codeBasicSecDO.getSecType())){
            codeBasicSecVO.setSecTypeText(EnumCache.getValue(EnumEnum.CODE_SEC_TYPE,codeBasicSecDO.getSecType()));
         }
         if(StringUtils.isNotBlank(codeBasicSecDO.getCodeLevelType())){
            codeBasicSecVO.setCodeLevelTypeText(EnumCache.getValue(EnumEnum.CODE_LEVEL_TYPE,codeBasicSecDO.getCodeLevelType()));
         }
         if(StringUtils.isNotBlank(codeBasicSecDO.getCodeSecLengthType())){
            codeBasicSecVO.setCodeSecLengthTypeText(EnumCache.getValue(EnumEnum.CODE_SEC_LENGTH,codeBasicSecDO.getCodeSecLengthType()));
         }
         if(StringUtils.isNotBlank(codeBasicSecDO.getValueCutType())){
            codeBasicSecVO.setValueCutTypeText(EnumCache.getValue(EnumEnum.CODE_CUT_TYPE,codeBasicSecDO.getValueCutType()));
         }
         if(StringUtils.isNotBlank(codeBasicSecDO.getCodeGetValueType())){
            codeBasicSecVO.setCodeGetValueTypeText(EnumCache.getValue(EnumEnum.CODE_GET_VALUE_TYPE,codeBasicSecDO.getCodeGetValueType()));
         }
         // 如果是分类码段需要查询所属分类的中文名称
         if(codeBasicSecDO.getSecType().equals("codeclassifysec") && Func.isNotEmpty(codeBasicSecDO.getParentClassifySecOid())){
            CodeBasicSec codeBasicSec = codeBasicSecMapper.selectOne(Wrappers.<CodeBasicSec>query().lambda()