Search in sources :

Example 16 with SysConfig

use of com.itrus.portal.db.SysConfig in project portal by ixinportal.

the class ChargingFailTask method ChargingAgain.

/**
 * 遍历所有计费失败的记录,重新计费
 *
 * @Scheduled(fixedRate = 1000 * 60 * 60 * 24) 设置为每天凌晨2点触发
 * @Scheduled(cron = "0 0 2 * * ?")
 */
@Scheduled(cron = "0 0/45 * * * ?")
public void ChargingAgain() {
    // start------------处理双机互斥----------
    // 系统是否配置同步任务的主机名
    SysConfig sysConfigHost = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "raInfoHost");
    if (null == sysConfigHost) {
        // 没有配置,直接返回
        return;
    }
    String host = sysConfigHost.getConfig();
    host = host.replaceAll(" ", "");
    String[] hosts = host.split(",");
    // 获取本机主机名称
    InetAddress ia = null;
    try {
        ia = ia.getLocalHost();
    } catch (UnknownHostException e1) {
        e1.printStackTrace();
        return;
    }
    String hostName = ia.getHostName();
    boolean flag_check = false;
    for (String str : hosts) {
        if (hostName.equals(str.replaceAll(" ", ""))) {
            flag_check = true;
        }
    }
    // 判断本地主机名称是否与系统配置的同步主机名称一致,不一致则返回
    if (!flag_check) {
        return;
    }
    // end------------处理双机互斥----------
    List<ChargingFail> chargingFails = chargingFailService.geChargingFails();
    if (null == chargingFails || chargingFails.size() == 0) {
        return;
    }
    for (int i = 0; i < chargingFails.size(); i++) {
        ChargingFail chargingFail = chargingFails.get(i);
        Map<String, Object> retMap = new HashMap<String, Object>();
        ApplicationInfo applicationInfo = certificationChargingService.getApplicationInfoByAppId(chargingFail.getAppId());
        AppService appService = certificationChargingService.getAppServiceByAppServiceId(chargingFail.getAppServiceId());
        retMap = certificationChargingService.charging(chargingFail.getAppId(), chargingFail.getAppServiceId(), chargingFail.getTransinfoName(), chargingFail.getTransinfoId(), applicationInfo, appService, chargingFail.getTransinfoPrimaryId(), chargingFail.getTransinfoTableName());
        Integer flag = (Integer) retMap.get("retCode");
        // 若插入成功
        if (null != flag && flag == 1) {
            chargingFail.setIsValidity(false);
            chargingFail.setModifyTime(new Date());
            Charging charging = (Charging) retMap.get("charging");
            chargingFail.setChargingId(charging.getChargingId());
            chargingFailService.update(chargingFail);
        }
    }
}
Also used : SysConfig(com.itrus.portal.db.SysConfig) AppService(com.itrus.portal.db.AppService) Charging(com.itrus.portal.db.Charging) UnknownHostException(java.net.UnknownHostException) HashMap(java.util.HashMap) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) Date(java.util.Date) ChargingFail(com.itrus.portal.db.ChargingFail) InetAddress(java.net.InetAddress) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 17 with SysConfig

use of com.itrus.portal.db.SysConfig in project portal by ixinportal.

the class ChargingRuleTask method setChargingRuleToInvalid.

/**
 * 定时任务,将过期的计费规则置为无效
 *
 * @Scheduled(fixedRate = 1000 * 60 * 60 * 24)
 * @Scheduled(cron = "0 0 2 * * ?")设置为每天凌晨2点触发
 */
