package org.jeecg.modules.zrzyqc.qyxx.service;

import com.alibaba.fastjson.JSONObject;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.handler.IFillRuleHandler;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.system.vo.SysDepartModel;
import org.jeecg.common.system.vo.SysUserCacheInfo;
import org.jeecg.common.util.PasswordUtil;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.encryption.AesEncryptUtil;

/**
 * @Description: TODO
 * @author: qiudongbao
 * @date: 2022年08月09日 10:56
 */
public class qybhRule implements IFillRuleHandler {
    @Override
    public Object execute(JSONObject params, JSONObject formData) {
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String orgCode = sysUser.getOrgCode();
        ISysBaseAPI api = (ISysBaseAPI) SpringContextUtils.getBean("sysBaseApiImpl");
        SysDepartModel departModel=api.selectAllById(api.getDepartIdsByOrgCode(orgCode));
        if(orgCode.substring(0,3).equals("A04")){
            String zgsjbString="";
            String yjqybm=orgCode.substring(4,6);
            Integer zgsjb=Integer.parseInt(departModel.getOrgType())-1;
            if(zgsjb==1) {
               return yjqybm;
            }else{
                if(zgsjb<10){
                    zgsjbString="0"+zgsjb.toString();
                }else{
                    zgsjbString=zgsjb.toString();
                }
               return yjqybm+"-"+zgsjbString;
            }
        }else{
            return "无";
        }
    }
}
