4023 lines
129 KiB
Java
4023 lines
129 KiB
Java
package com.rzyc.controller;
|
||
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.alibaba.fastjson.JSONArray;
|
||
import com.common.utils.*;
|
||
import com.common.utils.encryption.MD5;
|
||
import com.common.utils.encryption.PasswdFactory;
|
||
import com.common.utils.jpush.Jpush;
|
||
import com.common.utils.orcode.QRCodeUtil;
|
||
import com.common.utils.upload.FileUpload;
|
||
import com.common.utils.jwt.JwtUtil;
|
||
import com.rzyc.bean.*;
|
||
import com.common.utils.model.Pager;
|
||
import com.github.pagehelper.Page;
|
||
import com.rzyc.bean.bigdata.user.PerformInfo;
|
||
import com.rzyc.bean.bigdata.user.UnitList;
|
||
import com.rzyc.bean.check.CheckList;
|
||
import com.rzyc.bean.check.CheckPerform;
|
||
import com.rzyc.bean.user.PerformProgress;
|
||
import com.rzyc.config.ConstantsConfigure;
|
||
import com.rzyc.enums.*;
|
||
import com.rzyc.mapper.*;
|
||
import com.rzyc.mapper.check.*;
|
||
import com.rzyc.mapper.ent.*;
|
||
import com.rzyc.mapper.ex.*;
|
||
import com.rzyc.mapper.log.*;
|
||
import com.rzyc.mapper.organization.*;
|
||
import com.rzyc.mapper.oth.*;
|
||
import com.rzyc.mapper.personal.*;
|
||
import com.rzyc.mapper.sys.*;
|
||
import com.rzyc.mapper.user.*;
|
||
import com.rzyc.model.*;
|
||
import com.rzyc.model.check.BookEntCheck;
|
||
import com.rzyc.model.check.BookEntHT;
|
||
import com.rzyc.model.check.ChkPerson;
|
||
import com.rzyc.model.ent.*;
|
||
import com.rzyc.model.sys.SysLogAuth;
|
||
import com.rzyc.model.sys.SysLogOptWithBLOBs;
|
||
import com.rzyc.model.sys.SysOrg;
|
||
import com.rzyc.model.sys.SysRole;
|
||
import com.rzyc.model.user.*;
|
||
import com.common.utils.copy.ObjectConversion;
|
||
import com.rzyc.service.ProvinceService;
|
||
import org.apache.poi.ss.usermodel.*;
|
||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
||
import javax.annotation.Resource;
|
||
import javax.servlet.http.HttpServletRequest;
|
||
import java.io.InputStream;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.*;
|
||
|
||
/**
|
||
* 基础控制器 引入mappper 一些公用方法
|
||
*/
|
||
public class BaseController {
|
||
|
||
//培训学习
|
||
@Autowired
|
||
protected EducationStudyMapper educationStudyMapper;
|
||
|
||
//培训资料
|
||
@Autowired
|
||
protected EducationResourceMapper educationResourceMapper;
|
||
|
||
/*用户*/
|
||
@Autowired
|
||
protected SysUserMapper sysUserMapper;
|
||
|
||
/*部门*/
|
||
@Autowired
|
||
protected SysUnitDeptMapper sysUnitDeptMapper;
|
||
|
||
/*履职类别*/
|
||
@Autowired
|
||
protected ListPerformMapper listPerformMapper;
|
||
|
||
/*新闻*/
|
||
@Autowired
|
||
protected NewsCntMapper newsCntMapper;
|
||
|
||
/*地区信息*/
|
||
@Autowired
|
||
protected SysOrgMapper sysOrgMapper;
|
||
|
||
/*企业信息*/
|
||
@Autowired
|
||
protected SysEnterpriseMapper sysEnterpriseMapper;
|
||
|
||
//检查类型
|
||
@Autowired
|
||
protected ChkGovBillMapper chkGovBillMapper;
|
||
|
||
//检查项详情
|
||
@Autowired
|
||
protected ChkGovBillDetailMapper chkGovBillDetailMapper;
|
||
|
||
//检查记录
|
||
@Autowired
|
||
protected BookEntCheckMapper bookEntCheckMapper;
|
||
|
||
//检查记录详情
|
||
@Autowired
|
||
protected BookEntCheckDetailMapper bookEntCheckDetailMapper;
|
||
|
||
//隐患
|
||
@Autowired
|
||
protected BookEntHTMapper bookEntHTMapper;
|
||
|
||
//文件
|
||
@Autowired
|
||
protected SysdocumentMapper sysdocumentMapper;
|
||
|
||
//隐患 检查项关联
|
||
@Autowired
|
||
protected BookRelationMapper bookRelationMapper;
|
||
|
||
//检查人员表
|
||
@Autowired
|
||
protected ChkPersonMapper chkPersonMapper;
|
||
|
||
//检查库
|
||
@Autowired
|
||
protected ChkBillDetailMapper chkBillDetailMapper;
|
||
|
||
//职责
|
||
@Autowired
|
||
protected ListSafeMapper listSafeMapper;
|
||
|
||
//用户履职档案
|
||
@Autowired
|
||
protected ListFactorMapper listFactorMapper;
|
||
|
||
//动态
|
||
@Autowired
|
||
protected DynamicMapper dynamicMapper;
|
||
|
||
//隐患避难场所
|
||
@Autowired
|
||
protected OthRefugeMapper othRefugeMapper;
|
||
|
||
//应急队伍
|
||
@Autowired
|
||
protected OthTeamMapper othTeamMapper;
|
||
|
||
//应急队伍人员
|
||
@Autowired
|
||
protected OthPersonMapper othPersonMapper;
|
||
|
||
//应急装备
|
||
@Autowired
|
||
protected OthResourceMapper othResourceMapper;
|
||
|
||
//紧急预案
|
||
@Autowired
|
||
protected OthPlanMapper othPlanMapper;
|
||
|
||
//值班表
|
||
@Autowired
|
||
protected GovDutyMapper govDutyMapper;
|
||
|
||
//值班人员
|
||
@Autowired
|
||
protected GovDutyPersonMapper govDutyPersonMapper;
|
||
|
||
//企业清单
|
||
@Autowired
|
||
protected SysEntListMapper sysEntListMapper;
|
||
|
||
//企业用户
|
||
@Autowired
|
||
protected SysEntUserMapper sysEntUserMapper;
|
||
|
||
//企业承诺
|
||
@Autowired
|
||
protected EntPromiseMapper entPromiseMapper;
|
||
|
||
//企业承诺用户
|
||
@Autowired
|
||
protected EntPromiseUserMapper entPromiseUserMapper;
|
||
|
||
//重大危险源列表
|
||
@Autowired
|
||
protected EntRiskSourceMapper entRiskSourceMapper;
|
||
|
||
//企业清单关联表
|
||
@Autowired
|
||
protected EntBillConMapper entBillConMapper;
|
||
|
||
//履职记录详情
|
||
@Autowired
|
||
protected ListDetailMapper listDetailMapper;
|
||
|
||
//应急类型
|
||
@Autowired
|
||
protected OthTypeMapper othTypeMapper;
|
||
|
||
//角色
|
||
@Autowired
|
||
protected SysRoleMapper sysRoleMapper;
|
||
|
||
//行业类别
|
||
@Autowired
|
||
protected BaseInClassMapper baseInClassMapper;
|
||
|
||
//安全类别
|
||
@Autowired
|
||
protected BaseSafeClassMapper baseSafeClassMapper;
|
||
|
||
//任务
|
||
@Autowired
|
||
protected OATaskMapper oaTaskMapper;
|
||
|
||
//任务接收用户
|
||
@Autowired
|
||
protected OADistributionMapper oaDistributionMapper;
|
||
|
||
//动态分类
|
||
@Autowired
|
||
protected NewsClassMapper newsClassMapper;
|
||
|
||
//日志记录
|
||
@Autowired
|
||
protected SysLogOptMapper sysLogOptMapper;
|
||
|
||
//应急专家
|
||
@Autowired
|
||
protected OthExpertMapper othExpertMapper;
|
||
|
||
//履职记录-安全检查
|
||
@Autowired
|
||
protected ListdetacheckMapper listdetacheckMapper;
|
||
|
||
//事故
|
||
@Autowired
|
||
protected AccidentMapper accidentMapper;
|
||
|
||
//事故类型
|
||
@Autowired
|
||
protected AccidentTypeMapper accidentTypeMapper;
|
||
|
||
//政府部门
|
||
@Autowired
|
||
protected SysUnitMapper sysUnitMapper;
|
||
|
||
//日志
|
||
@Autowired
|
||
protected SysLogAuthMapper sysLogAuthMapper;
|
||
|
||
//app帮助文档
|
||
@Autowired
|
||
protected AppHelpMapper appHelpMapper;
|
||
|
||
//执法
|
||
@Autowired
|
||
protected BookLawMapper bookLawMapper;
|
||
|
||
//约谈
|
||
@Autowired
|
||
protected BookTalkMapper bookTalkMapper;
|
||
|
||
//企业统计信息
|
||
@Autowired
|
||
protected EntMessageMapper entMessageMapper;
|
||
|
||
//应急装备
|
||
@Autowired
|
||
protected OthEquipmentMapper othEquipmentMapper;
|
||
|
||
//类型
|
||
@Autowired
|
||
protected SysCodeMapper sysCodeMapper;
|
||
|
||
//功能
|
||
@Autowired
|
||
protected SysResourceMapper sysResourceMapper;
|
||
|
||
//角色资源
|
||
@Autowired
|
||
protected SysRoleResourceMapper sysRoleResourceMapper;
|
||
|
||
//浏览器对象
|
||
@Autowired
|
||
protected HttpServletRequest request;
|
||
|
||
@Autowired
|
||
protected BasekpiMapper basekpiMapper;
|
||
|
||
//任务类型
|
||
@Autowired
|
||
protected OaTaskTypeMapper oaTaskTypeMapper;
|
||
|
||
//日志
|
||
@Autowired
|
||
protected SysLogsMapper sysLogsMapper;
|
||
|
||
//法规
|
||
@Autowired
|
||
protected SysStatuteMapper sysStatuteMapper;
|
||
|
||
//法规详情
|
||
@Autowired
|
||
protected SysStatuteDescMapper sysStatuteDescMapper;
|
||
|
||
//最小工作单元
|
||
@Autowired
|
||
protected MinWorkUnitMapper minWorkUnitMapper;
|
||
|
||
|
||
//最小工作单元分类对应的检查项
|
||
@Autowired
|
||
protected MinMiddleIndexMapper minMiddleIndexMapper;
|
||
|
||
//最小工作单元检查中间表
|
||
@Autowired
|
||
protected MinWorkCheckMiddleMapper minWorkCheckMiddleMapper;
|
||
|
||
//检查记录,一次可以检查多个工作单元
|
||
@Autowired
|
||
protected MinCheckUnitIdsMapper minCheckUnitIdsMapper;
|
||
|
||
//最小工作单元分类
|
||
@Autowired
|
||
protected MinWorkUnitCategoryMapper minWorkUnitCategoryMapper;
|
||
|
||
//企业自查检查表
|
||
@Autowired
|
||
protected BookentcheckCompanyMapper bookentcheckCompanyMapper;
|
||
|
||
//企业自查检查项中间表
|
||
@Autowired
|
||
protected BookentcheckdetailCompanyMapper bookentcheckdetailCompanyMapper;
|
||
|
||
//企业自查隐患表
|
||
@Autowired
|
||
protected BookenthtCompanyMapper bookenthtCompanyMapper;
|
||
|
||
//通知
|
||
@Autowired
|
||
protected NoticeMapper noticeMapper;
|
||
|
||
//用户监管地区
|
||
@Autowired
|
||
protected SysUserAreaMapper sysUserAreaMapper;
|
||
|
||
//行业工作单元分类
|
||
@Autowired
|
||
protected IndustryWorkMapper industryWorkMapper;
|
||
|
||
//企业应急资源
|
||
@Autowired
|
||
protected EntEmEquipmentMapper entEmEquipmentMapper;
|
||
|
||
// //企业监管用户
|
||
// @Autowired
|
||
// protected EntUserMapper entUserMapper;
|
||
|
||
//责任树
|
||
@Autowired
|
||
protected DutyTreeMapper dutyTreeMapper;
|
||
|
||
//第三方机构
|
||
@Autowired
|
||
protected OrganizationMapper organizationMapper;
|
||
|
||
//第三方机构发起隐患
|
||
@Autowired
|
||
protected OrgDangerMapper orgDangerMapper;
|
||
|
||
//第三方机构管理企业关联表
|
||
@Autowired
|
||
protected OrgEnterpriseMapper orgEnterpriseMapper;
|
||
|
||
//三方机构隐患操作记录
|
||
@Autowired
|
||
protected OrgLogDangerOperateMapper orgLogDangerOperateMapper;
|
||
|
||
|
||
//隐患类型
|
||
@Autowired
|
||
protected OrgBookTypeMapper orgBookTypeMapper;
|
||
|
||
//三方检查记录
|
||
@Autowired
|
||
protected OrgBatchMapper orgBatchMapper;
|
||
|
||
//仓库
|
||
@Autowired
|
||
protected OtheWareHouseMapper otheWareHouseMapper;
|
||
|
||
//设备清单
|
||
@Autowired
|
||
protected OtheCheckListMapper otheCheckListMapper;
|
||
|
||
//装备记录
|
||
@Autowired
|
||
protected OtheEquipRecordMapper otheEquipRecordMapper;
|
||
|
||
//仓库
|
||
@Autowired
|
||
protected StorageMapper storageMapper;
|
||
|
||
//权限
|
||
@Autowired
|
||
protected SysAuthMapper sysAuthMapper;
|
||
|
||
//部门角色
|
||
@Autowired
|
||
protected SysUnitRoleMapper sysUnitRoleMapper;
|
||
|
||
@Autowired
|
||
protected OtheBackRecordMapper otheBackRecordMapper;
|
||
|
||
//配置文件
|
||
@Autowired
|
||
protected ConstantsConfigure constantsConfigure;
|
||
|
||
//最小工作单元格清单
|
||
@Autowired
|
||
protected ListWorkMapper listWorkMapper;
|
||
|
||
//清单考核指标
|
||
@Autowired
|
||
protected ListQuotaMapper listQuotaMapper;
|
||
|
||
//工作手册
|
||
@Autowired
|
||
protected ManualMapper manualMapper;
|
||
|
||
//工作手册标签
|
||
@Autowired
|
||
protected ManualLableMapper manualLableMapper;
|
||
|
||
//工作手册响应级别
|
||
@Autowired
|
||
protected ManualLevelMapper manualLevelMapper;
|
||
|
||
//工作手册时间
|
||
@Autowired
|
||
protected ManualTimeMapper manualTimeMapper;
|
||
|
||
//工作手册处置措施
|
||
@Autowired
|
||
protected ManualMeasuresMapper manualMeasuresMapper;
|
||
|
||
//工作手册处置措施标签
|
||
@Autowired
|
||
protected MaMeasuresLableMapper maMeasuresLableMapper;
|
||
|
||
//通知记录
|
||
@Autowired
|
||
protected NoRecordMapper noRecordMapper;
|
||
|
||
//危险源类型
|
||
@Autowired
|
||
protected RkRiskTypeMapper rkRiskTypeMapper;
|
||
|
||
//重大危险源
|
||
@Autowired
|
||
protected RkSourcesMapper rkSourcesMapper;
|
||
|
||
//文书模板
|
||
@Autowired
|
||
protected SysDocumenttempMapper sysDocumenttempMapper;
|
||
|
||
//企业清单
|
||
@Autowired
|
||
protected InListMapper inListMapper;
|
||
|
||
//所属清单项
|
||
@Autowired
|
||
protected InListItemMapper inListItemMapper;
|
||
|
||
//企业证照
|
||
@Autowired
|
||
protected EntCertificatesMapper entCertificatesMapper;
|
||
|
||
//用户任务关联
|
||
@Autowired
|
||
protected OaTaskUserMapper oaTaskUserMapper;
|
||
|
||
//任务记录
|
||
@Autowired
|
||
protected TaskRecordMapper taskRecordMapper;
|
||
|
||
//企业清单
|
||
@Autowired
|
||
protected InEntListMapper inEntListMapper;
|
||
|
||
//企业应急预案
|
||
@Autowired
|
||
protected EntEmReservePlanMapper entEmReservePlanMapper;
|
||
|
||
//政府智能预警
|
||
@Autowired
|
||
protected GovWarningMapper govWarningMapper;
|
||
|
||
//企业岗位
|
||
@Autowired
|
||
protected EntPostMapper entPostMapper;
|
||
|
||
//企业用户
|
||
@Autowired
|
||
protected EntUserMapper entUserMapper;
|
||
|
||
//企业公共岗位
|
||
@Autowired
|
||
protected InPostMapper inPostMapper;
|
||
|
||
//企业岗位关联责任清单
|
||
@Autowired
|
||
protected InPostItemMapper inPostItemMapper;
|
||
|
||
//企业岗位履职表
|
||
@Autowired
|
||
protected InPostListMapper inPostListMapper;
|
||
|
||
//企业岗位职责
|
||
@Autowired
|
||
protected EntPostDutyMapper entPostDutyMapper;
|
||
|
||
//企业岗位任务
|
||
@Autowired
|
||
protected EntPostTaskMapper entPostTaskMapper;
|
||
|
||
//智能预警类型
|
||
@Autowired
|
||
protected SysWarningTypeMapper sysWarningTypeMapper;
|
||
|
||
//智能预警类型
|
||
@Autowired
|
||
protected SysWarningMapper sysWarningMapper;
|
||
|
||
//智能预警类型
|
||
@Autowired
|
||
protected SysWarningUserMapper sysWarningUserMapper;
|
||
|
||
//变更记录
|
||
@Autowired
|
||
protected ListchangeMapper listchangeMapper;
|
||
|
||
//企业周边情况
|
||
@Autowired
|
||
protected RkSensitiveTypeMapper rkSensitiveTypeMapper;
|
||
|
||
//企业周边数据信息
|
||
@Autowired
|
||
protected RkEntSensitiveMapper rkEntSensitiveMapper;
|
||
|
||
//企业风险分级条款
|
||
@Autowired
|
||
protected RkScoreTypeMapper rkScoreTypeMapper;
|
||
|
||
//企业风险评估分数
|
||
@Autowired
|
||
protected RkEnterpriseScoreMapper rkEnterpriseScoreMapper;
|
||
|
||
//风险评估分数
|
||
@Autowired
|
||
protected RkCompanyDiagnosisMapper rkCompanyDiagnosisMapper;
|
||
|
||
//企业履职清单
|
||
@Autowired
|
||
protected EntPostListMapper entPostListMapper;
|
||
|
||
//部门行业关联
|
||
@Autowired
|
||
protected SysUnitTradeMapper sysUnitTradeMapper;
|
||
|
||
//企业设备
|
||
@Autowired
|
||
protected EntDeviceMapper entDeviceMapper;
|
||
|
||
//企业人员证照
|
||
@Autowired
|
||
protected EntUserCredentialMapper entUserCredentialMapper;
|
||
|
||
//app使用帮助
|
||
@Autowired
|
||
protected AppHelpVersionMapper appHelpVersionMapper;
|
||
|
||
//履职记录关联信息
|
||
@Autowired
|
||
protected ListRelationMapper listRelationMapper;
|
||
|
||
//ip登录信息
|
||
@Autowired
|
||
protected SysUserLoginMapper sysUserLoginMapper;
|
||
|
||
//党政同责考核
|
||
@Autowired
|
||
protected ExExamineMapper exExamineMapper;
|
||
|
||
//党政同责考核项
|
||
@Autowired
|
||
protected ExExamineItemMapper exExamineItemMapper;
|
||
|
||
//党政同责考核内容
|
||
@Autowired
|
||
protected ExStandardMapper exStandardMapper;
|
||
|
||
//部门评分信息
|
||
@Autowired
|
||
protected ExPerformMapper exPerformMapper;
|
||
|
||
//评分信息
|
||
@Autowired
|
||
protected ExScoreMapper exScoreMapper;
|
||
|
||
//评分附件信息
|
||
@Autowired
|
||
protected ExScoreFileMapper exScoreFileMapper;
|
||
|
||
//评分记录
|
||
@Autowired
|
||
protected ExScoreRecordMapper exScoreRecordMapper;
|
||
|
||
//省厅数据对接
|
||
@Resource
|
||
protected ProvinceService provinceService;
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/**
|
||
* 岗位不需要的字符串
|
||
*/
|
||
private static List<String> unwantedStr = new ArrayList<>();
|
||
|
||
/**
|
||
* 企业安全等级
|
||
*/
|
||
protected static Map<String,String> entRislLevelMap = new HashMap<String,String>();
|
||
|
||
/**
|
||
* 企业安全等级颜色
|
||
*/
|
||
protected static Map<String,String> entRislLevelColorMap = new HashMap<String,String>();
|
||
|
||
/**
|
||
* 企业通知类型
|
||
*/
|
||
protected static List<String> entTasks = new ArrayList<>();
|
||
|
||
/**
|
||
* 修改值班信息的角色
|
||
*/
|
||
protected static List<String> dutyRoles = new ArrayList<>();
|
||
|
||
/**
|
||
* 编辑动态的角色
|
||
*/
|
||
protected static List<String> changeDynamicRole = new ArrayList<>();
|
||
|
||
|
||
//管理员角色id
|
||
protected static String ADMIN_ROLE_ID = "295EF8C3-902F-41F0-95C8-D3AB9C6DA143";
|
||
|
||
/*部门父级id*/
|
||
protected String DEPT_UNIT_ID = "ed331634-5166-4532-9b6b-fcb1af74fcd8";
|
||
|
||
/*镇街、产业功能区父级id*/
|
||
protected String STREET_UNIT_ID = "fe4a2834-c754-4ed1-97db-4914c822d820";
|
||
|
||
/*部门职务父级id*/
|
||
protected String DEPT_RECORD_ID = "669dcdbd-aabd-44f7-b035-003c042f9e02";
|
||
|
||
/*镇街职务父级id*/
|
||
protected String STREET_RECORD_ID = "669dcdbd-aabd-44f7-b035-003c042f9e06";
|
||
|
||
|
||
//仓储分类id
|
||
protected String STORAGEID = "2b4f7675-cfcf-468c-8f82-7146936c2cd5";
|
||
|
||
//三方机构电气设备隐患类型id
|
||
protected String ELECTRIACLID = "78be60a1-55bf-44cc-9697-a983eeea98f2";
|
||
|
||
|
||
//登录密码错误次数
|
||
protected static Integer PASSWD_ERROR_NUM = 5;
|
||
|
||
|
||
/**
|
||
* 履职任务完成状态
|
||
*/
|
||
protected static Map<Integer,String> taskCompleteStateMap = new HashMap<>();
|
||
|
||
static{
|
||
|
||
/* 履职任务完成状态 start */
|
||
taskCompleteStateMap.put(1,"否");
|
||
taskCompleteStateMap.put(2,"是");
|
||
/* 履职任务完成状态 end */
|
||
|
||
/* 岗位不需要的字符串 start */
|
||
unwantedStr.add("<div>");
|
||
unwantedStr.add("</div>");
|
||
unwantedStr.add(" ");
|
||
unwantedStr.add(" ");
|
||
/* 岗位不需要的字符串 end */
|
||
|
||
|
||
/* 企业安全等级 start */
|
||
entRislLevelMap.put("重大风险","4");
|
||
entRislLevelMap.put("较大风险","3");
|
||
entRislLevelMap.put("一般风险","2");
|
||
entRislLevelMap.put("低风险","1");
|
||
/* 企业安全等级 end */
|
||
|
||
|
||
|
||
/* 企业安全等级颜色 start */
|
||
entRislLevelColorMap.put("重大风险","#FF4F4F");
|
||
entRislLevelColorMap.put("较大风险","#F86B34");
|
||
entRislLevelColorMap.put("一般风险","#F2AB21");
|
||
entRislLevelColorMap.put("低风险","#5784F6");
|
||
/* 企业安全等级颜色 end */
|
||
|
||
/* 企业通知类型 start */
|
||
entTasks.add("隐患排查");
|
||
entTasks.add("约谈");
|
||
entTasks.add("执法");
|
||
/* 企业通知类型 end */
|
||
|
||
/* 值班信息角色 start */
|
||
dutyRoles.add("f523c301-f33e-44e9-9e7d-5568713f0e80");
|
||
dutyRoles.add("295EF8C3-902F-41F0-95C8-D3AB9C6DA143");
|
||
/* 值班信息角色 end */
|
||
|
||
/* 编辑动态的角色 start */
|
||
changeDynamicRole.add("295EF8C3-902F-41F0-95C8-D3AB9C6DA143");
|
||
changeDynamicRole.add("295EF8C3-902F-41F0-95C8-D3AB9C6DA166");
|
||
/* 编辑动态的角色 end */
|
||
}
|
||
|
||
|
||
/*高敏感场所*/
|
||
protected String HIGH_SENSITIVE_PLACES = "502b1ff4-bd01-11eb-9d3c-00163e0c1c62";
|
||
/*重要目标*/
|
||
protected String KEY_OBJECTIVES = "502b2472-bd01-11eb-9d3c-00163e0c1c62";
|
||
/*人员密集区域*/
|
||
protected String DENSELY_POPULATED_PLACES = "c6d817c1-5eec-4c88-916c-4c2f20dec062";
|
||
|
||
|
||
//安全事故情况
|
||
protected String SAFETY_ACCIDENTS = "76752d5b-c787-413a-b228-63b5507eaa03";
|
||
//安全生产标准化达标情况
|
||
protected String STANDARDIZATION_OF_WORK_SAFETY = "2d32e694-5af5-4786-b540-c56a34196ff9";
|
||
|
||
|
||
/**
|
||
* 新都文件地址处理
|
||
* @param url
|
||
* @return
|
||
*/
|
||
protected String delServiceFile(String url) {
|
||
// url = url.replace(Constants.SERVICE_FILE_HEADER, "");
|
||
url = url.replace(constantsConfigure.getServiceFileHeader(), "");
|
||
return url;
|
||
}
|
||
|
||
/**
|
||
* 新都文件地址处理
|
||
* @param url
|
||
* @return
|
||
*/
|
||
protected String setServiceFile(String url) {
|
||
// url = Constants.SERVICE_FILE_HEADER + url;
|
||
url = constantsConfigure.getServiceFileHeader() + url;
|
||
return url;
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 查询用户部门
|
||
* @param sysUserId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected String getUnitName(String sysUserId) throws Exception{
|
||
String unitName = "";
|
||
//获取用户部门 查询用户职务 在通过执法 查询部门
|
||
ListPerform listPerform = listPerformMapper.findBuUserId(sysUserId);
|
||
if(null != listPerform){
|
||
//如果父级id等级新都部门的id 则直接返回部门名
|
||
String xniduUnit = "669dcdbd-aabd-44f7-b035-003c042f9e02";
|
||
if(xniduUnit.equals(listPerform.getSupclassid())){
|
||
unitName = listPerform.getPerformclassname();
|
||
}else{
|
||
ListPerform superPerform = listPerformMapper.selectByPrimaryKey(listPerform.getSupclassid());
|
||
if(null != superPerform){
|
||
unitName = superPerform.getPerformclassname();
|
||
}
|
||
}
|
||
|
||
}
|
||
return unitName;
|
||
}
|
||
|
||
/**
|
||
* 获取部门id
|
||
* @param sysUserId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected String getListPerformId(String sysUserId) throws Exception{
|
||
String listPerformId = "";
|
||
//获取用户部门 查询用户职务 在通过执法 查询部门
|
||
ListPerform listPerform = listPerformMapper.findBuUserId(sysUserId);
|
||
if(null != listPerform){
|
||
//如果父级id等级新都部门的id 则直接返回部门名
|
||
String xniduUnit = "669dcdbd-aabd-44f7-b035-003c042f9e02";
|
||
if(listPerform.getSupclassid().equals(xniduUnit)){
|
||
listPerformId = listPerform.getListperformid();
|
||
}else{
|
||
ListPerform superPerform = listPerformMapper.selectByPrimaryKey(listPerform.getSupclassid());
|
||
if(null != superPerform){
|
||
listPerformId = superPerform.getListperformid();
|
||
}
|
||
}
|
||
|
||
}
|
||
return listPerformId;
|
||
}
|
||
|
||
/**
|
||
* 替换不必要的字符串
|
||
* @param listStr
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected String getListStr(String listStr)throws Exception{
|
||
if(StringUtils.isNotBlank(listStr)){
|
||
for (String str : unwantedStr){
|
||
listStr = listStr.replace(str,"");
|
||
}
|
||
}
|
||
return listStr;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/**
|
||
* 回复推送消息
|
||
*/
|
||
public class SendMessage implements Runnable{
|
||
|
||
|
||
/**
|
||
* 发送者用户id
|
||
*/
|
||
private String sysUserId;
|
||
|
||
/**
|
||
* 接收者用户id
|
||
*/
|
||
private String receiveId;
|
||
|
||
/**
|
||
* 企业id
|
||
*/
|
||
private String enterpriseId;
|
||
|
||
/**
|
||
* 推送类型 :
|
||
* 1->新增隐患
|
||
* 2:法人审核隐患整改情况
|
||
* 3:隐患分配整改人员
|
||
* 4:授权签名
|
||
* 5:隐患完成整改
|
||
* 6:推送任务
|
||
* 7:履职提醒
|
||
* 8:推送履职任务
|
||
* 9:推送履职任务
|
||
*/
|
||
private Integer type;
|
||
|
||
/**
|
||
* 任务级别 1:安办 2:部门
|
||
*/
|
||
private String tasklevel;
|
||
|
||
/**
|
||
* 隐患id
|
||
*/
|
||
private String bookEntHtId;
|
||
|
||
/**
|
||
* 发送内容
|
||
*/
|
||
private String sendMsg;
|
||
|
||
/**
|
||
* 跳转到企业端检查通知
|
||
* @param enterpriseId
|
||
*/
|
||
public SendMessage(Integer type,String sendMsg, String enterpriseId) {
|
||
this.sendMsg = sendMsg;
|
||
this.enterpriseId = enterpriseId;
|
||
this.type = type;
|
||
}
|
||
|
||
/**
|
||
* 隐患推送构造方法
|
||
* @param receiveId
|
||
* @param type
|
||
* @param bookEntHtId
|
||
*/
|
||
public SendMessage(String receiveId, Integer type, String bookEntHtId) {
|
||
this.receiveId = receiveId;
|
||
this.type = type;
|
||
this.bookEntHtId = bookEntHtId;
|
||
}
|
||
|
||
public SendMessage(String sysUserId, String receiveId, Integer type, String sendMsg) {
|
||
this.sysUserId = sysUserId;
|
||
this.receiveId = receiveId;
|
||
this.type = type;
|
||
this.sendMsg = sendMsg;
|
||
}
|
||
|
||
public SendMessage(String sysUserId, String receiveId, String enterpriseId, Integer type, String tasklevel) {
|
||
this.sysUserId = sysUserId;
|
||
this.receiveId = receiveId;
|
||
this.enterpriseId = enterpriseId;
|
||
this.type = type;
|
||
this.tasklevel = tasklevel;
|
||
}
|
||
|
||
public SendMessage(String sysUserId, String receiveId, String enterpriseId, Integer type) {
|
||
this.sysUserId = sysUserId;
|
||
this.receiveId = receiveId;
|
||
this.enterpriseId = enterpriseId;
|
||
this.type = type;
|
||
}
|
||
|
||
public SendMessage(String sysUserId, String enterpriseId, Integer type) {
|
||
this.sysUserId = sysUserId;
|
||
this.enterpriseId = enterpriseId;
|
||
this.type = type;
|
||
}
|
||
|
||
public SendMessage() {
|
||
}
|
||
|
||
@Override
|
||
public void run() {
|
||
try {
|
||
|
||
//分配隐患人员推送
|
||
if(1 == type){
|
||
sendDangerMsg(enterpriseId,sysUserId);
|
||
}else if(2 == type){
|
||
sendexamineDangerMsg(enterpriseId,sysUserId);
|
||
}else if(3 == type){
|
||
handelDanger(sysUserId,receiveId);
|
||
}else if(4 == type){
|
||
autographAuth(sysUserId,receiveId);
|
||
}else if(5 == type){
|
||
completeRectification(receiveId,enterpriseId);
|
||
}else if(6 == type){
|
||
sendTask(receiveId,sysUserId,tasklevel);
|
||
}else if(7 == type){
|
||
sendFactorMsg(receiveId,sysUserId,sendMsg);
|
||
}else if(8 == type){
|
||
changeDanger(receiveId,bookEntHtId);
|
||
}else if(9 == type){
|
||
sendCheckMsg(enterpriseId,sendMsg);
|
||
}
|
||
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* 跳转到企业端检查通知
|
||
* @param enterpriseId
|
||
* @param sendMsg
|
||
*/
|
||
public void sendCheckMsg(String enterpriseId,String sendMsg){
|
||
try {
|
||
//推送别名
|
||
String alias = "";
|
||
//获取企业端法人账号
|
||
SysUser sysUser = sysUserMapper.findByEntId(enterpriseId);
|
||
if(null != sysUser){
|
||
alias = MD5.md5(sysUser.getSysuserid());
|
||
}
|
||
//如果别名不为空 则推送消息
|
||
if(StringUtils.isNotBlank(alias)){
|
||
|
||
String content = sendMsg;
|
||
//msg.wav
|
||
Map<String,String> map = new HashMap<String,String>();
|
||
map.put("type","6");//跳转企业端通知页面
|
||
|
||
Jpush.sendAllNotifications(alias,content,map);
|
||
}
|
||
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 统一处理分页
|
||
* @param pager api返回的对象
|
||
* @param page 分页插件对象
|
||
* @throws Exception
|
||
*/
|
||
protected void getDatePage(Pager pager, Page page)throws Exception{
|
||
pager.setTotal(page.getTotal());
|
||
pager.setRows(page.getResult());
|
||
}
|
||
|
||
/**
|
||
* 履职任务
|
||
* @param receiveId
|
||
* @param sendId
|
||
* @param sendMsg
|
||
*/
|
||
private void sendFactorMsg(String receiveId,String sendId,String sendMsg){
|
||
try {
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(sendId);
|
||
if(null != sysUser){
|
||
String alias = "";
|
||
String [] strs = receiveId.split(",");
|
||
for (String str : strs){
|
||
if(StringUtils.isNotBlank(alias)){
|
||
alias += ","+MD5.md5(str);
|
||
}else{
|
||
alias = MD5.md5(str);
|
||
}
|
||
}
|
||
|
||
String content = sendMsg;
|
||
//msg.wav
|
||
Map<String,String> map = new HashMap<String,String>();
|
||
map.put("type","4");//跳转到履职列表
|
||
|
||
Jpush.sendGovAllNotifications(alias,content,map);
|
||
}
|
||
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 推送履职任务
|
||
* @param receiveId
|
||
*/
|
||
private void changeDanger(String receiveId,String bookEntHtId){
|
||
try {
|
||
String alias = "";
|
||
String [] strs = receiveId.split(",");
|
||
for (String str : strs){
|
||
if(StringUtils.isNotBlank(alias)){
|
||
alias += ","+MD5.md5(str);
|
||
}else{
|
||
alias = MD5.md5(str);
|
||
}
|
||
}
|
||
|
||
String content = "你提交的隐患信息已提交整改资料,请到隐患详情查看整改资料,并闭环。";
|
||
//msg.wav
|
||
Map<String,String> map = new HashMap<String,String>();
|
||
map.put("type","5");//调整到隐患详情
|
||
map.put("bookEntHtId",bookEntHtId);//隐患id
|
||
|
||
Jpush.sendGovAllNotifications(alias,content,map);
|
||
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 新增任务推送
|
||
* @param receiveId
|
||
* @param sendId
|
||
* @param taskLevel
|
||
*/
|
||
private void sendTask(String receiveId,String sendId,String taskLevel){
|
||
try {
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(sendId);
|
||
if(null != sysUser){
|
||
String alias = "";
|
||
String [] strs = receiveId.split(",");
|
||
for (String str : strs){
|
||
if(StringUtils.isNotBlank(alias)){
|
||
alias += ","+MD5.md5(str);
|
||
}else{
|
||
alias = MD5.md5(str);
|
||
}
|
||
}
|
||
String sendUserName = "安办:";
|
||
|
||
if("1".equals(taskLevel)){
|
||
sendUserName += sysUser.getChinaname() + ",发布了新任务,请查看。";
|
||
}else if("2".equals(taskLevel)){
|
||
String unitName = this.getUnitName(sysUser.getSysuserid());
|
||
|
||
sendUserName = unitName+":"+sysUser.getChinaname() + ",发布了新任务,请查看。";
|
||
}
|
||
|
||
String content = sendUserName;
|
||
//msg.wav
|
||
Map<String,String> map = new HashMap<String,String>();
|
||
map.put("type","3");//跳转到隐患列表
|
||
|
||
Jpush.sendGovAllNotifications(alias,content,map);
|
||
}
|
||
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 完成整改
|
||
*/
|
||
private void completeRectification(String receiveId,String enterpriseId){
|
||
try {
|
||
String alias = "";
|
||
String [] strs = receiveId.split(",");
|
||
for (String str : strs){
|
||
if(StringUtils.isNotBlank(alias)){
|
||
alias += ","+MD5.md5(str);
|
||
}else{
|
||
alias = MD5.md5(str);
|
||
}
|
||
}
|
||
String compamyName = "企业";
|
||
SysEnterprise sysEnterprise =sysEnterpriseMapper.selectByPrimaryKey(enterpriseId);
|
||
if(null != sysEnterprise){
|
||
compamyName = sysEnterprise.getEntname();
|
||
}
|
||
String content = compamyName+"的隐患已完成整改";
|
||
//msg.wav
|
||
Map<String,String> map = new HashMap<String,String>();
|
||
map.put("type","1");//跳转到隐患列表
|
||
|
||
Jpush.sendGovAllNotifications(alias,content,map);
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 签名授权通知
|
||
*/
|
||
private void autographAuth(String sysUserId,String receiveId){
|
||
try {
|
||
if(StringUtils.isNotBlank(receiveId)){
|
||
String alias = "";
|
||
String [] strs = receiveId.split(",");
|
||
for (String str : strs){
|
||
if(StringUtils.isNotBlank(alias)){
|
||
alias += ","+MD5.md5(str);
|
||
}else{
|
||
alias = MD5.md5(str);
|
||
}
|
||
}
|
||
String deptName = this.getUnitName(sysUserId);
|
||
String content = deptName+"的安全检查需要授权签名.";
|
||
//msg.wav
|
||
Map<String,String> map = new HashMap<String,String>();
|
||
map.put("type","2");//调整到签名授权页面
|
||
|
||
Jpush.sendGovAllNotifications(alias,content,map);
|
||
}
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
|
||
|
||
}
|
||
|
||
/**
|
||
* 推送隐患消息
|
||
* @param enterpriseId
|
||
* @throws Exception
|
||
*/
|
||
public void sendDangerMsg(String enterpriseId,String sysUserId){
|
||
try {
|
||
//推送别名
|
||
String alias = "";
|
||
//获取企业端法人账号
|
||
SysUser sysUser = sysUserMapper.findByEntId(enterpriseId);
|
||
if(null != sysUser){
|
||
alias = MD5.md5(sysUser.getSysuserid());
|
||
}
|
||
|
||
//获取企业非法人账号别名
|
||
List<SysEntUser> sysEntUsers = sysEntUserMapper.entUser(enterpriseId);
|
||
if(null != sysEntUsers && sysEntUsers.size() > 0){
|
||
for (SysEntUser sysEntUser : sysEntUsers){
|
||
if(StringUtils.isNotBlank(alias)){
|
||
alias += ","+MD5.md5(sysEntUser.getSysentuserid());
|
||
}else{
|
||
alias += MD5.md5(sysEntUser.getSysentuserid());
|
||
}
|
||
}
|
||
}
|
||
|
||
//如果别名不为空 则推送消息
|
||
if(StringUtils.isNotBlank(alias)){
|
||
|
||
String deptName = this.getUnitName(sysUserId);
|
||
String content = "收到“"+deptName+"”的隐患整改通知";
|
||
//msg.wav
|
||
Map<String,String> map = new HashMap<String,String>();
|
||
map.put("type","1");
|
||
|
||
Jpush.sendAllNotifications(alias,content,map);
|
||
}
|
||
/*SendMessage sendMessage = new SendMessage();
|
||
sendMessage.run();*/
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 企业端非法人上传隐患整改资料 推行消息给法人账号
|
||
* @param enterpriseId
|
||
* @throws Exception
|
||
*/
|
||
public void sendexamineDangerMsg(String enterpriseId,String sysUserId){
|
||
try {
|
||
//推送别名
|
||
String alias = "";
|
||
//获取企业端法人账号
|
||
SysUser sysUser = sysUserMapper.findByEntId(enterpriseId);
|
||
if(null != sysUser){
|
||
alias = MD5.md5(sysUser.getSysuserid());
|
||
}
|
||
//如果别名不为空 则推送消息
|
||
if(StringUtils.isNotBlank(alias)){
|
||
|
||
String content = "收到隐患整改信息,请审核。";
|
||
//msg.wav
|
||
Map<String,String> map = new HashMap<String,String>();
|
||
map.put("type","1");
|
||
|
||
Jpush.sendAllNotifications(alias,content,map);
|
||
}
|
||
/*SendMessage sendMessage = new SendMessage();
|
||
sendMessage.run();*/
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 隐患分配人员后 推送消息
|
||
*/
|
||
private void handelDanger(String sysUserId,String receiveId){
|
||
try {
|
||
//推送别名
|
||
String alias = "";
|
||
//获取企业端法人账号
|
||
SysEntUser sysEntUser = sysEntUserMapper.findById(receiveId);
|
||
if(null != sysEntUser){
|
||
alias = MD5.md5(sysEntUser.getSysentuserid());
|
||
}
|
||
|
||
//如果别名不为空 则推送消息
|
||
if(StringUtils.isNotBlank(alias)){
|
||
|
||
String content = "收到需整改的隐患,请及时处理。";
|
||
//msg.wav
|
||
Map<String,String> map = new HashMap<String,String>();
|
||
map.put("type","1");
|
||
|
||
Jpush.sendAllNotifications(alias,content,map);
|
||
}
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 异步添加日志
|
||
* @param sysUserId
|
||
* @param enterpriseId
|
||
* @param tableName
|
||
* @param objectId
|
||
* @param optType
|
||
* @param data
|
||
* @throws Exception
|
||
*/
|
||
public void addLog(String sysUserId,String enterpriseId,String tableName,String objectId,String optType,String data)throws Exception{
|
||
LogService logService = new LogService(sysUserId, enterpriseId, tableName, objectId, optType, data);
|
||
Thread logThread = new Thread(logService);
|
||
logThread.start();
|
||
}
|
||
|
||
/**
|
||
* 日志保存
|
||
*/
|
||
class LogService implements Runnable{
|
||
|
||
/**
|
||
* 用户id
|
||
*/
|
||
private String sysUserId;
|
||
|
||
/**
|
||
* 企业id
|
||
*/
|
||
private String enterpriseId;
|
||
|
||
/**
|
||
* 表名
|
||
*/
|
||
private String tableName;
|
||
|
||
/**
|
||
* 对象id
|
||
*/
|
||
private String objectId;
|
||
|
||
/**
|
||
* 操作类型
|
||
*/
|
||
private String optType;
|
||
|
||
/**
|
||
* 数据
|
||
*/
|
||
private String data;
|
||
|
||
public LogService(String sysUserId, String enterpriseId, String tableName, String objectId, String optType, String data) {
|
||
this.sysUserId = sysUserId;
|
||
this.enterpriseId = enterpriseId;
|
||
this.tableName = tableName;
|
||
this.objectId = objectId;
|
||
this.optType = optType;
|
||
this.data = data;
|
||
}
|
||
|
||
public LogService() {
|
||
}
|
||
|
||
@Override
|
||
public void run() {
|
||
saveLog(sysUserId,enterpriseId,tableName,objectId,optType,data);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 记录操作日志
|
||
* @param sysUserId
|
||
* @param enterpriseId 企业id
|
||
* @param tableName
|
||
* @param objectId
|
||
* @param optType
|
||
* @param data
|
||
* @throws Exception
|
||
*/
|
||
public void saveLog(String sysUserId,String enterpriseId,String tableName,String objectId,String optType,String data){
|
||
try {
|
||
String userName = this.getEntUserName(sysUserId);
|
||
SysLogOptWithBLOBs sysLogOpt = new SysLogOptWithBLOBs();
|
||
sysLogOpt.setCreatedby(userName);
|
||
sysLogOpt.setCreatedon(new Date());
|
||
sysLogOpt.setModifiedby(userName);
|
||
sysLogOpt.setModifiedon(new Date());
|
||
sysLogOpt.setSyslogoptid(RandomNumber.getUUid());
|
||
sysLogOpt.setObjname(tableName);
|
||
sysLogOpt.setObjchinaname(tableName);
|
||
sysLogOpt.setObjectid(objectId);
|
||
sysLogOpt.setOptid(sysUserId);
|
||
sysLogOpt.setOptusername(userName);
|
||
sysLogOpt.setOptchinaname(userName);
|
||
sysLogOpt.setOpttype(optType);
|
||
sysLogOpt.setOpttime(new Date());
|
||
sysLogOpt.setObjcnt1(data);
|
||
sysLogOpt.setObjcnt2(data);
|
||
sysLogOpt.setSysenterpriseid(enterpriseId);
|
||
sysLogOptMapper.insertSelective(sysLogOpt);
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 如果选择了检查记录 则履职详情和检查记录关联
|
||
* @throws Exception
|
||
*/
|
||
protected void addListCheck(String listDetailId,String checkId,String sysUserId,SysUser sysUser) throws Exception{
|
||
if(StringUtils.isNotBlank(checkId)){
|
||
String [] checkIds = checkId.split(",");
|
||
|
||
List<Listdetacheck> listdetachecks = new ArrayList<>();
|
||
for (String str : checkIds){
|
||
Listdetacheck listdetacheck = new Listdetacheck();
|
||
listdetacheck.setListdetacheck(RandomNumber.getUUid());
|
||
listdetacheck.setBookentcheckid(str);
|
||
listdetacheck.setListdetailid(listDetailId);
|
||
listdetacheck.setCreatedby(sysUser.getChinaname());
|
||
listdetacheck.setCreatedon(new Date());
|
||
listdetacheck.setModifiedby(sysUser.getChinaname());
|
||
listdetacheck.setModifiedon(new Date());
|
||
listdetachecks.add(listdetacheck);
|
||
}
|
||
|
||
if(null != listdetachecks && listdetachecks.size() > 0){
|
||
listdetacheckMapper.insertList(listdetachecks);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 新增安全检查/检查签名授权时 如果选择了履职要素id 则关联到履职清单
|
||
* @param listfactorid 履职清单id 多个用逗号隔开
|
||
* @param worktitle 履职记录内容
|
||
* @param sysUserId 用户id
|
||
* @throws Exception
|
||
*/
|
||
protected void addCheckList(String listfactorid,String worktitle,String sysUserId,String checkId,SysUser sysUser)throws Exception{
|
||
if(StringUtils.isNotBlank(listfactorid) && StringUtils.isNotBlank(checkId)){
|
||
String[] strs = listfactorid.split(",");
|
||
for (String str :strs){
|
||
ListDetailWithBLOBs listDetail = new ListDetailWithBLOBs();
|
||
String listDetailId = RandomNumber.getUUid();
|
||
listDetail.setListdetailid(listDetailId);
|
||
listDetail.setListfactorid(str);
|
||
listDetail.setWorktitle(worktitle);
|
||
listDetail.setStarttime(new Date());
|
||
listDetail.setFactorCnt(worktitle);
|
||
listDetail.setWorkcnt(worktitle);
|
||
listDetail.setIsfinish("是");
|
||
listDetail.setFinishtime(new Date());
|
||
listDetail.setEndtime(new Date());
|
||
listDetail.setSysUserId(sysUserId);
|
||
listDetail.setDelState(DelState.NOT_DEL.getState());
|
||
listDetail.setCreatedby(sysUser.getChinaname());
|
||
listDetail.setModifiedby(sysUser.getChinaname());
|
||
listDetailMapper.insert(listDetail);
|
||
//检查id 关联到 履职记录
|
||
this.addListCheck(listDetailId,checkId,sysUserId,sysUser);
|
||
//修改履职档案完成情况
|
||
this.factorProgres(listfactorid);
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
|
||
/**
|
||
* 格式化任务详情数据
|
||
* @param oaTask
|
||
* @throws Exception
|
||
*/
|
||
protected void handleTaskDetail(OATask oaTask)throws Exception{
|
||
if(StringUtils.isBlank(oaTask.getTasktype())){
|
||
oaTask.setTasktype("履职任务");
|
||
}
|
||
|
||
String appstatus = "未完成";
|
||
if(StringUtils.isNotBlank(oaTask.getTaskStatus())){
|
||
appstatus = oaTask.getTaskStatus();
|
||
}else{
|
||
if("是".equals(oaTask.getIsfinish())){
|
||
appstatus = "已完成";
|
||
}
|
||
}
|
||
oaTask.setAppstatus(appstatus);
|
||
|
||
if(StringUtils.isBlank(oaTask.getSendName())){
|
||
oaTask.setSendName(oaTask.getCreatedby());
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 获取用户信息
|
||
* @param sysUserId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected SysUser getUser(String sysUserId) throws Exception{
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(sysUserId);
|
||
if(null == sysUser){
|
||
sysUser = new SysUser();
|
||
}
|
||
return sysUser;
|
||
}
|
||
|
||
/**
|
||
* 获取用户名
|
||
* @param sysUserId
|
||
* @param isLegal
|
||
* @return
|
||
*/
|
||
public String getNickName(String sysUserId, String isLegal){
|
||
String nickName = "";
|
||
if("1".equals(isLegal)){
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(sysUserId);
|
||
if(null != sysUser){
|
||
nickName = sysUser.getChinaname();
|
||
}
|
||
}else if("2".equals(isLegal)){
|
||
SysEntUser sysEntUser = sysEntUserMapper.findById(sysUserId);
|
||
if(null != sysEntUser){
|
||
nickName = sysEntUser.getNickname();
|
||
}
|
||
}
|
||
return nickName;
|
||
}
|
||
|
||
/**
|
||
* 修改履职进度
|
||
* @param listPerformId
|
||
* @throws Exception
|
||
*/
|
||
protected void changeListPerForm(String listPerformId)throws Exception{
|
||
String time = DateUtils.getNowDateTimeStr("yyyy");
|
||
List<ListFactor> listFactors = listFactorMapper.findByFactorIsFinish(listPerformId,time);
|
||
if(null != listFactors && listFactors.size() > 0){
|
||
//需完成的数量
|
||
Integer total = 0;
|
||
//已完成的数量
|
||
Integer finishTotal = 0;
|
||
|
||
for (ListFactor listFactor : listFactors){
|
||
|
||
//频次为空 设置值为1
|
||
if(null == listFactor.getCheckstandard()){
|
||
listFactor.setCheckstandard(1);
|
||
}
|
||
//频率为空 设置值为1
|
||
if(null == listFactor.getFrequency()){
|
||
listFactor.setFrequency(1);
|
||
}
|
||
|
||
//需完成数量
|
||
Integer factorNum = 0;
|
||
if(Checkstandard.CUSTOM.getStandard() == listFactor.getCheckstandard()){
|
||
factorNum = listFactor.getFrequency();
|
||
}else{
|
||
factorNum = listFactor.getCheckstandard() * listFactor.getFrequency();
|
||
}
|
||
total+=factorNum;
|
||
|
||
|
||
//已完成数量
|
||
Long listDetailNum = listDetailMapper.countListDetail(listFactor.getListfactorid());
|
||
if(null == listDetailNum){
|
||
listDetailNum = 0l;
|
||
}
|
||
|
||
//如果已完成数量超过规定数量 已完成数量等于需完成数量
|
||
if(listDetailNum > factorNum){
|
||
listDetailNum = factorNum.longValue();
|
||
}
|
||
|
||
finishTotal += listDetailNum.intValue();
|
||
|
||
}
|
||
Double progress = Arith.div(finishTotal,total)*100;
|
||
Integer allprogress = progress.intValue();
|
||
if(allprogress > 100){
|
||
allprogress = 100;
|
||
}
|
||
|
||
listPerformMapper.changeCompletion(listPerformId,allprogress+"");
|
||
}else{
|
||
listPerformMapper.changeCompletion(listPerformId,"0");
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 获取企业用户列表
|
||
* @param sysUserId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String getEntUserName(String sysUserId)throws Exception{
|
||
String sysUserName = "";
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(sysUserId);
|
||
if(null != sysUser){
|
||
sysUserName = sysUser.getChinaname();
|
||
}else{
|
||
SysEntUser sysEntUser = sysEntUserMapper.findById(sysUserId);
|
||
if(null != sysEntUser){
|
||
sysUserName = sysEntUser.getNickname();
|
||
}
|
||
}
|
||
return sysUserName;
|
||
}
|
||
|
||
/**
|
||
* 修改企业清单数量
|
||
* @param companyId
|
||
* @throws Exception
|
||
*/
|
||
protected void changeEntListNum(String companyId,String nickName)throws Exception{
|
||
EntMessage entMessage = entMessageMapper.findByEntId(companyId);
|
||
|
||
/**
|
||
* 主体清单数
|
||
*/
|
||
Integer mainNum = sysEntListMapper.countByEntId(companyId, EntListType.SUBJECT_LIST.getType());
|
||
|
||
/**
|
||
* 岗位清单数
|
||
*/
|
||
Integer postNum = sysEntListMapper.countByEntId(companyId, EntListType.POST_LIST.getType());
|
||
|
||
/**
|
||
* 检查清单数
|
||
*/
|
||
Integer checkNum = sysEntListMapper.countByEntId(companyId, EntListType.CHECK_LIST.getType());
|
||
|
||
/**
|
||
* 应急清单数
|
||
*/
|
||
Integer urgentNum = sysEntListMapper.countByEntId(companyId, EntListType.OTH_LIST.getType());
|
||
|
||
|
||
if(null != entMessage){
|
||
entMessage.setMainNum(mainNum);
|
||
entMessage.setPostNum(postNum);
|
||
entMessage.setCheckNum(checkNum);
|
||
entMessage.setUrgentNum(urgentNum);
|
||
entMessage.setModifiedBy(nickName);
|
||
entMessage.setModifiedOn(new Date());
|
||
entMessageMapper.changeByEntId(entMessage);
|
||
}else{
|
||
entMessage = new EntMessage();
|
||
entMessage.setSysEnterpriseId(companyId);
|
||
entMessage.setEntMessageId(RandomNumber.getUUid());
|
||
entMessage.setMainNum(mainNum);
|
||
entMessage.setPostNum(postNum);
|
||
entMessage.setCheckNum(checkNum);
|
||
entMessage.setUrgentNum(urgentNum);
|
||
entMessage.setCreatedBy(nickName);
|
||
entMessage.setCreatedOn(new Date());
|
||
entMessage.setModifiedBy(nickName);
|
||
entMessage.setModifiedOn(new Date());
|
||
entMessageMapper.insertSelective(entMessage);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 修改企业用户数
|
||
* @param companyId
|
||
* @throws Exception
|
||
*/
|
||
protected void changeEntUserNum(String companyId,String nickName)throws Exception{
|
||
EntMessage entMessage = entMessageMapper.findByEntId(companyId);
|
||
|
||
//企业岗位数
|
||
Integer userNum = sysEntUserMapper.countByEntId(companyId);
|
||
|
||
if(null != entMessage){
|
||
entMessage.setPost(userNum);
|
||
entMessage.setUserNum(userNum);
|
||
entMessage.setModifiedBy(nickName);
|
||
entMessage.setModifiedOn(new Date());
|
||
entMessageMapper.changeByEntId(entMessage);
|
||
}else{
|
||
entMessage = new EntMessage();
|
||
entMessage.setSysEnterpriseId(companyId);
|
||
entMessage.setEntMessageId(RandomNumber.getUUid());
|
||
entMessage.setPost(userNum);
|
||
entMessage.setUserNum(userNum);
|
||
entMessage.setCreatedBy(nickName);
|
||
entMessage.setCreatedOn(new Date());
|
||
entMessage.setModifiedBy(nickName);
|
||
entMessage.setModifiedOn(new Date());
|
||
entMessageMapper.insertSelective(entMessage);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 修改企业承诺数
|
||
* @param companyId
|
||
* @param nickName
|
||
* @throws Exception
|
||
*/
|
||
protected void changePromiseNum(String companyId,String nickName)throws Exception{
|
||
EntMessage entMessage = entMessageMapper.findByEntId(companyId);
|
||
|
||
//承诺数
|
||
Integer promiseNum = 0;
|
||
//未承诺数
|
||
Integer NOPromiseNum = 0;
|
||
|
||
List<SysEntUser> entUsers = sysEntUserMapper.promiseEntUser(companyId);
|
||
if(null != entUsers && entUsers.size() > 0){
|
||
for (SysEntUser entUser : entUsers){
|
||
if(entUser.getPromiseNum() > 0){
|
||
promiseNum++;
|
||
}else{
|
||
NOPromiseNum++;
|
||
}
|
||
}
|
||
}
|
||
|
||
if(null != entMessage){
|
||
entMessage.setPromiseNum(promiseNum);
|
||
entMessage.setNOPromiseNum(NOPromiseNum);
|
||
entMessage.setModifiedBy(nickName);
|
||
entMessage.setModifiedOn(new Date());
|
||
entMessageMapper.changeByEntId(entMessage);
|
||
}else{
|
||
entMessage = new EntMessage();
|
||
entMessage.setSysEnterpriseId(companyId);
|
||
entMessage.setEntMessageId(RandomNumber.getUUid());
|
||
entMessage.setPromiseNum(promiseNum);
|
||
entMessage.setNOPromiseNum(NOPromiseNum);
|
||
entMessage.setCreatedBy(nickName);
|
||
entMessage.setCreatedOn(new Date());
|
||
entMessage.setModifiedBy(nickName);
|
||
entMessage.setModifiedOn(new Date());
|
||
entMessageMapper.insertSelective(entMessage);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
/**
|
||
* 记录登录日志
|
||
* @param sysUserId
|
||
* @param optType
|
||
* @param optStatus
|
||
* @throws Exception
|
||
*/
|
||
public void addLogAuth(String sysUserId,String optType,String optStatus,String entId)throws Exception{
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(sysUserId);
|
||
if(null != sysUser){
|
||
SysLogAuth sysLogAuth = new SysLogAuth();
|
||
sysLogAuth.setSyslogauthid(RandomNumber.getUUid());
|
||
sysLogAuth.setAuthuserid(sysUser.getSysuserid());
|
||
sysLogAuth.setAuthusername(sysUser.getChinaname());
|
||
sysLogAuth.setAuthopttype(optType);
|
||
sysLogAuth.setAuthopttime(new Date());
|
||
sysLogAuth.setAuthoptstatus(optStatus);
|
||
sysLogAuth.setCreatedby("APP自动记录");
|
||
sysLogAuth.setCreatedon(new Date());
|
||
sysLogAuth.setModifiedby("APP自动记录");
|
||
sysLogAuth.setModifiedon(new Date());
|
||
sysLogAuth.setSysenterpriseid(entId);
|
||
sysLogAuthMapper.insert(sysLogAuth);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 新都地区代码
|
||
* */
|
||
public List<SysOrg>getSysOrg(String superiorOrgCode)throws Exception{
|
||
List<SysOrg> sysOrgs = sysOrgMapper.sysOrgList(superiorOrgCode);
|
||
return sysOrgs;
|
||
}
|
||
|
||
/**
|
||
* 新都地区代码最高级包括
|
||
* */
|
||
public List<SysOrg>getSysOrgHighLevel()throws Exception{
|
||
List<SysOrg> sysOrgs = sysOrgMapper.sysOrgList(null);
|
||
return sysOrgs;
|
||
}
|
||
|
||
|
||
/**
|
||
* 将id(安全类别/行业类别)转换成中文
|
||
* @param type 1 = 安全类别 2 = 行业类别
|
||
* */
|
||
public List<String>exchange(String id,int type){
|
||
List<String>stringList = new ArrayList<>();
|
||
if(StringUtils.isNotBlank(id)){
|
||
String [] arr = id.split(",");
|
||
if (type == 1){
|
||
List<BaseSafeClass>baseSafeClasses = baseSafeClassMapper.findAll();
|
||
for (String ar:arr) {
|
||
for (BaseSafeClass bs:baseSafeClasses) {
|
||
if (ar.equals(bs.getBasesafeclassid())){
|
||
stringList.add(bs.getSafeclassname());
|
||
}
|
||
}
|
||
}
|
||
}else if(type == 2){
|
||
List<BaseInClass>baseInClasses = baseInClassMapper.findAll();
|
||
for (String ar:arr) {
|
||
for (BaseInClass bi:baseInClasses) {
|
||
if (ar.equals(bi.getBaseinclassid())){
|
||
stringList.add(bi.getIndustryclassname());
|
||
}
|
||
}
|
||
}
|
||
}else if(type == 3){
|
||
List<BaseInClass>baseInClasses = baseInClassMapper.findAll();
|
||
for (String ar:arr) {
|
||
for (BaseInClass bi:baseInClasses) {
|
||
if (ar.equals(bi.getBaseinclassid())){
|
||
stringList.add(bi.getIndustryclassname());
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
return stringList;
|
||
}
|
||
|
||
/**
|
||
* 安全类别
|
||
* */
|
||
public List<BaseSafeClass>baseSafeClasses(int isTree){
|
||
List<BaseSafeClass>baseSafeClasses;
|
||
if (isTree == 1){
|
||
baseSafeClasses = baseSafeClassMapper.findAllTree();
|
||
}else {
|
||
baseSafeClasses = baseSafeClassMapper.findAll();
|
||
}
|
||
return baseSafeClasses;
|
||
}
|
||
|
||
/**
|
||
* 行业类别
|
||
* */
|
||
public List<TreeModel>baseInClasses(int isTree, Integer type)throws Exception{
|
||
List<TreeModel> baseInClasses = baseInClassMapper.findInClass();
|
||
JSONArray jsonArray = handleTreeModel(baseInClasses);
|
||
List<TreeModel> treeModels = JSONArray.parseArray(jsonArray.toJSONString(),TreeModel.class);
|
||
return treeModels;
|
||
}
|
||
|
||
/**
|
||
* 地区树形结构
|
||
* @param treeModels
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public JSONArray handleTreeModel(List<TreeModel> treeModels)throws Exception{
|
||
List<Map<String,Object>> data = new ArrayList<>();
|
||
for(TreeModel treeModel : treeModels){
|
||
if(StringUtils.isBlank(treeModel.getParentId())){
|
||
treeModel.setParentId("");
|
||
}
|
||
Map<String,Object> entUserMap = new HashMap<String,Object>();
|
||
entUserMap.put("label",treeModel.getLabel());
|
||
entUserMap.put("id",treeModel.getId());
|
||
entUserMap.put("parentId",treeModel.getParentId());
|
||
entUserMap.put("code",treeModel.getCode());
|
||
entUserMap.put("isSelect",treeModel.getIsSelect());
|
||
|
||
data.add(entUserMap);
|
||
}
|
||
JSONArray result = TypeConversion.listToTree(JSONArray.parseArray(JSON.toJSONString(data)),"id","parentId","children");
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 统一处理分页
|
||
* @param pager api返回的对象
|
||
* @param page 分页插件对象
|
||
* @throws Exception
|
||
*/
|
||
/* protected void getDatePage(Pager pager, Page page)throws Exception{
|
||
pager.setTotal(page.getTotal());
|
||
pager.setRows(page.getResult());
|
||
}*/
|
||
|
||
/**
|
||
* 获取用户职务
|
||
* @param sysUser
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected SysUser getUserDuty(SysUser sysUser)throws Exception{
|
||
//获取部门名
|
||
String unitName = getUnitName(sysUser.getSysuserid());
|
||
if(StringUtils.isNotBlank(unitName)){
|
||
sysUser.setSysunitorentname(unitName);
|
||
}
|
||
|
||
//职务
|
||
if(StringUtils.isNotBlank(sysUser.getSystitle())){
|
||
ListPerform listPerform = listPerformMapper.selectByPrimaryKey(sysUser.getSystitle());
|
||
if(null != listPerform){
|
||
sysUser.setPerformId(listPerform.getSupclassid());
|
||
String titleName = listPerform.getPerformclassname();
|
||
if(StringUtils.isNotBlank(sysUser.getSysunitorentname())){
|
||
titleName = titleName.replace(sysUser.getSysunitorentname(),"");
|
||
}
|
||
sysUser.setSystitlename(titleName);
|
||
}
|
||
}
|
||
|
||
// sysUser.setSystitle(sysUser.getSysdeptname());
|
||
return sysUser;
|
||
}
|
||
|
||
/**
|
||
* 通过用户id 获取用户履职记录id
|
||
* @param sysUserId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected List<String> getListFactorId(String sysUserId)throws Exception{
|
||
List<String> listFactorIds = new ArrayList<>();
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(sysUserId);
|
||
if(null != sysUser && StringUtils.isNotBlank(sysUser.getSystitle())){
|
||
String time = DateUtils.getNowDateTimeStr("yyyy");
|
||
List<ListFactor> listFactors = listFactorMapper.userListFactor(sysUser.getSystitle(),time);
|
||
if(null != listFactors && listFactors.size() > 0){
|
||
for (ListFactor listFactor : listFactors){
|
||
listFactorIds.add(listFactor.getListfactorid());
|
||
}
|
||
}
|
||
}
|
||
return listFactorIds;
|
||
}
|
||
|
||
/**
|
||
* 获取接收任务的用户id
|
||
* 如果是部门管理员 则返回部门id 和 自己的用户id 其他只返回用户id
|
||
* @param sysUserId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected List<String> getReceiveTaskUserId(String sysUserId)throws Exception{
|
||
List<String> sysUserIds = new ArrayList<>();
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(sysUserId);
|
||
if(null != sysUser){
|
||
sysUserIds.add(sysUserId);
|
||
Integer userRole = getUserRole(sysUser.getUserroles());
|
||
if(null != userRole && 2 == userRole){
|
||
String listPerformId = getListPerformId(sysUserId);
|
||
if(StringUtils.isNotBlank(listPerformId)){
|
||
sysUserIds.add(listPerformId);
|
||
}
|
||
}
|
||
}
|
||
return sysUserIds;
|
||
}
|
||
|
||
/**
|
||
* 获取用户角色
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected Integer getUserRole(String userroles) throws Exception{
|
||
Integer userRole = 0;
|
||
if(StringUtils.isNotBlank(userroles)){
|
||
List<String> roleIds = new ArrayList<>();
|
||
String [] strs = userroles.split(",");
|
||
for (String str : strs){
|
||
roleIds.add(str);
|
||
}
|
||
List<SysRole> sysRoles = sysRoleMapper.userRoles(roleIds);
|
||
//用户角色 0:其他 1:安办 2:部门管理员
|
||
//安办角色id
|
||
String anbanRole = "295EF8C3-902F-41F0-95C8-D3AB9C6DA144";
|
||
//部门管理员角色id
|
||
String deptRole = "295EF8C3-902F-41F0-95C8-D3AB9C6DA166";
|
||
for (SysRole sysRole : sysRoles){
|
||
if(anbanRole.equals(sysRole.getSysroleid())){
|
||
userRole = 1;
|
||
}else if(deptRole.equals(sysRole.getSysroleid())){
|
||
//部门管理员
|
||
userRole = 2;
|
||
}
|
||
}
|
||
}
|
||
//全部设置成安办账号
|
||
// userRole = 2;
|
||
return userRole;
|
||
}
|
||
|
||
/**
|
||
* 履职代办任务
|
||
* @param tasks
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected List<OATask> stayTask(List<OATask> tasks)throws Exception{
|
||
List<OATask> oaTasks = new ArrayList<>();
|
||
if(null != tasks && tasks.size() > 0){
|
||
for (OATask task : tasks){
|
||
if(null == task.getYellowAlert()){
|
||
task.setYellowAlert(1);
|
||
}
|
||
|
||
Integer dayTime = task.getYellowAlert() * 24 * 60 * 60 * 1000;
|
||
Long nowTime = Calendar.getInstance().getTimeInMillis();
|
||
Long endTime = task.getPlanenddate().getTime();
|
||
if((endTime - nowTime) < dayTime){
|
||
oaTasks.add(task);
|
||
}
|
||
}
|
||
// oaTasks.addAll(tasks);
|
||
|
||
}
|
||
return oaTasks;
|
||
}
|
||
|
||
/**
|
||
* 处理任务结束时间
|
||
* 如果任务已完成 结束时间为空 则把计划结束时间存到结束时间字段
|
||
* @param oaTask
|
||
*/
|
||
protected void handleEndDate(OATask oaTask){
|
||
|
||
//履职id
|
||
oaTask.setListfactorid(oaTask.getOtcid());
|
||
|
||
if(IsFinish.YES.getFinish().equals(oaTask.getIsfinish())){
|
||
if(null == oaTask.getEnddate()){
|
||
oaTask.setEnddate(oaTask.getPlanenddate());
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 计算提醒类型 1:正常 2:黄色提醒 3:红色提醒
|
||
* @param listFactors
|
||
* @throws Exception
|
||
*/
|
||
protected void handleFactorAlert(List<ListFactor> listFactors)throws Exception{
|
||
for (ListFactor listFactor : listFactors){
|
||
System.out.println("Frequency -> "+listFactor.getFrequency());
|
||
|
||
//需要完成的总次数
|
||
Integer factorTotal = 0;
|
||
if(Checkstandard.CUSTOM.getStandard() == listFactor.getCheckstandard()){
|
||
factorTotal = listFactor.getFrequency();
|
||
}else{
|
||
factorTotal = listFactor.getCheckstandard() * listFactor.getFrequency();
|
||
}
|
||
listFactor.setFactorTotal(factorTotal);
|
||
|
||
//已完成次数
|
||
Integer factorNum = 0;
|
||
|
||
if(null != listFactor.getFactorTimes() && listFactor.getFactorTimes().size() > 0){
|
||
factorNum = listFactor.getFactorTimes().size();
|
||
listFactor.setChangeTime(listFactor.getFactorTimes().get(0).getChangeTime());
|
||
}
|
||
listFactor.setFactorNum(factorNum);
|
||
|
||
|
||
if(!"100".equals(listFactor.getFinishProgres())){
|
||
listFactor.setFactorAlert(4);
|
||
}
|
||
|
||
/*
|
||
* 一年一次 半年一次 每季度一次 每月一次
|
||
* 一年一次 判断当前时间到12月31号的天数
|
||
* 半年一次 先判断是上半年还是下半年 上半年就判断到6月30的天数 下半年判断到12月30号的天数
|
||
* 每季度一次 判断到当前季度最后一天的天数
|
||
* 每月一次 判断到本月最后一天的天数
|
||
*
|
||
* 在获取提醒天数 判断提醒类型 黄色 红色
|
||
*/
|
||
|
||
FactorDay factorDay = getDay(listFactor.getCheckstandard());
|
||
Integer day = factorDay.getDay();
|
||
// System.out.println("day -> "+day);
|
||
|
||
List<Integer> months = factorDay.getMonths();
|
||
|
||
Integer red = TypeConversion.StringToInteger(listFactor.getRedAlert());
|
||
Integer yellow = TypeConversion.StringToInteger(listFactor.getYellowAlert());
|
||
|
||
|
||
Integer changeMonth = 0;
|
||
if(null != listFactor.getChangeTime()){
|
||
changeMonth = DateUtils.parseDate2Calendar(listFactor.getChangeTime()).get(Calendar.MONTH)+1;
|
||
}
|
||
|
||
// System.out.println("months -> "+months);
|
||
// System.out.println("months -> "+changeMonth);
|
||
// System.out.println("months.contains(changeMonth) -> "+months.contains(changeMonth));
|
||
if(!(months.contains(changeMonth))){
|
||
//计算报警类型
|
||
if(day <= red){
|
||
listFactor.setFactorAlert(3);
|
||
}else if( day >red && day <= yellow){
|
||
listFactor.setFactorAlert(2);
|
||
}
|
||
|
||
}
|
||
// System.out.println("getFactorAlert -> "+listFactor.getFactorAlert());
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 计算提醒类型 1:正常 2:黄色提醒 3:红色提醒
|
||
* @param ListFactor
|
||
* @throws Exception
|
||
*/
|
||
protected void handleFactorAlert(ListFactor listFactor)throws Exception{
|
||
System.out.println("Frequency -> "+listFactor.getFrequency());
|
||
|
||
//需要完成的总次数
|
||
Integer factorTotal = listFactor.getCheckstandard() * listFactor.getFrequency();
|
||
listFactor.setFactorTotal(factorTotal);
|
||
|
||
//已完成次数
|
||
Integer factorNum = 0;
|
||
|
||
if(null != listFactor.getFactorTimes() && listFactor.getFactorTimes().size() > 0){
|
||
factorNum = listFactor.getFactorTimes().size();
|
||
listFactor.setChangeTime(listFactor.getFactorTimes().get(0).getChangeTime());
|
||
}
|
||
listFactor.setFactorNum(factorNum);
|
||
|
||
|
||
if(!"100".equals(listFactor.getFinishProgres())){
|
||
listFactor.setFactorAlert(4);
|
||
}
|
||
|
||
/*
|
||
* 一年一次 半年一次 每季度一次 每月一次
|
||
* 一年一次 判断当前时间到12月31号的天数
|
||
* 半年一次 先判断是上半年还是下半年 上半年就判断到6月30的天数 下半年判断到12月30号的天数
|
||
* 每季度一次 判断到当前季度最后一天的天数
|
||
* 每月一次 判断到本月最后一天的天数
|
||
*
|
||
* 在获取提醒天数 判断提醒类型 黄色 红色
|
||
*/
|
||
|
||
FactorDay factorDay = getDay(listFactor.getCheckstandard());
|
||
Integer day = factorDay.getDay();
|
||
// System.out.println("day -> "+day);
|
||
|
||
List<Integer> months = factorDay.getMonths();
|
||
|
||
Integer red = TypeConversion.StringToInteger(listFactor.getRedAlert());
|
||
Integer yellow = TypeConversion.StringToInteger(listFactor.getYellowAlert());
|
||
|
||
|
||
Integer changeMonth = 0;
|
||
if(null != listFactor.getChangeTime()){
|
||
changeMonth = DateUtils.parseDate2Calendar(listFactor.getChangeTime()).get(Calendar.MONTH)+1;
|
||
}
|
||
|
||
// System.out.println("months -> "+months);
|
||
// System.out.println("months -> "+changeMonth);
|
||
// System.out.println("months.contains(changeMonth) -> "+months.contains(changeMonth));
|
||
if(!(months.contains(changeMonth))){
|
||
//计算报警类型
|
||
if(day <= red){
|
||
listFactor.setFactorAlert(3);
|
||
}else if( day >red && day <= yellow){
|
||
listFactor.setFactorAlert(2);
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 获取剩余天数
|
||
* @param checkstandard
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected FactorDay getDay(Integer checkstandard)throws Exception{
|
||
FactorDay factorDay = new FactorDay();
|
||
List<Integer> months = new ArrayList<>();
|
||
Integer days = 100;
|
||
String nowTime = DateUtils.getNowDateTimeStr(Constants.DATA_MEET);
|
||
Integer month = Calendar.getInstance().get(Calendar.MONTH) + 1;
|
||
Integer year = Calendar.getInstance().get(Calendar.YEAR);
|
||
String entTime = "";
|
||
if(null == checkstandard || 1 == checkstandard){
|
||
//年最后一天
|
||
entTime = year + "-12-31";
|
||
months.add(1);
|
||
months.add(2);
|
||
months.add(3);
|
||
months.add(4);
|
||
months.add(5);
|
||
months.add(6);
|
||
months.add(7);
|
||
months.add(8);
|
||
months.add(9);
|
||
months.add(10);
|
||
months.add(11);
|
||
months.add(12);
|
||
}else if(2 == checkstandard){
|
||
//上半年和下半年的最后一天
|
||
if(month <= 6){
|
||
months.add(1);
|
||
months.add(2);
|
||
months.add(3);
|
||
months.add(4);
|
||
months.add(5);
|
||
months.add(6);
|
||
entTime = year + "-06-30";
|
||
}else{
|
||
entTime = year + "-12-31";
|
||
months.add(7);
|
||
months.add(8);
|
||
months.add(9);
|
||
months.add(10);
|
||
months.add(11);
|
||
months.add(12);
|
||
}
|
||
}else if(4 == checkstandard){
|
||
//每季度最后一天
|
||
if(month <= 3){
|
||
months.add(1);
|
||
months.add(2);
|
||
months.add(3);
|
||
entTime = year + "-3-31";
|
||
}else if(3 < month && month <= 6){
|
||
entTime = year + "-06-30";
|
||
months.add(4);
|
||
months.add(5);
|
||
months.add(6);
|
||
}else if(6 < month && month <= 9){
|
||
entTime = year + "-09-30";
|
||
months.add(7);
|
||
months.add(8);
|
||
months.add(9);
|
||
}else if(9 < month){
|
||
entTime = year + "-12-31";
|
||
months.add(10);
|
||
months.add(11);
|
||
months.add(12);
|
||
}
|
||
}else if(12 == checkstandard){
|
||
months.add(month);
|
||
//每个月最后一天
|
||
Integer day = DateUtils.getMonthLastDay(year,month);
|
||
entTime = year + "-" + month + "-" + day;
|
||
}else if(6 == checkstandard){
|
||
if(0 != checkstandard%2){
|
||
checkstandard = checkstandard + 1;
|
||
}
|
||
month = checkstandard;
|
||
Integer day = DateUtils.getMonthLastDay(year,month);
|
||
entTime = year + "-" + month + "-" + day;
|
||
}else if(8 == checkstandard){
|
||
Integer day = DateUtils.getMonthLastDay(year,month);
|
||
if(month <= 8){
|
||
entTime = year + "-" + month + "-" + day;
|
||
}else{
|
||
year += 1;
|
||
entTime = year + "-" + month + "-" + day;
|
||
}
|
||
}
|
||
|
||
|
||
if(StringUtils.isBlank(entTime)){
|
||
entTime = year+"-12-31";
|
||
}
|
||
|
||
//计算当前时间和最后履职截止时间相差的天数
|
||
Calendar start = DateUtils.getDateTimeStr(nowTime,Constants.DATA_MEET);
|
||
Calendar end = DateUtils.getDateTimeStr(entTime,Constants.DATA_MEET);
|
||
Long total = end.getTimeInMillis() - start.getTimeInMillis();
|
||
Long day = total / (1000*60*60*24);
|
||
days = day.intValue();
|
||
factorDay.setDay(days);
|
||
factorDay.setMonths(months);
|
||
return factorDay;
|
||
}
|
||
|
||
/**
|
||
* 岗位进度
|
||
* @param performIds
|
||
* @param year
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public Map<String,PerformProgress> getPerformProgress(List<String> performIds,String year)throws Exception{
|
||
//之前是当前年之前的年份 计算
|
||
|
||
//岗位进度
|
||
Map<String,PerformProgress> progressMap = new HashMap<>();
|
||
|
||
//岗位履职情况
|
||
Map<String,List<FactorYear>> factorYearMap = new HashMap<>();
|
||
|
||
//所有岗位履职列表
|
||
List<FactorYear> factorYears = listFactorMapper.findByYear(performIds,year);
|
||
if(null != factorYears && factorYears.size() > 0){
|
||
|
||
//按岗位分组
|
||
for (FactorYear factorYear : factorYears){
|
||
List<FactorYear> factors = new ArrayList<>();
|
||
if(factorYearMap.containsKey(factorYear.getListPerformId())){
|
||
factors = factorYearMap.get(factorYear.getListPerformId());
|
||
}
|
||
factors.add(factorYear);
|
||
factorYearMap.put(factorYear.getListPerformId(),factors);
|
||
}
|
||
|
||
|
||
|
||
//岗位分组后计算进度
|
||
for (Map.Entry<String, List<FactorYear>> factorMap : factorYearMap.entrySet()) {
|
||
PerformProgress performProgress = new PerformProgress();
|
||
Integer allprogress = 0;
|
||
List<FactorYear> factorProgres = factorMap.getValue();
|
||
if(null != factorProgres && factorProgres.size() > 0){
|
||
//需完成的数量
|
||
Integer total = 0;
|
||
//已完成的数量
|
||
Integer finishTotal = 0;
|
||
|
||
for (FactorYear factorProgre : factorProgres){
|
||
if(null == factorProgre.getCheckStandard()){
|
||
factorProgre.setCheckStandard(1);
|
||
}
|
||
|
||
if(null == factorProgre.getFrequency()){
|
||
factorProgre.setFrequency(1);
|
||
}
|
||
|
||
//需完成数量
|
||
Integer factorNum = (factorProgre.getFrequency() * factorProgre.getCheckStandard());
|
||
total += factorNum;
|
||
|
||
//已完成数量
|
||
Long listDetailNum = factorProgre.getFactorNum();
|
||
if(listDetailNum > factorNum){
|
||
listDetailNum = factorNum.longValue();
|
||
}
|
||
finishTotal += listDetailNum.intValue();
|
||
|
||
}
|
||
|
||
Double progress = Arith.div(finishTotal,total)*100;
|
||
allprogress = progress.intValue();
|
||
if(allprogress > 100){
|
||
allprogress = 100;
|
||
}
|
||
|
||
performProgress.setTotal(total);
|
||
performProgress.setFinishTotal(finishTotal);
|
||
performProgress.setAllprogress(allprogress);
|
||
}
|
||
|
||
|
||
|
||
progressMap.put(factorMap.getKey(),performProgress);
|
||
}
|
||
}
|
||
return progressMap;
|
||
}
|
||
|
||
/**
|
||
* 获取当前年之前的履职进度
|
||
* @throws Exception
|
||
*/
|
||
public void handerPerform(List<UserDepart> userDeparts, String year, List<String> performIds)throws Exception{
|
||
String nowYear = DateUtils.getNowDateTimeStr("yyyy");
|
||
|
||
Map<String,PerformProgress> progressMap = getPerformProgress(performIds,year);
|
||
|
||
for (UserDepart userDepart : userDeparts){
|
||
|
||
userDepart.setPostName(userDepart.getUnitName()+userDepart.getPostName()+"("+userDepart.getUserName()+")");
|
||
|
||
|
||
Integer completion = 0;
|
||
/**
|
||
* 需完成的数量
|
||
*/
|
||
Integer total = 0;
|
||
|
||
/**
|
||
* 已完成的数量
|
||
*/
|
||
Integer finishTotal = 0;
|
||
|
||
PerformProgress performProgress = progressMap.get(userDepart.getListPerformId());
|
||
|
||
if(null != performProgress){
|
||
//获取岗位进度
|
||
completion = performProgress.getAllprogress();
|
||
if(null == completion){
|
||
completion = 0;
|
||
}
|
||
|
||
total = performProgress.getTotal();
|
||
finishTotal = performProgress.getFinishTotal();
|
||
}
|
||
userDepart.setCompletion(completion+"");
|
||
|
||
//需完成总数
|
||
userDepart.setTotal(total);
|
||
//已完成总数
|
||
userDepart.setFinishTotal(finishTotal);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 处理职务
|
||
* @param sysUsers
|
||
* @throws Exception
|
||
*/
|
||
protected void handleUser(List<SysUser> sysUsers)throws Exception{
|
||
for (SysUser sysUser : sysUsers){
|
||
if(StringUtils.isNotBlank(sysUser.getPerformclassname()) && StringUtils.isNotBlank(sysUser.getSuperName())){
|
||
// String postName = sysUser.getPerformClassName();
|
||
// String deptName = sysUser.getSuperName();
|
||
// postName = postName.replace(deptName,"");
|
||
// postName = deptName + postName;
|
||
// sysUser.setPerformclassname(postName);
|
||
|
||
// String postName = sysUser.getPerformClassName();
|
||
String deptName = sysUser.getSuperName();
|
||
// postName = postName.replace(deptName,"");
|
||
// postName = deptName + postName;
|
||
sysUser.setUnitName(deptName);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 通过userToken获取用户信息
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected String getChinaName()throws Exception{
|
||
String chinaName = "";
|
||
String userId = "";
|
||
String userToken = request.getHeader("userToken");
|
||
if(StringUtils.isNotBlank(userToken)){
|
||
userToken = userToken.replaceAll("Bearer ","");
|
||
userId = JwtUtil.getTokenMsg(userToken);
|
||
}
|
||
if(StringUtils.isNotBlank(userId)){
|
||
SysUser sysUser = sysUserMapper.findById(userId);
|
||
if(null != sysUser){
|
||
// chinaName = sysUser.getChinaname();
|
||
chinaName = sysUser.getSysuserid();
|
||
}
|
||
}
|
||
return chinaName;
|
||
}
|
||
|
||
/**
|
||
* 通过userToken获取用户信息
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected String getUserId()throws Exception{
|
||
String userId = "";
|
||
String userToken = request.getHeader("userToken");
|
||
if(StringUtils.isNotBlank(userToken)){
|
||
userToken = userToken.replaceAll("Bearer ","");
|
||
userId = JwtUtil.getTokenMsg(userToken);
|
||
}
|
||
return userId;
|
||
}
|
||
|
||
/**
|
||
* 获取用户部门id
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2023/8/23 14:23
|
||
*/
|
||
protected String getUnitId(String userId)throws Exception{
|
||
String unitId = "";
|
||
ListPerform listPerform = listPerformMapper.findBuUserId(userId);
|
||
if(null != listPerform){
|
||
unitId = listPerform.getSupclassid();
|
||
}
|
||
return unitId;
|
||
}
|
||
|
||
/**
|
||
* 修改任务状态
|
||
* @param oaTask
|
||
* @param listfactorid
|
||
* @throws Exception
|
||
*/
|
||
protected void changeTaskState(OATask oaTask,String listfactorid)throws Exception{
|
||
Long total = oaTask.getFrequency();
|
||
if(null == total){
|
||
total = 0l;
|
||
}
|
||
total++;
|
||
ListFactor listFactor = listFactorMapper.selectByPrimaryKey(oaTask.getOtcid());
|
||
if(null == listFactor.getFrequency()){
|
||
listFactor.setFrequency(1);
|
||
}
|
||
String isFinsh = "否";
|
||
if(total >= listFactor.getFrequency()){
|
||
isFinsh = "是";
|
||
}
|
||
oaTaskMapper.changeFrequency(oaTask.getOataskid(),total,isFinsh);
|
||
}
|
||
|
||
/**
|
||
* 获取岗位编码
|
||
* @return
|
||
*/
|
||
public String GetSysOrganCode(ListPerform listPerform)throws Exception{
|
||
String SysOrganCode = "";
|
||
//1、有上级;(1、上级有成员,取上级最后一成员编码加1;2、上级无成员,上级编码加001;)
|
||
//2、无上级;(1、已有无上级成员,去最后一位成员编码加1;2、无上级成员初始化为001;)
|
||
String SupCalssCode = listPerform.getPerformclasscode();
|
||
String code = "";
|
||
if(null != listPerform){
|
||
code = listPerform.getPerformclasscode();
|
||
}
|
||
if (StringUtils.isNotBlank(code)) {
|
||
int a=code.length() - 3;
|
||
String LastNUM = code.substring(code.length() - 3,code.length());
|
||
String OrganNUM = code.substring(0, code.length() - 3);
|
||
SysOrganCode = String.valueOf(Integer.valueOf(LastNUM) + 1);
|
||
if ((SysOrganCode.length()%3) == 1)
|
||
{
|
||
SysOrganCode = OrganNUM + "00" + SysOrganCode;
|
||
}
|
||
else if ((SysOrganCode.length()%3) == 2)
|
||
{
|
||
SysOrganCode = OrganNUM + "0" + SysOrganCode;
|
||
}
|
||
else
|
||
{
|
||
SysOrganCode = OrganNUM + SysOrganCode;
|
||
}
|
||
}else{
|
||
SysOrganCode = SupCalssCode + "001";
|
||
}
|
||
return SysOrganCode;
|
||
}
|
||
|
||
|
||
/**
|
||
* 创建岗位任务
|
||
* @param listFactor
|
||
* @throws Exception
|
||
*/
|
||
public void addFactorTask(ListFactor listFactor,String sysUserId)throws Exception{
|
||
//任务列表
|
||
List<OATask> oaTasks = new ArrayList<>();
|
||
if(Checkstandard.YEAR.getStandard() == listFactor.getCheckstandard()){
|
||
oaTasks = this.getYearTask(listFactor,sysUserId);
|
||
}else if(Checkstandard.HALF_YEAR.getStandard() == listFactor.getCheckstandard()){
|
||
oaTasks = this.getHalfYearTask(listFactor,sysUserId);
|
||
}else if(Checkstandard.QUARTER.getStandard() == listFactor.getCheckstandard()){
|
||
oaTasks = this.getQuarterTask(listFactor,sysUserId);
|
||
}else if(Checkstandard.MONTH.getStandard() == listFactor.getCheckstandard()){
|
||
oaTasks = this.getMonthTask(listFactor,sysUserId);
|
||
}else if(Checkstandard.CUSTOM.getStandard() == listFactor.getCheckstandard()){
|
||
oaTasks = this.getCustomTask(listFactor,sysUserId);
|
||
}
|
||
|
||
if(null != oaTasks && oaTasks.size() > 0){
|
||
oaTaskMapper.insertList(oaTasks);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 获取月任务信息
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
private List<OATask> getMonthTask(ListFactor listFactor,String sysUserId)throws Exception{
|
||
List<OATask> oaTasks = new ArrayList<>();
|
||
List<OaTaskTime> taskTimes = this.getTaskTime(listFactor.getCheckstandard());
|
||
Integer year = null;
|
||
if (StringUtils.isBlank(listFactor.getSysyear())){
|
||
year = Calendar.getInstance().get(Calendar.YEAR);
|
||
}else {
|
||
year = Integer.parseInt(listFactor.getSysyear());
|
||
}
|
||
Integer index = 1;
|
||
for (OaTaskTime taskTime : taskTimes){
|
||
OATask oaTask = new OATask();
|
||
String subject = year+"年第"+index+"月工作任务:"+listFactor.getFactorcnt();
|
||
oaTask.setSubject(subject);
|
||
oaTask.setFrequency(0l);
|
||
oaTask.setIsfinish("否");
|
||
oaTask.setOtcid(listFactor.getListfactorid());
|
||
oaTask.setOataskid(RandomNumber.getUUid());
|
||
oaTask.setTasktype("履职任务");
|
||
Date start = DateUtils.parseString2Date(taskTime.getStartTime(),Constants.DATA);
|
||
Date end = DateUtils.parseString2Date(taskTime.getEndTime(),Constants.DATA);
|
||
oaTask.setStartdate(start);
|
||
oaTask.setPlanenddate(end);
|
||
oaTask.setDelState(DelState.NOT_DEL.getState());
|
||
oaTask.setCreatedby(sysUserId);
|
||
oaTask.setCreatedon(new Date());
|
||
oaTask.setModifiedby(sysUserId);
|
||
oaTask.setModifiedon(new Date());
|
||
oaTasks.add(oaTask);
|
||
index++;
|
||
}
|
||
return oaTasks;
|
||
}
|
||
|
||
/**
|
||
* 获取季度任务信息
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
private List<OATask> getQuarterTask(ListFactor listFactor,String sysUserId)throws Exception{
|
||
List<OATask> oaTasks = new ArrayList<>();
|
||
List<OaTaskTime> taskTimes = this.getTaskTime(listFactor.getCheckstandard());
|
||
Integer year = null;
|
||
if (StringUtils.isBlank(listFactor.getSysyear())){
|
||
year = Calendar.getInstance().get(Calendar.YEAR);
|
||
}else {
|
||
year = Integer.parseInt(listFactor.getSysyear());
|
||
}
|
||
Integer index = 1;
|
||
for (OaTaskTime taskTime : taskTimes){
|
||
OATask oaTask = new OATask();
|
||
String subject = year+"年第"+index+"季度工作任务::"+listFactor.getFactorcnt();
|
||
oaTask.setSubject(subject);
|
||
oaTask.setFrequency(0l);
|
||
oaTask.setIsfinish("否");
|
||
oaTask.setOtcid(listFactor.getListfactorid());
|
||
oaTask.setOataskid(RandomNumber.getUUid());
|
||
oaTask.setTasktype("履职任务");
|
||
Date start = DateUtils.parseString2Date(taskTime.getStartTime(),Constants.DATA);
|
||
Date end = DateUtils.parseString2Date(taskTime.getEndTime(),Constants.DATA);
|
||
oaTask.setStartdate(start);
|
||
oaTask.setPlanenddate(end);
|
||
oaTask.setDelState(DelState.NOT_DEL.getState());
|
||
oaTask.setCreatedby(sysUserId);
|
||
oaTask.setCreatedon(new Date());
|
||
oaTask.setModifiedby(sysUserId);
|
||
oaTask.setModifiedon(new Date());
|
||
oaTasks.add(oaTask);
|
||
index++;
|
||
}
|
||
return oaTasks;
|
||
}
|
||
|
||
/**
|
||
* 获取自定义任务
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
private List<OATask> getCustomTask(ListFactor listFactor,String sysUserId)throws Exception{
|
||
List<OATask> oaTasks = new ArrayList<>();
|
||
OATask oaTask = new OATask();
|
||
String startTime = DateUtils.parseDate2String(listFactor.getStartTime(),"yyyy-MM-dd");
|
||
String endTime = DateUtils.parseDate2String(listFactor.getEndTime(),"yyyy-MM-dd");
|
||
|
||
String subject = "工作任务("+startTime+"至"+endTime+"):"+listFactor.getFactorcnt();
|
||
oaTask.setSubject(subject);
|
||
oaTask.setFrequency(0l);
|
||
oaTask.setIsfinish("否");
|
||
oaTask.setOtcid(listFactor.getListfactorid());
|
||
oaTask.setOataskid(RandomNumber.getUUid());
|
||
oaTask.setTasktype("履职任务");
|
||
oaTask.setStartdate(listFactor.getStartTime());
|
||
oaTask.setPlanenddate(listFactor.getEndTime());
|
||
oaTask.setDelState(DelState.NOT_DEL.getState());
|
||
oaTask.setCreatedby(sysUserId);
|
||
oaTask.setCreatedon(new Date());
|
||
oaTask.setModifiedby(sysUserId);
|
||
oaTask.setModifiedon(new Date());
|
||
oaTasks.add(oaTask);
|
||
return oaTasks;
|
||
}
|
||
|
||
/**
|
||
* 获取年任务信息
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
private List<OATask> getYearTask(ListFactor listFactor,String sysUserId)throws Exception{
|
||
List<OATask> oaTasks = new ArrayList<>();
|
||
OATask oaTask = new OATask();
|
||
Integer year = null;
|
||
if (StringUtils.isBlank(listFactor.getSysyear())){
|
||
year = Calendar.getInstance().get(Calendar.YEAR);
|
||
}else {
|
||
year = Integer.parseInt(listFactor.getSysyear());
|
||
}
|
||
String startTime = year + "-01-01 00:00:01";
|
||
String endTime = year + "-12-31 23:59:59";
|
||
String subject = year+"年工作任务:"+listFactor.getFactorcnt();
|
||
oaTask.setSubject(subject);
|
||
oaTask.setFrequency(0l);
|
||
oaTask.setIsfinish("否");
|
||
oaTask.setOtcid(listFactor.getListfactorid());
|
||
oaTask.setOataskid(RandomNumber.getUUid());
|
||
oaTask.setTasktype("履职任务");
|
||
Date start = DateUtils.parseString2Date(startTime,Constants.DATA);
|
||
Date end = DateUtils.parseString2Date(endTime,Constants.DATA);
|
||
oaTask.setStartdate(start);
|
||
oaTask.setPlanenddate(end);
|
||
oaTask.setDelState(DelState.NOT_DEL.getState());
|
||
oaTask.setCreatedby(sysUserId);
|
||
oaTask.setCreatedon(new Date());
|
||
oaTask.setModifiedby(sysUserId);
|
||
oaTask.setModifiedon(new Date());
|
||
oaTasks.add(oaTask);
|
||
return oaTasks;
|
||
}
|
||
|
||
/**
|
||
* 获取半年任务信息
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
private List<OATask> getHalfYearTask(ListFactor listFactor,String sysUserId)throws Exception{
|
||
List<OATask> oaTasks = new ArrayList<>();
|
||
List<OaTaskTime> taskTimes = this.getTaskTime(listFactor.getCheckstandard());
|
||
Integer year = null;
|
||
if (StringUtils.isBlank(listFactor.getSysyear())){
|
||
year = Calendar.getInstance().get(Calendar.YEAR);
|
||
}else {
|
||
year = Integer.parseInt(listFactor.getSysyear());
|
||
}
|
||
for (OaTaskTime taskTime : taskTimes){
|
||
OATask oaTask = new OATask();
|
||
String subject = year+"年工作任务:"+listFactor.getFactorcnt();
|
||
oaTask.setSubject(subject);
|
||
oaTask.setFrequency(0l);
|
||
oaTask.setIsfinish("否");
|
||
oaTask.setOtcid(listFactor.getListfactorid());
|
||
oaTask.setOataskid(RandomNumber.getUUid());
|
||
oaTask.setTasktype("履职任务");
|
||
Date start = DateUtils.parseString2Date(taskTime.getStartTime(),Constants.DATA);
|
||
Date end = DateUtils.parseString2Date(taskTime.getEndTime(),Constants.DATA);
|
||
oaTask.setStartdate(start);
|
||
oaTask.setPlanenddate(end);
|
||
oaTask.setDelState(DelState.NOT_DEL.getState());
|
||
oaTask.setCreatedby(sysUserId);
|
||
oaTask.setCreatedon(new Date());
|
||
oaTask.setModifiedby(sysUserId);
|
||
oaTask.setModifiedon(new Date());
|
||
oaTasks.add(oaTask);
|
||
}
|
||
return oaTasks;
|
||
}
|
||
|
||
/**
|
||
* 获取任务时间段
|
||
* @param checkstandard
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
private List<OaTaskTime> getTaskTime(Integer checkstandard)throws Exception{
|
||
List<OaTaskTime> oaTaskTimes = new LinkedList<>();
|
||
List<Integer> months = new ArrayList<>();
|
||
Integer year = Calendar.getInstance().get(Calendar.YEAR);
|
||
if(2 == checkstandard){
|
||
months.add(1);
|
||
months.add(7);
|
||
for (Integer month : months){
|
||
|
||
Integer endMonth = month + 5;
|
||
Integer day = DateUtils.getMonthLastDay(year,endMonth);
|
||
OaTaskTime oaTaskTime = new OaTaskTime();
|
||
oaTaskTime.setStartTime(year+"-0"+month+"-01 00:00:01");
|
||
if(endMonth < 10){
|
||
oaTaskTime.setEndTime(year+"-0"+endMonth+"-"+day+" 23:59:59");
|
||
}else{
|
||
oaTaskTime.setEndTime(year+"-"+endMonth+"-"+day+" 23:59:59");
|
||
}
|
||
oaTaskTimes.add(oaTaskTime);
|
||
}
|
||
}else if(4 == checkstandard){
|
||
months.add(1);
|
||
months.add(4);
|
||
months.add(7);
|
||
months.add(10);
|
||
for (Integer month : months){
|
||
|
||
Integer entMonth = month + 2;
|
||
Integer day = DateUtils.getMonthLastDay(year,entMonth);
|
||
OaTaskTime oaTaskTime = new OaTaskTime();
|
||
|
||
String startMonthStr = "";
|
||
String endMonthStr = "";
|
||
if(month < 10){
|
||
startMonthStr = "0"+month;
|
||
}else{
|
||
startMonthStr = ""+month;
|
||
}
|
||
if(entMonth < 10){
|
||
endMonthStr = "0"+entMonth;
|
||
}else{
|
||
endMonthStr = entMonth+"";
|
||
}
|
||
oaTaskTime.setStartTime(year+"-"+startMonthStr+"-01 00:00:01");
|
||
oaTaskTime.setEndTime(year+"-"+endMonthStr+"-"+day+" 23:59:59");
|
||
oaTaskTimes.add(oaTaskTime);
|
||
}
|
||
}else if(12 == checkstandard){
|
||
months.add(1);
|
||
months.add(2);
|
||
months.add(3);
|
||
months.add(4);
|
||
months.add(5);
|
||
months.add(6);
|
||
months.add(7);
|
||
months.add(8);
|
||
months.add(9);
|
||
months.add(10);
|
||
months.add(11);
|
||
months.add(12);
|
||
for (Integer month : months){
|
||
Integer day = DateUtils.getMonthLastDay(year,month);
|
||
OaTaskTime oaTaskTime = new OaTaskTime();
|
||
String startMonthStr = "";
|
||
if(month < 10){
|
||
startMonthStr = "0"+month;
|
||
}else{
|
||
startMonthStr = ""+month;
|
||
}
|
||
oaTaskTime.setStartTime(year+"-"+startMonthStr+"-01 00:00:01");
|
||
oaTaskTime.setEndTime(year+"-"+startMonthStr+"-"+day+" 23:59:59");
|
||
oaTaskTimes.add(oaTaskTime);
|
||
}
|
||
}
|
||
return oaTaskTimes;
|
||
}
|
||
|
||
|
||
/**
|
||
*
|
||
* 处理动态详情
|
||
* @param dynamic
|
||
* @throws Exception
|
||
*/
|
||
public void handleDynamic(Dynamic dynamic)throws Exception{
|
||
dynamic.setCover(setServiceFile(dynamic.getCover()));
|
||
dynamic.setDetailUrl(constantsConfigure.getHtmlHeader()+"xindu/dynamicDetail?dynamicId="+dynamic.getDynamicid());
|
||
}
|
||
|
||
/**
|
||
* 修改企业风险等级
|
||
* @param companyId
|
||
* @throws Exception
|
||
*/
|
||
public void changeEntRiskLevel(String companyId)throws Exception{
|
||
|
||
|
||
Integer score = 100;
|
||
List<BookEntHT> entHts = bookEntHTMapper.notRectifiedDanger(companyId);
|
||
if(null != entHts && entHts.size() > 0){
|
||
for (BookEntHT bookEntHT : entHts){
|
||
if(HtlevelType.MAJOR.getType().equals(bookEntHT.getHtlevel())){
|
||
score -= 20;
|
||
}else{
|
||
score -= 5;
|
||
}
|
||
}
|
||
}
|
||
|
||
//风险等级
|
||
String riskLevel = "重大风险";
|
||
if (score >= 80) {
|
||
riskLevel = "低风险";
|
||
}
|
||
if (score < 80 & score >= 70) {
|
||
riskLevel = "一般风险";
|
||
}
|
||
if (score < 70 & score >= 60) {
|
||
riskLevel = "较大风险";
|
||
}
|
||
|
||
System.out.println("score -> " + score + " & riskLevel -> " + riskLevel);
|
||
sysEnterpriseMapper.chnageScore(companyId,score,riskLevel);
|
||
|
||
|
||
}
|
||
|
||
/**
|
||
* 是否是管理员
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected Boolean isAdmin(String roleId)throws Exception{
|
||
//是否是管理员 1:是 0:不是
|
||
Boolean result = false;
|
||
if(roleId.equals(ADMIN_ROLE_ID)){
|
||
result = true;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 处理检查数据
|
||
* @param bookEntCheck
|
||
* @throws Exception
|
||
*/
|
||
protected void handleCheckDetail(BookEntCheck bookEntCheck, String minProgram)throws Exception{
|
||
//检查人员签名列表
|
||
List<ChkPerson> chkPeople = chkPersonMapper.checkUser(bookEntCheck.getBookentcheckid(),minProgram);
|
||
if(null != chkPeople && chkPeople.size() > 0){
|
||
bookEntCheck.setChkPeople(chkPeople);
|
||
}
|
||
|
||
|
||
//参与人员
|
||
bookEntCheck.setCheckUser(bookEntCheck.getZhifaren());
|
||
String joinUser = "";
|
||
List<ChkPerson> checkUser = chkPersonMapper.checkUserName(bookEntCheck.getBookentcheckid());
|
||
if(null != checkUser && checkUser.size() > 0){
|
||
for (ChkPerson person : checkUser){
|
||
if(!person.getChinaName().equals(bookEntCheck.getZhifaren())){
|
||
if(StringUtils.isNotBlank(joinUser)){
|
||
joinUser += "、"+person.getChinaName();
|
||
}else{
|
||
joinUser = person.getChinaName();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
bookEntCheck.setJoinUser(joinUser);
|
||
}
|
||
|
||
/**
|
||
* 任务详情
|
||
* @param oaTask
|
||
* @param sysUserId
|
||
* @throws Exception
|
||
*/
|
||
/* protected void getTaskDetail(OATask oaTask,String sysUserId)throws Exception{
|
||
//发布人名
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(oaTask.getCreatedby());
|
||
if(null != sysUser){
|
||
oaTask.setSendName(sysUser.getChinaname());
|
||
}
|
||
|
||
//接收人列表
|
||
List<OADistribution> distributions = new ArrayList<>();
|
||
//修改任务读取状态
|
||
sysUserId = getListPerformId(sysUserId);
|
||
oaDistributionMapper.changeStatus(oaTask.getOataskid(),sysUserId);
|
||
//查询部门
|
||
distributions = oaDistributionMapper.receiveUnit(oaTask.getOataskid());
|
||
|
||
oaTask.setDistributions(distributions);
|
||
|
||
if("上级提醒".equals(oaTask.getTasktype())){
|
||
//修改
|
||
List<String> taskIds = new ArrayList<>();
|
||
taskIds.add(oaTask.getOataskid());
|
||
oaTaskMapper.changeIsFinish(taskIds);
|
||
}
|
||
}
|
||
*/
|
||
/**
|
||
* 生成企业二维码
|
||
* @param entId
|
||
* @throws Exception
|
||
*/
|
||
public String entQrCode(String entId)throws Exception{
|
||
Map<String,String> entMap = new HashMap<>();
|
||
entMap.put("entId",entId);
|
||
String content = JSONArray.toJSONString(entMap);
|
||
InputStream is = QRCodeUtil.getBase64QRCode(content,constantsConfigure.getLogoUrl());
|
||
String name = RandomNumber.randomUUidPK();
|
||
|
||
name += ".png";
|
||
|
||
String url = "";
|
||
url = FileUpload.uploadFile(is, name,constantsConfigure.getFileHeader(),constantsConfigure.getFileLocation());
|
||
return url;
|
||
}
|
||
|
||
/**
|
||
* 生成最小工作单元二维码
|
||
* entId 企业id
|
||
* 最小工作单元id
|
||
* @throws Exception
|
||
*/
|
||
public String minWorkQrCode(String entId,String id)throws Exception{
|
||
Map<String,String> entMap = new HashMap<>();
|
||
entMap.put("entId",entId);
|
||
entMap.put("id",id);
|
||
String content = JSONArray.toJSONString(entMap);
|
||
InputStream is = QRCodeUtil.getBase64QRCode(content,constantsConfigure.getLogoUrl());
|
||
String name = RandomNumber.randomUUidPK();
|
||
name += ".png";
|
||
String url = FileUpload.uploadFile(is, name,constantsConfigure.getFileHeader(),constantsConfigure.getFileLocation());
|
||
return url;
|
||
}
|
||
|
||
/**
|
||
* 新增企业用户
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2023/1/6 15:23
|
||
*/
|
||
public void handleEetUser(String entId)throws Exception{
|
||
SysEnterprise enterprise = sysEnterpriseMapper.selectByPrimaryKey(entId);
|
||
if(null != enterprise){
|
||
EntPost entPost = new EntPost();
|
||
String postId = RandomNumber.getUUid();
|
||
entPost.setPostId(postId);
|
||
entPost.setEnterpriseId(enterprise.getSysenterpriseid());
|
||
entPost.setName("法人");
|
||
entPost.setPostPath(postId);
|
||
entPost.setParentName("法人");
|
||
entPost.setCreateBy("");
|
||
entPost.setCreateTime(new Date());
|
||
entPost.setModifyBy("");
|
||
entPost.setModifyTime(new Date());
|
||
entPostMapper.insertEntPost(entPost);
|
||
|
||
|
||
EntUser entUser = new EntUser();
|
||
String userId = RandomNumber.getUUid();
|
||
entUser.setEntUserId(userId);
|
||
entUser.setPostId(postId);
|
||
entUser.setEnterpriseId(enterprise.getSysenterpriseid());
|
||
entUser.setAccount(enterprise.getEntname());
|
||
entUser.setName(enterprise.getEntname());
|
||
entUser.setMobile(enterprise.getLrlinktel());
|
||
entUser.setPostPath(postId);
|
||
entUser.setPostPathName(entPost.getName());
|
||
entUser.setCreateBy("");
|
||
entUser.setCreateTime(new Date());
|
||
entUser.setPasswd(MD5.md5(constantsConfigure.getDefaultPasswd()));
|
||
entUserMapper.insert(entUser);
|
||
}
|
||
|
||
|
||
//存企业用户
|
||
/**/
|
||
}
|
||
|
||
/**
|
||
* 普查的时候 创建企业用户
|
||
* @throws Exception
|
||
*/
|
||
public void createEntUser(SysEnterprise enterprese,String sysUserId,SysUser createUser){
|
||
try {
|
||
SysUser sysUser = sysUserMapper.findByEntId(enterprese.getSysenterpriseid());
|
||
if(null == sysUser){
|
||
sysUser = new SysUser();
|
||
sysUser.setSysuserid(RandomNumber.getUUid());
|
||
sysUser.setUsertype("企业用户");
|
||
sysUser.setSysunitorentid(enterprese.getSysenterpriseid());
|
||
sysUser.setSysdeptid(enterprese.getSysenterpriseid());
|
||
sysUser.setSysunitorentname(enterprese.getEntname());
|
||
sysUser.setSysdeptname(enterprese.getEntname());
|
||
sysUser.setSysusername(enterprese.getEntname());
|
||
sysUser.setSyspassword(PasswdFactory.encryptPasswd(sysUser.getSysuserid(), sysUser.getSysusername(), constantsConfigure.getDefaultPasswd()));
|
||
sysUser.setChinaname(enterprese.getEntname());
|
||
sysUser.setCreatedby(sysUserId);
|
||
sysUser.setCreatedon(new Date());
|
||
sysUser.setModifiedon(new Date());
|
||
sysUser.setModifiedby(sysUserId);
|
||
sysUser.setState("启用");
|
||
sysUserMapper.insert(sysUser);
|
||
}else{
|
||
|
||
sysUser.setSysusername(enterprese.getEntname());
|
||
sysUser.setChinaname(enterprese.getEntname());
|
||
sysUserMapper.changeUserName(sysUser);
|
||
}
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
/**
|
||
*
|
||
* @param entId
|
||
* @throws Exception
|
||
*/
|
||
public void saveEntWork(String entId)throws Exception{
|
||
SysEnterprise sysEnterprise = sysEnterpriseMapper.selectByPrimaryKey(entId);
|
||
if(null != sysEnterprise && StringUtils.isNotBlank(sysEnterprise.getWorkClassId())){
|
||
minWorkUnitMapper.delWorkUnit(sysEnterprise.getSysenterpriseid());
|
||
List<MinWorkUnitCategory> workTypes = minWorkUnitCategoryMapper.findByIndustryId(sysEnterprise.getWorkClassId());
|
||
if(workTypes.size() > 0){
|
||
String chinaName = getChinaName();
|
||
for (MinWorkUnitCategory workType : workTypes){
|
||
MinWorkUnit minWorkUnit = new MinWorkUnit();
|
||
minWorkUnit.setId(RandomNumber.getUUid());
|
||
minWorkUnit.setMinCategory(workType.getId());
|
||
minWorkUnit.setTitle(workType.getTitle());
|
||
minWorkUnit.setDelState(DelState.NOT_DEL.getState());
|
||
minWorkUnit.setParentId(entId);
|
||
minWorkUnit.setCreateBy(chinaName);
|
||
minWorkUnit.setCreateTime(new Date());
|
||
minWorkUnit.setModifyTime(new Date());
|
||
minWorkUnit.setModifyBy(chinaName);
|
||
minWorkUnit.setQrCode(minWorkQrCode(entId,minWorkUnit.getId()));
|
||
minWorkUnitMapper.insert(minWorkUnit);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 生成企业责任清单
|
||
* @author Xu wanxin
|
||
* @param industryId
|
||
* @param companyId
|
||
* @throws Exception
|
||
*/
|
||
public void saveEntInList(String industryId,String companyId)throws Exception{
|
||
List<InListItem> inListItem = inListItemMapper.selectContents(industryId,null,null);
|
||
List<InEntList> entLists = ObjectConversion.copy(inListItem,InEntList.class);
|
||
for (InEntList in:entLists) {
|
||
in.setEnterpriseId(companyId);
|
||
in.setEntListId(RandomNumber.getUUid());
|
||
in.setCreateBy(getUserId());
|
||
in.setCreateTime(new Date());
|
||
}
|
||
int result = inEntListMapper.insertList(entLists);
|
||
}
|
||
|
||
|
||
/**
|
||
* 获取政府机构的管辖区域的id
|
||
* @param userId
|
||
* @return
|
||
*/
|
||
public String getUserLevel(String userId){
|
||
String areaCode = "";
|
||
SysUser sysUser = sysUserMapper.findById(userId);
|
||
if(null != sysUser && StringUtils.isNotBlank(sysUser.getOrgcode())){
|
||
if (StringUtils.isNotBlank(sysUser.getStreetCode())){
|
||
return sysUser.getStreetCode();
|
||
}
|
||
if (StringUtils.isNotBlank(sysUser.getCommunityCode())){
|
||
return sysUser.getCommunityCode();
|
||
}
|
||
if (StringUtils.isNotBlank(sysUser.getOrgcode())){
|
||
return sysUser.getOrgcode();
|
||
}
|
||
}
|
||
return areaCode;
|
||
}
|
||
|
||
/**
|
||
* 获取用户地区idchangeArea
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String getUserArea(String userId)throws Exception{
|
||
String areaCode = "";
|
||
SysUser sysUser = sysUserMapper.findById(userId);
|
||
if(null != sysUser){
|
||
areaCode = sysUser.getAreaCode();
|
||
}else{
|
||
areaCode = constantsConfigure.getSuperiorOrgCode();
|
||
}
|
||
return areaCode;
|
||
}
|
||
|
||
/**
|
||
* 每次打开首页更新一下履职进度
|
||
* @param listPerformId
|
||
*/
|
||
public void getFactor(String listPerformId){
|
||
try {
|
||
String time = DateUtils.getNowDateTimeStr("yyyy");
|
||
List<ListFactor> listFactors = listFactorMapper.userListFactor(listPerformId,time);
|
||
if(null != listFactors && listFactors.size() > 0){
|
||
for (ListFactor listFactor : listFactors){
|
||
factorProgres(listFactor.getListfactorid());
|
||
}
|
||
}else{
|
||
//修改总体履职进度
|
||
this.changeListPerForm(listPerformId);
|
||
}
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 计算履职档案完成进度
|
||
* @param listfactorid
|
||
* @throws Exception
|
||
*/
|
||
protected void factorProgres(String listfactorid)throws Exception{
|
||
ListFactor listFactor = listFactorMapper.selectByPrimaryKey(listfactorid);
|
||
if(null != listFactor){
|
||
Long factorNum = listDetailMapper.countListDetail(listfactorid);
|
||
if(null == factorNum){
|
||
factorNum = 0l;
|
||
}
|
||
//频次为空 设置值为1
|
||
if(null == listFactor.getCheckstandard()){
|
||
listFactor.setCheckstandard(1);
|
||
}
|
||
//频率为空 设置值为1
|
||
if(null == listFactor.getFrequency()){
|
||
listFactor.setFrequency(1);
|
||
}
|
||
|
||
Integer finishProgres = 0;//完成情况
|
||
if(factorNum > 0){
|
||
String isfinish = "";//是否完成
|
||
//履职需完成总次数
|
||
Integer factorTotal = listFactor.getCheckstandard() * listFactor.getFrequency();
|
||
if(factorNum >= factorTotal){
|
||
isfinish = "是";
|
||
finishProgres = 100;
|
||
}else{
|
||
Double progres = Arith.div(factorNum,factorTotal) * 100;
|
||
finishProgres = progres.intValue();
|
||
}
|
||
|
||
//修改履职档案完成情况
|
||
if(StringUtils.isNotBlank(isfinish)){
|
||
listFactorMapper.changeIsFinish(listfactorid);
|
||
}
|
||
//修改履职档案完成百分比
|
||
listFactorMapper.changeFinishProgres(listfactorid,finishProgres);
|
||
}else{
|
||
listFactorMapper.changeFinishProgres(listfactorid,finishProgres);
|
||
}
|
||
//修改总体履职进度
|
||
this.changeListPerForm(listFactor.getListperformid());
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* 获取检查履职信息和清单
|
||
* @param sysUser
|
||
* @throws Exception
|
||
*/
|
||
public CheckPerform getCheckPerform(SysUser sysUser)throws Exception{
|
||
|
||
CheckPerform checkPerform = new CheckPerform();
|
||
Integer memberType = sysUser.getMemberType();
|
||
|
||
|
||
if(MemberType.COMMUNITY.getType().equals(memberType)){
|
||
//社区人员清单
|
||
checkPerform = getCommunityList(sysUser.getSysuserid());
|
||
|
||
}else{
|
||
//用户类型 1:区级用户 2:镇正领导 3:镇副领导 4:驻村干部 5:社区 6:其他
|
||
Map<Integer,Integer> checkNumMap = new HashMap<>();
|
||
checkNumMap.put(2,1);
|
||
checkNumMap.put(3,2);
|
||
checkNumMap.put(4,4);
|
||
|
||
Integer checkNum = checkNumMap.get(sysUser.getMemberType());
|
||
if(null != checkNum){
|
||
checkPerform = getStreetList(sysUser.getSysuserid(),checkNum);
|
||
}
|
||
|
||
}
|
||
return checkPerform;
|
||
|
||
}
|
||
|
||
/**
|
||
* 村/社区检查履职信息
|
||
* @param userId
|
||
* @param totalNum 需检查企业总数
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public CheckPerform getStreetList(String userId,Integer totalNum)throws Exception{
|
||
CheckPerform checkPerform = new CheckPerform();
|
||
|
||
|
||
//完成率
|
||
Double completionRate = 0.0;
|
||
|
||
List<CheckList> checkLists = new ArrayList<>();
|
||
//清单项
|
||
String checkItem = "每月对辖区生产经营单位开展监督检查"+totalNum+"次";
|
||
CheckList checkList = new CheckList();
|
||
checkList.setListName(checkItem);
|
||
|
||
//当月检查次数
|
||
Integer checkNum = chkPersonMapper.countByMonth(userId);
|
||
checkPerform.setCheckNum(checkNum);
|
||
|
||
//当月检查企业总数
|
||
Integer completeNum = chkPersonMapper.countByMonth(userId);
|
||
|
||
checkList.setCompleteNum(completeNum);
|
||
checkList.setTotalNum(totalNum);
|
||
|
||
if(totalNum > 0){
|
||
completionRate = Arith.div(completeNum,totalNum);
|
||
}
|
||
|
||
completionRate = TypeConversion.decimalFormat(completionRate,2);
|
||
completionRate = completionRate * 100;
|
||
if(completionRate > 100){
|
||
completionRate = 100.0;
|
||
}
|
||
|
||
|
||
checkLists.add(checkList);
|
||
|
||
checkPerform.setCompletionRate(completionRate.intValue());
|
||
checkPerform.setCheckList(checkLists);
|
||
|
||
return checkPerform;
|
||
}
|
||
|
||
/**
|
||
* 村/社区检查履职信息
|
||
* @param userId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public CheckPerform getCommunityList(String userId)throws Exception{
|
||
CheckPerform checkPerform = new CheckPerform();
|
||
|
||
|
||
//完成率
|
||
Double completionRate = 0.0;
|
||
|
||
List<CheckList> checkLists = new ArrayList<>();
|
||
//清单项
|
||
String checkItem = "每月对辖区生产经营单位开展一次全覆盖监督检查";
|
||
CheckList checkList = new CheckList();
|
||
checkList.setListName(checkItem);
|
||
|
||
//当月检查次数
|
||
Integer checkNum = chkPersonMapper.countByMonth(userId);
|
||
checkPerform.setCheckNum(checkNum);
|
||
|
||
//需检查企业总数
|
||
Integer totalNum = dutyTreeMapper.userEntNum(userId);
|
||
|
||
//当月检查企业总数
|
||
Integer completeNum = dutyTreeMapper.userCheckEntNum(userId);
|
||
|
||
checkList.setCompleteNum(completeNum);
|
||
checkList.setTotalNum(totalNum);
|
||
|
||
if(totalNum > 0){
|
||
completionRate = Arith.div(completeNum,totalNum);
|
||
}
|
||
|
||
completionRate = TypeConversion.decimalFormat(completionRate,2);
|
||
completionRate = completionRate * 100;
|
||
if(completionRate > 100){
|
||
completionRate = 100.0;
|
||
}
|
||
|
||
|
||
checkLists.add(checkList);
|
||
|
||
checkPerform.setCompletionRate(completionRate.intValue());
|
||
checkPerform.setCheckList(checkLists);
|
||
|
||
return checkPerform;
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 处理隐患数量
|
||
* @param allEntHts
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected void getEntNums(Pager<BookEntHT> pager,List<BookEntHT> allEntHts)throws Exception{
|
||
Map<String,Integer> entNumMap = new HashMap<>();
|
||
|
||
Integer totalDanger = 0;//总数
|
||
Integer notRectify = 0;//未整改
|
||
Integer rectify = 0;//整改中
|
||
Integer rectifyComplete = 0;//已整改
|
||
Integer unCheck = 0;//审核中
|
||
|
||
if(null != allEntHts && allEntHts.size() > 0){
|
||
for (BookEntHT bookEntHT : allEntHts){
|
||
if("未整改".equals(bookEntHT.getHtstate())){
|
||
notRectify += 1;
|
||
}
|
||
if("已整改".equals(bookEntHT.getHtstate())){
|
||
rectifyComplete += 1;
|
||
}
|
||
if("整改中".equals(bookEntHT.getHtstate())){
|
||
rectify += 1;
|
||
}
|
||
if("审核中".equals(bookEntHT.getHtreport())){
|
||
unCheck += 1;
|
||
}
|
||
}
|
||
}
|
||
totalDanger = notRectify + rectify + rectifyComplete;
|
||
|
||
pager.setTotalDanger(totalDanger);
|
||
pager.setNotRectify(notRectify);
|
||
pager.setRectify(rectify);
|
||
pager.setRectifyComplete(rectifyComplete);
|
||
pager.setUnCheck(unCheck);
|
||
}
|
||
|
||
|
||
/**
|
||
* 设置excel
|
||
* @param wb
|
||
* @param enterprise
|
||
* @throws Exception
|
||
*/
|
||
public void getWorkbook(XSSFWorkbook wb, SysEnterprise enterprise)throws Exception{
|
||
//3.读取sheet对象
|
||
Sheet sheet = wb.getSheetAt(0);
|
||
|
||
|
||
//设置企业名
|
||
String entName = enterprise.getEntname();
|
||
if(StringUtils.isNotBlank(entName)){
|
||
Row entRow = sheet.getRow(0);
|
||
Cell entCell = entRow.getCell(0);
|
||
entCell.setCellValue(entName);
|
||
}else{
|
||
Row entRow = sheet.getRow(0);
|
||
Cell entCell = entRow.getCell(0);
|
||
entCell.setCellValue("");
|
||
}
|
||
|
||
//地址
|
||
String address = enterprise.getSysaddress();
|
||
if(StringUtils.isNotBlank(address)){
|
||
Row entRow = sheet.getRow(1);
|
||
Cell entCell = entRow.getCell(0);
|
||
entCell.setCellValue(address);
|
||
}else{
|
||
Row entRow = sheet.getRow(1);
|
||
Cell entCell = entRow.getCell(0);
|
||
entCell.setCellValue("");
|
||
}
|
||
|
||
//经营范围
|
||
String manageType = enterprise.getManageType();
|
||
if(StringUtils.isNotBlank(manageType)){
|
||
Row entRow = sheet.getRow(2);
|
||
Cell entCell = entRow.getCell(0);
|
||
entCell.setCellValue(manageType);
|
||
}else{
|
||
Row entRow = sheet.getRow(2);
|
||
Cell entCell = entRow.getCell(0);
|
||
entCell.setCellValue("");
|
||
}
|
||
|
||
|
||
|
||
//房屋使用类型
|
||
String enttype = enterprise.getEnttype();
|
||
if(StringUtils.isNotBlank(enttype)){
|
||
Row entRow = sheet.getRow(3);
|
||
Cell entCell = entRow.getCell(0);
|
||
entCell.setCellValue(enttype);
|
||
}else{
|
||
Row entRow = sheet.getRow(3);
|
||
Cell entCell = entRow.getCell(0);
|
||
entCell.setCellValue("");
|
||
}
|
||
|
||
//单位负责人
|
||
String legalrepre = enterprise.getLegalrepre();
|
||
if(StringUtils.isBlank(legalrepre)){
|
||
legalrepre = "";
|
||
}
|
||
String lrlinktel = enterprise.getLrlinktel();
|
||
if(StringUtils.isBlank(lrlinktel)){
|
||
lrlinktel = "";
|
||
}
|
||
lrlinktel = "联系电话 "+lrlinktel;
|
||
Row entRow = sheet.getRow(4);
|
||
Cell legalrepreCell = entRow.getCell(0);
|
||
legalrepreCell.setCellValue(legalrepre);
|
||
Cell lrlinktelCell = entRow.getCell(2);
|
||
lrlinktelCell.setCellValue(lrlinktel);
|
||
|
||
|
||
String entId = enterprise.getSysenterpriseid();
|
||
|
||
|
||
//村社定点干部
|
||
DutyTree communitydutyTree = dutyTreeMapper.findTargetId(entId);
|
||
if(null != communitydutyTree){
|
||
//村社定点干部
|
||
SysUser dutyerUser = sysUserMapper.findById(communitydutyTree.getUserId());
|
||
if(null != dutyerUser){
|
||
Row leaderUserRow = sheet.getRow(7);
|
||
Cell leaderUserCell = leaderUserRow.getCell(1);
|
||
leaderUserCell.setCellValue(dutyerUser.getChinaname());
|
||
|
||
Cell leaderMobileCell = leaderUserRow.getCell(2);
|
||
String mobile = "";
|
||
if(StringUtils.isNotBlank(dutyerUser.getMobiletel())){
|
||
mobile = dutyerUser.getMobiletel();
|
||
}else{
|
||
mobile = dutyerUser.getSysusername();
|
||
}
|
||
if(!mobile.contains("1")){
|
||
mobile = "";
|
||
}
|
||
|
||
mobile = "联系电话 "+mobile;
|
||
leaderMobileCell.setCellValue(mobile);
|
||
}else{
|
||
setentDutyerNull(sheet,7);
|
||
}
|
||
}else{
|
||
setentDutyerNull(sheet,7);
|
||
}
|
||
|
||
//镇街定点干部
|
||
DutyTree cadreDutyTree = null;
|
||
if(null != communitydutyTree){
|
||
|
||
//镇街定点干部
|
||
cadreDutyTree = dutyTreeMapper.findTargetId(communitydutyTree.getUserId());
|
||
if(null != cadreDutyTree){
|
||
|
||
//镇街定点干部
|
||
SysUser cadreUser = sysUserMapper.findById(cadreDutyTree.getUserId());
|
||
if(null != cadreUser){
|
||
Row leaderUserRow = sheet.getRow(6);
|
||
Cell leaderUserCell = leaderUserRow.getCell(1);
|
||
leaderUserCell.setCellValue(cadreUser.getChinaname());
|
||
|
||
Cell leaderMobileCell = leaderUserRow.getCell(2);
|
||
String mobile = "";
|
||
if(StringUtils.isNotBlank(cadreUser.getMobiletel())){
|
||
mobile = cadreUser.getMobiletel();
|
||
}else{
|
||
mobile = cadreUser.getSysusername();
|
||
}
|
||
if(!mobile.contains("1")){
|
||
mobile = "";
|
||
}
|
||
|
||
mobile = "联系电话 "+mobile;
|
||
leaderMobileCell.setCellValue(mobile);
|
||
}else{
|
||
setentDutyerNull(sheet,6);
|
||
}
|
||
}else{
|
||
setentDutyerNull(sheet,6);
|
||
}
|
||
}else{
|
||
setentDutyerNull(sheet,6);
|
||
}
|
||
|
||
if(null != cadreDutyTree){
|
||
//镇街定点干部
|
||
DutyTree leaderDutyTree = dutyTreeMapper.findTargetId(cadreDutyTree.getUserId());
|
||
if(null != leaderDutyTree){
|
||
SysUser leaderUser = sysUserMapper.findById(leaderDutyTree.getUserId());
|
||
if(null != leaderUser){
|
||
Row leaderUserRow = sheet.getRow(5);
|
||
Cell leaderUserCell = leaderUserRow.getCell(1);
|
||
leaderUserCell.setCellValue(leaderUser.getChinaname());
|
||
|
||
Cell leaderMobileCell = leaderUserRow.getCell(2);
|
||
String mobile = "";
|
||
if(StringUtils.isNotBlank(leaderUser.getMobiletel())){
|
||
mobile = leaderUser.getMobiletel();
|
||
}else{
|
||
mobile = leaderUser.getSysusername();
|
||
}
|
||
if(!mobile.contains("1")){
|
||
mobile = "";
|
||
}
|
||
|
||
mobile = "联系电话 "+mobile;
|
||
leaderMobileCell.setCellValue(mobile);
|
||
}else{
|
||
setentDutyerNull(sheet,5);
|
||
}
|
||
}else{
|
||
setentDutyerNull(sheet,5);
|
||
}
|
||
}else{
|
||
setentDutyerNull(sheet,5);
|
||
}
|
||
|
||
|
||
//静态风险
|
||
String inherentRisk = enterprise.getInherentRisk();
|
||
if(StringUtils.isBlank(inherentRisk)){
|
||
inherentRisk = "1";
|
||
}
|
||
Map<String,String> riskMap = new HashMap<>();
|
||
riskMap.put("1","低风险(蓝色)");
|
||
riskMap.put("2","一般风险(黄色)");
|
||
riskMap.put("3","较大风险(橙色)");
|
||
riskMap.put("4","重大风险(红色)");
|
||
|
||
Row riskRow = sheet.getRow(8);
|
||
Cell riskCell = riskRow.getCell(0);
|
||
riskCell.setCellValue(riskMap.get(inherentRisk));
|
||
|
||
|
||
List<MinWorkUnit> workUnits = minWorkUnitMapper.findDanger(enterprise.getSysenterpriseid());
|
||
Integer index = 9;
|
||
//先设置为空
|
||
for(int i = index;i<=17;i++){
|
||
setWorkunitNull(sheet,i);
|
||
}
|
||
if(null != workUnits && workUnits.size() > 0){
|
||
|
||
for (MinWorkUnit workUnit : workUnits ){
|
||
Row dangerRow = sheet.getRow(index);
|
||
Cell titleCell = dangerRow.getCell(0);
|
||
titleCell.setCellValue(workUnit.getTitle());
|
||
Cell dangerCell = dangerRow.getCell(1);
|
||
dangerCell.setCellValue(workUnit.getDangerinfo());
|
||
index++;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 设置为空
|
||
* @param sheet
|
||
* @param index
|
||
* @throws Exception
|
||
*/
|
||
public void setentDutyerNull(Sheet sheet,Integer index)throws Exception{
|
||
Row leaderUserRow = sheet.getRow(index);
|
||
Cell leaderUserCell = leaderUserRow.getCell(1);
|
||
leaderUserCell.setCellValue("");
|
||
Cell leaderMobileCell = leaderUserRow.getCell(2);
|
||
leaderMobileCell.setCellValue("");
|
||
}
|
||
|
||
/**
|
||
* 设置工作单元信息
|
||
* @param sheet
|
||
* @param index
|
||
* @throws Exception
|
||
*/
|
||
public void setWorkunitNull(Sheet sheet,Integer index)throws Exception{
|
||
Row leaderUserRow = sheet.getRow(index);
|
||
Cell leaderUserCell = leaderUserRow.getCell(0);
|
||
leaderUserCell.setCellValue("");
|
||
Cell leaderMobileCell = leaderUserRow.getCell(1);
|
||
leaderMobileCell.setCellValue("");
|
||
}
|
||
|
||
|
||
/**
|
||
* 获取当前周周一
|
||
* @param weekFrist
|
||
* @return
|
||
*/
|
||
public static String getWeekFirst(String weekFrist)throws Exception{
|
||
Calendar cal = Calendar.getInstance();
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||
cal.setTime(sdf.parse(weekFrist));
|
||
// 设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一
|
||
cal.setFirstDayOfWeek(Calendar.MONDAY);
|
||
// 判断要计算的日期是否是周日,如果是则减一天计算周六的,否则会出问题,计算到下一周去了
|
||
int dayWeek = cal.get(Calendar.DAY_OF_WEEK);// 获得当前日期是一个星期的第几天
|
||
if (1 == dayWeek) {
|
||
cal.add(Calendar.DAY_OF_MONTH, -1);
|
||
}
|
||
// 获得当前日期是一个星期的第几天
|
||
int day = cal.get(Calendar.DAY_OF_WEEK);
|
||
// 获取该周第一天
|
||
cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - day);
|
||
String beginDate = sdf.format(cal.getTime());
|
||
|
||
return beginDate;
|
||
}
|
||
|
||
/**
|
||
* 获取当前周周天
|
||
* @param weekEnd
|
||
* @return
|
||
*/
|
||
public static String getWeekEnd(String weekEnd)throws Exception{
|
||
Calendar cal = Calendar.getInstance();
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||
cal.setTime(sdf.parse(weekEnd));
|
||
// 设置一个星期的第一天,第一天是星期一
|
||
cal.setFirstDayOfWeek(Calendar.MONDAY);
|
||
// 判断要计算的日期是否是周日,如果是则减一天计算周六的,否则会出问题,计算到下一周去了
|
||
int dayWeek = cal.get(Calendar.DAY_OF_WEEK);// 获得当前日期是一个星期的第几天
|
||
if (1 == dayWeek) {
|
||
cal.add(Calendar.DAY_OF_MONTH, -1);
|
||
}
|
||
// 获取该周最后一天
|
||
cal.add(Calendar.DATE, 6);
|
||
String endDate = sdf.format(cal.getTime());
|
||
|
||
return endDate;
|
||
}
|
||
|
||
/**
|
||
* 上周周天
|
||
* @param beforeWeekEnd
|
||
* @return
|
||
*/
|
||
public String getLastTimeInterval1(String beforeWeekEnd) throws Exception{
|
||
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||
Calendar calendar2 = Calendar.getInstance();
|
||
calendar2.setTime(sdf.parse(beforeWeekEnd));
|
||
|
||
int dayOfWeek = calendar2.get(Calendar.DAY_OF_WEEK) - 1;
|
||
if(dayOfWeek <= 0){
|
||
dayOfWeek = 7;
|
||
}
|
||
int offset2 = 7 - dayOfWeek;
|
||
calendar2.add(Calendar.DATE, offset2 - 7);
|
||
// last Sunday
|
||
return sdf.format(calendar2.getTime());
|
||
}
|
||
|
||
/**
|
||
* 上周周一
|
||
* @param beforeWeekFirst
|
||
* @return
|
||
*/
|
||
public String getLastTimeInterval2(String beforeWeekFirst) throws Exception {
|
||
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||
Calendar calendar1 = Calendar.getInstance();
|
||
calendar1.setTime(sdf.parse(beforeWeekFirst));
|
||
|
||
int dayOfWeek = calendar1.get(Calendar.DAY_OF_WEEK) - 1;
|
||
if(dayOfWeek <= 0){
|
||
dayOfWeek = 7;
|
||
}
|
||
int offset1 = 1 - dayOfWeek;
|
||
calendar1.add(Calendar.DATE, offset1 - 7);
|
||
|
||
return sdf.format(calendar1.getTime());
|
||
}
|
||
|
||
/**
|
||
* 所在年的第一天
|
||
* @param year
|
||
* @return
|
||
*/
|
||
public static String getFirstDayDateOfYear(String year) throws Exception{
|
||
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||
Calendar cal = Calendar.getInstance();
|
||
cal.setTime(sdf.parse(year));
|
||
|
||
final int last = cal.getActualMinimum(Calendar.DAY_OF_YEAR);
|
||
|
||
cal.set(Calendar.DAY_OF_YEAR, last);
|
||
|
||
return sdf.format(cal.getTime());
|
||
|
||
}
|
||
|
||
/**
|
||
* 当前年最后一天
|
||
* @param year
|
||
* @return
|
||
*/
|
||
public static String getLastDayOfYear(String year) throws Exception{
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||
Calendar cal = Calendar.getInstance();
|
||
|
||
cal.setTime(sdf.parse(year));
|
||
|
||
final int last = cal.getActualMaximum(Calendar.DAY_OF_YEAR);
|
||
|
||
cal.set(Calendar.DAY_OF_YEAR, last);
|
||
|
||
return sdf.format(cal.getTime());
|
||
|
||
}
|
||
|
||
/**
|
||
* 所在月的第一天
|
||
* @param month
|
||
* @return
|
||
*/
|
||
public static String getFirstDayDateOfMonth(String month) throws Exception{
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||
Calendar cal = Calendar.getInstance();
|
||
|
||
cal.setTime(sdf.parse(month));
|
||
|
||
final int last = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
|
||
|
||
cal.set(Calendar.DAY_OF_MONTH, last);
|
||
|
||
return sdf.format(cal.getTime());
|
||
|
||
}
|
||
|
||
/**
|
||
* 所在月的最后一天
|
||
* @param month
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public static String getLastDayOfMonth(final String month) throws Exception{
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||
Calendar cal = Calendar.getInstance();
|
||
|
||
cal.setTime(sdf.parse(month));
|
||
|
||
final int last = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||
|
||
cal.set(Calendar.DAY_OF_MONTH, last);
|
||
|
||
return sdf.format(cal.getTime());
|
||
|
||
}
|
||
|
||
/**
|
||
* 用户权限
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected void userAuth(SysUser user)throws Exception{
|
||
List<SysAuth> auths = sysAuthMapper.findByUnitId(user.getUserroles(),user.getSysunitorentid());
|
||
if(null != auths && auths.size() > 0){
|
||
for (SysAuth sysAuth : auths){
|
||
Integer authState = 2;
|
||
if(StringUtils.isNotBlank(sysAuth.getUnitRoleId())){
|
||
authState = 1;
|
||
}
|
||
|
||
//都选择
|
||
authState = 1;
|
||
sysAuth.setAuthState(authState+"");
|
||
}
|
||
}
|
||
user.setAuths(auths);
|
||
|
||
}
|
||
|
||
/**
|
||
* 用户权限MAP
|
||
* @param user
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
protected Map<String,String> userAuthMap(SysUser user)throws Exception{
|
||
Map<String,String> authMap = new HashMap<>();
|
||
List<SysAuth> auths = sysAuthMapper.findByUnitId(user.getUserroles(),user.getSysunitorentid());
|
||
if(null != auths && auths.size() > 0){
|
||
for (SysAuth sysAuth : auths){
|
||
Integer authState = 2;
|
||
if(StringUtils.isNotBlank(sysAuth.getUnitRoleId())){
|
||
authState = 1;
|
||
}
|
||
authMap.put(sysAuth.getAuthKey(),authState+"");
|
||
}
|
||
}
|
||
return authMap;
|
||
}
|
||
|
||
/**
|
||
* 处理清单履职信息
|
||
* @param unitLists
|
||
* @throws Exception
|
||
*/
|
||
protected void handleUnitLists(List<UnitList> unitLists)throws Exception{
|
||
for (UnitList unitList : unitLists){
|
||
|
||
//总数
|
||
Integer totalNum = 0;
|
||
//完成数
|
||
Integer completeNum = 0;
|
||
|
||
|
||
List<PerformInfo> performInfos = unitList.getPerformInfos();
|
||
if (null != performInfos && performInfos.size() > 0) {
|
||
for (PerformInfo performInfo : performInfos){
|
||
|
||
//频率
|
||
Integer frequency = performInfo.getFrequency();
|
||
if(null == frequency ){
|
||
if(StringUtils.isNotBlank(performInfo.getListFactorId())){
|
||
frequency = 1;
|
||
}else{
|
||
frequency = 0;
|
||
}
|
||
}
|
||
|
||
//指标
|
||
Integer checkStandard = performInfo.getCheckStandard();
|
||
if(null == checkStandard){
|
||
if(StringUtils.isNotBlank(performInfo.getListFactorId())){
|
||
checkStandard = 1;
|
||
}else{
|
||
checkStandard = 0;
|
||
}
|
||
}
|
||
//单个清单目标数
|
||
Integer facotrTotal = frequency * checkStandard;
|
||
|
||
//完成数超过目标数 完成数等于目标数
|
||
Integer detailNum = performInfo.getDetailNum();
|
||
if(detailNum > facotrTotal){
|
||
detailNum = facotrTotal;
|
||
}
|
||
totalNum += facotrTotal;
|
||
completeNum += detailNum;
|
||
}
|
||
}
|
||
|
||
unitList.setPerformInfos(new ArrayList<>());
|
||
|
||
unitList.setCompleteNum(completeNum);
|
||
unitList.setTotalNum(totalNum);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 企业新增的时候 统一处理企业的清单信息
|
||
* 从行业清单获取行业下的清单 分配到企业清单
|
||
* 后期使用异步方式调用
|
||
*
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2022/11/10 16:31
|
||
*/
|
||
public void handleEntList(String entId)throws Exception{
|
||
SysEnterprise enterprise = sysEnterpriseMapper.selectByPrimaryKey(entId);
|
||
if(null != enterprise){
|
||
|
||
//如果企业没有清单,则生成清单
|
||
List<InEntList> entLists = inEntListMapper.selectByEnterpriseId(entId);
|
||
if(null == entLists || entLists.size() == 0){
|
||
List<InListItem> listItems = inListItemMapper.findByIndustryId(enterprise.getWorkClassId());
|
||
if(null != listItems && listItems.size() > 0){
|
||
|
||
for (InListItem listItem : listItems){
|
||
InEntList entList = new InEntList();
|
||
entList.setEntListId(RandomNumber.getUUid());
|
||
entList.setItemId(listItem.getItemId());
|
||
entList.setListId(listItem.getListId());
|
||
entList.setEnterpriseId(entId);
|
||
entList.setItemTitle(listItem.getItemTitle());
|
||
entList.setItemContent(listItem.getItemContent());
|
||
entList.setStandard(listItem.getStandard());
|
||
entList.setFrequency(listItem.getFrequency());
|
||
entList.setEnclosure(listItem.getEnclosure());
|
||
entList.setItemBasis(listItem.getItemBasis());
|
||
entList.setItemProof(listItem.getItemProof());
|
||
entList.setItemLaw(listItem.getItemLaw());
|
||
entList.setSortId(listItem.getSortId());
|
||
entList.setDelState(listItem.getDelState());
|
||
entList.setCreateTime(new Date());
|
||
entList.setModifyTime(new Date());
|
||
entList.setCreateBy("");
|
||
entList.setModifyBy("");
|
||
inEntListMapper.insert(entList);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 修改诊断列表
|
||
* @param score
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public void updateOrAddDiagnosis(Integer score,String enterpriseId,String category)throws Exception{
|
||
String chinaName = getChinaName();
|
||
Date date = new Date();
|
||
rkCompanyDiagnosisMapper.deletByEnterpriseId(enterpriseId);
|
||
RkCompanyDiagnosis rkCompanyDiagnosis = new RkCompanyDiagnosis();
|
||
rkCompanyDiagnosis.setDiagnosisId(RandomNumber.getUUid());
|
||
rkCompanyDiagnosis.setModified(chinaName);
|
||
rkCompanyDiagnosis.setCreated(chinaName);
|
||
rkCompanyDiagnosis.setModifyTime(date);
|
||
rkCompanyDiagnosis.setCreateTime(date);
|
||
rkCompanyDiagnosis.setEnterpriseId(enterpriseId);
|
||
rkCompanyDiagnosis.setAssessTime(date);
|
||
rkCompanyDiagnosis.setScore(score);
|
||
rkCompanyDiagnosis.setCategory(category);
|
||
rkCompanyDiagnosis.setStatus(FlowQueryStatus.PENDING);
|
||
if (score < 60){
|
||
rkCompanyDiagnosis.setGrade(1);
|
||
}else if (score >=60 && score < 75){
|
||
rkCompanyDiagnosis.setGrade(2);
|
||
}else if (score >= 75 && score < 90){
|
||
rkCompanyDiagnosis.setGrade(3);
|
||
}else{
|
||
rkCompanyDiagnosis.setGrade(4);
|
||
}
|
||
rkCompanyDiagnosisMapper.insert(rkCompanyDiagnosis);
|
||
|
||
//修改企业静态风险等级
|
||
Map<Integer,Integer> riskMap = new HashMap<>();
|
||
riskMap.put(4,1);
|
||
riskMap.put(3,2);
|
||
riskMap.put(2,3);
|
||
riskMap.put(1,4);
|
||
sysEnterpriseMapper.changeInherentRisk(enterpriseId,riskMap.get(rkCompanyDiagnosis.getScore()));
|
||
}
|
||
|
||
}
|