@Scheduled(cron = "0 0/35 * * * ?")
public void setChargingRuleToInvalid() {
    // start------------处理双机互斥----------
    // 系统是否配置同步任务的主机名
    SysConfig sysConfigHost = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "raInfoHost");
    if (null == sysConfigHost) {
        // 没有配置,直接返回
        return;
    }
    String host = sysConfigHost.getConfig();
    host = host.replaceAll(" ", "");
    String[] hosts = host.split(",");
    // 获取本机主机名称
    InetAddress ia = null;
    try {
        ia = ia.getLocalHost();
    } catch (UnknownHostException e1) {
        e1.printStackTrace();
        return;
    }
    String hostName = ia.getHostName();
    boolean flag_check = false;
    for (String str : hosts) {
        if (hostName.equals(str.replaceAll(" ", ""))) {
            flag_check = true;
        }
    }
    // 判断本地主机名称是否与系统配置的同步主机名称一致,不一致则返回
    if (!flag_check) {
        return;
    }
    // end------------处理双机互斥----------
    CertificationChargingExample cce = new CertificationChargingExample();
    CertificationChargingExample.Criteria criteria = cce.or();
    Date now = new Date();
    criteria.andEndTimeLessThan(now);
    List<CertificationCharging> list = certificationChargingService.selectByExample(cce);
    if (null != list && list.size() > 0) {
        List<ServiceName> serviceNames = serviceNameService.selectListByCertificationChargings(list);
        if (null != serviceNames && serviceNames.size() > 0) {
            for (ServiceName serviceName : serviceNames) {
                if (serviceName.getIsValidity() == true) {
                    serviceName.setIsValidity(false);
                    serviceNameService.update(serviceName);
                    LogUtil.syslog(sqlSession, "将计费规则置为无效", "计费规则id为:" + serviceName.getCertificationCharging() + ", 服务表id为:" + serviceName.getId());
                }
            }
        }
    }
}
Also used : SysConfig(com.itrus.portal.db.SysConfig) CertificationChargingExample(com.itrus.portal.db.CertificationChargingExample) UnknownHostException(java.net.UnknownHostException) CertificationCharging(com.itrus.portal.db.CertificationCharging) Date(java.util.Date) ServiceName(com.itrus.portal.db.ServiceName) InetAddress(java.net.InetAddress) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 18 with SysConfig

use of com.itrus.portal.db.SysConfig in project portal by ixinportal.

the class SysConfigController method update.

// 修改处理
@RequestMapping(method = RequestMethod.PUT, produces = "text/html")
public String update(@Valid SysConfig sysconfig, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        uiModel.addAttribute("sysconfig", sysconfig);
        return "sysconfigs/update";
    }
    SysConfig sysconfig0 = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByPrimaryKey", sysconfig.getId());
    checkCDNurl(sysconfig);
    sqlSession.update("com.itrus.portal.db.SysConfigMapper.updateByPrimaryKey", sysconfig);
    String oper = "修改配置项";
    String info = "原内容,名称: " + sysconfig0.getType() + ",内容: " + sysconfig0.getConfig();
    LogUtil.adminlog(sqlSession, oper, info);
    oper = "修改配置项";
    info = "新内容,名称: " + sysconfig.getType() + ",内容: " + sysconfig.getConfig();
    LogUtil.adminlog(sqlSession, oper, info);
    cacheCustomer.initSysConfig();
    return "redirect:/sysconfigs";
}
Also used : SysConfig(com.itrus.portal.db.SysConfig) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with SysConfig

use of com.itrus.portal.db.SysConfig in project portal by ixinportal.

the class SysConfigController method delete.

// 删除
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
public String delete(@PathVariable("id") Long id, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
    SysConfig sysconfig = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByPrimaryKey", id);
    sqlSession.delete("com.itrus.portal.db.SysConfigMapper.deleteByPrimaryKey", id);
    String oper = "删除配置项";
    String info = "名称: " + sysconfig.getType() + ",内容: " + sysconfig.getConfig();
    LogUtil.adminlog(sqlSession, oper, info);
    cacheCustomer.initSysConfig();
    return "redirect:/sysconfigs";
}
Also used : SysConfig(com.itrus.portal.db.SysConfig) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with SysConfig

use of com.itrus.portal.db.SysConfig in project portal by ixinportal.

the class SystemConfigService method getpdfurl.

public String getpdfurl() {
    String type = SystemConfigService.PDF_URL;
    SysConfig sysConfig = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", type);
    if (sysConfig != null) {
        return sysConfig.getConfig();
    } else {
        return null;
    }
}
Also used : SysConfig(com.itrus.portal.db.SysConfig)

Aggregations

SysConfig (com.itrus.portal.db.SysConfig)33 UnknownHostException (java.net.UnknownHostException)15 InetAddress (java.net.InetAddress)9 HashMap (java.util.HashMap)7 Date (java.util.Date)5 Scheduled (org.springframework.scheduling.annotation.Scheduled)5 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ApplicationInfo (com.itrus.portal.db.ApplicationInfo)2 Charging (com.itrus.portal.db.Charging)2 Product (com.itrus.portal.db.Product)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)2 JSONObject (com.alibaba.fastjson.JSONObject)1 AppService (com.itrus.portal.db.AppService)1 AuditSystemConfig (com.itrus.portal.db.AuditSystemConfig)1 AuditSystemConfigExample (com.itrus.portal.db.AuditSystemConfigExample)1 Bill (com.itrus.portal.db.Bill)1 BusinessLicense (com.itrus.portal.db.BusinessLicense)1 Certification (com.itrus.portal.db.Certification)1