1786 lines
65 KiB
Java
1786 lines
65 KiB
Java
package com.zcloud.controller.app;
|
||
|
||
import cn.hutool.crypto.digest.DigestUtil;
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
|
||
import com.zcloud.controller.base.BaseController;
|
||
import com.zcloud.entity.Page;
|
||
import com.zcloud.entity.PageData;
|
||
import com.zcloud.service.bus.*;
|
||
import com.zcloud.service.hiddenApi.HiddenApiService;
|
||
import com.zcloud.service.hiddenApi.HiddenCheckApiService;
|
||
import com.zcloud.service.hiddenApi.HiddenExamineApiService;
|
||
import com.zcloud.service.inspection.SafetyEnvironmentalService;
|
||
import com.zcloud.service.system.DepartmentService;
|
||
import com.zcloud.service.system.FHlogService;
|
||
import com.zcloud.service.system.UsersService;
|
||
import com.zcloud.util.*;
|
||
import com.zcloud.util.event.DeviceHiddenEvent;
|
||
import com.zcloud.util.message.MessageService;
|
||
import net.sf.json.JSONArray;
|
||
import org.apache.commons.io.FileUtils;
|
||
import org.apache.commons.lang.StringUtils;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.context.ApplicationContext;
|
||
import org.springframework.stereotype.Controller;
|
||
import org.springframework.transaction.annotation.Transactional;
|
||
import org.springframework.web.bind.annotation.RequestMapping;
|
||
import org.springframework.web.bind.annotation.RequestParam;
|
||
import org.springframework.web.bind.annotation.ResponseBody;
|
||
import org.springframework.web.multipart.MultipartFile;
|
||
|
||
import javax.annotation.Resource;
|
||
import javax.servlet.http.HttpServletRequest;
|
||
import java.io.File;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.*;
|
||
|
||
/**
|
||
* 说明:隐患 作者:luoxiaobao 时间:2021-01-04 官网:www.zcloudchina.com
|
||
*/
|
||
@Controller
|
||
@RequestMapping("/app/hidden")
|
||
public class AppHiddenController extends BaseController {
|
||
|
||
@Autowired
|
||
private HiddenService hiddenService;
|
||
@Autowired
|
||
private ImgFilesService imgFilesService;
|
||
@Autowired
|
||
private UsersService usersService;
|
||
@Autowired
|
||
private ListCheckItemService listcheckitemService;
|
||
@Autowired
|
||
private DepartmentService departmentService;
|
||
@Autowired
|
||
private HiddenSchemeService hiddenSchemeService;
|
||
@Autowired
|
||
private HiddenCheckService hiddenCheckService;
|
||
@Autowired
|
||
private CorpInfoService corpinfoService;
|
||
@Autowired
|
||
private ListManagerService listmanagerService;
|
||
//@Autowired
|
||
//private CheckRecordService checkrecordService;
|
||
|
||
@Autowired
|
||
private SMSManagementService smsmanagementService;
|
||
@Autowired
|
||
private MSMLoginService msmloginService;
|
||
@Autowired
|
||
private HiddenUserService hiddenUserService; // 隐患相关人员信息
|
||
@Autowired
|
||
private HiddenExamineService hiddenexamineService; // 隐患意见
|
||
@Autowired
|
||
private HiddenRegionService hiddenRegionService;
|
||
@Autowired
|
||
private SafetyEnvironmentalService safetyenvironmentalService;
|
||
@Autowired
|
||
private HiddenExamineService hiddenExamineService; //隐患审核
|
||
@Autowired
|
||
private HiddenMailService hiddenMailService;
|
||
@Autowired
|
||
private FHlogService FHLOG;//日志记录
|
||
|
||
@Autowired
|
||
private NoticeCorpUtil noticeUtil;
|
||
@Resource
|
||
private ApplicationContext applicationContext;
|
||
@Autowired
|
||
private HiddenCheckApiService hiddenCheckApiService ; //隐患验收人
|
||
@Autowired
|
||
private HiddenApiService hiddenApiService;
|
||
@Autowired
|
||
private HiddenExamineApiService hiddenExamineApiService; //隐患审核 隐患的审核步骤的人员的信息的记录
|
||
@Autowired
|
||
private MessageService messageService;
|
||
/**
|
||
* app首页获取数量
|
||
*
|
||
* @param page
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/getCountByUserId")
|
||
@ResponseBody
|
||
public Object getCountByUserId(Page page) throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
Map<String, Object> hidCount = new HashMap<>();
|
||
pd.put("userId", pd.getString("userId")); // 发现人
|
||
Integer dzg = 0;// 待整改 1
|
||
Integer ycq = 0;// 已超期 5
|
||
Integer dfc = 0;// 待复查 2
|
||
Integer yys = 0;// 已验收 4
|
||
Integer dys = 0;// 待验收 3
|
||
Integer dpc = 0;// 待排查
|
||
Integer dqr = 0;// 待确认
|
||
Integer tscz = 0;//特殊处置1
|
||
Integer yq = 0;//延期2
|
||
// STATE -- 隐患状态 0-未提交 1- 未整改 2-已整改 3-已复查 4-已验收 5-已过期
|
||
if (Tools.notEmpty(pd.get("userId").toString())) {
|
||
pd.put("SELFUSERID", pd.get("userId"));
|
||
List<PageData> rectifiHid = hiddenService.getCountByRectifiCationorId(pd); // 根据人员id获取整改隐患信息 state 1 5
|
||
for (int i = 0; i < rectifiHid.size(); i++) {
|
||
PageData rec = rectifiHid.get(i);
|
||
if (null == rec.get("STATE")) {
|
||
continue;
|
||
}
|
||
if (rec.get("STATE").equals("1") || rec.get("STATE").equals("-1") || rec.get("STATE").equals("10")) {
|
||
dzg++;
|
||
}
|
||
}
|
||
|
||
List<PageData> checkorHid = hiddenService.getCountByCheckorId(pd); // 根据人员id获取整改隐患信息 state 1 5
|
||
for (int i = 0; i < checkorHid.size(); i++) {
|
||
PageData che = checkorHid.get(i);
|
||
if (null == che.get("STATE")) {
|
||
continue;
|
||
}
|
||
if (che.get("STATE").equals("2")) { //原来是3,但是手机端待验收数据与列表数据不对。调整为2
|
||
dys++;
|
||
}
|
||
}
|
||
|
||
List<PageData> confirmHid = hiddenService.getCountByConfirmId(pd); // 根据人员id获取整改隐患信息 state 1 5
|
||
for (int i = 0; i < confirmHid.size(); i++) {
|
||
PageData che = confirmHid.get(i);
|
||
if (null == che.get("STATE")) {
|
||
continue;
|
||
}
|
||
if (che.get("STATE").equals("-2")) { //待确认是-2
|
||
dqr++;
|
||
}
|
||
}
|
||
// userId -> 85437f01be1f4c959f71a850b1d731a1
|
||
List<PageData> specialHid = hiddenService.getCountSpecialByhId(pd); // 根据人员id获取特殊处理隐患和延期隐患信息 state 1 5
|
||
for (int i = 0; i < specialHid.size(); i++) {
|
||
PageData che = specialHid.get(i);
|
||
if (null == che.get("TYPE")) {
|
||
continue;
|
||
}
|
||
if (che.get("TYPE").toString().equals("1")) { //特殊处置1
|
||
tscz++;
|
||
}
|
||
if (che.get("TYPE").toString().equals("2")) { //延期是2
|
||
yq++;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
List<PageData> creatorHid = hiddenService.getCountByCreatorId(pd); // 根据人员id获取发现隐患信息
|
||
for (int i = 0; i < creatorHid.size(); i++) {
|
||
PageData cre = creatorHid.get(i);
|
||
if (null == cre.get("STATE")) {
|
||
continue;
|
||
}
|
||
if (cre.get("STATE").equals("2")) {
|
||
dfc++;
|
||
}
|
||
if (cre.get("STATE").equals("4")) {
|
||
yys++;
|
||
}
|
||
// if(cre.get("STATE").equals("3")) {
|
||
// dys++;
|
||
// }
|
||
if (cre.get("STATE").equals("-1")) {
|
||
ycq++;
|
||
}
|
||
}
|
||
}
|
||
hidCount.put("dys", dys);
|
||
hidCount.put("dzg", dzg);
|
||
hidCount.put("ycq", ycq);
|
||
hidCount.put("dfc", dfc);
|
||
hidCount.put("yys", yys);
|
||
hidCount.put("dqr", dqr);
|
||
hidCount.put("tscz", tscz);
|
||
hidCount.put("yq",yq);
|
||
|
||
// 待排查数量
|
||
String USER_NAME = pd.getString("USER_NAME");
|
||
String DEPARTMENT_ID = pd.getString("CHECK_DEPARTMENT_ID");
|
||
String ids = departmentService.getDEPARTMENT_IDS(DEPARTMENT_ID);
|
||
// if(pd.getString("IS_MAIN").equals("0")) {
|
||
if (ids != null && Tools.notEmpty(ids) && ids.lastIndexOf(",") > -1) {
|
||
ids = ids.substring(0, ids.lastIndexOf(","));
|
||
pd.put("DEPARTMENT_IDS", ids.split(","));
|
||
} else {
|
||
pd.put("DEPARTMENT_ID", DEPARTMENT_ID);
|
||
}
|
||
// }
|
||
int wjcNum = 0;
|
||
int yjcNum = 0;
|
||
List<PageData> varList = listmanagerService.listAll(pd);// 列出ListManager列表
|
||
for (PageData list : varList) {
|
||
String cycle = list.getString("PERIODNAME");
|
||
if (list.getString("TYPE").equals("listType0005")) {
|
||
if (Integer.parseInt(list.get("checkCount").toString()) > 0) {
|
||
yjcNum++;
|
||
} else {
|
||
wjcNum++;
|
||
}
|
||
continue;
|
||
}
|
||
if (Integer.parseInt(list.get("checkCount").toString()) > 0) {
|
||
yjcNum++;
|
||
} else {
|
||
wjcNum++;
|
||
}
|
||
}
|
||
hidCount.put("dpc", wjcNum);
|
||
map.put("hidCount", hidCount);
|
||
|
||
map.put("page", page);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 新增
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/add")
|
||
@ResponseBody
|
||
public Object add() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
PageData mes = new PageData();
|
||
pd = this.getPageData();
|
||
pd.put("HIDDEN_ID", this.get32UUID()); // 主键
|
||
pd.put("CREATTIME", DateUtil.date2Str(new Date())); // 发现时间
|
||
pd.put("CREATOR", pd.get("CREATOR")); // 发现时间
|
||
pd.put("ISDELETE", "0"); // 是否删除 1 删除 0未删除
|
||
pd.put("ISCONFIRM", "0"); //
|
||
// pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业id
|
||
if (pd.get("RECTIFICATIONTYPE") != null && Tools.notEmpty(pd.get("RECTIFICATIONTYPE").toString())) {
|
||
if ("1".equals(pd.get("RECTIFICATIONTYPE").toString())) {
|
||
pd.put("RECTIFICATIONTIME", DateUtil.getDay()); // 整改时间
|
||
pd.put("RECTIFICATIONOR", pd.get("CREATOR")); // 整改人
|
||
pd.put("RECTIFICATIONDEPT", pd.get("HIDDENFINDDEPT"));
|
||
}
|
||
}
|
||
if (pd.get("RISKITEM_ID") != null && Tools.notEmpty(pd.get("RISKITEM_ID").toString())) {
|
||
PageData item = new PageData();
|
||
item.put("LISTCHECKITEM_ID", pd.get("RISKITEM_ID"));
|
||
item = this.listcheckitemService.findById(item);
|
||
pd.put("RISK_UNIT", item.get("RISKUNITNAME"));
|
||
pd.put("IDENTIFICATION", item.get("PARTSNAME"));
|
||
pd.put("RISK_DESCR", item.get("RISK_DESCR"));
|
||
pd.put("RISK_POSITION", item.get("POSITIONNAME"));
|
||
pd.put("LEVEL", item.get("DNAME5"));
|
||
}
|
||
List<JSONObject> list = (List<JSONObject>) JSON.parse(pd.get("other").toString()); // 隐患发现人
|
||
for (JSONObject json : list){
|
||
PageData hiddenconUserAdd = new PageData();
|
||
hiddenconUserAdd.put("HIDDENUSER_ID", UuidUtil.get32UUID());
|
||
hiddenconUserAdd.put("HIDDEN_ID",pd.getString("HIDDEN_ID"));
|
||
hiddenconUserAdd.put("USER_ID",json.get("USER_ID"));
|
||
hiddenconUserAdd.put("TYPE","1");
|
||
hiddenconUserAdd.put("IS_MAIN","0");
|
||
hiddenUserService.save(hiddenconUserAdd); // 添加隐患发现人
|
||
}
|
||
if(pd.getString("HIDDENLEVEL").equals("jdyh001") || pd.getString("HIDDENLEVEL").equals("hiddenLevel2002")){//判断是否是重大隐患
|
||
PageData userpd = new PageData();
|
||
userpd.put("USER_ID",pd.getString("CREATOR"));
|
||
userpd.put("DEPARTMENT_ID",usersService.findById(userpd).getString("DEPARTMENT_ID"));//获取登录人的部门ID
|
||
if(departmentService.findById(userpd).getString("LEVEL").equals("departmentLevel0003")){//判断部门级别是不是班组
|
||
userpd.put("DEPARTMENT_ID",departmentService.findById(userpd).getString("DEPARTMENT_ID"));
|
||
if(Tools.isEmpty(departmentService.findById(userpd).getString("HEADMAN"))){//判断部门是否有负责人
|
||
map.put("msg", "所在部门未维护部门负责人");
|
||
return map;
|
||
}else {
|
||
userpd.put("USER_ID",departmentService.findById(userpd).getString("HEADMAN"));
|
||
pd.put("CONFIRM_USER",usersService.findById(userpd).getString("USER_ID"));//通过名字查询用户获取出ID
|
||
mes.put("RECEIVER_ID",usersService.findById(userpd).getString("USER_ID")); // 如果是较大或重大隐患在这里给站内信接收人赋值
|
||
}
|
||
}else{
|
||
if(Tools.isEmpty(departmentService.findById(userpd).getString("HEADMAN"))) {//判断部门是否有负责人
|
||
map.put("msg", "所在部门未维护部门负责人");
|
||
return map;
|
||
}{
|
||
userpd.put("USER_ID",departmentService.findById(userpd).getString("HEADMAN"));
|
||
userpd.put("CORPINFO_ID", pd.getString("CORPINFO_ID"));
|
||
if (Tools.isEmpty(usersService.findById(userpd))) {
|
||
map.put("msg", "所在部门未维护部门负责人");
|
||
return map;
|
||
}else{
|
||
pd.put("CONFIRM_USER", usersService.findById(userpd).getString("USER_ID"));//通过名字查询用户获取出ID
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
PageData before = new PageData();// 添加隐患初始信息
|
||
before.put("TYPE","0");
|
||
before.put("STATE","2");
|
||
before.put("HIDDEN_ID",pd.get("HIDDEN_ID"));
|
||
before.put("spare1",pd.getString("HIDDENLEVEL"));
|
||
before.put("spare2",pd.getString("RECTIFICATIONOR"));
|
||
before.put("spare3",pd.getString("RECTIFICATIONDEADLINE"));
|
||
before.put("spare4",pd.getString("RECTIFICATIONDEPT"));
|
||
before.put("CREATOR", pd.getString("loginUserId"));
|
||
before.put("OPERATOR",pd.getString("loginUserId"));
|
||
hiddenExamineService.saveApp(before);
|
||
hiddenService.save(pd);
|
||
if(!pd.getString("STATE").equals("0")){
|
||
messageService.sendMessageByParameter("HIDDEN_MAIL_001","友情提示:有一条隐患需要确认",pd.getString("CORPINFO_ID"),pd.getString("CONFIRM_USER"),pd.getString("HIDDEN_ID"),
|
||
pd.getString("HIDDENDESCR"),"隐患确认","确认","","");
|
||
}
|
||
// 清除同检查记录合格图片
|
||
if(pd.get("CLEARIMG") != null && Tools.notEmpty(pd.get("CLEARIMG").toString()) && "1".equals(pd.get("CLEARIMG").toString())) {
|
||
imgFilesService.delete(pd);
|
||
PageData img = new PageData();
|
||
img.put("FOREIGN_KEY", pd.get("RECORDITEM_ID"));
|
||
img.put("TYPE", "14");
|
||
List<PageData> imgs = imgFilesService.listAll(img); //根据ID读取
|
||
if(imgs != null && imgs.size() > 0) {
|
||
for(PageData i: imgs) {
|
||
File file = new File(PathUtil.getProjectpath()+i.getString("FILEPATH"));
|
||
file.delete();
|
||
imgFilesService.delete(i);
|
||
}
|
||
}
|
||
|
||
}
|
||
map.put("result", errInfo);
|
||
map.put("pd", pd);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 新增
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/appAdd")
|
||
@ResponseBody
|
||
public Object appAdd() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
pd.put("HIDDEN_ID", this.get32UUID()); // 主键
|
||
// pd.put("CREATOR", Jurisdiction.getUSER_ID()); //发现人
|
||
// pd.put("HIDDENFINDDEPT", Jurisdiction.getDEPARTMENT_ID());
|
||
pd.put("CREATTIME", DateUtil.date2Str(new Date())); // 发现时间
|
||
pd.put("ISDELETE", "0"); // 是否删除 1 删除 0未删除
|
||
// pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业id
|
||
if (pd.get("RECTIFICATIONTYPE") != null && Tools.notEmpty(pd.get("RECTIFICATIONTYPE").toString())) {
|
||
if ("1".equals(pd.get("RECTIFICATIONTYPE").toString())) { // 立即整改
|
||
pd.put("RECTIFICATIONTIME", DateUtil.getDay()); // 整改时间
|
||
pd.put("RECTIFICATIONOR", pd.get("CREATOR")); // 整改人
|
||
pd.put("RECTIFICATIONDEPT", pd.get("HIDDENFINDDEPT"));
|
||
pd.put("RECTIFICATIONDEADLINE", DateUtil.date2Str(new Date()));
|
||
pd.put("STATE", "-2");
|
||
} else {
|
||
pd.put("STATE", "-2");
|
||
}
|
||
}
|
||
PageData before = new PageData();// 添加隐患初始信息
|
||
before.put("TYPE","0");
|
||
before.put("STATE","2");
|
||
before.put("HIDDEN_ID",pd.get("HIDDEN_ID"));
|
||
before.put("spare1",pd.getString("HIDDENLEVEL"));
|
||
before.put("spare2",pd.getString("RECTIFICATIONOR"));
|
||
before.put("spare3",pd.getString("RECTIFICATIONDEADLINE"));
|
||
before.put("spare4",pd.getString("RECTIFICATIONDEPT"));
|
||
before.put("CREATOR", pd.getString("loginUserId"));
|
||
before.put("OPERATOR",pd.getString("loginUserId"));
|
||
hiddenExamineService.saveApp(before);
|
||
if (pd.get("RISKITEM_ID") != null && Tools.notEmpty(pd.get("RISKITEM_ID").toString())) {
|
||
if("2".equals(pd.getString("SOURCE"))){
|
||
PageData item = new PageData();
|
||
item.put("LISTCHECKITEM_ID", pd.get("RISKITEM_ID"));
|
||
item = this.listcheckitemService.findById(item);
|
||
pd.put("RISK_UNIT", item.get("RISKUNITNAME")); // 风险单元
|
||
pd.put("IDENTIFICATION", item.get("PARTSNAME")); //辨识部位
|
||
pd.put("RISK_DESCR", item.get("RISK_DESCR")); //存在风险
|
||
pd.put("RISK_POSITION", item.get("POSITIONNAME")); // 风险点位置
|
||
pd.put("LEVEL", item.get("DNAME5")); //风险分级
|
||
}else if("6".equals(pd.getString("SOURCE"))){
|
||
// 消防点检 切换为为提交的状态
|
||
// 隐患状态 0-未提交
|
||
// 1- 未整改 2-已整改
|
||
// 3-已复查 4-已验收
|
||
// 7待处理的特殊申请隐患 8已处理的特殊隐患
|
||
// -1-已过期 -2待确认
|
||
// ,5忽略隐患6重大隐患。
|
||
// 7待处理的特殊隐患。8处理的特殊隐患。
|
||
// 10验收打回。11分公司安委会办公室副主任核定。
|
||
// 12分公司安委会办公室副主任核实
|
||
//13港股分公司安委会办公室副主任核定、重大隐患待整改
|
||
//14重大隐患待验收
|
||
//15重大隐患已归档
|
||
//16确认打回
|
||
//100-安全环保检查暂存的隐患
|
||
//101.检查已归档,待指派
|
||
//102.检查已归档,指派中
|
||
pd.put("STATE", "0");
|
||
}
|
||
|
||
}
|
||
|
||
if("6".equals(pd.getString("SOURCE"))){
|
||
// 消防点检 切换为为提交的状态
|
||
// 隐患状态 0-未提交
|
||
// 1- 未整改 2-已整改
|
||
// 3-已复查 4-已验收
|
||
// 7待处理的特殊申请隐患 8已处理的特殊隐患
|
||
// -1-已过期 -2待确认
|
||
// ,5忽略隐患6重大隐患。
|
||
// 7待处理的特殊隐患。8处理的特殊隐患。
|
||
// 10验收打回。11分公司安委会办公室副主任核定。
|
||
// 12分公司安委会办公室副主任核实
|
||
//13港股分公司安委会办公室副主任核定、重大隐患待整改
|
||
//14重大隐患待验收
|
||
//15重大隐患已归档
|
||
//16确认打回
|
||
//100-安全环保检查暂存的隐患
|
||
//101.检查已归档,待指派
|
||
//102.检查已归档,指派中
|
||
pd.put("STATE", "0");
|
||
}
|
||
List<JSONObject> list = (List<JSONObject>) JSON.parse(pd.get("other").toString()); // 隐患发现人
|
||
for (JSONObject json : list){
|
||
PageData hiddenconUserAdd = new PageData();
|
||
hiddenconUserAdd.put("HIDDENUSER_ID", UuidUtil.get32UUID());
|
||
hiddenconUserAdd.put("HIDDEN_ID",pd.getString("HIDDEN_ID"));
|
||
hiddenconUserAdd.put("USER_ID",json.get("USER_ID"));
|
||
hiddenconUserAdd.put("TYPE","1");
|
||
hiddenconUserAdd.put("IS_MAIN","0");
|
||
hiddenUserService.save(hiddenconUserAdd); // 添加隐患发现人
|
||
}
|
||
pd.put("ISCONFIRM", "0");
|
||
if(pd.getString("HIDDENLEVEL").equals("jdyh001") || pd.getString("HIDDENLEVEL").equals("hiddenLevel2002")){//判断是否是重大隐患
|
||
PageData userpd = new PageData();
|
||
userpd.put("USER_ID",pd.getString("CREATOR"));
|
||
userpd.put("DEPARTMENT_ID",usersService.findById(userpd).getString("DEPARTMENT_ID"));//获取登录人的部门ID
|
||
if(departmentService.findById(userpd).getString("LEVEL").equals("departmentLevel0003")){//判断部门级别是不是班组
|
||
userpd.put("DEPARTMENT_ID",departmentService.findById(userpd).getString("DEPARTMENT_ID"));
|
||
if(Tools.isEmpty(departmentService.findById(userpd).getString("HEADMAN"))){//判断部门是否有负责人
|
||
map.put("msg", "所在部门未维护部门负责人");
|
||
return map;
|
||
}else {
|
||
userpd.put("USER_ID",departmentService.findById(userpd).getString("HEADMAN"));
|
||
PageData byId = usersService.findById(userpd);
|
||
if (byId == null || Tools.isEmpty(byId.getString("USER_ID"))) {
|
||
map.put("msg", "未查询到部门负责人");
|
||
return map;
|
||
} else {
|
||
pd.put("CONFIRM_USER",usersService.findById(userpd).getString("USER_ID"));//通过名字查询用户获取出ID
|
||
}
|
||
/**
|
||
* 下面代码如果findById(userpd)为空,那么getString("USER_ID")会报空指针异常
|
||
* @date 2024年2月6日
|
||
* @author limingyu
|
||
*/
|
||
// if(Tools.notEmpty(usersService.findById(userpd).getString("USER_ID"))){
|
||
// pd.put("CONFIRM_USER",usersService.findById(userpd).getString("USER_ID"));//通过名字查询用户获取出ID
|
||
// }else {
|
||
// map.put("msg", "未查询到部门负责人");
|
||
// }
|
||
}
|
||
}else{
|
||
if(Tools.isEmpty(departmentService.findById(userpd).getString("HEADMAN"))) {//判断部门是否有负责人
|
||
map.put("msg", "所在部门未维护部门负责人");
|
||
return map;
|
||
}{
|
||
userpd.put("USER_ID",departmentService.findById(userpd).getString("HEADMAN"));
|
||
userpd.put("CORPINFO_ID", pd.getString("CORPINFO_ID"));
|
||
PageData usersPd = usersService.findById(userpd);
|
||
if(usersPd != null && Tools.notEmpty(usersPd.getString("USER_ID"))){
|
||
pd.put("CONFIRM_USER",usersService.findById(userpd).getString("USER_ID"));//通过名字查询用户获取出ID
|
||
}else {
|
||
map.put("msg", "所在部门未维护部门负责人");
|
||
return map;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
hiddenService.save(pd);
|
||
// 发送短信
|
||
if(Tools.notEmpty(pd.getString("CONFIRM_USER")) && !pd.getString("STATE").equals("0")){
|
||
messageService.sendMessageByParameter("HIDDEN_MAIL_001","友情提示:有一条隐患需要确认",pd.getString("CORPINFO_ID"),pd.getString("CONFIRM_USER"),pd.getString("HIDDEN_ID"),
|
||
pd.getString("HIDDENDESCR"),"隐患确认","确认","","");
|
||
}
|
||
map.put("result", errInfo);
|
||
map.put("pd", pd);
|
||
return map;
|
||
}
|
||
|
||
public String getCode() {
|
||
String code = "";
|
||
Random random = new Random();
|
||
for (int i = 0; i < 6; i++) {
|
||
|
||
int r = random.nextInt(10); // 每次随机出一个数字(0-9)
|
||
|
||
code = code + r; // 把每次随机出的数字拼在一起
|
||
|
||
}
|
||
return code;
|
||
}
|
||
|
||
/**
|
||
* 上传图片
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/uploadImg")
|
||
@ResponseBody
|
||
public Object uploadImg(@RequestParam(value = "FFILE", required = false) MultipartFile file,
|
||
@RequestParam(value = "TYPE", required = false) String TYPE,
|
||
@RequestParam(value = "FOREIGN_KEY", required = false) String FOREIGN_KEY) throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
String suffixName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1).toLowerCase();
|
||
if (!"pdf".equals(suffixName) && !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName) && !"mp4".equals(suffixName)) {
|
||
errInfo = "fail";
|
||
map.put("result", errInfo);
|
||
map.put("msg", "文件格式不正确!");
|
||
return map;
|
||
}
|
||
File tempFile = new File(file.getOriginalFilename());
|
||
FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile);
|
||
String md5 = DigestUtil.md5Hex(tempFile);
|
||
if (!FileUpload.isImage(tempFile)) {
|
||
tempFile.delete();
|
||
map.put("result", "failed");
|
||
map.put("exception", "上传图片格式不正确,请重新上传");
|
||
return map;
|
||
}
|
||
if (tempFile.exists()) {
|
||
tempFile.delete();
|
||
}
|
||
String ffile = DateUtil.getDays();
|
||
// String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile; //文件上传路径
|
||
// String fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传
|
||
String fileName = this.get32UUID()
|
||
+ file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
||
Smb.sshSftp(file, fileName, Const.FILEPATHFILE + ffile);
|
||
PageData pd = new PageData();
|
||
pd.put("IMGFILES_ID", this.get32UUID());
|
||
pd.put("MD5", md5);
|
||
pd.put("FILEPATH", Const.FILEPATHFILE + ffile + "/" + fileName);
|
||
pd.put("TYPE", TYPE);
|
||
|
||
pd.put("FOREIGN_KEY", FOREIGN_KEY);
|
||
imgFilesService.save(pd);
|
||
|
||
return map;
|
||
}
|
||
|
||
/**去修改页面获取数据
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value="/goEditWeui")
|
||
@ResponseBody
|
||
public Object goEditWeui() throws Exception{
|
||
Map<String,Object> map = new HashMap<String,Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
pd = hiddenService.findById(pd); //根据ID读取
|
||
PageData pd2 = new PageData();
|
||
pd2.put("FOREIGN_KEY", pd.getString("HIDDEN_ID"));
|
||
pd2.put("TYPE",3);
|
||
List<PageData> hImgs = imgFilesService.listAll(pd2);//隐患图片
|
||
pd2.put("TYPE",4);
|
||
List<PageData> rImgs = imgFilesService.listAll(pd2);//整改图片
|
||
pd2.put("TYPE",102);
|
||
List<PageData> hiddenVideo = imgFilesService.listAll(pd2);//隐患视频
|
||
/*pd2.put("TYPE",5);
|
||
List<PageData> cImgs = imgFilesService.listAll(pd2);//验收图片
|
||
*/ //查询整改方案
|
||
PageData hs = hiddenSchemeService.findByHdId(pd);
|
||
List<PageData> sImgs = new ArrayList<PageData>();
|
||
|
||
if(hs != null && hs.getString("HIDDENSCHEME_ID") != null) {
|
||
PageData pd3 = new PageData();
|
||
pd3.put("FOREIGN_KEY", hs.getString("HIDDENSCHEME_ID"));
|
||
pd3.put("TYPE",8);
|
||
sImgs = imgFilesService.listAll(pd3);//方案图片
|
||
}
|
||
|
||
List<PageData> checkList = hiddenCheckService.listAll(pd);
|
||
if(checkList != null && checkList.size() > 0) {
|
||
PageData pd3 = new PageData();
|
||
pd3.put("TYPE",5);
|
||
for(PageData check: checkList) {
|
||
pd3.put("FOREIGN_KEY", check.get("HIDDENCHECK_ID"));
|
||
check.put("cImgs", imgFilesService.listAll(pd3));//验收图片
|
||
}
|
||
}
|
||
map.put("pd", pd);
|
||
map.put("hs", hs);
|
||
map.put("hImgs", hImgs);
|
||
map.put("rImgs", rImgs);
|
||
// map.put("cImgs", cImgs);
|
||
map.put("sImgs", sImgs);
|
||
map.put("checkList", checkList);
|
||
map.put("hiddenVideo",hiddenVideo);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 删除
|
||
*
|
||
* @param out
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/delete")
|
||
@ResponseBody
|
||
public Object delete() throws Exception {
|
||
// 获取IP
|
||
HttpServletRequest request = this.getRequest();
|
||
String ip = "";
|
||
if (request.getHeader("x-forwarded-for") == null) {
|
||
ip = request.getRemoteAddr();
|
||
}else{
|
||
ip = request.getHeader("x-forwarded-for");
|
||
}
|
||
Map<String, String> map = new HashMap<String, String>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
hiddenService.delete(pd);
|
||
FHLOG.save(pd.getString("loginUserName"), "删除隐患ID:"+pd.getString("HIDDEN_ID"),ip); //记录日志 用户ID 隐患id 时间
|
||
applicationContext.publishEvent(new DeviceHiddenEvent(new Object(),pd.getString("HIDDEN_ID"),"1"));
|
||
map.put("result", errInfo); // 返回结果
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 获取清单风险点
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/getOtherHidden")
|
||
@ResponseBody
|
||
public Object getOtherHidden() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
String USER_ID = pd.getString("USER_ID");
|
||
pd = listmanagerService.findById(pd);
|
||
if (pd.getString("TYPE").equals("listType0005")) {
|
||
if (DateUtil.timeCalendar(new Date(), DateUtil.fomatDateTime(pd.getString("START_DATE") + " 00:00:00"),
|
||
DateUtil.fomatDateTime(pd.getString("END_DATE") + " 23:59:59"))) {
|
||
PageData type = new PageData();
|
||
type.put("LISTMANAGER_ID", pd.get("LISTMANAGER_ID"));
|
||
type.put("IS_XUN", 1);// 查询方法和旬一样,直接借用
|
||
type.put("STATE", "0");
|
||
type.put("USER_ID", USER_ID);
|
||
type.put("BEGINTIME", pd.getString("START_DATE") + " 00:00:00");
|
||
type.put("ENDTIME", pd.getString("END_DATE") + " 23:59:59");
|
||
List<PageData> hiddenList = hiddenService.getOtherHidden(type);
|
||
map.put("hiddenList", hiddenList);
|
||
}
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
String cycle = pd.getString("PERIODNAME");
|
||
PageData type = new PageData();
|
||
if (cycle.equals("每日")) {
|
||
type.put("LISTMANAGER_ID", pd.get("LISTMANAGER_ID"));
|
||
type.put("IS_DAY", 1);
|
||
type.put("STATE", "0");
|
||
type.put("USER_ID", USER_ID);
|
||
} else if (cycle.equals("每周")) {
|
||
type.put("LISTMANAGER_ID", pd.get("LISTMANAGER_ID"));
|
||
type.put("IS_WEEK", 1);
|
||
type.put("STATE", "0");
|
||
type.put("USER_ID", USER_ID);
|
||
} else if (cycle.equals("每旬")) {
|
||
// 1-10
|
||
if (DateUtil.timeCalendar(new Date(),
|
||
DateUtil.fomatDateTime(DateUtil.getYear() + "-" + DateUtil.getMonth() + "-" + "01 00:00:00"),
|
||
DateUtil.fomatDateTime(DateUtil.getYear() + "-" + DateUtil.getMonth() + "-" + "10 23:59:59"))) {
|
||
type.put("LISTMANAGER_ID", pd.get("LISTMANAGER_ID"));
|
||
type.put("IS_XUN", 1);
|
||
type.put("STATE", "0");
|
||
type.put("USER_ID", USER_ID);
|
||
type.put("BEGINTIME", DateUtil.getYear() + "-" + DateUtil.getMonth() + "-" + "01 00:00:00");
|
||
type.put("ENDTIME", DateUtil.getYear() + "-" + DateUtil.getMonth() + "-" + "10 23:59:59");
|
||
}
|
||
// 11-20
|
||
if (DateUtil.timeCalendar(new Date(),
|
||
DateUtil.fomatDateTime(DateUtil.getYear() + "-" + DateUtil.getMonth() + "-" + "11 00:00:00"),
|
||
DateUtil.fomatDateTime(DateUtil.getYear() + "-" + DateUtil.getMonth() + "-" + "20 23:59:59"))) {
|
||
type.put("LISTMANAGER_ID", pd.get("LISTMANAGER_ID"));
|
||
type.put("IS_XUN", 1);
|
||
type.put("STATE", "0");
|
||
type.put("USER_ID", USER_ID);
|
||
type.put("BEGINTIME", DateUtil.getYear() + "-" + DateUtil.getMonth() + "-" + "11 00:00:00");
|
||
type.put("ENDTIME", DateUtil.getYear() + "-" + DateUtil.getMonth() + "-" + "20 23:59:59");
|
||
}
|
||
// 21-月底
|
||
if (DateUtil.timeCalendar(new Date(),
|
||
DateUtil.fomatDateTime(DateUtil.getYear() + "-" + DateUtil.getMonth() + "-" + "21 00:00:00"),
|
||
DateUtil.fomatDateTime(DateUtil.getMonthEndDay() + " 23:59:59"))) {
|
||
type.put("LISTMANAGER_ID", pd.get("LISTMANAGER_ID"));
|
||
type.put("IS_XUN", 1);
|
||
type.put("STATE", "0");
|
||
type.put("USER_ID", USER_ID);
|
||
type.put("BEGINTIME", DateUtil.getYear() + "-" + DateUtil.getMonth() + "-" + "21 00:00:00");
|
||
type.put("ENDTIME", DateUtil.getMonthEndDay() + " 23:59:59");
|
||
}
|
||
|
||
} else if (cycle.equals("每月")) {
|
||
type.put("LISTMANAGER_ID", pd.get("LISTMANAGER_ID"));
|
||
type.put("IS_MONTH", 1);
|
||
type.put("STATE", "0");
|
||
type.put("USER_ID", USER_ID);
|
||
} else if (cycle.equals("每季")) {
|
||
type.put("LISTMANAGER_ID", pd.get("LISTMANAGER_ID"));
|
||
type.put("IS_QUARTER", 1);
|
||
type.put("STATE", "0");
|
||
type.put("USER_ID", USER_ID);
|
||
} else if (cycle.equals("半年")) {
|
||
type.put("LISTMANAGER_ID", pd.get("LISTMANAGER_ID"));
|
||
type.put("IS_HALFYEAR", 1);
|
||
type.put("STATE", "0");
|
||
type.put("USER_ID", USER_ID);
|
||
} else if (cycle.equals("每年")) {
|
||
type.put("LISTMANAGER_ID", pd.get("LISTMANAGER_ID"));
|
||
type.put("IS_YEAR", 1);
|
||
type.put("STATE", "0");
|
||
type.put("USER_ID", USER_ID);
|
||
}
|
||
|
||
List<PageData> hiddenList = hiddenService.getOtherHidden(type);
|
||
map.put("result", errInfo);
|
||
map.put("hiddenList", hiddenList);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 修改
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/edit")
|
||
@ResponseBody
|
||
public Object edit() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
|
||
hiddenUserService.delete(pd); //删除隐患相关人员 -- 隐患发现人
|
||
if(pd.getString("STATE").equals("16")){//如果状态等于16进入此方法肯定是提交过来的,赋值给待确认
|
||
pd.put("STATE","-2");
|
||
if(Tools.notEmpty(pd.getString("POSITIONDESC"))){hiddenService.editInformation(pd);}
|
||
hiddenService.editstate(pd);
|
||
}
|
||
hiddenService.editInfo(pd);
|
||
|
||
List<JSONObject> list = (List<JSONObject>) JSON.parse(pd.get("other").toString()); // 隐患发现人
|
||
for (JSONObject json : list){
|
||
PageData hiddenconUserAdd = new PageData();
|
||
hiddenconUserAdd.put("HIDDENUSER_ID", UuidUtil.get32UUID());
|
||
hiddenconUserAdd.put("HIDDEN_ID",pd.getString("HIDDEN_ID"));
|
||
hiddenconUserAdd.put("USER_ID",json.get("USER_ID"));
|
||
hiddenconUserAdd.put("TYPE","1");
|
||
hiddenconUserAdd.put("IS_MAIN","0");
|
||
hiddenUserService.save(hiddenconUserAdd); // 添加隐患发现人
|
||
}
|
||
map.put("pd", pd);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 修改
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/editRec")
|
||
@ResponseBody
|
||
public Object editRec() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
hiddenService.edit(pd);
|
||
|
||
pd = hiddenService.findById(pd);
|
||
PageData corpinfo = new PageData();
|
||
corpinfo.put("CORPINFO_ID", pd.getString("CORPINFO_ID"));
|
||
corpinfo = corpinfoService.findById(pd);
|
||
|
||
PageData lpd = new PageData();
|
||
lpd.put("STATE", "OK");
|
||
lpd.put("CORPINFO_ID", pd.getString("CORPINFO_ID"));
|
||
int usedCount = msmloginService.msUsedCount(lpd);
|
||
PageData sms = new PageData();
|
||
sms.put("CORPINFO_ID", pd.getString("CORPINFO_ID"));
|
||
sms.put("ISENABLE", "1");
|
||
sms.put("SMSCODE", "SMS_215820677");
|
||
List<PageData> sList = smsmanagementService.listAll(sms);
|
||
if (corpinfo.getString("ISRECEIVE").equals("1")
|
||
&& Integer.parseInt(corpinfo.getString("SMS_COUNT")) - usedCount > 0 && sList.size() > 0) {
|
||
if (!"1".equals(pd.get("RECTIFICATIONTYPE").toString())) {
|
||
|
||
PageData user = new PageData();
|
||
user.put("USER_ID", pd.get("RECTIFICATIONOR"));
|
||
user = usersService.findById(user);
|
||
if (user.get("USERNAME") != null && Tools.notEmpty(user.get("USERNAME").toString())) {
|
||
String phone = user.get("USERNAME").toString();
|
||
Map<String, Object> mes = new HashMap<String, Object>();
|
||
mes.put("phone", phone);
|
||
mes.put("templateCode", "SMS_215820677");
|
||
mes.put("time", pd.get("RECTIFICATIONDEADLINE"));
|
||
mes.put("type", "1");
|
||
SendSmsResponse ssms = AliSmsUtil.sendSms(mes);
|
||
msmloginService.addForAliSmsUtil(mes, pd.getString("CORPINFO_ID"), ssms);
|
||
// System.out.println(ssms.getCode());
|
||
if (ssms.getCode().equals("OK")) {
|
||
map.put("result", "success");
|
||
} else {
|
||
map.put("result", "fail");
|
||
map.put("msg", "您的操作过去频繁,请稍后重试!");
|
||
}
|
||
}
|
||
if (sList.get(0).getString("ADDRESSEE") != null) {
|
||
String[] uid = sList.get(0).getString("ADDRESSEE").split(",");
|
||
for (int i = 0; i < uid.length; i++) {
|
||
PageData suser = new PageData();
|
||
suser.put("USER_ID", uid[i].toString());
|
||
suser = usersService.findById(suser);
|
||
if (suser.get("USERNAME") != null && Tools.notEmpty(suser.get("USERNAME").toString())) {
|
||
String uphone = suser.get("USERNAME").toString();
|
||
Map<String, Object> umes = new HashMap<String, Object>();
|
||
umes.put("phone", uphone);
|
||
umes.put("templateCode", "SMS_215820677");
|
||
umes.put("time", pd.get("RECTIFICATIONDEADLINE"));
|
||
umes.put("type", "1");
|
||
PageData ewpd = new PageData();
|
||
ewpd.put("STATE", "OK");
|
||
ewpd.put("CORPINFO_ID", pd.getString("CORPINFO_ID"));
|
||
int ewusedCount = msmloginService.msUsedCount(ewpd);
|
||
if (Integer.parseInt(corpinfo.getString("SMS_COUNT")) - ewusedCount > 0) {
|
||
SendSmsResponse ussms = AliSmsUtil.sendSms(umes);
|
||
msmloginService.addForAliSmsUtil(umes, pd.getString("CORPINFO_ID"), ussms);
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
map.put("pd", pd);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
@RequestMapping(value = "/upFile")
|
||
@ResponseBody
|
||
public Object upFile(@RequestParam(value = "file", required = false) MultipartFile file) throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
if (null != file && !file.isEmpty()) {
|
||
String suffixName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1).toLowerCase();
|
||
if (!"pdf".equals(suffixName) && !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName) && !"mp4".equals(suffixName)) {
|
||
errInfo = "fail";
|
||
map.put("result", errInfo);
|
||
map.put("msg", "文件格式不正确!");
|
||
return map;
|
||
}
|
||
PageData hs = hiddenSchemeService.findById(pd);
|
||
String ffile = DateUtil.getDays();
|
||
// String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile; //文件上传路径
|
||
// String fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传
|
||
String fileName = this.get32UUID()
|
||
+ file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
||
Smb.sshSftp(file, fileName, Const.FILEPATHFILE + ffile);
|
||
pd.put("FILEPATH", Const.FILEPATHFILE + ffile + "/" + fileName);
|
||
hs.put("ISDELETE", "0");
|
||
hiddenSchemeService.edit(hs);
|
||
}
|
||
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 整改
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/rectify")
|
||
@ResponseBody
|
||
@Transactional
|
||
public Object rectify() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
PageData corpinfo = new PageData();
|
||
corpinfo.put("CORPINFO_ID", pd.getString("CORPINFO_ID"));
|
||
corpinfo = corpinfoService.findById(pd);
|
||
pd.put("STATE","2");
|
||
pd.put("INVESTMENT_FUNDS",pd.getString("INVEST_FUNDS"));
|
||
hiddenService.rectify(pd);
|
||
|
||
pd.put("HIDDENSCHEME_ID", this.get32UUID()); // 主键
|
||
hiddenSchemeService.deleteHd(pd);
|
||
if (Tools.notEmpty(pd.get("HAVESCHEME").toString())) {
|
||
pd.put("CREATOR", pd.get("USER_ID")); //
|
||
pd.put("CREATTIME", DateUtil.date2Str(new Date())); //
|
||
pd.put("OPERATOR", pd.get("USER_ID")); //
|
||
pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //
|
||
pd.put("ISDELETE", "0"); // 是否删除 1 删除 0未删除
|
||
pd.put("CORPINFO_ID", pd.get("CORPINFO_ID")); // 企业id
|
||
hiddenSchemeService.save(pd);
|
||
}
|
||
this.hiddenCheckService.delete(pd);
|
||
if(Tools.notEmpty(pd.getString("CHECKOR"))){//判断验收人是否空,否就发送站内信
|
||
PageData mes = new PageData();
|
||
PageData hiddenPd = hiddenService.findById(pd);
|
||
messageService.sendMessageByParameter("HIDDEN_MAIL_004","友情提示:有一条隐患需要验收",
|
||
hiddenPd.getString("CORPINFO_ID"),pd.getString("USER_ID"),hiddenPd.getString("HIDDEN_ID"),
|
||
hiddenPd.getString("HIDDENDESCR"),"隐患验收","验收","","");
|
||
}
|
||
|
||
if (pd.get("OTHER") != null && !pd.get("OTHER").equals("")) {
|
||
List<JSONObject> list = (List<JSONObject>) JSON.parse(pd.get("OTHER").toString());
|
||
for (JSONObject json : list) {
|
||
// if (json.get("DEPARTMENT_ID") != null && json.get("DEPARTMENT_ID") != "" && json.get("USER_ID") != null
|
||
// && json.get("USER_ID") != "") {
|
||
if(!Tools.isEmpty(json.get("DEPARTMENT_ID")) && !Tools.isEmpty(json.get("USER_ID")) ){
|
||
PageData other = new PageData();
|
||
other.put("HIDDENCHECK_ID", this.get32UUID()); // 主键
|
||
other.put("HIDDEN_ID", pd.get("HIDDEN_ID"));
|
||
other.put("DEPARTMENT_ID", json.get("DEPARTMENT_ID"));
|
||
other.put("USER_ID", json.get("USER_ID"));
|
||
other.put("STATUS", "0");
|
||
hiddenCheckService.save(other);
|
||
PageData hiddenPd = hiddenService.findById(pd);
|
||
messageService.sendMessageByParameter("HIDDEN_MAIL_004","友情提示:有一条隐患需要验收",
|
||
hiddenPd.getString("CORPINFO_ID"),json.get("USER_ID").toString(),hiddenPd.getString("HIDDEN_ID"),
|
||
hiddenPd.getString("HIDDENDESCR"),"隐患验收","验收","","");
|
||
}
|
||
}
|
||
}
|
||
map.put("result", errInfo);
|
||
map.put("HIDDENSCHEME_ID", pd.get("HIDDENSCHEME_ID"));
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 复查
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/review")
|
||
@ResponseBody
|
||
public Object review() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
hiddenService.review(pd);
|
||
// 删除整改照片
|
||
if (pd.get("ISPASS") != null && Tools.notEmpty(pd.get("ISPASS").toString())) {
|
||
if ("0".equals(pd.get("ISPASS").toString())) {
|
||
PageData pic = new PageData();
|
||
List<PageData> picList = new ArrayList<PageData>();
|
||
pic.put("FOREIGN_KEY", pd.get("HIDDEN_ID"));
|
||
pic.put("TYPE", "4");
|
||
picList = imgFilesService.listAll(pic);
|
||
if (picList != null && picList.size() > 0) {
|
||
for (PageData deletePic : picList) {
|
||
File file = new File(PathUtil.getProjectpath() + deletePic.getString("FILEPATH"));
|
||
file.delete();
|
||
}
|
||
}
|
||
imgFilesService.deleteList(pic);
|
||
List<PageData> picsList = new ArrayList<PageData>();
|
||
pic.put("FOREIGN_KEY", pd.get("HIDDENSCHEME_ID"));
|
||
pic.put("TYPE", "8");
|
||
picsList = imgFilesService.listAll(pic);
|
||
if (picsList != null && picsList.size() > 0) {
|
||
for (PageData deletePic : picsList) {
|
||
File file = new File(PathUtil.getProjectpath() + deletePic.getString("FILEPATH"));
|
||
file.delete();
|
||
}
|
||
}
|
||
hiddenSchemeService.deleteHd(pd);
|
||
imgFilesService.deleteList(pic);
|
||
}
|
||
|
||
}
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 验收
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/check")
|
||
@ResponseBody
|
||
public Object check() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
if (pd.get("ISQUALIFIED").equals("1")) { //验收合格
|
||
List<PageData> pd2 = this.hiddenCheckService.findByHidden(pd); //获取这个隐患的验收人信息
|
||
if(pd2.size()>0){
|
||
for(PageData checklist: pd2){
|
||
pd.put("STATUS", 1);
|
||
pd.put("HIDDENCHECK_ID", checklist.get("HIDDENCHECK_ID"));
|
||
pd.put("DEPARTMENT_ID", checklist.get("DEPARTMENT_ID"));
|
||
pd.put("USER_ID", checklist.get("USER_ID"));
|
||
hiddenCheckService.edit(pd);
|
||
}
|
||
}
|
||
|
||
// List<PageData> checkList = hiddenCheckService.listAll(pd);
|
||
// for (PageData check : checkList) {
|
||
// if (check.get("STATUS").toString().equals("0")) {
|
||
// break;
|
||
// }
|
||
// }
|
||
List<PageData> checkList = hiddenCheckService.listAll(pd);
|
||
for (PageData check : checkList) {
|
||
if (check.get("STATUS").toString().equals("0")) {
|
||
map.put("result", errInfo);
|
||
map.put("code","1000");
|
||
map.put("errorMessage","此次检查还有未合格项,不能验收");
|
||
map.put("check", pd);
|
||
return map;
|
||
}
|
||
}
|
||
if(Tools.isEmpty(pd.getString("CHECKTIME")) && Tools.notEmpty(pd.getString("CHECK_TIME"))){//用于手机端传验收时间,存隐患表20220920
|
||
pd.put("CHECKTIME",pd.getString("CHECK_TIME"));
|
||
}
|
||
hiddenService.check(pd);
|
||
if (Tools.notEmpty(pd.getString("INSPECTION_ID"))) { //安全环保检查验收
|
||
pd.put("ACCEPTSTEP", 6);
|
||
List<PageData> list = hiddenService.listOtherNotAccept(pd);
|
||
PageData inspection = new PageData();
|
||
if (list.size() == 0) {
|
||
inspection.put("INSPECTION_ID", pd.getString("INSPECTION_ID"));
|
||
inspection.put("OPERATOR", pd.getString("CHECKOR"));
|
||
inspection.put("OPERATTIME", DateUtil.date2Str(new Date()));
|
||
inspection.put("INSPECTION_STATUS", "6"); // 已验收
|
||
safetyenvironmentalService.editStatus(inspection);
|
||
}
|
||
inspection.put("INSPECTION_ID", pd.getString("INSPECTION_ID"));
|
||
inspection.put("OPERATOR", pd.getString("CHECKOR"));
|
||
inspection.put("HIDDEN_vector",pd.getString("HIDDEN_ID"));
|
||
noticeUtil.SE_ThreeStepUtil(inspection);
|
||
}
|
||
// 隐患验收清理点检处的状态
|
||
applicationContext.publishEvent(new DeviceHiddenEvent(new Object(),pd.getString("HIDDEN_ID"),"0"));
|
||
} else {
|
||
PageData pd2 = new PageData(); //验收打回
|
||
pd2.put("FOREIGN_KEY", pd.get("HIDDEN_ID"));
|
||
pd2.put("TYPE", "4");
|
||
List<PageData> zgImgs = imgFilesService.listAll(pd2);
|
||
for (PageData pageData : zgImgs) {
|
||
|
||
imgFilesService.delete(pageData);
|
||
if(Tools.notEmpty(pageData.getString("FILEPATH"))) {
|
||
Smb.deleteFile(pageData.getString("FILEPATH"));
|
||
}
|
||
|
||
}
|
||
/** 删除所有验收人数据。**/
|
||
hiddenCheckApiService.deleteByHiddenId(pd.getString("HIDDEN_ID"));
|
||
/** 验收打回 **/
|
||
hiddenApiService.repulseCheck(pd.getString("HIDDEN_ID"));
|
||
/** 记录打回 **/
|
||
hiddenExamineApiService.saveRepulseCheckApp(pd.getString("HIDDEN_ID"),pd.getString("CONTENT"),pd.getString("CHECKOR"));
|
||
}
|
||
hiddenMailService.apphiddneCheckAdopt(pd);
|
||
map.put("check", pd);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 列表
|
||
*
|
||
* @param page
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/list")
|
||
@ResponseBody
|
||
public Object list() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
Page page = new Page();
|
||
pd = this.getPageData();
|
||
page.setCurrentPage(Integer.parseInt(pd.get("currentPage").toString()));
|
||
page.setShowCount(Integer.parseInt(pd.get("showCount").toString()));
|
||
page.setTotalResult(Integer.parseInt(pd.get("totalResult").toString()));
|
||
// String DEPARTMENT_ID = pd.getString("USERDEPT");
|
||
// String ids = departmentService.getDEPARTMENT_IDS(DEPARTMENT_ID);
|
||
// if(ids!=null && Tools.notEmpty(ids)) {
|
||
// ids = ids.substring(0,ids.lastIndexOf(","));
|
||
// pd.put("DEPARTMENT_IDS", ids.split(","));
|
||
// }
|
||
String KEYWORDS = pd.getString("KEYWORDS"); // 关键词检索条件
|
||
if (Tools.notEmpty(KEYWORDS))
|
||
pd.put("KEYWORDS", KEYWORDS.trim());
|
||
String HIDDENDESCR = pd.getString("HIDDENDESCR"); // 关键词检索条件
|
||
if (Tools.notEmpty(HIDDENDESCR))
|
||
pd.put("HIDDENDESCR", HIDDENDESCR.trim());
|
||
String ISQUALIFIED = pd.getString("ISQUALIFIED"); // 关键词检索条件
|
||
if (Tools.notEmpty(ISQUALIFIED))
|
||
pd.put("ISQUALIFIED", ISQUALIFIED.trim());
|
||
String HIDDENLEVELE = pd.getString("HIDDENLEVELE"); // 关键词检索条件
|
||
if (Tools.notEmpty(HIDDENLEVELE))
|
||
pd.put("HIDDENLEVELE", HIDDENLEVELE.trim());
|
||
String STARTTIME = pd.getString("STARTTIME"); // 关键词检索条件
|
||
if (Tools.notEmpty(STARTTIME))
|
||
pd.put("STARTTIME", STARTTIME.trim());
|
||
String ENDTIME = pd.getString("ENDTIME"); // 关键词检索条件
|
||
if (Tools.notEmpty(ENDTIME))
|
||
pd.put("ENDTIME", ENDTIME.trim());
|
||
if (pd.get("isIndex") != null && Tools.notEmpty(pd.get("isIndex").toString())
|
||
&& pd.get("isIndex").toString().equals("1")) {
|
||
pd.put("SELF_USER_ID", pd.get("SELFUSERID"));
|
||
}
|
||
pd.put("ISMAIN", "0");
|
||
String DISPOSESTATE = pd.getString("DISPOSESTATE"); // 关键词检索条件
|
||
if (Tools.notEmpty(DISPOSESTATE)) {
|
||
pd.put("DISPOSESTATE", DISPOSESTATE.trim());
|
||
pd.put("SELFUSERID", pd.get("SELFUSERID"));
|
||
pd.put("USERDEPT", pd.get("USERDEPT"));
|
||
}
|
||
page.setPd(pd);
|
||
List<PageData> varList = hiddenService.list(page); // 列出Hidden列表
|
||
varList = hiddenUserService.getHiddebFind(varList);
|
||
map.put("varList", varList);
|
||
map.put("page", page);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 去修改页面获取数据
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/goEdit")
|
||
@ResponseBody
|
||
public Object goEdit() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
pd = hiddenService.findById(pd); // 根据ID读取
|
||
if(pd.getString("CONFIRM_USER")!=null || pd.getString("CONFIRM_USER").equals("undefined")){
|
||
pd.put("USER_ID",pd.getString("CONFIRM_USER"));
|
||
PageData user = usersService.findById(pd);
|
||
if(user!=null){
|
||
pd.put("confirmDeptId",user.getString("DEPARTMENT_ID"));
|
||
pd.put("conUserId",pd.getString("CONFIRM_USER"));
|
||
}
|
||
}
|
||
PageData pd2 = new PageData();
|
||
pd2.put("FOREIGN_KEY", pd.getString("HIDDEN_ID"));
|
||
pd2.put("TYPE", 3);
|
||
List<PageData> hImgs = imgFilesService.listAll(pd2);// 隐患图片
|
||
pd2.put("TYPE", 4);
|
||
List<PageData> rImgs = imgFilesService.listAll(pd2);// 整改图片
|
||
/*
|
||
* pd2.put("TYPE",5); List<PageData> cImgs = imgFilesService.listAll(pd2);//验收图片 d770367816c34f53bf22177da3965f6c
|
||
*/ // 查询整改方案
|
||
PageData hs = hiddenSchemeService.findByHdId(pd);
|
||
List<PageData> sImgs = new ArrayList<PageData>();
|
||
|
||
if (hs != null && hs.getString("HIDDENSCHEME_ID") != null) {
|
||
PageData pd3 = new PageData();
|
||
pd3.put("FOREIGN_KEY", pd.getString("HIDDEN_ID"));
|
||
pd3.put("TYPE", 8);
|
||
sImgs = imgFilesService.listAll(pd3);// 方案图片
|
||
|
||
|
||
PageData pd31 = new PageData();
|
||
pd31.put("FOREIGN_KEY", hs.getString("HIDDENSCHEME_ID"));
|
||
pd31.put("TYPE", 8);
|
||
List<PageData> sImgs2 = imgFilesService.listAll(pd31);// 方案图片
|
||
sImgs.addAll(sImgs2);
|
||
}
|
||
|
||
List<PageData> checkList = hiddenCheckService.listAll(pd);
|
||
if (checkList != null && checkList.size() > 0) {
|
||
PageData pd3 = new PageData();
|
||
pd3.put("TYPE", 5);
|
||
for (PageData check : checkList) {
|
||
pd3.put("FOREIGN_KEY", check.get("HIDDENCHECK_ID"));
|
||
check.put("cImgs", imgFilesService.listAll(pd3));// 验收图片
|
||
}
|
||
}
|
||
List<PageData> hiddenExa = hiddenExamineService.listAllByHiddenId(pd.getString("HIDDEN_ID")); // 隐患流程信息
|
||
List<PageData> repulsecause = hiddenExamineService.findByHiddenId(pd);//确认人打回信息
|
||
for (PageData pageData :hiddenExa){
|
||
if("0".equals(pageData.getString("TYPE"))){
|
||
pd.put("editUserName",pageData.get("editUserName"));
|
||
pd.put("editDeptName",pageData.get("editDeptName"));
|
||
pd.put("editLevelName",pageData.get("editLevelName"));
|
||
pd.put("editRectificationDeadline",pageData.get("spare3"));
|
||
}
|
||
}
|
||
map.put("hiddenExa", hiddenExa); // //特殊审批信息
|
||
List<PageData> hiddenFindPeople = hiddenUserService.listAll(pd);// 隐患相关人员信息 --隐患发现人
|
||
map.put("pd", pd);
|
||
map.put("hs", hs);
|
||
map.put("hImgs", hImgs);
|
||
map.put("rImgs", rImgs);
|
||
map.put("hiddenVideo", imgFilesService.getListByKeyAndType(pd.getString("HIDDEN_ID"),"102"));// 隐患视频
|
||
// map.put("cImgs", cImgs);
|
||
map.put("sImgs", sImgs);
|
||
map.put("hiddenFindPeople", hiddenFindPeople); // 隐患相关人员信息
|
||
map.put("checkList", checkList);
|
||
map.put("repulsecause",repulsecause);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 首页统计
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/statistic")
|
||
@ResponseBody
|
||
public Object statistic() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");// 设置日期格式
|
||
Date now = new Date();
|
||
String endDay = sdf.format(now);
|
||
Calendar calendar = Calendar.getInstance();
|
||
calendar.setTime(now);
|
||
calendar.add(Calendar.DATE, -15);
|
||
String startDay = sdf.format(calendar.getTime());
|
||
pd.put("START_DAY", startDay);
|
||
pd.put("END_DAY", endDay);
|
||
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
pd.put("HIDDENLEVEL", "hiddenLevel0001");// 一般隐患
|
||
List<PageData> nhds = hiddenService.hiddenStatisticsByDay(pd);
|
||
System.out.println(nhds.toString());
|
||
pd.put("HIDDENLEVEL", "hiddenLevel0002");// 一般隐患
|
||
List<PageData> zhds = hiddenService.hiddenStatisticsByDay(pd);
|
||
|
||
List<PageData> hdAll = hiddenService.hiddenStatisticsAll(pd);
|
||
map.put("nhds", nhds);
|
||
map.put("zhds", zhds);
|
||
map.put("hdAll", hdAll);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 首页统计
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/getIndexCount")
|
||
@ResponseBody
|
||
public Object getIndexCount() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
List<PageData> varList = hiddenService.getBICount(pd);
|
||
if (varList != null && varList.size() > 0) {
|
||
map.put("total", varList.size());
|
||
int checked = 0;
|
||
int uncheck = 0;
|
||
for (PageData hidden : varList) {
|
||
if (hidden.get("STATE").toString().equals("4")||hidden.get("STATE").toString().equals("2")) {
|
||
checked++;
|
||
} else {
|
||
uncheck++;
|
||
}
|
||
|
||
}
|
||
map.put("checked", checked);
|
||
map.put("uncheck", uncheck);
|
||
} else {
|
||
map.put("total", 0);
|
||
map.put("checked", 0);
|
||
map.put("uncheck", 0);
|
||
}
|
||
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
/**
|
||
* 获取检查记录风险点
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/getChcenkHidden")
|
||
@ResponseBody
|
||
public Object getChcenkHidden() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
List<PageData> hiddenList = hiddenService.getOtherHidden(pd);
|
||
map.put("result", errInfo);
|
||
map.put("hiddenList", hiddenList);
|
||
return map;
|
||
}
|
||
/**
|
||
* 列表 隐患列表接口
|
||
*
|
||
* @param page
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/listGwj")
|
||
@ResponseBody
|
||
public Object listGwj(Page page) throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
if(Tools.isEmpty(pd.get("loginUserId"))){ // 由我确认的隐患
|
||
map.put("varList", new ArrayList<>());
|
||
map.put("page", page);
|
||
map.put("result", "Error");
|
||
map.put("msg", "未找到登录人信息,请联系管理员");
|
||
}
|
||
/*
|
||
1. 让我确认的信息 -- 确认人是我的隐患
|
||
|
||
2. 让我整改的隐患
|
||
|
||
3.让我验收的隐患
|
||
*/
|
||
if("0".equals(pd.getString("stateConfirm"))){ //确认的隐患 stateConfirm:0全部 。1未确认的,2已确认的
|
||
pd.put("CONFIRM_USER",pd.get("loginUserId"));
|
||
}
|
||
if("0".equals(pd.getString("stateRectify"))){ //我整改的隐患
|
||
pd.put("RECTIFICATIONOR",pd.get("loginUserId"));
|
||
pd.put("STATE","1");
|
||
}
|
||
if (!Tools.isEmpty(pd.get("corpinfoId"))){
|
||
pd.put("CORPINFO_ID",pd.getString("corpinfoId"));
|
||
}
|
||
page.setPd(pd);
|
||
List<PageData> varList = hiddenService.listGwj(page); // 列出Hidden列表
|
||
varList = hiddenUserService.getHiddebFind(varList); //添加发现人
|
||
map.put("varList", varList);
|
||
map.put("page", page);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 列表 隐患列表接口
|
||
*
|
||
* @param page
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/listIgnore")
|
||
@ResponseBody
|
||
public Object listIgnore(Page page) throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
if(Tools.isEmpty(pd.get("loginUserId"))){ // 由我确认的隐患
|
||
map.put("varList", new ArrayList<>());
|
||
map.put("page", page);
|
||
map.put("result", "Error");
|
||
map.put("msg", "未找到登录人信息,请联系管理员");
|
||
}
|
||
pd.put("CONFIRM_USER",pd.getString("loginUserId"));
|
||
if (!Tools.isEmpty(pd.get("corpinfoId"))){
|
||
pd.put("CORPINFO_ID",pd.getString("corpinfoId"));
|
||
}
|
||
page.setPd(pd);
|
||
List<PageData> varList = hiddenService.listIgnore(page); // 列出Hidden列表
|
||
varList = hiddenUserService.getHiddebFind(varList); //添加发现人
|
||
map.put("varList", varList);
|
||
map.put("page", page);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* --确认隐患
|
||
*
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/confirm")
|
||
@ResponseBody
|
||
public Object confirmUpdate() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
if("1".equals(pd.get("isEmis"))){
|
||
errInfo = hiddenService.goEmis(pd);
|
||
if("success".equals(errInfo)){
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}else{
|
||
map.put("result", "errInfo");
|
||
map.put("msg", errInfo);
|
||
return map;
|
||
}
|
||
|
||
}
|
||
PageData editHidden = new PageData();
|
||
if("hiddenLevel1001".equals(pd.getString("HIDDENLEVEL"))){ // 如果是忽略隐患
|
||
editHidden.put("STATE","5");
|
||
applicationContext.publishEvent(new DeviceHiddenEvent(new Object(),pd.getString("HIDDEN_ID"),"0"));
|
||
}else if("hiddenLevel2002".equals(pd.getString("HIDDENLEVEL"))){ // 如果是是重大隐患
|
||
editHidden.put("STATE","6");
|
||
}else {
|
||
editHidden.put("STATE","1");
|
||
}
|
||
|
||
editHidden.put("CONFIRM_USER",pd.get("USER_ID")); // 隐患确认人
|
||
editHidden.put("CONFIRM_TIME",DateUtil.date2Str(new Date())); // 隐患确认时间
|
||
editHidden.put("RECTIFICATIONDEPT",pd.get("RECTIFICATIONDEPT")); // 整改部门
|
||
editHidden.put("RECTIFICATIONOR",pd.get("RECTIFICATIONOR")); // 整改人
|
||
editHidden.put("RECTIFICATIONDEADLINE",pd.get("RECTIFICATIONDEADLINE")); // 整改期限
|
||
editHidden.put("HIDDENLEVEL",pd.get("HIDDENLEVEL")); // 隐患级别
|
||
editHidden.put("HIDDEN_ID",pd.get("HIDDEN_ID")); // 隐患id
|
||
PageData hidden = hiddenService.findById(pd);
|
||
if("1".equals(hidden.get("RECTIFICATIONTYPE").toString())){
|
||
editHidden.put("STATE","4");
|
||
}
|
||
PageData exaPd = new PageData(); // 添加隐患确认信息
|
||
exaPd.put("TYPE","4");
|
||
exaPd.put("STATE","2");
|
||
exaPd.put("HIDDEN_ID",hidden.get("HIDDEN_ID"));
|
||
exaPd.put("spare1",pd.getString("HIDDENLEVEL"));
|
||
exaPd.put("spare2",pd.getString("RECTIFICATIONOR"));
|
||
exaPd.put("spare3",pd.getString("RECTIFICATIONDEADLINE"));
|
||
exaPd.put("spare4",pd.getString("RECTIFICATIONDEPT"));
|
||
exaPd.put("CREATOR", pd.getString("loginUserId"));
|
||
exaPd.put("OPERATOR",pd.getString("loginUserId"));
|
||
hiddenExamineService.saveApp(exaPd);
|
||
if("1".equals(hidden.get("RECTIFICATIONTYPE").toString())){ //确认时判断是否是立即整改
|
||
if(pd.getString("isTrue").equals("1")){
|
||
editHidden.put("STATE","4");
|
||
editHidden.put("CHECKOR",hidden.getString("CREATOR"));
|
||
}else {
|
||
editHidden.put("STATE","1");
|
||
editHidden.put("RECTIFICATIONTYPE","2");
|
||
}
|
||
|
||
}
|
||
hiddenService.confirmHidden(editHidden); // 隐患确认
|
||
if(Tools.notEmpty(pd.getString("RECTIFICATIONOR")) && !hidden.getString("RECTIFICATIONTYPE").equals("1")){
|
||
messageService.sendMessageByParameter("HIDDEN_MAIL_002","友情提示:有一条隐患需要整改",
|
||
hidden.getString("CORPINFO_ID"),pd.getString("USER_ID"),hidden.getString("HIDDEN_ID"),
|
||
hidden.getString("HIDDENDESCR"),"隐患整改","整改","","");
|
||
}else if("1".equals(hidden.getString("RECTIFICATIONTYPE"))){
|
||
messageService.sendMessageByParameter("HIDDEN_MAIL_003","友情提示:有一条隐患已验收",
|
||
hidden.getString("CORPINFO_ID"),pd.getString("USER_ID"),hidden.getString("HIDDEN_ID"),
|
||
hidden.getString("HIDDENDESCR"),"通过","整改","","");
|
||
}
|
||
List<PageData> repulsecause = hiddenExamineService.findByHiddenId(pd);//确认人打回信息
|
||
if(repulsecause.size()>0){
|
||
for(PageData IDS:repulsecause){
|
||
PageData repulse = new PageData();
|
||
repulse.put("HIDDENEXAMINE_ID",IDS.getString("HIDDENEXAMINE_ID"));
|
||
hiddenExamineService.editrepulse(repulse); //有打回记录的隐患信息,把spare5改成1。确认通过后就不显示出来
|
||
}
|
||
}
|
||
|
||
map.put("pd", pd);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
|
||
/**
|
||
* 获取隐患部位列表(菜单管理)
|
||
* @return
|
||
*/
|
||
@RequestMapping(value="/getTreehiddenRegionListAll")
|
||
@ResponseBody
|
||
public Object getTreehiddenRegionListAll()throws Exception{
|
||
Map<String,String> map = new HashMap<String,String>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
JSONArray arr = JSONArray.fromObject(hiddenRegionService.listAll("0" , pd.getString("CORPINFO_ID")));
|
||
String json = arr.toString();
|
||
json = json.replaceAll("HIDDENREGION_ID", "id")
|
||
.replaceAll("PARENT_ID", "pId")
|
||
.replaceAll("HIDDENREGION", "name")
|
||
.replaceAll("subhiddenRegion", "children")
|
||
.replaceAll("hashiddenRegion", "checked")
|
||
.replaceAll("HIDDENREGION_URL", "url");
|
||
map.put("zTreeNodes", json);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 列表
|
||
*
|
||
* @param page
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/listForSafetyEnvironmental")
|
||
@ResponseBody
|
||
public Object listForSafetyEnvironmental(Page page) throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
|
||
page.setPd(pd);
|
||
|
||
List<PageData> varList = hiddenService.listForSafetyEnvironmental(page); // 列出Hidden列表
|
||
varList = hiddenUserService.getHiddebFind(varList);
|
||
//对于超期数据状态的
|
||
varList.stream()
|
||
.filter(n -> "1".equals(n.getString("STATE")))
|
||
.forEach(n -> {
|
||
String limit_date = n.getString("RECTIFICATIONDEADLINE");
|
||
if (StringUtils.isNotBlank(limit_date)) {
|
||
if ("1".equals(n.getString("RECTIFICATIONTYPE"))) {
|
||
if (DateUtil.fomatDate(limit_date).getTime() < new Date().getTime())
|
||
n.put("OVERTIME_FLAG", "1");
|
||
} else {
|
||
if (DateUtil.fomatDate(limit_date).getTime() < new Date().getTime())
|
||
n.put("OVERTIME_FLAG", "2");
|
||
}
|
||
}
|
||
});
|
||
map.put("varList", varList);
|
||
map.put("page", page);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
/**
|
||
* 安全环保检查隐患指派
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/assign")
|
||
@ResponseBody
|
||
public Object assign() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
// PageData hidden = hiddenService.findById(pd);
|
||
pd.put("STATE", pd.getString("HIDDEN_STATUS"));
|
||
List<PageData> list = hiddenService.listOtherNotAssign(pd);
|
||
PageData inspection = new PageData();
|
||
inspection.put("INSPECTION_ID", pd.getString("INSPECTION_ID"));
|
||
inspection.put("OPERATOR", pd.getString("OPERATOR"));
|
||
inspection.put("OPERATTIME", DateUtil.date2Str(new Date()));
|
||
if ("-2".equals(pd.getString("HIDDEN_STATUS"))) {
|
||
pd.put("ISCONFIRM", "0"); //
|
||
pd.put("CONFIRM_TIME",DateUtil.date2Str(new Date()));
|
||
if (list.size() == 0) {
|
||
inspection.put("INSPECTION_STATUS", "5"); // 指派完成
|
||
} else {
|
||
inspection.put("INSPECTION_STATUS", "4"); // 指派中
|
||
}
|
||
safetyenvironmentalService.editStatus(inspection);
|
||
}
|
||
hiddenService.assign(pd);
|
||
if(Tools.notEmpty(pd.getString("CONFIRM_USER"))){
|
||
messageService.sendMessageByParameter("HIDDEN_MAIL_001","友情提示:有一条隐患需要确定",pd.getString("CORPINFO_ID"),
|
||
pd.getString("CONFIRM_USER"),"",
|
||
pd.getString("HIDDENDESCR"),"隐患确认","确认","","");
|
||
}
|
||
map.put("result", errInfo);
|
||
map.put("pd", pd);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 安全环保检查验收
|
||
*
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/finalcheck")
|
||
@ResponseBody
|
||
public Object finalcheck() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
hiddenService.finalcheck(pd);
|
||
if ("1".equals(pd.get("FINAL_CHECK").toString())) {
|
||
if (Tools.notEmpty(pd.getString("INSPECTION_ID"))) { //安全环保检查验收
|
||
pd.put("ACCEPTSTEP", 7);
|
||
List<PageData> list = hiddenService.listOtherNotAccept4pc(pd);
|
||
if (list.size() == 0) {
|
||
PageData inspection = new PageData();
|
||
inspection.put("INSPECTION_ID", pd.getString("INSPECTION_ID"));
|
||
inspection.put("OPERATOR", pd.getString("FINAL_CHECKOR"));
|
||
inspection.put("OPERATTIME", DateUtil.date2Str(new Date()));
|
||
inspection.put("INSPECTION_STATUS", "8"); // 已验收
|
||
safetyenvironmentalService.editStatus(inspection);
|
||
}
|
||
}
|
||
} else {
|
||
PageData pd2 = new PageData();
|
||
pd2.put("FOREIGN_KEY", pd.get("HIDDEN_ID"));
|
||
pd2.put("TYPE", "4");
|
||
List<PageData> zgImgs = imgFilesService.listAll(pd2);
|
||
for (PageData pageData : zgImgs) {
|
||
|
||
imgFilesService.delete(pageData);
|
||
if(Tools.notEmpty(pageData.getString("FILEPATH"))) {
|
||
Smb.deleteFile(pageData.getString("FILEPATH"));
|
||
}
|
||
}
|
||
PageData hidden = new PageData();
|
||
hidden.put("HIDDEN_ID", pd.get("HIDDEN_ID"));
|
||
hidden.put("STATE", "101"); //修改隐患表状态为验收打回
|
||
hiddenService.changeState(hidden);
|
||
|
||
PageData inspection = new PageData();
|
||
inspection.put("INSPECTION_ID", pd.getString("INSPECTION_ID"));
|
||
inspection.put("OPERATOR", pd.getString("FINAL_CHECKOR"));
|
||
inspection.put("OPERATTIME", DateUtil.date2Str(new Date()));
|
||
inspection.put("INSPECTION_STATUS", "3"); // 安全环保检查打回到归档,隐患待指派
|
||
safetyenvironmentalService.editStatus(inspection);
|
||
|
||
inspection.put("SENDER_ID",pd.getString("FINAL_CHECKOR"));
|
||
inspection.put("SENDER_NAME",pd.getString("FINAL_CHECKOR"));
|
||
noticeUtil.SE_Repulse(inspection);
|
||
// hiddenExamineService.deleteByHiddenId(pd); //如果验收打回删除隐患相关信息
|
||
// hidden.put("HIDDENEXAMINE_ID",this.get32UUID());
|
||
// hidden.put("EXAMINE",pd.get("CONTENT"));//打回意见
|
||
// hidden.put("CREATOR",pd.getString("FINAL_CHECKOR"));
|
||
// hidden.put("CREATTIME",DateUtil.date2Str(new Date()));
|
||
// hidden.put("OPERATOR",pd.getString("FINAL_CHECKOR"));
|
||
// hidden.put("OPERATTIME",DateUtil.date2Str(new Date()));
|
||
// hidden.put("TYPE",3);//验收打回
|
||
// hidden.put("STATE",-1);//验收打回变成初始状态-1
|
||
// hiddenExamineService.saveApp(hidden);
|
||
}
|
||
map.put("check", pd);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 隐患确认打回
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/repulseHidden")
|
||
//@RequiresPermissions("hidden:edit")
|
||
@ResponseBody
|
||
public Object repulseHidden() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
hiddenService.editstate(pd);
|
||
pd.put("HIDDENEXAMINE_ID", UuidUtil.get32UUID());
|
||
pd.put("CREATTIME", DateUtil.date2Str(new Date()));
|
||
pd.put("OPERATTIME",DateUtil.date2Str(new Date()));
|
||
hiddenExamineService.saverepulse(pd);
|
||
hiddenMailService.reject(pd);
|
||
map.put("result",errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 列表
|
||
*
|
||
* @param page
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/listV2")
|
||
@ResponseBody
|
||
public Object listV2() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
Page page = new Page();
|
||
pd = this.getPageData();
|
||
page.setCurrentPage(Integer.parseInt(pd.get("currentPage").toString()));
|
||
page.setShowCount(Integer.parseInt(pd.get("showCount").toString()));
|
||
page.setTotalResult(Integer.parseInt(pd.get("totalResult").toString()));
|
||
|
||
|
||
pd.put("CORPINFO_ID",pd.getString("CORPINFO_ID"));
|
||
pd.put("queryUserId",pd.getString("SELFUSERID"));
|
||
page.setPd(pd);
|
||
List<PageData> varList = hiddenService.getListForTianzhang(page); // 列出Hidden列表
|
||
varList = hiddenUserService.getHiddebFind(varList);
|
||
map.put("varList", varList);
|
||
map.put("page", page);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 判断登录人是否已经验收
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value = "/isChek")
|
||
//@RequiresPermissions("hidden:edit")
|
||
@ResponseBody
|
||
public Object isChek() throws Exception {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
List<PageData> checkList = hiddenCheckService.findByHidden(pd);
|
||
if(checkList.size()>0){
|
||
for(PageData arr:checkList){
|
||
if(arr.getString("STATUS").equals("1")){
|
||
map.put("istrue","1");
|
||
} else if (arr.getString("STATUS").equals("0")){
|
||
map.put("istrue","0");
|
||
}
|
||
}
|
||
}
|
||
map.put("result",errInfo);
|
||
return map;
|
||
}
|
||
}
|