xiejun
2023-12-06 e9a590e862148092027510b15d33cdd32691a6f5
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -60,6 +60,7 @@
import com.vci.ubcs.system.feign.ISysClient;
import com.vci.ubcs.system.user.entity.User;
import com.vci.ubcs.system.user.feign.IUserClient;
import io.swagger.models.auth.In;
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
import oracle.sql.TIMESTAMP;
import org.slf4j.Logger;
@@ -67,6 +68,7 @@
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.log.annotation.OperateLog;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
@@ -504,6 +506,7 @@
        CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
        CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
        CodeRuleVO ruleVO = ruleService.getObjectHasSecByOid(orderDTO.getCodeRuleOid());
      final BladeUser user = AuthUtil.getUser();
        //1.判断规则中除了流水码段,是否有其他码段
        checkSecValueOnOrder(ruleVO, orderDTO);
        //2.判断必输项
@@ -534,13 +537,13 @@
      //cbo.setCreator(String.valueOf(AuthUtil.getUser().getUserId()));、
      if(authUser) {
         // 要求显示账号,所以做了更改
         cbo.setCreator(String.valueOf(AuthUtil.getUser().getAccount()));
         cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount()));
         cbo.setCreator(String.valueOf(user.getAccount()));
         cbo.setLastModifier(String.valueOf(user.getAccount()));
      }else{
         cbo.setCreator(orderDTO.getCreator());
         cbo.setLastModifier(orderDTO.getLastModifier());
      }
      cbo.setTenantId(AuthUtil.getTenantId());
      cbo.setTenantId(user.getTenantId());
      if(StringUtils.isNotBlank(orderDTO.getLcStatus())||StringUtils.isNotBlank(orderDTO.getData().get("lcStatus"))){
         cbo.setLcStatus(StringUtils.isNotBlank(orderDTO.getLcStatus())?orderDTO.getLcStatus():orderDTO.getData().get("lcStatus"));
      }
@@ -553,7 +556,7 @@
        cbo.setDescription(orderDTO.getDescription());
        cboList.add(cbo);
        List<String> codeList = productCodeService.productCodeAndSaveData(classifyFullInfo, templateVO, ruleVO, orderDTO.getSecDTOList(), cboList);
        List<String> codeList = productCodeService.productCodeAndSaveData(classifyFullInfo, templateVO, ruleVO, orderDTO.getSecDTOList(), cboList,user);
        batchSaveSelectChar(templateVO, cboList);
        return codeList.size() > 0 ? codeList.get(0) : "";
@@ -1140,6 +1143,75 @@
   @Override
   public String addSaveBZCodeNotauthUser(CodeBZApplyDTO codeBZApplyDTO, boolean authUser) throws Exception {
      return   addSaveBZCode(codeBZApplyDTO,authUser);
   }
   /**
    * 获取统计分析数据
    * @param btmNames 业务类型
    * @return 数据集
    */
   @Override
   public R getStatisticAnalysis(String btmNames) {
      //查询业务类型对应的数据库表
      R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Arrays.asList(btmNames.split(",")));
      if (!listR.isSuccess() || listR.getData().size() == 0) {
         throw new ServiceException("传入业务类型未查询到相应表单,请检查!");
      }
      List tableData = new ArrayList();
      for (BtmTypeVO datum : listR.getData()) {
         String sql = "select count(*) countNum, to_char(CREATETIME, 'mm') countDate\n" +
                     "from "+ datum.getTableName() +"\n" +
                     "where CREATETIME >= to_date(EXTRACT(YEAR FROM SYSDATE) || '-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND LASTV = '1'\n" +
                     "group by to_char(CREATETIME, 'mm')\n" +
                     "order by to_char(CREATETIME, 'mm')";
         //查询出需要处理的数据
         List<Map> maps = commonsMapper.selectBySql(sql);
         if(maps.size() == 0){
            throw new ServiceException("传入类型["+ datum.getName() + ":" +
               datum.getId() +"]未查到相关统计数据,请确认!!!!");
         }
         //当年每月月份之前之和
         List<Integer> monthCount = new ArrayList<>(12);
         //当年每月的月份数据
         List<Integer> month = new ArrayList<>();
         //获取当前月的数字
         Calendar instance = Calendar.getInstance();
         int nowmonth = instance.get(Calendar.MONTH) + 1;
         //从1到12月进行处理
         for (Integer i = 1; i <= 12; i++) {
            //当前月后所有数据设置为0
            if(i>nowmonth){
               monthCount.add(0);
               month.add(0);
            }
            //当前月份之前之和
            Integer count = 0;
            //当前月份数据
            Integer sameMonth = 0;
            //对数据库查的数据进行处理,对当前月份进行累加
            for (Map map : maps) {
               Integer mounDate = Integer.parseInt(String.valueOf(map.get("COUNTDATE")));
               if(mounDate <= i){
                  count += Integer.parseInt(String.valueOf(map.get("COUNTNUM")));
               }
               if (mounDate == i) {
                  sameMonth = Integer.parseInt(String.valueOf(map.get("COUNTNUM")));
               }
            }
            monthCount.add(count);
            month.add(sameMonth);
         }
         //对数据进行整合
         HashMap<String,Object> menuData = new HashMap<>();
         menuData.put("menuName",datum.getName());
         menuData.put("codeType",null);
         ArrayList monthData = new ArrayList();
         monthData.add(monthCount);
         monthData.add(month);
         menuData.put("menuData",monthData);
         tableData.add(menuData);
      }
      return R.data(tableData);
   }
   /**
@@ -3116,6 +3188,15 @@
         updateBatchByBaseModel(oldCbo.getBtmname(), Collections.singletonList(oldCbo));
         // 插入新的数据
            insertBatchByType(cbo.getBtmname(), Collections.singletonList(cbo));
         //处理码值表,对码值表进行处理替换创建数据的oid
         QueryWrapper<CodeAllCode> wrapper = new QueryWrapper<>();
         wrapper.eq("CREATECODEOID",orderDTO.getCopyFromVersion());
         CodeAllCode codeAllCode = codeAllCodeService.getOne(wrapper);
         codeAllCode.setCreateCodeOid(cbo.getOid());
         codeAllCode.setLastModifyTime(new Date());
         codeAllCode.setTs(new Date());
         codeAllCode.setLastModifier(AuthUtil.getUser().getUserName());
         codeAllCodeService.updateById(codeAllCode);
         // 记录数据更改日志
         saveLogUtil.operateLog("数据更改",false, StringUtil.format("{}\n修改为:\n{}",JSON.toJSONString(Collections.singletonList(oldCbo)),JSON.toJSONString(Collections.singletonList(cbo))));
      } catch (Exception vciError) {