2880 lines
129 KiB
Plaintext
2880 lines
129 KiB
Plaintext
package com.nationalelectric.greenH5;
|
||
|
||
import java.io.IOException;
|
||
import java.math.BigDecimal;
|
||
import java.text.ParseException;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.ArrayList;
|
||
import java.util.Arrays;
|
||
import java.util.Calendar;
|
||
import java.util.Date;
|
||
import java.util.HashMap;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
import java.util.UUID;
|
||
|
||
import javax.annotation.Resource;
|
||
import javax.servlet.http.HttpServletRequest;
|
||
|
||
import org.apache.commons.lang.StringUtils;
|
||
import org.codehaus.jackson.map.ObjectMapper;
|
||
import org.codehaus.jackson.type.TypeReference;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||
import org.springframework.stereotype.Controller;
|
||
import org.springframework.transaction.annotation.Transactional;
|
||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||
import org.springframework.web.bind.annotation.RequestBody;
|
||
import org.springframework.web.bind.annotation.RequestMapping;
|
||
import org.springframework.web.bind.annotation.RequestMethod;
|
||
import org.springframework.web.bind.annotation.ResponseBody;
|
||
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.jysoft.weChat.service.WechatService;
|
||
import com.jysoft.weChat.vo.ContentVo;
|
||
import com.nationalelectirc.Constant.ApplyRoleConstant;
|
||
import com.nationalelectirc.Constant.Constant;
|
||
import com.nationalelectirc.utils.PushMessageUtil;
|
||
import com.nationalelectirc.utils.RestResult;
|
||
import com.nationalelectric.greenH5.bizc.BaseServiceImpl;
|
||
import com.nationalelectric.greenH5.bizc.IGreenApplyListBizc;
|
||
import com.nationalelectric.greenH5.bizc.IGreenHaircutInfoBizc;
|
||
import com.nationalelectric.greenH5.bizc.IGreenHaircutRemainBizc;
|
||
import com.nationalelectric.greenH5.bizc.IGreenOperateLogBizc;
|
||
import com.nationalelectric.greenH5.bizc.IGreenRetinueInfoBizc;
|
||
import com.nationalelectric.greenH5.bizc.IGreenUserInfoBizc;
|
||
import com.nationalelectric.greenH5.bizc.IGreenVisitorInfoBizc;
|
||
import com.nationalelectric.greenH5.identityAuth.service.IdentityAuthService;
|
||
import com.nationalelectric.greenH5.identityAuth.util.PhotoUtil;
|
||
import com.nationalelectric.greenH5.po.GreenApplyList;
|
||
import com.nationalelectric.greenH5.po.GreenGrantAuth;
|
||
import com.nationalelectric.greenH5.po.GreenHaircutInfo;
|
||
import com.nationalelectric.greenH5.po.GreenHaircutRemain;
|
||
import com.nationalelectric.greenH5.po.GreenMealTicketNum;
|
||
import com.nationalelectric.greenH5.po.GreenRetinueInfo;
|
||
import com.nationalelectric.greenH5.po.GreenUserInfo;
|
||
import com.nationalelectric.greenH5.po.GreenVisitorInfo;
|
||
import com.nationalelectric.greenH5.po.GreenVisitorRetinueInfo;
|
||
import com.nationalelectric.greenH5.po.Result;
|
||
import com.nationalelectric.greenH5.utils.AesEncryptUtil;
|
||
import com.nationalelectric.greenH5.utils.Base64Utils;
|
||
import com.nationalelectric.greenH5.utils.DateTime;
|
||
import com.nationalelectric.greenH5.utils.DateUtil;
|
||
import com.nationalelectric.greenH5.utils.JSONUtil;
|
||
import com.sgcc.uap.persistence.IHibernateDao;
|
||
import com.sgcc.uap.service.validator.ServiceValidatorBaseException;
|
||
import com.sgcc.uap.service.validator.ServiceValidatorUtil;
|
||
|
||
import net.sf.json.JSONObject;
|
||
import okhttp3.Call;
|
||
import okhttp3.FormBody;
|
||
import okhttp3.OkHttpClient;
|
||
import okhttp3.Request;
|
||
import okhttp3.Response;
|
||
|
||
/**
|
||
* <b>概述</b>:<br>
|
||
* <p>
|
||
* <b>功能</b>:<br>
|
||
*
|
||
* @author chenweikang
|
||
*/
|
||
@Controller
|
||
@RequestMapping("/greenVisitorInfo")
|
||
public class GreenVisitorInfoController extends GreenBaseController {
|
||
|
||
@Autowired
|
||
private IdentityAuthService identityAuthService;
|
||
|
||
@Autowired
|
||
private BaseServiceImpl BaseService;
|
||
/**
|
||
* 访客预约service
|
||
*/
|
||
@Resource
|
||
private WechatService wService;
|
||
@Resource
|
||
private IGreenVisitorInfoBizc greenvisitorinfoBizc;
|
||
/**
|
||
* 我的申请service
|
||
*/
|
||
@Resource
|
||
private IGreenApplyListBizc greenApplyListBizc;
|
||
/**
|
||
* 员工卡controller
|
||
*/
|
||
@Resource
|
||
private GreenStaffCardInfoController greenStaffCardInfoController;
|
||
/**
|
||
* 临时停车controller
|
||
*/
|
||
@Resource
|
||
private GreenTempParkInfoController greenTempParkInfoController;
|
||
/**
|
||
* 故障报修controller
|
||
*/
|
||
@Resource
|
||
private GreenFaultRepairInfoController greenFaultRepairInfoController;
|
||
/**
|
||
* 理发预约controller
|
||
*/
|
||
@Resource
|
||
private GreenHaircutInfoController greenHaircutInfoController;
|
||
/**
|
||
* 随行人员service
|
||
*/
|
||
@Resource
|
||
private IGreenRetinueInfoBizc greenretinueinfoBizc;
|
||
/**
|
||
* 餐券申请controller
|
||
*/
|
||
@Resource
|
||
private GreenMealTicketApplyController greenMealTicketApplyController;
|
||
/**
|
||
* 用户controller
|
||
*/
|
||
@Resource
|
||
private GreenUserInfoController greenUserInfoController;
|
||
/**
|
||
* 施工申请controller
|
||
*/
|
||
@Resource
|
||
private GreenConstructInfoController greenConstructInfoController;
|
||
/**
|
||
* 用户service
|
||
*/
|
||
@Resource
|
||
private IGreenUserInfoBizc greenuserinfoBizc;
|
||
/**
|
||
* 理发预约service
|
||
*/
|
||
@Resource
|
||
private IGreenHaircutInfoBizc greenhaircutinfoBizc;
|
||
/**
|
||
* 理发师余额service
|
||
*/
|
||
@Resource
|
||
private IGreenHaircutRemainBizc greenhaircutremainBizc;
|
||
/**
|
||
* 保存图片controller
|
||
*/
|
||
@Resource
|
||
private GreenImageInfoController greenImageInfoController;
|
||
/**
|
||
* 字典表controller
|
||
*/
|
||
@Resource
|
||
private GreenDictionaryInfoController greenDictionaryInfoController;
|
||
@Resource
|
||
private IGreenOperateLogBizc greenOperateLogBizc;
|
||
/**
|
||
* HibernateDao逻辑构件
|
||
*/
|
||
@Autowired
|
||
IHibernateDao hibernateDao;
|
||
|
||
@Autowired
|
||
private BaseServiceImpl baseService;
|
||
/**
|
||
* 不可取消申请的状态集合
|
||
*/
|
||
private static final String[] IS_CANCEL_ARR = { "1", "2", "3", "9", "11" };
|
||
|
||
/**
|
||
* 保存访客预约
|
||
*
|
||
* @param greenVisitorInfo
|
||
* @param request
|
||
* @return
|
||
*/
|
||
@SuppressWarnings("unchecked")
|
||
@Transactional(rollbackFor = Exception.class)
|
||
@RequestMapping(value = "/saveVistorInfo", method = RequestMethod.POST)
|
||
public @ResponseBody RestResult saveVistorInfo(@RequestBody Object requestBody, HttpServletRequest request) {
|
||
GreenVisitorRetinueInfo greenVisitorRetinueInfo = new ObjectMapper().convertValue(requestBody,
|
||
new TypeReference<GreenVisitorRetinueInfo>() {
|
||
});
|
||
try {
|
||
|
||
/*
|
||
* 根据判断被访人姓名和手机号码是否与国网组织架构信息匹配
|
||
*/
|
||
String UserInfoByIdSql = "SELECT dp.name departmentName,ui.* from GREEN_USER_INFO ui LEFT JOIN green_department dp ON "
|
||
+ " ui.department_id = dp.id and dp.is_deleted = 'N' WHERE ui.is_deleted = 'N' AND ui.mobile = ? and ui.is_inner=1 and ui.user_status=2 ";
|
||
//+ " ui.department_id = dp.id and dp.is_deleted = 'N' WHERE ui.is_deleted = 'N' and ui.real_name = ? AND ui.mobile = ? and dp.name = ? AND ui.ORG_name ='省公司' ";
|
||
// 被访问人姓名
|
||
String visitedPersonName = greenVisitorRetinueInfo.getVisitedPersonName();
|
||
// 被访问人电话
|
||
String visitedPersonTel = greenVisitorRetinueInfo.getVisitedPersonTel();
|
||
// 被访问人电话
|
||
String visitedDeptName = greenVisitorRetinueInfo.getVisitedDeptName();
|
||
|
||
// // 执行sql
|
||
List<Map<String, Object>> userInfolist = hibernateDao.queryForListWithSql(UserInfoByIdSql, new Object[] { visitedPersonTel});
|
||
// // 判断被访问人信息是否正确
|
||
if (userInfolist.size() <= 0) {
|
||
return new RestResult(Constant.FAILED, "被访人手机号错误或尚未注册,请核实后再预约!");
|
||
}else{
|
||
String real_name = (String) userInfolist.get(0).get("real_name");
|
||
String departmentName = (String) userInfolist.get(0).get("departmentName");
|
||
String str = "被访人";
|
||
if(!visitedPersonName.equals(real_name)){
|
||
str+="姓名";
|
||
if(!visitedDeptName.equals(departmentName)){
|
||
str+="、部门信息有误或手机号错误,请核实后再预约!";
|
||
}else{
|
||
str+="信息有误或手机号有误,请核实后再预约!";
|
||
}
|
||
return new RestResult(Constant.FAILED, str);
|
||
}else{
|
||
if(!visitedDeptName.equals(departmentName)){
|
||
str+="部门信息有误或手机号有误,请核实后再预约!";
|
||
return new RestResult(Constant.FAILED, str);
|
||
}
|
||
}
|
||
|
||
}
|
||
String userId = greenVisitorRetinueInfo.getUserId();
|
||
GreenUserInfo info = getUserInfo(userId);
|
||
GreenGrantAuth gaInfo = getGaInfo(userId);
|
||
if (info == null && gaInfo == null) {
|
||
return new RestResult(Constant.FAILED, "非法用户");
|
||
}
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||
SimpleDateFormat Hsdf = new SimpleDateFormat("HH");
|
||
|
||
|
||
String startH = Hsdf.format(DateTime.strToDate(greenVisitorRetinueInfo.getVisitStartTime(), "yyyy-MM-dd HH:mm"));
|
||
String statTime = sdf.format(DateTime.strToDate(greenVisitorRetinueInfo.getVisitStartTime(), "yyyy-MM-dd HH:mm"));
|
||
String endH = Hsdf.format(DateTime.strToDate(greenVisitorRetinueInfo.getVisitEndTime(), "yyyy-MM-dd HH:mm"));
|
||
List<Map<String, Object>> visitStartHourmap = greenDictionaryInfoController.getDictionaryInfo("visitStartHour");
|
||
int visitStartHour = Integer.valueOf(visitStartHourmap.get(0).get("data_value")+"");
|
||
|
||
List<Map<String, Object>> visitEndHourmap = greenDictionaryInfoController.getDictionaryInfo("visitEndHour");
|
||
int visitEndHour = Integer.valueOf(visitEndHourmap.get(0).get("data_value")+"");
|
||
|
||
// if(visitStartHour > Integer.valueOf(startH)){
|
||
// //访客预约开始时间选取超时提示
|
||
// List<Map<String, Object>> visiterPointStart = greenDictionaryInfoController.getDictionaryInfo("visiterPoint_start");
|
||
// String visitPointStart = visiterPointStart.get(0).get("data_value").toString();
|
||
// return new RestResult(Constant.FAILED, visitPointStart);
|
||
// }
|
||
// if(visitEndHour <= Integer.valueOf(endH)){//结束时间需在18点前
|
||
// //访客预约结束时间选取超时提示
|
||
// List<Map<String, Object>> visiterPointEnd = greenDictionaryInfoController.getDictionaryInfo("visiterPoint_end");
|
||
// String visitPointEnd = visiterPointEnd.get(0).get("data_value").toString();
|
||
// return new RestResult(Constant.FAILED, visitPointEnd);
|
||
// }
|
||
String nowDate = sdf.format(new Date());
|
||
// 判断开始时间是否小于当前时间
|
||
if ((greenVisitorRetinueInfo.getVisitStartTime()).compareTo(nowDate) < 0) {
|
||
return new RestResult(Constant.FAILED, "开始时间不能小于当前时间,请重新输入!");
|
||
}
|
||
// 判断结束时间是否小于当前时间
|
||
if ((greenVisitorRetinueInfo.getVisitEndTime()).compareTo(nowDate) < 0) {
|
||
return new RestResult(Constant.FAILED, "结束时间不能小于当前时间,请重新输入!");
|
||
}
|
||
|
||
|
||
// 判断来访开始时间是否大于结束时间
|
||
if ((greenVisitorRetinueInfo.getVisitEndTime()).compareTo(greenVisitorRetinueInfo.getVisitStartTime()) < 0) {
|
||
return new RestResult(Constant.FAILED, "来访开始时间不能大于结束时间,请重新输入!");
|
||
}
|
||
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
|
||
Date startd = sdf2.parse(greenVisitorRetinueInfo.getVisitStartTime());
|
||
Date endd = sdf2.parse(greenVisitorRetinueInfo.getVisitEndTime());
|
||
if(!sdf2.format(startd).equals(sdf2.format(endd))){
|
||
List<Map<String, Object>> visitCrossDay = greenDictionaryInfoController.getDictionaryInfo("visitCrossDay");
|
||
String visitcrossday = visitCrossDay.get(0).get("data_value").toString();
|
||
return new RestResult(Constant.FAILED, visitcrossday);
|
||
}
|
||
|
||
|
||
if(info.getRealName() != null && info.getMobile() != null && info.getRealName().equals(visitedPersonName) && info.getMobile().equals(visitedPersonTel)){
|
||
return new RestResult(Constant.FAILED, "被访者不可为本人!");
|
||
}
|
||
// 获取保存信息
|
||
GreenVisitorInfo vistor = new GreenVisitorInfo();
|
||
vistor.setOrgName(greenVisitorRetinueInfo.getOrgName());
|
||
// 用户id
|
||
vistor.setUserId(greenVisitorRetinueInfo.getUserId());
|
||
// 被访人id
|
||
vistor.setVisitedPersonId(userInfolist.get(0).get("id").toString());
|
||
// 被访人姓名
|
||
vistor.setVisitedPersonName(greenVisitorRetinueInfo.getVisitedPersonName());
|
||
// 被访人手机号码
|
||
vistor.setVisitedPersonTel(greenVisitorRetinueInfo.getVisitedPersonTel());
|
||
// 身份证号,要加密处理
|
||
String cardno = greenVisitorRetinueInfo.getIdcard();
|
||
try {
|
||
cardno = AesEncryptUtil.encrypt(cardno);
|
||
} catch (Exception e) {
|
||
}
|
||
vistor.setIdcard(cardno);
|
||
|
||
// 来访开始时间
|
||
vistor.setVisitStartTime(greenVisitorRetinueInfo.getVisitStartTime());
|
||
// 来访结束时间
|
||
vistor.setVisitEndTime(greenVisitorRetinueInfo.getVisitEndTime());
|
||
// 来访事由
|
||
if ("\"null\"".equals(greenVisitorRetinueInfo.getVisitReason())) {
|
||
greenVisitorRetinueInfo.setVisitReason("null");
|
||
}
|
||
vistor.setVisitReason(greenVisitorRetinueInfo.getVisitReason());
|
||
// 访客姓名
|
||
if ("\"null\"".equals(greenVisitorRetinueInfo.getVisitorName())) {
|
||
greenVisitorRetinueInfo.setVisitorName("null");
|
||
}
|
||
vistor.setVisitorName(greenVisitorRetinueInfo.getVisitorName());
|
||
// 访客手机号码
|
||
vistor.setVisitorTel(greenVisitorRetinueInfo.getVisitorTel());
|
||
|
||
vistor.setVisitPlace(greenVisitorRetinueInfo.getStayArea());
|
||
|
||
// 身份证照片1
|
||
String picture1 = greenVisitorRetinueInfo.getIdcardPic1() == null ? "" : greenVisitorRetinueInfo.getIdcardPic1();
|
||
String picture2 = greenVisitorRetinueInfo.getIdcardPic2() == null ? "" : greenVisitorRetinueInfo.getIdcardPic2();
|
||
boolean flag = true;
|
||
String picture = "";
|
||
String pictureData = "";
|
||
if(!"".equals(picture1)){
|
||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd");
|
||
String date = sdf1.format(new Date()) + "/";
|
||
String uuid = date + UUID.randomUUID().toString().replaceAll("-","");
|
||
// String uuid = greenImageInfoController.saveImage(picture1, userId);
|
||
flag = baseService.saveImgToIO(uuid+Constant.IMG_SUFFIX, picture1);
|
||
picture = uuid+Constant.IMG_SUFFIX;
|
||
pictureData = uuid;
|
||
vistor.setIdcardPic1(picture);
|
||
vistor.setIdcardPic1Data(pictureData);
|
||
}
|
||
// 身份证照片2
|
||
if(!"".equals(picture2)){
|
||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd");
|
||
String date = sdf1.format(new Date()) + "/";
|
||
String uuid = date + UUID.randomUUID().toString().replaceAll("-","");
|
||
// String uuid = greenImageInfoController.saveImage(picture2, userId);
|
||
flag = baseService.saveImgToIO(uuid+Constant.IMG_SUFFIX, picture2);
|
||
picture = uuid+Constant.IMG_SUFFIX;
|
||
pictureData = uuid;
|
||
vistor.setIdcardPic2(picture);
|
||
vistor.setIdcardPic2Data(pictureData);
|
||
}
|
||
// 面部照片1
|
||
String facepic1 = greenVisitorRetinueInfo.getFacePic1() == null ? "" : greenVisitorRetinueInfo.getFacePic1();
|
||
String facepic2 = greenVisitorRetinueInfo.getFacePic2() == null ? "" : greenVisitorRetinueInfo.getFacePic2();
|
||
String facepic1Url = "";
|
||
boolean flagFace = true;
|
||
if(!"".equals(facepic1)){
|
||
if(facepic1.indexOf("http")!=-1){
|
||
picture = info.getFacePic1();
|
||
pictureData = info.getFacePic1Data();
|
||
facepic1Url += baseService.getAppImgDir()+picture;//"D:/ystp/"+picture;//
|
||
vistor.setFacePic1(picture);
|
||
vistor.setFacePic1Data(pictureData);
|
||
}else{
|
||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd");
|
||
String date = sdf1.format(new Date()) + "/";
|
||
String uuid = date + UUID.randomUUID().toString().replaceAll("-","");
|
||
// String uuid = greenImageInfoController.saveImage(picture1, userId);
|
||
flagFace = baseService.saveImgToIO(uuid+Constant.IMG_SUFFIX, facepic1);
|
||
picture = uuid+Constant.IMG_SUFFIX;
|
||
facepic1Url += baseService.getAppImgDir()+picture;//"D:/ystp/"+picture;//
|
||
System.out.println("facepic1Url------------------->"+facepic1Url);
|
||
pictureData = uuid;
|
||
vistor.setFacePic1(picture);
|
||
vistor.setFacePic1Data(pictureData);
|
||
}
|
||
}
|
||
// 面部照片2
|
||
if(!"".equals(facepic2)){
|
||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd");
|
||
String date = sdf1.format(new Date()) + "/";
|
||
String uuid = date + UUID.randomUUID().toString().replaceAll("-","");
|
||
// String uuid = greenImageInfoController.saveImage(picture2, userId);
|
||
flagFace = baseService.saveImgToIO(uuid+Constant.IMG_SUFFIX, facepic2);
|
||
picture = uuid+Constant.IMG_SUFFIX;
|
||
pictureData = uuid;
|
||
vistor.setFacePic2(picture);
|
||
vistor.setFacePic2Data(pictureData);
|
||
}
|
||
|
||
//清除图片地址信息
|
||
baseService.initImage();
|
||
|
||
//判断被访人是否是本人
|
||
if(userInfolist.get(0).get("id").equals(greenVisitorRetinueInfo.getUserId())){
|
||
vistor.setPushState(1);
|
||
}else{
|
||
vistor.setPushState(0);
|
||
}
|
||
vistor.setUuid(UUID.randomUUID().toString());
|
||
// 创建者
|
||
vistor.setCreator(greenVisitorRetinueInfo.getUserId().toString());
|
||
// 修改者
|
||
vistor.setModifier(greenVisitorRetinueInfo.getUserId().toString());
|
||
// 创建时间
|
||
vistor.setGmtCreated(new Date());
|
||
// 修改时间
|
||
vistor.setGmtModified(new Date());
|
||
// 删除标记
|
||
vistor.setIsDeleted("N");
|
||
vistor.setVisitPlace(greenVisitorRetinueInfo.getVisitPlace());
|
||
vistor.setImgStatus(1);
|
||
String isCar = greenVisitorRetinueInfo.getIsCar();
|
||
vistor.setIsCar(isCar);
|
||
if("1".equals(isCar)){
|
||
vistor.setLicensePlate(greenVisitorRetinueInfo.getLicensePlate());
|
||
}
|
||
// 添加访客信息到访客信息表
|
||
greenvisitorinfoBizc.add(vistor);
|
||
|
||
// 保存访客随行人员信息
|
||
for (GreenRetinueInfo greenRetinueInfo : greenVisitorRetinueInfo.getGreenRetinueInfoList()) {
|
||
// 访客id
|
||
greenRetinueInfo.setVisitorId(vistor.getId());
|
||
greenRetinueInfo.setRetinueName(greenRetinueInfo.getRetinueName());
|
||
greenRetinueInfo.setVisitorTel(greenRetinueInfo.getVisitorTel());
|
||
|
||
// 身份证号,要加密处理
|
||
String idcard = greenRetinueInfo.getIdcard();
|
||
try {
|
||
idcard = AesEncryptUtil.encrypt(idcard);
|
||
} catch (Exception e) {
|
||
}
|
||
greenRetinueInfo.setIdcard(idcard);
|
||
// 创建者
|
||
greenRetinueInfo.setCreator(greenVisitorRetinueInfo.getUserId().toString());
|
||
// 修改者
|
||
greenRetinueInfo.setModifier(greenVisitorRetinueInfo.getUserId().toString());
|
||
// 创建时间
|
||
greenRetinueInfo.setGmtCreated(new Date());
|
||
// 修改时间
|
||
greenRetinueInfo.setGmtModified(new Date());
|
||
// 删除标记
|
||
greenRetinueInfo.setIsDeleted("N");
|
||
String uuid = UUID.randomUUID().toString();
|
||
greenRetinueInfo.setUuid(uuid);
|
||
|
||
if(userInfolist.get(0).get("id").equals(greenVisitorRetinueInfo.getUserId())){
|
||
greenRetinueInfo.setPushState(1);
|
||
}else{
|
||
greenRetinueInfo.setPushState(0);
|
||
}
|
||
|
||
greenretinueinfoBizc.add(greenRetinueInfo);
|
||
|
||
}
|
||
|
||
// --------处理图片保存数据--------------------
|
||
// 由于不在一个事务里,查不到,不能用以下方法了
|
||
// BaseService.saveVisitorImg(vistor.getId());
|
||
// -----------------------------
|
||
|
||
// 添加访客信息到申请信息list表
|
||
GreenApplyList list = new GreenApplyList();
|
||
// 申请人id
|
||
list.setUserId(greenVisitorRetinueInfo.getUserId());
|
||
// 申请事项详情ID
|
||
list.setDetailId(vistor.getId());
|
||
// 申请类型
|
||
list.setApplyType("02");
|
||
// 申请类型名称
|
||
list.setApplyTypeName("访客预约");
|
||
// 申请详情1(被访问人)
|
||
list.setApplyInfo1(vistor.getVisitedPersonName());
|
||
// 申请详情2(申请时间)
|
||
list.setApplyInfo2(DateTime.dateToStr(DateTime.strToDateLong4(greenVisitorRetinueInfo.getVisitStartTime()),
|
||
"MM-dd HH:mm") + "~" +
|
||
DateTime.dateToStr( DateTime.strToDateLong4(greenVisitorRetinueInfo.getVisitEndTime()),"MM-dd HH:mm"));
|
||
|
||
list.setAppointmentType(greenVisitorRetinueInfo.getAppointmentType());
|
||
|
||
int isOneself = 0;
|
||
// 一级审批状态
|
||
List<Map<String, String>> iAuthList = BaseService.getDictionaryInfo("identityAuth", "identityAuth");
|
||
String dataValue = iAuthList.get(0).get("data_value");
|
||
// if ("1".equals(dataValue)) { // 开启身份验证
|
||
// list.setFirstStatus("5"); // 访客身份 比对中
|
||
// } else {
|
||
// //判断被访人是否是本人
|
||
// if(userInfolist.get(0).get("id").equals(greenVisitorRetinueInfo.getUserId())){
|
||
// list.setFirstStatus("3");
|
||
// }else{
|
||
// list.setFirstStatus("0");
|
||
// }
|
||
// }
|
||
//添加一级审批人id,被访人id
|
||
String approval = (String)userInfolist.get(0).get("id");
|
||
|
||
|
||
if(userInfolist.get(0).get("id").equals(greenVisitorRetinueInfo.getUserId())){
|
||
if(userInfolist.get(0).get("userLevel").equals("0")){
|
||
list.setFirstStatus("3");
|
||
list.setCurrentStatus("13");
|
||
list.setFirstApproval(approval);
|
||
}else if(userInfolist.get(0).get("userLevel").equals("1")){
|
||
list.setSecondStatus("3");
|
||
list.setCurrentStatus("23");
|
||
list.setSecondApproval(approval);
|
||
}else if(userInfolist.get(0).get("userLevel").equals("2")){
|
||
list.setThirdStatus("3");
|
||
list.setCurrentStatus("33");
|
||
list.setThirdApproval(approval);
|
||
}
|
||
}else{
|
||
if(userInfolist.get(0).get("userLevel").equals("0")){
|
||
list.setFirstStatus("0");
|
||
list.setCurrentStatus("10");
|
||
list.setFirstApproval(approval);
|
||
}else if(userInfolist.get(0).get("userLevel").equals("1")){
|
||
list.setSecondStatus("0");
|
||
list.setCurrentStatus("20");
|
||
list.setSecondApproval(approval);
|
||
}else if(userInfolist.get(0).get("userLevel").equals("2")){
|
||
list.setThirdStatus("0");
|
||
list.setCurrentStatus("30");
|
||
list.setThirdApproval(approval);
|
||
}
|
||
|
||
}
|
||
// 申请时间
|
||
list.setApplyTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
// 创建者
|
||
list.setCreator(greenVisitorRetinueInfo.getUserId().toString());
|
||
// 修改者
|
||
list.setModifier(greenVisitorRetinueInfo.getUserId().toString());
|
||
// 创建时间
|
||
list.setGmtCreated(new Date());
|
||
// 修改时间
|
||
list.setGmtModified(new Date());
|
||
// 删除标识
|
||
list.setIsDeleted("N");
|
||
|
||
// //添加二级审批人id
|
||
// String secondApproval = firstApproval;//"";
|
||
// list.setSecondApproval(secondApproval);
|
||
// //取审批中心是否开启开关
|
||
// List<Map<String, String>> approvalCenterList = BaseService.getDictionaryInfo("approvalCenter", "001");
|
||
// String approvalCenter = approvalCenterList.get(0).get("data_value");
|
||
// if("1".equals(approvalCenter)){
|
||
// String tenthApproval = firstApproval;//"";
|
||
// list.setTenthApproval(tenthApproval);
|
||
// }
|
||
|
||
// 添加申请到申请list表
|
||
greenApplyListBizc.add(list);
|
||
|
||
// 异步核对 人脸数据
|
||
identityAuthService.auth(info,userInfolist.get(0).get("id").toString(),userInfolist.get(0).get("wxopenid").toString(), greenVisitorRetinueInfo.getIdcard(), facepic1Url, statTime,list,greenVisitorRetinueInfo);
|
||
//if (!"1".equals(dataValue)) { // 关闭身份验证
|
||
String openIdString = userInfolist.get(0).get("wxopenid").toString();
|
||
Map<String, ContentVo> data = new HashMap<String, ContentVo>();
|
||
data.put("first", new ContentVo("您好,您有一条访客信息需处理", "#173177"));
|
||
data.put("keyword1", new ContentVo(greenVisitorRetinueInfo.getVisitorName(), "#black"));
|
||
data.put("keyword2", new ContentVo("未知", "#black"));
|
||
data.put("keyword3", new ContentVo(greenVisitorRetinueInfo.getVisitorTel(), "#black"));
|
||
data.put("keyword4", new ContentVo(greenVisitorRetinueInfo.getOrgName().equals("") ? "未知":greenVisitorRetinueInfo.getOrgName(), "#black"));
|
||
data.put("keyword5", new ContentVo(statTime, "#black"));
|
||
data.put("remark", new ContentVo("请您至\"指尖上的后勤\"微信公众号审核确认", "#173177"));
|
||
wService.publishMsg(data, openIdString, 1);
|
||
//}
|
||
|
||
System.out.println("返回数据-----");
|
||
return new RestResult(Constant.SUCCESS, "预约成功");
|
||
} catch (ServiceValidatorBaseException e) {
|
||
e.printStackTrace();
|
||
/*
|
||
* greenOperateLogBizc.addLog(Constant.VISITOR,
|
||
* Constant.SUBMIT_RESERVE, Constant.OPERATE_FAIL, "提交访客预约",
|
||
* Constant.LOG_ERROR, greenVisitorRetinueInfo.getUserId());
|
||
*/
|
||
// 设置手动回滚
|
||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||
return new RestResult(Constant.FAILED, e.getMessage());
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
/*
|
||
* greenOperateLogBizc.addLog(Constant.VISITOR,
|
||
* Constant.SUBMIT_RESERVE, Constant.OPERATE_FAIL, "提交访客预约",
|
||
* Constant.LOG_ERROR, greenVisitorRetinueInfo.getUserId());
|
||
*/
|
||
// 设置手动回滚
|
||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||
return new RestResult(Constant.FAILED, "预约失败,请重试");
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 保存访客结束状态
|
||
*
|
||
* @param greenVisitorInfo
|
||
* @param request
|
||
* @return
|
||
*/
|
||
@SuppressWarnings({ "unchecked", "unused", "rawtypes" })
|
||
@Transactional(rollbackFor = Exception.class)
|
||
@RequestMapping(value = "/saveVistorState", method = RequestMethod.POST)
|
||
public @ResponseBody RestResult saveVistorEndState(@RequestBody Object requestBody, HttpServletRequest request) {
|
||
try {
|
||
Map maps = (Map)JSON.parse(requestBody.toString());
|
||
String userId = "";
|
||
userId = maps.get("userId").toString();
|
||
String applyId = maps.get("id").toString();
|
||
GreenUserInfo info2 = getUserInfo(userId);
|
||
if (info2 == null) {
|
||
return new RestResult(Constant.FAILED, "非法用户");
|
||
}
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||
String nowDate = sdf.format(new Date());
|
||
|
||
|
||
String visitorsql = "SELECT dp.name departmentName,vi.visit_place,vi.visited_person_name,vi.visit_start_time,vi.visit_end_time,vi.visitor_name,vi.visitor_tel,idcard,vi.visit_reason FROM green_visitor_info vi "
|
||
+ " LEFT JOIN green_user_info ui ON vi.visited_person_id = ui.id and ui.is_deleted = 'N' "
|
||
+ " LEFT JOIN green_department dp on ui.department_id = dp.id and dp.is_deleted = 'N' WHERE vi.is_deleted= 'N' and vi.id = ? ";
|
||
|
||
List<Map<String, Object>> dictionaryInfo = greenDictionaryInfoController.getDictionaryInfo("visitAddUserSwitch");
|
||
int visitAddUserSwitch = Integer.valueOf(dictionaryInfo.get(0).get("data_value")+"");
|
||
|
||
List<HashMap<String, Object>> visitorInfoList = hibernateDao.queryForListWithSql(visitorsql, new Object[] { applyId });
|
||
String idcard = AesEncryptUtil.desEncrypt(visitorInfoList.get(0).get("idcard").toString());
|
||
|
||
List<Map<String, Object>> dictionaryInfo2 = greenDictionaryInfoController.getDictionaryInfo("visitFromTime");
|
||
Integer VisitFormTime = Integer.valueOf(dictionaryInfo2.get(0).get("data_value")+"");
|
||
|
||
if(visitAddUserSwitch == 1){
|
||
String startTime = visitorInfoList.get(0).get("visit_start_time").toString();
|
||
String endTime = visitorInfoList.get(0).get("visit_end_time").toString();
|
||
String reason = visitorInfoList.get(0).get("visit_reason").toString();
|
||
String personName = visitorInfoList.get(0).get("visited_person_name").toString();
|
||
String visitPlace = visitorInfoList.get(0).get("visit_place").toString();
|
||
String departmentName = visitorInfoList.get(0).get("departmentName").toString();
|
||
// visitorMsg(restult.getUserId(), idcard, visitorInfoList.get(0).get("visitor_name"),
|
||
// personName, reason,
|
||
// startTime, endTime);
|
||
|
||
String retinueInfoSql = "SELECT ri.retinue_name,ri.idcard ,ri.uuid FROM GREEN_RETINUE_INFO ri"
|
||
+ " WHERE ri.is_deleted= 'N' and ri.visitor_id = ?";
|
||
|
||
List<Object> retinueInfoList = hibernateDao.queryForListWithSql(retinueInfoSql, new Object[] { applyId });
|
||
for (Object map : retinueInfoList) {
|
||
Map info = (Map) map;
|
||
String cardNo = String.valueOf(info.get("idcard"));
|
||
String retinueName = String.valueOf(info.get("retinue_name"));
|
||
String uuid = String.valueOf(info.get("uuid"));
|
||
try {
|
||
cardNo = AesEncryptUtil.desEncrypt(cardNo);
|
||
if (cardNo != null) {
|
||
cardNo = cardNo.trim();
|
||
}
|
||
} catch (Exception e) {
|
||
}
|
||
info.put("idcard", cardNo);
|
||
String visitFromTime = new DateTime().addMinutes(VisitFormTime).toString();
|
||
String stayArea = "";
|
||
if(Integer.valueOf(visitPlace) == 1){
|
||
stayArea = "西单";
|
||
}else{
|
||
stayArea = "银座";
|
||
}
|
||
boolean visitorMsg = visitorMsg(userId, cardNo, retinueName,
|
||
personName, reason,
|
||
startTime, endTime,uuid,visitFromTime,stayArea,departmentName);
|
||
String updateSql = "";
|
||
if(visitorMsg){
|
||
updateSql = "UPDATE GREEN_RETINUE_INFO SET gmt_modified = NOW() ,modifier = ? ,push_State = 2 where is_deleted='N' AND visitor_id = ?";
|
||
} else{
|
||
updateSql = "UPDATE GREEN_RETINUE_INFO SET gmt_modified = NOW() ,modifier = ? ,push_State = 3 where is_deleted='N' AND visitor_id = ?";
|
||
}
|
||
hibernateDao.updateWithSql(updateSql,new Object[]{userId,applyId});
|
||
}
|
||
}
|
||
String updateSql = "UPDATE green_visitor_info SET gmt_modified = NOW() ,visit_from_time = DATE_FORMAT(?,'%Y-%m-%d %T') ,push_State = 2 where is_deleted='N' AND id = ?";
|
||
hibernateDao.updateWithSql(updateSql,new Object[]{new DateTime().addMinutes(VisitFormTime).toString(),applyId});
|
||
} catch (Exception e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
return new RestResult(Constant.SUCCESS, "失败");
|
||
}
|
||
return new RestResult(Constant.SUCCESS, "成功");
|
||
}
|
||
|
||
|
||
/**
|
||
* 根据id查询访客预约详情
|
||
*
|
||
* @param id
|
||
* @param applyType
|
||
* @return
|
||
*/
|
||
@SuppressWarnings("unchecked")
|
||
public List<Object> getVisitorInfo(String id, String applyType) {
|
||
List<Object> resultList = new ArrayList<Object>();
|
||
List<Object> retinueInfoList = new ArrayList<Object>();
|
||
Map<String, Object> retinueInfoMap = new HashMap<String, Object>();
|
||
String applyInfoByIdSql = "SELECT al.id, case vi.visit_place WHEN 1 THEN '科技楼' when 2 then '物业楼' else '无' END visit_place,vi.IDcard_pic1 picture1,vi.IDcard_pic2 picture2,"
|
||
+ " vi.visited_person_name,vi.licensePlate,"
|
||
//+ " vi.org_name dpname,"原代码
|
||
/*20200218修改*/
|
||
+ " user.org_name orgNameCover,user.department_name dpnameCover,vi.org_name orgName,al.identityAuth,al.appointmentType, "
|
||
+ " al.second_status,al.third_status,al.current_status,"
|
||
/**/
|
||
+ "dp.code dpid, vi.visit_start_time, vi.visit_end_time,vi.face_pic1,"
|
||
+ " vi.visitor_tel,vi.visited_person_tel, vi.visitor_name, al.first_status, vi.visit_reason, vi.idcard ,al.first_status "
|
||
+ " FROM GREEN_APPLY_LIST al "
|
||
+ " LEFT JOIN green_visitor_info vi ON vi.id = al.detail_id"
|
||
+ " LEFT JOIN green_user_info USER ON USER.id = vi.visited_person_id "
|
||
+ " LEFT JOIN green_department dp ON USER.department_id = dp.id "
|
||
+ " WHERE vi.id = ? and al.is_deleted = 'N' and vi.is_deleted = 'N'";
|
||
|
||
// String applyInfoByIdSql = " SELECT CASE vi.visit_place WHEN 1 THEN '西单' WHEN 2 THEN '银座' END stayArea,ui.real_name realName,dp.name departmentName,vi.*,vi.idcard, "
|
||
// + " al.detail_id,al.apply_type,al.apply_type_name,al.first_approval,al.first_status,al.first_approve_time,"
|
||
// + " vi.IDcard_pic1 pic1, vi.IDcard_pic2 pic2,"
|
||
// + " CASE first_status WHEN '0' THEN '待审批' WHEN '1' THEN '已同意' WHEN '2' THEN '已拒绝' WHEN '3' THEN '已取消' END AS first_status_value"
|
||
// + " FROM GREEN_VISITOR_INFO vi INNER JOIN GREEN_APPLY_LIST al ON vi.id = al.detail_id "
|
||
// + " LEFT JOIN green_user_info ui ON vi.user_id = ui.id "
|
||
// + " LEFT JOIN green_department dp ON ui.department_id = dp.id "
|
||
// + " WHERE vi.id = ? AND al.apply_type = ?";
|
||
resultList = hibernateDao.queryForListWithSql(applyInfoByIdSql, new Object[] { id });
|
||
|
||
for (Object map : resultList) {
|
||
Map info = (Map) map;
|
||
String idcard = String.valueOf(info.get("idcard"));
|
||
try {
|
||
idcard = AesEncryptUtil.desEncrypt(idcard);
|
||
if (idcard != null) {
|
||
idcard = idcard.trim();
|
||
}
|
||
} catch (Exception e) {
|
||
}
|
||
info.put("idcard", idcard);
|
||
|
||
// String picture=(String)info.get("picture1");
|
||
// info.put("picture1", baseService.getImageBase64(picture));
|
||
if(info.get("face_pic1") != null){
|
||
String picture1= (String)info.get("face_pic1");
|
||
info.put("face_pic1", baseService.getImageBase64(picture1) );
|
||
}
|
||
|
||
if(info.get("picture1") != null){
|
||
String picture1= (String)info.get("picture1");
|
||
info.put("picture1", baseService.getImageBase64(picture1) );
|
||
}
|
||
if(info.get("picture2") != null){
|
||
String picture2=(String)info.get("picture2");
|
||
info.put("picture2", baseService.getImageBase64(picture2) );
|
||
}
|
||
// System.out.println("======== pic1:" + pic1name + " pic2:" + pic2name);
|
||
}
|
||
|
||
String retinueInfoSql = " SELECT ri.*,IDcard_pic1 AS pic1,IDcard_pic2 AS pic2, ri.idcard " + " FROM GREEN_RETINUE_INFO ri"
|
||
+ " WHERE ri.visitor_id = ? "
|
||
+ "and ri.is_deleted = 'N' ";
|
||
retinueInfoList = hibernateDao.queryForListWithSql(retinueInfoSql, new Object[] { id });
|
||
for (Object map : retinueInfoList) {
|
||
Map info = (Map) map;
|
||
|
||
String cardNo = String.valueOf(info.get("idcard"));
|
||
try {
|
||
cardNo = AesEncryptUtil.desEncrypt(cardNo);
|
||
if (cardNo != null) {
|
||
cardNo = cardNo.trim();
|
||
}
|
||
} catch (Exception e) {
|
||
}
|
||
info.put("idcard", cardNo);
|
||
}
|
||
|
||
retinueInfoMap.put("greenRetinueInfoList", retinueInfoList);
|
||
resultList.add(retinueInfoMap);
|
||
|
||
// //处理二维码
|
||
// if(resultList.size()>0){
|
||
// Map visitorMap = (Map)resultList.get(0);
|
||
// String first_status = getMapString(visitorMap, "first_status");
|
||
// if(first_status.equals("1")){
|
||
// String visited_person_name = getMapString(visitorMap, "visited_person_name");
|
||
// String visited_person_tel = getMapString(visitorMap, "visited_person_tel");
|
||
// String visit_start_time = getMapString(visitorMap, "visit_start_time");
|
||
// String visit_end_time = getMapString(visitorMap, "visit_end_time");
|
||
//
|
||
// String idcard = getMapString(visitorMap, "idcard");
|
||
// String visitor_name = getMapString(visitorMap, "visitor_name");
|
||
// String visitor_tel = getMapString(visitorMap, "visitor_tel");
|
||
//
|
||
// Map resMap = new HashMap();
|
||
// resMap.put("visitedName", visited_person_name);
|
||
// resMap.put("visitedMobile", visited_person_tel);
|
||
// resMap.put("startTime", visit_start_time);
|
||
// resMap.put("endTime", visit_end_time);
|
||
//
|
||
// resMap.put("idcard", idcard);
|
||
// resMap.put("visitorName", visitor_name);
|
||
// resMap.put("visitorMobile", visitor_tel);
|
||
//
|
||
// List list = new ArrayList();
|
||
// for (Object o: retinueInfoList) {
|
||
// Map r = (Map)o;
|
||
// String retinue_name = getMapString(r, "retinue_name");
|
||
// String retinue_idcard = getMapString(r, "idcard");
|
||
// Map ss = new HashMap();
|
||
// ss.put("followName", retinue_name);
|
||
// ss.put("followIdCard", retinue_idcard);
|
||
// list.add(ss);
|
||
// }
|
||
//
|
||
// resMap.put("follows", list);
|
||
//
|
||
// String tt = JSONUtil.objectToJson(resMap);
|
||
// try {
|
||
// tt = AesEncryptUtil.desEncrypt(tt, "greenh5visitmsgs", "greenh5visitmsgs");
|
||
// } catch (Exception e) {
|
||
// // TODO Auto-generated catch block
|
||
// e.printStackTrace();
|
||
// }
|
||
// System.out.println("===" + tt);
|
||
//// tt = Base64Utils.en(tt);
|
||
//// tt = Base64Utils.en(tt);
|
||
// visitorMap.put("qrcode", tt);
|
||
// }
|
||
// }
|
||
return resultList;
|
||
}
|
||
|
||
private String getMapString(Map map, String key){
|
||
if(map == null){
|
||
return null;
|
||
}
|
||
if(key==null||key.equals("")){
|
||
return null;
|
||
}
|
||
Object object = map.get(key);
|
||
if(object==null){
|
||
return null;
|
||
}
|
||
return String.valueOf(object);
|
||
}
|
||
|
||
|
||
/**
|
||
* 查询我的申请列表和我的待办列表
|
||
*
|
||
* @param result
|
||
* @return
|
||
*/
|
||
@SuppressWarnings("unchecked")
|
||
@RequestMapping(value = "/getMyApplyList", method = RequestMethod.POST)
|
||
public @ResponseBody RestResult getMyApplyList(@RequestBody Object requestBody) {
|
||
Result result = new ObjectMapper().convertValue(requestBody, new TypeReference<Result>() {
|
||
});
|
||
try {
|
||
String userId = result.getUserId();
|
||
GreenUserInfo info = getUserInfo(userId);
|
||
// GreenGrantAuth gaInfo = getGaInfo(userId);
|
||
if (info == null) {
|
||
return new RestResult(Constant.FAILED, "非法用户");
|
||
}
|
||
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
|
||
List<String> paramList = new ArrayList<String>();
|
||
// 根据用户id查询该用户具有的权限
|
||
List<Map<String, Object>> queryRoleList = greenUserInfoController.queryRoleById(result.getUserId());
|
||
if (queryRoleList.size() <= 0) {
|
||
return new RestResult(Constant.FAILED, "该角色暂无任何权限,请联系管理员!");
|
||
}
|
||
// List<Map<String, Object>> dictionaryInfo = greenDictionaryInfoController.getDictionaryInfo("visitEndSwitch");
|
||
//
|
||
// int visitEndSwitch = Integer.valueOf(dictionaryInfo.get(0).get("data_value")+"");
|
||
|
||
String userRoleStr = "";
|
||
String[] userRoleArr = null;
|
||
if(queryRoleList.get(0).get("userRole") != null && !"".equals(queryRoleList.get(0).get("userRole"))){
|
||
// 切割查询的权限
|
||
userRoleArr = queryRoleList.get(0).get("userRole").toString().split(",");
|
||
for (String value : userRoleArr) {
|
||
userRoleStr = userRoleStr + "'" + value + "',";
|
||
}
|
||
userRoleStr = "(" + userRoleStr.substring(0, userRoleStr.length() - 1) + ")";
|
||
}else{
|
||
userRoleArr =new String[]{"1"};
|
||
userRoleStr = "(1)";
|
||
}
|
||
// 判断申请类型
|
||
if ("01".equals(result.getType())) {// 我的申请列表查询
|
||
String myApplyListSql = " SELECT vi.push_state pushState,ui.real_name apply_info_3,dp.name apply_info_4,'申请人:' apply_info3_name,'申请人部门:' apply_info4_name,al.detail_id,al.apply_type,al.apply_type_name,al.apply_info_1,al.apply_info_2,"
|
||
+ " al.apply_time,hc.id AS comment_id,'' AS entry_order_pic,"
|
||
+ " di1.data_value AS apply_info1_name,di2.data_value AS apply_info2_name,al.comment_status,"
|
||
+ " CASE al.apply_type"
|
||
+ " WHEN '03' THEN IF(al.first_status = '1',IF(al.second_status = '1',al.third_status,al.second_status),al.first_status)"
|
||
+ " WHEN '04' THEN IF(al.first_status = '1',al.second_status,al.first_status)"
|
||
+ " WHEN '08' THEN IF(al.first_status = '1',IF(al.second_status = '1',IF(al.third_status = '1',"
|
||
+ " IF(al.fourth_status = '1',al.fifth_status,al.fourth_status),al.third_status),al.second_status),al.first_status)"
|
||
+ " ELSE al.first_status END AS statusCode,di3.data_value AS statusValue,"
|
||
+ " IF(al.first_status IN('1','2','3','9','10','11','12','13') OR al.second_status IN('1','2','3','9','10','11','12','13') OR al.third_status IN('1','2','3','9','10','11','12','13') OR al.fourth_status IN('1','2','3','9','10','11','12','13')"
|
||
+ " OR al.fifth_status IN('1','2','3','9','10','11','12','13'),'N','Y') AS is_cancel"
|
||
+ " FROM GREEN_APPLY_LIST al"
|
||
+ " INNER JOIN GREEN_DICTIONARY_INFO di1 ON al.apply_type = di1.data_code AND di1.data_type = 'applyInfo1'"
|
||
+ " INNER JOIN GREEN_DICTIONARY_INFO di2 ON al.apply_type = di2.data_code AND di2.data_type = 'applyInfo2'"
|
||
+ " LEFT JOIN GREEN_DICTIONARY_INFO di3 ON (CASE al.apply_type"
|
||
+ " WHEN '03' THEN IF(al.first_status = '1',IF(al.second_status = '1',al.third_status,al.second_status),al.first_status)"
|
||
+ " WHEN '04' THEN IF(al.first_status = '1',al.second_status,al.first_status)"
|
||
+ " WHEN '08' THEN IF(al.first_status = '1',IF(al.second_status = '1',IF(al.third_status = '1',"
|
||
+ " IF(al.fourth_status = '1',al.fifth_status,al.fourth_status),al.third_status),al.second_status),al.first_status)"
|
||
+ " ELSE al.first_status END) = di3.data_code AND di3.data_type = 'approveStatus'"
|
||
+ " LEFT JOIN GREEN_HAIRCUT_COMMENT hc ON al.detail_id = hc.detail_id AND al.apply_type = '06'"
|
||
+ " LEFT JOIN GREEN_STAFF_CARD_INFO ci ON al.detail_id = ci.id AND al.apply_type = '03'"
|
||
+ " LEFT JOIN GREEN_IMAGE_INFO gii1 ON ci.entry_order_pic = gii1.id "
|
||
+ " LEFT JOIN green_user_info ui ON al.user_id = ui.id "
|
||
+ " LEFT JOIN green_department dp ON ui.department_id = dp.id "
|
||
+ " LEFT JOIN green_visitor_info vi ON al.apply_type = '02' AND vi.id = al.detail_id "
|
||
+ " WHERE al.user_id = ? ORDER by al.apply_time DESC LIMIT 0,100";
|
||
list = hibernateDao.queryForListWithSql(myApplyListSql, new Object[] { result.getUserId() });
|
||
for (int i = 0; i < list.size(); i++) {
|
||
if(list.get(i).get("apply_type").toString().equals("02")){
|
||
if(Integer.valueOf(list.get(i).get("pushState").toString()) == 2 ){
|
||
list.get(i).put("statusValue", "已结束拜访");
|
||
}
|
||
// if(visitEndSwitch == 1){
|
||
// list.get(i).put("statusCode", 0);
|
||
// }
|
||
}
|
||
}
|
||
} else if ("02".equals(result.getType())) {// 我的待办列表查询
|
||
String myWaitHandleListSql = " SELECT ui.real_name apply_info_3,dp.name apply_info_4,'申请人:' apply_info3_name,'申请人部门:' apply_info4_name,gal.*,di1.data_value AS apply_info1_name,"
|
||
+ " di2.data_value AS apply_info2_name,di3.data_value AS statusValue"
|
||
+ " FROM (SELECT al.user_id,al.detail_id,al.apply_type,al.apply_type_name,"
|
||
+ " al.apply_info_1,al.apply_info_2,al.apply_time,"
|
||
+ " al.gmt_created,al.third_status AS statusCode,al.comment_status,"
|
||
+ " al.third_approval AS approvalDept,gii1.image_content AS entry_order_pic"
|
||
+ " FROM GREEN_APPLY_LIST al"
|
||
+ " LEFT JOIN GREEN_STAFF_CARD_INFO ci ON al.detail_id = ci.id AND al.apply_type = '03'"
|
||
+ " LEFT JOIN GREEN_IMAGE_INFO gii1 ON ci.entry_order_pic = gii1.id"
|
||
+ " WHERE 1=1 AND al.first_status = '1' AND al.second_status = '1' AND al.third_status IN ('4','5')"
|
||
+ " AND al.apply_type = '03'" + " UNION ALL"
|
||
+ " SELECT al.user_id,detail_id,al.apply_type,al.apply_type_name,al.apply_info_1,"
|
||
+ " al.apply_info_2,al.apply_time,"
|
||
+ " al.gmt_created,al.second_status AS statusCode,al.comment_status,"
|
||
+ " al.second_approval AS approvalDept,'' AS entry_order_pic FROM GREEN_APPLY_LIST al"
|
||
+ " WHERE 1=1 AND al.first_status = '1' AND al.second_status IN ('6','7')"
|
||
+ " AND al.apply_type = '04') gal"
|
||
+ " INNER JOIN GREEN_DICTIONARY_INFO di1 ON gal.apply_type = di1.data_code AND di1.data_type = 'applyInfo1'"
|
||
+ " INNER JOIN GREEN_DICTIONARY_INFO di2 ON gal.apply_type = di2.data_code AND di2.data_type = 'applyInfo2'"
|
||
+ " INNER JOIN GREEN_DICTIONARY_INFO di3 ON gal.statusCode = di3.data_code AND di3.data_type = 'approveStatus'"
|
||
+ " LEFT JOIN green_user_info ui ON gal.user_id = ui.id "
|
||
+ " LEFT JOIN green_department dp ON ui.department_id = dp.id"
|
||
+ " WHERE 1=1";
|
||
// // 判断用户权限
|
||
if (!Arrays.asList(userRoleArr).contains(ApplyRoleConstant.TEMP_PARK_AUTHORIZE)
|
||
&& !Arrays.asList(userRoleArr).contains(ApplyRoleConstant.STAFF_CARD_MAKE)
|
||
&& !Arrays.asList(userRoleArr).contains(ApplyRoleConstant.SUPER_ADMIN)) {
|
||
myWaitHandleListSql = myWaitHandleListSql + " AND 1=2";
|
||
} else {
|
||
// 超级管理员
|
||
if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.SUPER_ADMIN)) {
|
||
myWaitHandleListSql = myWaitHandleListSql + " AND 1=1";
|
||
} else {
|
||
String tmpSQL = "";
|
||
// 临时停车授权
|
||
if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.TEMP_PARK_AUTHORIZE)) {
|
||
tmpSQL = tmpSQL + " OR (gal.approvalDept = ? AND gal.apply_type = '04')";
|
||
paramList.add(ApplyRoleConstant.TEMP_PARK_AUTHORIZE);
|
||
}
|
||
// 员工卡制卡
|
||
if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.STAFF_CARD_MAKE)) {
|
||
tmpSQL = tmpSQL + " OR (gal.approvalDept = ? AND gal.apply_type = '03')";
|
||
paramList.add(ApplyRoleConstant.STAFF_CARD_MAKE);
|
||
}
|
||
|
||
if (!tmpSQL.trim().equals("")) {
|
||
tmpSQL = tmpSQL.replaceFirst("OR", "");
|
||
myWaitHandleListSql += " and (" + tmpSQL + ")";
|
||
}
|
||
}
|
||
}
|
||
|
||
myWaitHandleListSql = myWaitHandleListSql + " and ";
|
||
// 排序
|
||
myWaitHandleListSql = myWaitHandleListSql + " ORDER BY gal.apply_time DESC LIMIT 0,100";
|
||
|
||
// 执行sql
|
||
list = hibernateDao.queryForListWithSql(myWaitHandleListSql, paramList.toArray());
|
||
|
||
} else if ("03".equals(result.getType())) {// 我的审批列表查询
|
||
|
||
// // 其他申请查询
|
||
// String myWaitHandleListSql = " SELECT vi.push_state pushState,ui.real_name apply_info_3,dp.name apply_info_4,'申请人:' apply_info3_name,'申请人部门:' apply_info4_name,al.detail_id,al.apply_type,al.apply_type_name,al.apply_info_1,al.apply_info_2,"
|
||
// + " di1.data_value AS apply_info1_name,di2.data_value AS apply_info2_name,al.comment_status,al.apply_time,gii1.image_content AS entry_order_pic,"
|
||
// + " CASE al.apply_type" + " WHEN '03' THEN IF(al.first_approval IN " + userRoleStr
|
||
// + " ,al.first_status,IF(al.second_approval IN " + userRoleStr + ",second_status,"
|
||
// + " IF(al.third_approval IN " + userRoleStr + ",al.third_status,null)))"
|
||
//
|
||
// + " WHEN '04' THEN IF(al.first_status = '1',al.second_status,al.first_status)"
|
||
//
|
||
// + " WHEN '08' THEN IF(al.first_approval IN " + userRoleStr
|
||
// + " ,al.first_status,IF(al.second_approval IN " + userRoleStr + ",second_status,"
|
||
// + " IF(al.third_approval IN " + userRoleStr + ",al.third_status,IF(al.fourth_approval IN"
|
||
// + userRoleStr + ",al.fourth_status," + " IF(al.fifth_approval IN " + userRoleStr
|
||
// + " ,fifth_status,null)))))"
|
||
// + " ELSE al.first_status END AS statusCode,di3.data_value AS statusValue"
|
||
// + " FROM GREEN_APPLY_LIST al"
|
||
// + " INNER JOIN GREEN_DICTIONARY_INFO di1 ON al.apply_type = di1.data_code AND di1.data_type = 'applyInfo1'"
|
||
// + " INNER JOIN GREEN_DICTIONARY_INFO di2 ON al.apply_type = di2.data_code AND di2.data_type = 'applyInfo2'"
|
||
// + " INNER JOIN GREEN_DICTIONARY_INFO di3 ON" + " (CASE al.apply_type"
|
||
// + " WHEN '03' THEN IF(al.first_approval IN " + userRoleStr
|
||
// + " ,al.first_status,IF(al.second_approval IN " + userRoleStr + ",second_status,"
|
||
// + " IF(al.third_approval IN " + userRoleStr + ",al.third_status,null)))"
|
||
// + " WHEN '04' THEN IF(al.first_status = '1',al.second_status,al.first_status)"
|
||
// + " WHEN '08' THEN " + " IF(al.first_approval IN " + userRoleStr
|
||
// + " ,al.first_status,IF(al.second_approval IN " + userRoleStr + ",second_status,"
|
||
// + " IF(al.third_approval IN " + userRoleStr + ",al.third_status,IF(al.fourth_approval IN"
|
||
// + userRoleStr + ",al.fourth_status," + " IF(al.fifth_approval IN " + userRoleStr
|
||
// + " ,fifth_status,null)))))"
|
||
// /*
|
||
// * +
|
||
// * " IF(al.first_status = '1',IF(al.second_status = '1',IF(al.third_status = '1',"
|
||
// * +
|
||
// * " IF(al.fourth_status = '1',fifth_status,al.fourth_status),al.third_status),al.second_status),al.first_status)"
|
||
// */
|
||
// + " ELSE al.first_status END)" + " = di3.data_code AND di3.data_type = 'approveStatus'"
|
||
// + " LEFT JOIN GREEN_STAFF_CARD_INFO ci ON al.detail_id = ci.id AND al.apply_type = '03'"
|
||
// + " LEFT JOIN GREEN_IMAGE_INFO gii1 ON ci.entry_order_pic = gii1.id"
|
||
// + " LEFT JOIN green_user_info ui ON al.user_id = ui.id "
|
||
// + " LEFT JOIN green_department dp ON ui.department_id = dp.id"
|
||
// + " LEFT JOIN green_visitor_info vi ON al.apply_type = '02' AND vi.id = al.detail_id "
|
||
// + " WHERE 1=1 and al.is_deleted='N' AND al.first_status IN ('0','1','2','10')";
|
||
//
|
||
// // 判断用户权限
|
||
// if (!Arrays.asList(userRoleArr).contains(ApplyRoleConstant.SUPER_ADMIN) && // 超级管理员
|
||
// !Arrays.asList(userRoleArr).contains(ApplyRoleConstant.VISITOR_APPROVE) && // 访客审批
|
||
// !Arrays.asList(userRoleArr).contains(ApplyRoleConstant.MEAL_TICKET_APPROVE) && // 餐券审批
|
||
// !Arrays.asList(userRoleArr).contains(ApplyRoleConstant.STAFF_CARD_GENERAL) && // 员工卡申请审批_后勤总务处
|
||
// !Arrays.asList(userRoleArr).contains(ApplyRoleConstant.STAFF_CARD_SECURITY) && // 员工卡申请审批_后勤保卫处
|
||
// !Arrays.asList(userRoleArr).contains(ApplyRoleConstant.TEMP_PARK_APPROVE) && // 临时停车审批
|
||
// !Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_PROJECT) && // 施工申请审批_工程部
|
||
// !Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_DEFEND) && // 施工申请审批_秩序维护部
|
||
// !Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_DIRECTOR) && // 施工申请审批_分管主任
|
||
// !Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_GENERAL) && // 施工申请审批_后勤总务处
|
||
// !Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_SECURITY)) // 施工申请审批_后勤保卫处
|
||
//
|
||
// {
|
||
// myWaitHandleListSql = myWaitHandleListSql + " AND 1=2";
|
||
// } else {
|
||
// // 超级管理员
|
||
// if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.SUPER_ADMIN)) {
|
||
// myWaitHandleListSql = myWaitHandleListSql + " AND 1=1";
|
||
// } else {
|
||
//
|
||
// String tmpSQL = "";
|
||
// // 访客预约审批
|
||
// if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.VISITOR_APPROVE)) {
|
||
// tmpSQL += " OR (al.first_approval = ? AND al.apply_type = '02')";
|
||
// paramList.add(result.getUserId());
|
||
// }
|
||
// // 餐券申请审批
|
||
// if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.MEAL_TICKET_APPROVE)) {
|
||
// tmpSQL += " OR (al.first_approval = ? AND al.apply_type = '01')";
|
||
// paramList.add(ApplyRoleConstant.MEAL_TICKET_APPROVE);
|
||
// }
|
||
// // 员工卡申请审批_后勤总务处
|
||
// if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.STAFF_CARD_GENERAL)) {
|
||
// tmpSQL += " OR (al.first_approval = ? AND al.apply_type = '03')";
|
||
// paramList.add(ApplyRoleConstant.STAFF_CARD_GENERAL);
|
||
// }
|
||
// // 员工卡申请审批_后勤保卫处
|
||
// if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.STAFF_CARD_SECURITY)) {
|
||
// tmpSQL += " OR (al.second_approval = ? AND al.apply_type = '03' AND al.first_status = '1')";
|
||
// paramList.add(ApplyRoleConstant.STAFF_CARD_SECURITY);
|
||
// }
|
||
// /*// 临时停车申请一级审批
|
||
// if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.TEMP_PARK_CZ)) {
|
||
// tmpSQL += " OR (al.lead_id = ? AND al.first_approval = ? AND al.apply_type = '04' and al.first_status = 0)";
|
||
// paramList.add(userId);
|
||
// paramList.add(ApplyRoleConstant.TEMP_PARK_CZ);
|
||
// }*/
|
||
// // 临时停车申请二级审批
|
||
// if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.TEMP_PARK_APPROVE)) {
|
||
// tmpSQL += " OR (al.first_approval = ? AND al.apply_type = '04')";
|
||
// paramList.add(ApplyRoleConstant.TEMP_PARK_APPROVE);
|
||
// }
|
||
// // 施工申请审批_工程部
|
||
// if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_PROJECT)) {
|
||
// tmpSQL += " OR (al.first_approval = ? AND al.apply_type = '08')";
|
||
// paramList.add(ApplyRoleConstant.CONSTRUCT_APPROVE_PROJECT);
|
||
// }
|
||
// // 施工申请审批_秩序维护部
|
||
// if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_DEFEND)) {
|
||
// tmpSQL += " OR (al.second_approval = ? AND al.apply_type = '08' AND al.first_status = '1')";
|
||
// paramList.add(ApplyRoleConstant.CONSTRUCT_APPROVE_DEFEND);
|
||
// }
|
||
// // 施工申请审批_分管主任
|
||
// if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_DIRECTOR)) {
|
||
// tmpSQL += " OR (al.third_approval = ? AND al.apply_type = '08' AND al.second_status = '1')";
|
||
// paramList.add(ApplyRoleConstant.CONSTRUCT_APPROVE_DIRECTOR);
|
||
// }
|
||
// // 施工申请审批_后勤总务处
|
||
// if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_GENERAL)) {
|
||
// tmpSQL += " OR (al.fourth_approval = ? AND al.apply_type = '08' AND al.third_status = '1')";
|
||
// paramList.add(ApplyRoleConstant.CONSTRUCT_APPROVE_GENERAL);
|
||
// }
|
||
// // 施工申请审批_后勤保卫处
|
||
// if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_SECURITY)) {
|
||
// tmpSQL += " OR (al.fifth_approval = ? AND al.apply_type = '08' AND al.fourth_status = '1')";
|
||
// paramList.add(ApplyRoleConstant.CONSTRUCT_APPROVE_SECURITY);
|
||
// }
|
||
// if (!tmpSQL.trim().equals("")) {
|
||
// tmpSQL = tmpSQL.replaceFirst("OR", "");
|
||
// myWaitHandleListSql += " and (" + tmpSQL + ")";
|
||
// }
|
||
// }
|
||
// }
|
||
|
||
StringBuffer myWaitHandleListSql = new StringBuffer("SELECT vi.push_state,al.user_id,al.detail_id, vi.visited_person_name,");
|
||
myWaitHandleListSql.append(" vi.visit_start_time, vi.visitor_name, al.apply_time ,al.first_status");
|
||
myWaitHandleListSql.append(" FROM GREEN_APPLY_LIST al LEFT JOIN green_user_info user ON user.id = al.user_id ");
|
||
myWaitHandleListSql.append(" LEFT JOIN green_visitor_info vi ON vi.id = al.detail_id ");
|
||
myWaitHandleListSql.append(" LEFT JOIN green_department dp ON user.department_id = dp.id ");
|
||
myWaitHandleListSql.append(" WHERE al.apply_type = '02' ");
|
||
myWaitHandleListSql.append(" AND al.is_deleted = 'N' and vi.is_deleted = 'N'");
|
||
//判断是邀约记录还是审批授权
|
||
String flag = result.getFlag();
|
||
String page = result.getPage();
|
||
String pageSize = result.getPageSize();
|
||
ArrayList<Object> params = new ArrayList<Object>();
|
||
if("1".equals(flag)){
|
||
myWaitHandleListSql.append(" and vi.visited_person_id = ? and vi.user_id != vi.visited_person_id");
|
||
params.add(userId);
|
||
} else if ("2".equals(flag)){
|
||
myWaitHandleListSql.append(" and vi.user_id = ? and vi.user_id = vi.visited_person_id ");
|
||
params.add(userId);
|
||
} else if ("3".equals(flag)) {
|
||
myWaitHandleListSql.append(" and vi.user_id = ? and vi.user_id != vi.visited_person_id");
|
||
params.add(userId);
|
||
} else if("4".equals(flag)){
|
||
myWaitHandleListSql.append(" and vi.visitor_name = ? and vi.visitor_tel = ? and al.user_id != ?");
|
||
// params.add(gaInfo.getUsername());
|
||
// params.add(gaInfo.getTelnumber());
|
||
params.add(userId);
|
||
}
|
||
// 排序
|
||
if(page.matches("\\d+") && pageSize.matches("\\d+")){
|
||
Integer x = Integer.valueOf(page);
|
||
Integer y = Integer.valueOf(pageSize);
|
||
params.add((x-1)*y);
|
||
params.add(y);
|
||
myWaitHandleListSql.append(" ORDER BY apply_time DESC LIMIT ?,?");
|
||
}
|
||
// myWaitHandleListSql = myWaitHandleListSql + " ORDER BY apply_time DESC LIMIT 0,100";
|
||
// 执行sql
|
||
list = hibernateDao.queryForListWithSql(myWaitHandleListSql.toString(), params.toArray());
|
||
// for (int i = 0; i < list.size(); i++) {
|
||
// if(list.get(i).get("apply_type").toString().equals("02")){
|
||
// if(Integer.valueOf(list.get(i).get("pushState").toString()) == 2 ){
|
||
// list.get(i).put("statusValue", "已结束拜访");
|
||
// }
|
||
//// if(visitEndSwitch == 1){
|
||
//// list.get(i).put("statusCode", 0);
|
||
//// }
|
||
// }
|
||
// }
|
||
}
|
||
|
||
/*
|
||
* if ("01".equals(result.getType())) {
|
||
* greenOperateLogBizc.addLog(Constant.MY_APPLY, Constant.QUERY,
|
||
* Constant.OPERATE_SUCCESS, "查询我的申请列表", Constant.LOG_OPERATE,
|
||
* result.getUserId()); } else if ("02".equals(result.getType())) {
|
||
* greenOperateLogBizc.addLog(Constant.MY_TODO, Constant.QUERY,
|
||
* Constant.OPERATE_SUCCESS, "查询我的待办列表", Constant.LOG_OPERATE,
|
||
* result.getUserId()); } else {
|
||
* greenOperateLogBizc.addLog(Constant.MY_APPROVAL, Constant.QUERY,
|
||
* Constant.OPERATE_SUCCESS, "查询我的审批列表", Constant.LOG_OPERATE,
|
||
* result.getUserId()); }
|
||
*/
|
||
|
||
return new RestResult(Constant.SUCCESS, "", list);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
/*
|
||
* if ("01".equals(result.getType())) {
|
||
* greenOperateLogBizc.addLog(Constant.MY_APPLY, Constant.QUERY,
|
||
* Constant.OPERATE_FAIL, "查询我的申请列表", Constant.LOG_ERROR,
|
||
* result.getUserId()); } else if ("02".equals(result.getType())) {
|
||
* greenOperateLogBizc.addLog(Constant.MY_TODO, Constant.QUERY,
|
||
* Constant.OPERATE_FAIL, "查询我的待办列表", Constant.LOG_ERROR,
|
||
* result.getUserId()); } else {
|
||
* greenOperateLogBizc.addLog(Constant.MY_APPROVAL, Constant.QUERY,
|
||
* Constant.OPERATE_FAIL, "查询我的审批列表", Constant.LOG_ERROR,
|
||
* result.getUserId()); }
|
||
*/
|
||
return new RestResult(Constant.FAILED, "查询失败!");
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 统计我的申请列表和我的待办列表
|
||
*
|
||
* @param result
|
||
* @return
|
||
*/
|
||
@RequestMapping(value = "/countMyApplyList", method = RequestMethod.POST)
|
||
public @ResponseBody RestResult countMyApplyList(@RequestBody Object requestBody) {
|
||
Result result = new ObjectMapper().convertValue(requestBody, new TypeReference<Result>() {
|
||
});
|
||
try {
|
||
String userId = result.getUserId();
|
||
GreenUserInfo info = getUserInfo(userId);
|
||
if (info == null) {
|
||
return new RestResult(Constant.FAILED, "非法用户");
|
||
}
|
||
int myWaitHandleListCount1 = 0;
|
||
int myWaitHandleListCount2 = 0;
|
||
int myWaitHandleListCount3 = 0;
|
||
int myWaitHandleListCount4 = 0;
|
||
int myWaitHandleListCount5 = 0;
|
||
int myWaitHandleListCount6 = 0;
|
||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||
List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
|
||
// 根据用户id查询该用户具有的权限
|
||
List<Map<String, Object>> queryRoleList = greenUserInfoController.queryRoleById(result.getUserId());
|
||
if (queryRoleList.size() <= 0) {
|
||
return new RestResult(Constant.FAILED, "该角色暂无任何权限,请联系管理员!");
|
||
}
|
||
// 切割查询的权限
|
||
String userRoleStr = "";
|
||
String[] userRoleArr = null;
|
||
if(queryRoleList.get(0).get("userRole") != null && !"".equals(queryRoleList.get(0).get("userRole"))){
|
||
// 切割查询的权限
|
||
userRoleArr = queryRoleList.get(0).get("userRole").toString().split(",");
|
||
for (String value : userRoleArr) {
|
||
userRoleStr = userRoleStr + "'" + value + "',";
|
||
}
|
||
userRoleStr = "(" + userRoleStr.substring(0, userRoleStr.length() - 1) + ")";
|
||
}else{
|
||
userRoleArr =new String[]{"1"};
|
||
userRoleStr = "(1)";
|
||
}
|
||
// 统计我的申请
|
||
String myApplyListCountSql = "SELECT COUNT(*) FROM GREEN_APPLY_LIST WHERE user_id = ? AND DATE_FORMAT(apply_time,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d')";
|
||
int myApplyListCount = hibernateDao.queryForIntWithSql(myApplyListCountSql,
|
||
new Object[] { result.getUserId() });
|
||
/*
|
||
* 统计我的待办 (访客预约的审批部门(数据库字段为first_approval)是被访问人的userid,
|
||
* 而其他的申请审批部门为具有审批该申请权限的角色id,因为查询条件不同,所以要分开统计)
|
||
*/
|
||
// 一级审批统计(访客预约)
|
||
String myWaitHandleListCountSql1 = " SELECT COUNT(*) FROM GREEN_APPLY_LIST WHERE 1=1 AND apply_type = '02' AND first_status = '0'";// IN
|
||
// ('0','1','2')
|
||
// 一级审批统计(除访客预约以外的申请)
|
||
String myWaitHandleListCountSql2 = " SELECT COUNT(*) FROM GREEN_APPLY_LIST WHERE 1=1 AND apply_type <> '02' AND first_status = '0'";// IN
|
||
// ('0','1','2')
|
||
// 二级审批
|
||
String myWaitHandleListCountSql3 = " SELECT COUNT(*) FROM GREEN_APPLY_LIST WHERE 1=1 AND first_status = '1' AND second_status IN('0','6')";
|
||
// 三级审批
|
||
String myWaitHandleListCountSql4 = " SELECT COUNT(*) FROM GREEN_APPLY_LIST WHERE 1=1 AND second_status = '1' AND third_status IN('0','4')";// IN('0','1','2');
|
||
// 四级审批
|
||
String myWaitHandleListCountSql5 = " SELECT COUNT(*) FROM GREEN_APPLY_LIST WHERE 1=1 AND third_status = '1' AND fourth_status = '0'";// IN('0','1','2')";
|
||
// 五级审批
|
||
String myWaitHandleListCountSql6 = " SELECT COUNT(*) FROM GREEN_APPLY_LIST WHERE 1=1 AND fourth_status = '1' AND fifth_status = '0'";// IN('0','1','2')";
|
||
// 超级管理员
|
||
if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.SUPER_ADMIN)) {
|
||
myWaitHandleListCountSql1 = myWaitHandleListCountSql1 + " AND 1=1";
|
||
myWaitHandleListCountSql2 = myWaitHandleListCountSql2 + " AND 1=1";
|
||
myWaitHandleListCountSql3 = myWaitHandleListCountSql3 + " AND 1=1";
|
||
myWaitHandleListCountSql4 = myWaitHandleListCountSql4 + " AND 1=1";
|
||
myWaitHandleListCountSql5 = myWaitHandleListCountSql5 + " AND 1=1";
|
||
myWaitHandleListCountSql6 = myWaitHandleListCountSql6 + " AND 1=1";
|
||
myWaitHandleListCount1 = hibernateDao.queryForIntWithSql(myWaitHandleListCountSql1);
|
||
myWaitHandleListCount2 = hibernateDao.queryForIntWithSql(myWaitHandleListCountSql2);
|
||
myWaitHandleListCount3 = hibernateDao.queryForIntWithSql(myWaitHandleListCountSql3);
|
||
myWaitHandleListCount4 = hibernateDao.queryForIntWithSql(myWaitHandleListCountSql4);
|
||
myWaitHandleListCount5 = hibernateDao.queryForIntWithSql(myWaitHandleListCountSql5);
|
||
myWaitHandleListCount6 = hibernateDao.queryForIntWithSql(myWaitHandleListCountSql6);
|
||
} else {
|
||
myWaitHandleListCountSql1 = myWaitHandleListCountSql1 + " AND first_approval = ?";
|
||
myWaitHandleListCountSql2 = myWaitHandleListCountSql2 + " AND first_approval IN" + userRoleStr;
|
||
myWaitHandleListCountSql3 = myWaitHandleListCountSql3 + " AND second_approval IN" + userRoleStr;
|
||
myWaitHandleListCountSql4 = myWaitHandleListCountSql4 + " AND third_approval IN" + userRoleStr;
|
||
myWaitHandleListCountSql5 = myWaitHandleListCountSql5 + " AND fourth_approval IN" + userRoleStr;
|
||
myWaitHandleListCountSql6 = myWaitHandleListCountSql6 + " AND fifth_approval IN" + userRoleStr;
|
||
myWaitHandleListCount1 = hibernateDao.queryForIntWithSql(myWaitHandleListCountSql1,new Object[] { result.getUserId() });
|
||
myWaitHandleListCount2 = hibernateDao.queryForIntWithSql(myWaitHandleListCountSql2);
|
||
myWaitHandleListCount3 = hibernateDao.queryForIntWithSql(myWaitHandleListCountSql3);
|
||
myWaitHandleListCount4 = hibernateDao.queryForIntWithSql(myWaitHandleListCountSql4);
|
||
myWaitHandleListCount5 = hibernateDao.queryForIntWithSql(myWaitHandleListCountSql5);
|
||
myWaitHandleListCount6 = hibernateDao.queryForIntWithSql(myWaitHandleListCountSql6);
|
||
}
|
||
// 统计我的待办数量
|
||
int myWaitHandleListCount = myWaitHandleListCount1 + myWaitHandleListCount2 + myWaitHandleListCount3
|
||
+ myWaitHandleListCount4 + myWaitHandleListCount5 + myWaitHandleListCount6;
|
||
// 封装返回结果
|
||
resultMap.put("myApplyListCount", myApplyListCount);
|
||
resultMap.put("myWaitHandleListCount", myWaitHandleListCount);
|
||
resultList.add(resultMap);
|
||
/*
|
||
* greenOperateLogBizc.addLog(Constant.HOME, Constant.QUERY,
|
||
* Constant.OPERATE_SUCCESS, "查询我的待办与审批总数", Constant.LOG_OPERATE,
|
||
* result.getUserId());
|
||
*/
|
||
// 返回结果
|
||
return new RestResult(Constant.SUCCESS, "", resultList);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
/*
|
||
* greenOperateLogBizc.addLog(Constant.HOME, Constant.QUERY,
|
||
* Constant.OPERATE_FAIL, "查询我的待办与审批总数", Constant.LOG_ERROR,
|
||
* result.getUserId());
|
||
*/
|
||
return new RestResult(Constant.FAILED, "查询失败!");
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 根据id和申请类型查询申请详情
|
||
*
|
||
* @param result
|
||
* @return
|
||
*/
|
||
@RequestMapping(value = "/getApplyInfo", method = RequestMethod.POST)
|
||
public @ResponseBody RestResult getApplyInfo(@RequestBody Object requestBody, HttpServletRequest request) {
|
||
Result result = new ObjectMapper().convertValue(requestBody, new TypeReference<Result>() {
|
||
});
|
||
try {
|
||
String userId = result.getUserId();
|
||
GreenUserInfo info = getUserInfo(userId);
|
||
// GreenGrantAuth gaInfo = getGaInfo(userId);
|
||
if (info == null) {
|
||
return new RestResult(Constant.FAILED, "非法用户");
|
||
}
|
||
// 判断申请类型
|
||
if (Constant.MEAL_TICKET_APPLY.equals(result.getApplyType())) {// 餐券申请
|
||
return new RestResult(Constant.SUCCESS, "",
|
||
greenMealTicketApplyController.getMealTicketApplyInfo(result.getId(), result.getApplyType()));
|
||
} else if (Constant.VISITOR_APPLY.equals(result.getApplyType())) {// 访客预约
|
||
return new RestResult(Constant.SUCCESS, "", getVisitorInfo(result.getId(), Constant.VISITOR_APPLY));
|
||
} else if (Constant.STAFF_CARD_APPLY.equals(result.getApplyType())) {// 员工卡申请
|
||
return new RestResult(Constant.SUCCESS, "", greenStaffCardInfoController
|
||
.getStaffCardInfo(result.getId(), Constant.STAFF_CARD_APPLY, result.getUserId()));
|
||
} else if (Constant.TEMP_PARK_APPLY.equals(result.getApplyType())) {// 临时停车预约
|
||
return new RestResult(Constant.SUCCESS, "",
|
||
greenTempParkInfoController.getTempParkInfo(result.getId(), Constant.TEMP_PARK_APPLY));
|
||
} else if (Constant.FAULT_REPAIR_APPLY.equals(result.getApplyType())) {// 故障报修申请
|
||
return new RestResult(Constant.SUCCESS, "",
|
||
greenFaultRepairInfoController.getFaultRepairInfo(result.getId(), Constant.FAULT_REPAIR_APPLY));
|
||
} else if (Constant.HAIRCUT_APPLY.equals(result.getApplyType())) {// 理发预约
|
||
return new RestResult(Constant.SUCCESS, "", greenHaircutInfoController.getHaircutInfo(result.getId()));
|
||
} else if (Constant.MEAL_TICKET_GET.equals(result.getApplyType())) {// 餐券领取
|
||
return new RestResult(Constant.SUCCESS, "",
|
||
greenMealTicketApplyController.getMealTicketApplyInfo(result.getId(), result.getApplyType()));
|
||
} else if (Constant.CONSTRUCT_APPLY.equals(result.getApplyType())) {// 施工申请
|
||
return new RestResult(Constant.SUCCESS, "", greenConstructInfoController
|
||
.getConstructInfo(result.getId(), result.getApplyType(), result.getUserId()));
|
||
} else {
|
||
return new RestResult(Constant.FAILED, "申请类型有误!");
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
return new RestResult(Constant.FAILED, "查询失败!");
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 申请的审批
|
||
*
|
||
* @param restult
|
||
* @return
|
||
*/
|
||
@SuppressWarnings({ "unchecked", "deprecation", "rawtypes" })
|
||
@Transactional(rollbackFor = Exception.class)
|
||
@RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
|
||
public @ResponseBody RestResult updateStatus(@RequestBody Object requestBody) {
|
||
Result restult = new ObjectMapper().convertValue(requestBody, new TypeReference<Result>() {
|
||
});
|
||
try {
|
||
// 根据用户id查询该用户具有的权限
|
||
List<Map<String, Object>> queryRoleList = greenUserInfoController.queryRoleById(restult.getUserId());
|
||
if (queryRoleList.size() <= 0) {
|
||
return new RestResult(Constant.FAILED, "该角色暂无任何权限,请联系管理员!");
|
||
}
|
||
// 切割查询的权限
|
||
|
||
if(queryRoleList.get(0).get("userRole") == null || "".equals(queryRoleList.get(0).get("userRole"))){
|
||
return new RestResult(Constant.FAILED, "该角色暂无审批权限,请联系管理员!");
|
||
}
|
||
String[] userRoleArr = queryRoleList.get(0).get("userRole").toString().split(",");
|
||
GreenApplyList old = null;
|
||
// 根据申请详情id查询申请列表list
|
||
|
||
String applyListSql = "SELECT * from GREEN_APPLY_LIST WHERE detail_id = ? AND apply_type = ?";
|
||
// 执行查询sql
|
||
List<GreenApplyList> list = hibernateDao.queryForListWithSql(applyListSql,
|
||
new Object[] { restult.getApplyId(), restult.getApplyType() },
|
||
new BeanPropertyRowMapper(GreenApplyList.class));
|
||
String subSql = "SELECT ui.login_name submitter from GREEN_APPLY_LIST al LEFT JOIN green_user_info ui on ui.is_deleted = 'N' AND ui.id = al.user_id WHERE al.is_deleted = 'N' and al.detail_id = ? AND al.apply_type = ? ";
|
||
// 执行查询sql
|
||
if (list.size() > 0) {
|
||
GreenApplyList greenApplyList = list.get(0);
|
||
long pk = greenApplyList.getId();
|
||
String firstStatus = greenApplyList.getFirstStatus();
|
||
String secondStatus = greenApplyList.getSecondStatus();
|
||
String thirdStatus = greenApplyList.getThirdStatus();
|
||
String fourthStatus = greenApplyList.getFourthStatus();
|
||
old = greenApplyListBizc.get(pk);
|
||
// 根据userId查询用户信息
|
||
String userSql = "SELECT login_name FROM GREEN_USER_INFO WHERE id=?";
|
||
List<Map<String, String>> userList = hibernateDao.queryForListWithSql(userSql,
|
||
new Object[] { greenApplyList.getUserId() });
|
||
Map<String, String> user = userList.get(0);
|
||
//临时停车新逻辑
|
||
/*List<Map<String, Object>> dictionaryInfo1 = greenDictionaryInfoController.getDictionaryInfo("appIconSwitch");
|
||
if(restult.getApplyType()!=null && restult.getApplyType().equals("04")){
|
||
GreenApplyList old1=getParkCarInfo(list.get(0),restult.getUserId(),userList.get(0),restult);
|
||
greenApplyListBizc.update(old, pk);
|
||
return new RestResult(Constant.SUCCESS, "处理成功");
|
||
}else{*/
|
||
// 判断一级审批状态是否为已同意
|
||
if ("1".equals(firstStatus)) {
|
||
// 员工卡申请
|
||
if (Constant.STAFF_CARD_APPLY.equals(restult.getApplyType())) {
|
||
// 判断用户角色
|
||
if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.STAFF_CARD_GENERAL)) {
|
||
throw new MyException("该申请已经同意");
|
||
}
|
||
if ("1".equals(secondStatus)) {
|
||
// 判断用户角色
|
||
if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.STAFF_CARD_SECURITY)) {
|
||
throw new MyException("该申请已经同意");
|
||
}
|
||
if ("5".equals(restult.getStatus())) {
|
||
old.setThirdStatus(restult.getStatus());
|
||
old.setThirdApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
// 推送消息给申请人
|
||
String userName = user.get("login_name");
|
||
String msgname = "领取通知";
|
||
String tm = "您提交的【员工卡申请】已完成制卡,请前往物业领取";
|
||
|
||
PushMessageUtil.getInstance().pushMessage(msgname, tm, userName,hibernateDao);
|
||
|
||
/*
|
||
* // 推送消息给一级审批人 // 根据角色名称查询员工卡申请审批的用户 String
|
||
* staffAppSql =
|
||
* " SELECT `user`.login_name FROM GREEN_USER_ROLE_REL role INNER JOIN GREEN_USER_INFO user on role.user_id=`user`.id"
|
||
* +
|
||
* " WHERE role.role_name = '员工卡申请审批_后勤总务处' OR role.role_name = '员工卡申请审批_后勤保卫处'"
|
||
* ;
|
||
*
|
||
* List<GreenUserInfo> staffAppList =
|
||
* hibernateDao.queryForListWithSql(staffAppSql,
|
||
* new Object[] {}, new
|
||
* BeanPropertyRowMapper(GreenUserInfo.class));
|
||
* String msgname1 = "审批通知";
|
||
*
|
||
* String tm1 = "您提交的【员工卡申请】已完成制卡";
|
||
*
|
||
* for (int i = 0; i < staffAppList.size(); i++)
|
||
* {
|
||
*
|
||
* String name =
|
||
* staffAppList.get(i).getLoginName();
|
||
* PushMessageUtil.getInstance().pushMessage(
|
||
* msgname1, tm1, name); }
|
||
*/
|
||
}
|
||
} else if ("3".equals(secondStatus)) {
|
||
throw new MyException("该申请已经被取消");
|
||
} else if ("2".equals(secondStatus)) {
|
||
throw new MyException("该申请已经被拒绝");
|
||
} else {
|
||
old.setSecondStatus(restult.getStatus());
|
||
old.setSecondApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
// 推送消息给申请人
|
||
String userName = user.get("login_name");
|
||
String msgname = "申请通知";
|
||
String tm = "您提交的【员工卡申请】已由后勤保卫处审批通过,制卡完成后可前往物业领取";
|
||
|
||
PushMessageUtil.getInstance().pushMessage(msgname, tm, userName,hibernateDao);
|
||
}
|
||
|
||
// 临时停车
|
||
} else if (Constant.TEMP_PARK_APPLY.equals(restult.getApplyType())
|
||
&& "7".equals(restult.getStatus())) {
|
||
old.setSecondStatus(restult.getStatus());
|
||
old.setSecondApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
String userName = user.get("login_name");
|
||
// 推送消息给申请人
|
||
String msgname = "授权通知";
|
||
String tm = "您申请的【临时停车申请】已授权完成,可出入停车地点";
|
||
|
||
PushMessageUtil.getInstance().pushMessage(msgname, tm, userName,hibernateDao);
|
||
|
||
|
||
//没必要给一级审批人推送信息
|
||
// 推送消息给一级审批人
|
||
// 根据角色名称查询临时停车审批的用户
|
||
// String parkAppSql = " SELECT user.login_name FROM GREEN_USER_ROLE_REL role INNER JOIN GREEN_USER_INFO user ON role.user_id =user.id"
|
||
// + " WHERE role.role_name = '临时停车申请审批'";
|
||
//
|
||
// List<GreenUserInfo> parkAppList = hibernateDao.queryForListWithSql(parkAppSql, new Object[] {},
|
||
// new BeanPropertyRowMapper(GreenUserInfo.class));
|
||
//
|
||
// String msgname1 = "审批通知";
|
||
//
|
||
// String tm1 = "您审批的【临时停车申请】已授权完成";
|
||
//
|
||
// for (int i = 0; i < parkAppList.size(); i++) {
|
||
// String name = parkAppList.get(i).getLoginName();
|
||
// PushMessageUtil.getInstance().pushMessage(msgname1, tm1, name,hibernateDao);
|
||
// }
|
||
// 施工申请
|
||
} else if (Constant.CONSTRUCT_APPLY.equals(restult.getApplyType())) {
|
||
// 判断用户角色
|
||
if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_PROJECT)) {
|
||
throw new MyException("该申请已经同意");
|
||
}
|
||
if ("1".equals(secondStatus)) {
|
||
// 判断用户角色
|
||
if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_DEFEND)) {
|
||
throw new MyException("该申请已经同意");
|
||
}
|
||
if ("1".equals(thirdStatus)) {
|
||
// 判断用户角色
|
||
if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_DIRECTOR)) {
|
||
throw new MyException("该申请已经同意");
|
||
}
|
||
if ("1".equals(fourthStatus)) {
|
||
// 判断用户角色
|
||
if (Arrays.asList(userRoleArr)
|
||
.contains(ApplyRoleConstant.CONSTRUCT_APPROVE_GENERAL)) {
|
||
throw new MyException("该申请已经同意");
|
||
}
|
||
if ("3".equals(fourthStatus)) {
|
||
throw new MyException("该申请已经被取消");
|
||
} else if ("2".equals(fourthStatus)) {
|
||
throw new MyException("该申请已经被后勤保卫处拒绝");
|
||
} else {
|
||
old.setFifthStatus(restult.getStatus());
|
||
old.setFifthApproveTime(
|
||
new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
// 推送消息给申请人
|
||
String userName = user.get("login_name");
|
||
String msgname = "审批通知";
|
||
String tm = "您提交的【施工申请】已完成审批";
|
||
PushMessageUtil.getInstance().pushMessage(msgname, tm, userName,hibernateDao);
|
||
}
|
||
|
||
} else if ("3".equals(fourthStatus)) {
|
||
throw new MyException("该申请已经被取消");
|
||
} else if ("2".equals(fourthStatus)) {
|
||
throw new MyException("该申请已经被后勤部总务处拒绝");
|
||
} else {
|
||
old.setFourthStatus(restult.getStatus());
|
||
old.setFourthApproveTime(
|
||
new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
}
|
||
} else if ("3".equals(thirdStatus)) {
|
||
throw new MyException("该申请已经被取消");
|
||
} else if ("2".equals(thirdStatus)) {
|
||
throw new MyException("该申请已经被分管主任拒绝");
|
||
} else {
|
||
old.setThirdStatus(restult.getStatus());
|
||
old.setThirdApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
}
|
||
} else if ("3".equals(secondStatus)) {
|
||
throw new MyException("该申请已经被取消");
|
||
} else if ("2".equals(secondStatus)) {
|
||
throw new MyException("该申请已经被秩序维护部拒绝");
|
||
} else {
|
||
old.setSecondStatus(restult.getStatus());
|
||
old.setSecondApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
}
|
||
}
|
||
// TODO 一级审批
|
||
} else {
|
||
// 取消申请时候判断该申请是否已经开始审批
|
||
if (Arrays.asList(IS_CANCEL_ARR).contains(firstStatus)
|
||
&& "3".equals(restult.getStatus())) {
|
||
throw new MyException("该申请不可取消");
|
||
}
|
||
// 理发预约时间小于当前时间则不允许取消
|
||
if (Constant.HAIRCUT_APPLY.equals(restult.getApplyType())
|
||
&& "13".equals(firstStatus)) {
|
||
throw new MyException("理发已开始");
|
||
}
|
||
// if(Constant.HAIRCUT_APPLY.equals(restult.getApplyType())){
|
||
// String ss = "delete from GREEN_HAIRCUT_INFO where id = "
|
||
// + restult.getApplyId();
|
||
// hibernateDao.executeSqlUpdate(ss);
|
||
// }
|
||
old.setFirstStatus(restult.getStatus());
|
||
old.setFirstApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
String userName = user.get("login_name");
|
||
|
||
// 访客预约申请
|
||
String applyType = restult.getApplyType();
|
||
if (applyType.equals("02")) {
|
||
String msgname = "申请通知";
|
||
String tm = "您提交的【访客申请】已审批通过,打开申请详情前往接待室办理出入";
|
||
if(restult.getStatus().equals("2")){
|
||
tm = "您提交的【访客申请】已被拒绝。";
|
||
PushMessageUtil.getInstance().pushMessage(msgname, tm, userName,hibernateDao);
|
||
}else if(restult.getStatus().equals("1")){
|
||
|
||
|
||
PushMessageUtil.getInstance().pushMessage(msgname, tm, userName,hibernateDao);
|
||
String visitorsql = "SELECT dp.name departmentName,vi.visit_place,vi.visited_person_name,vi.visit_start_time,vi.visit_end_time,vi.visitor_name,vi.visitor_tel,idcard,vi.visit_reason FROM green_visitor_info vi "
|
||
+ " LEFT JOIN green_user_info ui ON vi.visited_person_id = ui.id and ui.is_deleted = 'N' "
|
||
+ " LEFT JOIN green_department dp on ui.department_id = dp.id and dp.is_deleted = 'N' WHERE vi.is_deleted= 'N' and vi.id = ? ";
|
||
|
||
String updateRemainSql = "UPDATE green_visitor_info SET push_state = 1,gmt_modified = now() WHERE id = ?";
|
||
hibernateDao.executeSqlUpdate(updateRemainSql,new Object[]{restult.getApplyId()});
|
||
|
||
|
||
|
||
List<Map<String, Object>> dictionaryInfo = greenDictionaryInfoController.getDictionaryInfo("visitAddUserSwitch");
|
||
int visitAddUserSwitch = Integer.valueOf(dictionaryInfo.get(0).get("data_value")+"");
|
||
List<HashMap<String, Object>> visitorInfoList = hibernateDao.queryForListWithSql(visitorsql, new Object[] { restult.getApplyId() });
|
||
String idcard = AesEncryptUtil.desEncrypt(visitorInfoList.get(0).get("idcard").toString());
|
||
if(visitAddUserSwitch == 1){
|
||
String startTime = visitorInfoList.get(0).get("visit_start_time").toString();
|
||
String endTime = visitorInfoList.get(0).get("visit_end_time").toString();
|
||
String reason = visitorInfoList.get(0).get("visit_reason").toString();
|
||
String personName = visitorInfoList.get(0).get("visited_person_name").toString();
|
||
// visitorMsg(restult.getUserId(), idcard, visitorInfoList.get(0).get("visitor_name"),
|
||
// personName, reason,
|
||
// startTime, endTime);
|
||
String visitPlace = visitorInfoList.get(0).get("visit_place").toString()+"";
|
||
String retinueInfoSql = "SELECT ri.retinue_name,ri.idcard ,ri.uuid FROM GREEN_RETINUE_INFO ri"
|
||
+ " WHERE ri.visitor_id = ?";
|
||
String departmentName = visitorInfoList.get(0).get("departmentName").toString();
|
||
List<Object> retinueInfoList = hibernateDao.queryForListWithSql(retinueInfoSql, new Object[] { restult.getApplyId() });
|
||
for (Object map : retinueInfoList) {
|
||
Map info = (Map) map;
|
||
|
||
String cardNo = String.valueOf(info.get("idcard"));
|
||
String retinueName = String.valueOf(info.get("retinue_name"));
|
||
String uuid = String.valueOf(info.get("uuid"));
|
||
try {
|
||
cardNo = AesEncryptUtil.desEncrypt(cardNo);
|
||
if (cardNo != null) {
|
||
cardNo = cardNo.trim();
|
||
}
|
||
} catch (Exception e) {
|
||
}
|
||
info.put("idcard", cardNo);
|
||
|
||
String stayArea = "";
|
||
if(Integer.valueOf(visitPlace) == 1){
|
||
stayArea = "西单";
|
||
}else{
|
||
stayArea = "银座";
|
||
}
|
||
|
||
boolean flag = visitorMsg(restult.getUserId(), cardNo, retinueName,
|
||
personName, reason,
|
||
startTime, endTime,uuid,endTime,stayArea,departmentName);
|
||
if(flag){
|
||
String updateRemainSql2 = "UPDATE GREEN_RETINUE_INFO SET push_state = 1,gmt_modified = now() WHERE visitor_id = ?";
|
||
hibernateDao.executeSqlUpdate(updateRemainSql2,new Object[]{restult.getApplyId()});
|
||
}else{
|
||
String updateRemainSql2 = "UPDATE GREEN_RETINUE_INFO SET push_state = 4,gmt_modified = now() WHERE visitor_id = ?";
|
||
hibernateDao.executeSqlUpdate(updateRemainSql2,new Object[]{restult.getApplyId()});
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
}
|
||
// 临时停车申请
|
||
if (applyType.equals("04")) {
|
||
if(restult.getStatus().equals("2")){
|
||
String msgname = "申请通知";
|
||
String tm = "您提交的【临时停车申请】已被拒绝。";
|
||
// sendMsg("temp_park_authorize",msgname, "您有一个【临时停车申请】待授权", userName,hibernateDao);
|
||
//审批拒绝发送消息给提交人
|
||
PushMessageUtil.getInstance().pushMessage(msgname, tm, userName,hibernateDao);
|
||
}else{
|
||
String msgname = "授权通知";
|
||
//String tm = "您提交的【临时停车申请】已审批通过,授权后可出入停车地点";
|
||
//审批拒绝发送消息给提交人
|
||
sendMsg("temp_park_authorize",msgname, "您有一个【临时停车申请】待授权", userName,hibernateDao);
|
||
}
|
||
}
|
||
// 员工卡申请
|
||
if (applyType.equals("03")) {
|
||
if(restult.getStatus().equals("2")){
|
||
String msgname = "申请通知";
|
||
String tm = "您提交的【员工卡申请】已被后勤部总务处拒绝";
|
||
PushMessageUtil.getInstance().pushMessage(msgname, tm, userName,hibernateDao);
|
||
}else{
|
||
String msgname = "申请通知";
|
||
String tm = "您提交的【员工卡申请】已由后勤部总务处审批通过";
|
||
PushMessageUtil.getInstance().pushMessage(msgname, tm, userName,hibernateDao);
|
||
}
|
||
}
|
||
// 餐券申请
|
||
if (applyType.equals("01")) {
|
||
String msgname = "申请通知";
|
||
String tm = "您提交的【餐券申请】已审批通过,可正常领取";
|
||
|
||
PushMessageUtil.getInstance().pushMessage(msgname, tm, userName,hibernateDao);
|
||
}
|
||
}
|
||
// TYPE-餐券申请 审批后,审批的餐券数量插入餐券数量表
|
||
String applyType = restult.getApplyType();
|
||
String status = restult.getStatus();
|
||
if ("1".equals(status) && Constant.MEAL_TICKET_APPLY.equals(applyType)) {
|
||
String applyId = restult.getApplyId();
|
||
List<Map<String, Object>> list1 = hibernateDao.queryForListWithSql(
|
||
"Select a.*,d.id as 'deptId',d.parent_id from GREEN_MEAL_TICKET_APPLY a left join GREEN_DEPARTMENT d on a.applicant_department_id = d.id where a.id = ? ",
|
||
new Object[] { applyId });
|
||
// 拿到开始日期-结束日期-数量
|
||
|
||
String[] split = String.valueOf(list1.get(0).get("start_date")).split("-");
|
||
|
||
String deptId = String.valueOf(list1.get(0).get("deptId"));
|
||
// if ("1".equals(parentId) || "2".equals(parentId)) {
|
||
// parentId = String.valueOf(list1.get(0).get("id"));
|
||
// }
|
||
String issueDate = split[0] + "-" + split[1];
|
||
List<GreenMealTicketNum> list2 = hibernateDao.queryForListWithSql(
|
||
"Select * from GREEN_MEAL_TICKET_NUM where department_id = ? and DATE_FORMAT(issue_date,'%Y-%m') = ? and is_deleted = 'N'",
|
||
new Object[] { deptId, issueDate }, new BeanPropertyRowMapper(GreenMealTicketNum.class));
|
||
if (list2.isEmpty()) {
|
||
return new RestResult(Constant.FAILED, "当前部门未设置下发餐券功能,申请失败!");
|
||
}
|
||
|
||
String ticketNum = String.valueOf(list1.get(0).get("meal_ticket_num"));
|
||
// 拿到申请的每天日期
|
||
List<String> betweenDays = getBetweenDays(String.valueOf(list1.get(0).get("start_date")),
|
||
String.valueOf(list1.get(0).get("end_date")));
|
||
// 更改申请数
|
||
for (String day : betweenDays) {
|
||
for (GreenMealTicketNum greenMealTicketNum : list2) {
|
||
if (day.equals(greenMealTicketNum.getIssueDate())) {
|
||
|
||
String extraNum = greenMealTicketNum.getExtraNum();
|
||
String unusedNum = greenMealTicketNum.getExtraUnusedNum();
|
||
BigDecimal ticketNumBD = new BigDecimal(ticketNum);
|
||
BigDecimal extraNumBD = new BigDecimal(extraNum);
|
||
BigDecimal unusedNumBD = new BigDecimal(unusedNum);
|
||
BigDecimal add = ticketNumBD.add(extraNumBD);
|
||
BigDecimal add2 = ticketNumBD.add(unusedNumBD);
|
||
hibernateDao.updateWithSql(
|
||
"update GREEN_MEAL_TICKET_NUM set extra_num = ? ,extra_unused_num = ? where id = ? and is_deleted = 'N'",
|
||
new Object[] { add, add2, greenMealTicketNum.getId() });
|
||
}
|
||
|
||
}
|
||
}
|
||
// 更改申请状态
|
||
hibernateDao.updateWithSql("update GREEN_MEAL_TICKET_APPLY set approval_status = '1' where id = ?",
|
||
new Object[] { applyId });
|
||
|
||
}
|
||
|
||
greenApplyListBizc.update(old, pk);
|
||
|
||
// 如果取消理发预约,把其预约的时间段余额加一
|
||
if (Constant.HAIRCUT_APPLY.equals(restult.getApplyType())
|
||
&& "3".equals(restult.getStatus())
|
||
&& !"3".equals(firstStatus)
|
||
&& !"9".equals(firstStatus)) {
|
||
// 根据id查询理发预约详情
|
||
GreenHaircutInfo updateGreenHaircutInfo = greenhaircutinfoBizc
|
||
.get(Long.valueOf(restult.getApplyId()));
|
||
// 根据预约日期和时间段查询其余额
|
||
String queryRemain = "SELECT * FROM GREEN_HAIRCUT_REMAIN hr WHERE hr.barbershop = ? AND hr.barber_id = ?"
|
||
+ " AND hr.haircut_date = ? AND hr.haircut_time_id = ?";
|
||
List<GreenHaircutRemain> remainList = hibernateDao.queryForListWithSql(queryRemain,
|
||
new Object[] { updateGreenHaircutInfo.getBarbershopArea(),
|
||
updateGreenHaircutInfo.getBarberId(), updateGreenHaircutInfo.getApplyDate(),
|
||
updateGreenHaircutInfo.getApplyTimeId() },
|
||
new BeanPropertyRowMapper<GreenHaircutRemain>(GreenHaircutRemain.class));
|
||
// 获取理发余额数据
|
||
GreenHaircutRemain greenHaircutRemain = remainList.get(0);
|
||
// 将理发余额加一
|
||
greenHaircutRemain.setHaircutRemain(greenHaircutRemain.getHaircutRemain() + 1);
|
||
// 执行更新余额的操作
|
||
greenhaircutremainBizc.update(greenHaircutRemain, greenHaircutRemain.getId());
|
||
|
||
if (Constant.HAIRCUT_APPLY.equals(restult.getApplyType())) {
|
||
String ss = "update GREEN_HAIRCUT_INFO set is_deleted='Y' where id = " + restult.getApplyId();
|
||
hibernateDao.executeSqlUpdate(ss);
|
||
}
|
||
|
||
}
|
||
|
||
if ("2".equals(status) && Constant.MEAL_TICKET_APPLY.equals(applyType)) {
|
||
String applyId = restult.getApplyId();
|
||
hibernateDao.updateWithSql("update GREEN_MEAL_TICKET_APPLY set approval_status = '2' where id = ?",
|
||
new Object[] { applyId });
|
||
|
||
}
|
||
|
||
if ("3".equals(status) && Constant.MEAL_TICKET_APPLY.equals(applyType)) {
|
||
String applyId = restult.getApplyId();
|
||
hibernateDao.updateWithSql("update GREEN_MEAL_TICKET_APPLY set approval_status = '3' where id = ?",
|
||
new Object[] { applyId });
|
||
}
|
||
return new RestResult(Constant.SUCCESS, "处理成功");
|
||
}
|
||
/*} */else {
|
||
return new RestResult(Constant.FAILED, "处理失败");
|
||
}
|
||
} catch (MyException e) {
|
||
e.printStackTrace();
|
||
addLog(Constant.MY_APPLY, Constant.APPROVAL, Constant.OPERATE_FAIL, "审批申请",
|
||
Constant.LOG_ERROR, restult.getUserId());
|
||
// 设置手动回滚
|
||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||
return new RestResult(Constant.FAILED, e.getMessage());
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
addLog(Constant.MY_APPLY, Constant.APPROVAL, Constant.OPERATE_FAIL, "审批申请",
|
||
Constant.LOG_ERROR, restult.getUserId());
|
||
// 设置手动回滚
|
||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||
return new RestResult(Constant.FAILED, "处理失败");
|
||
}
|
||
}
|
||
|
||
@SuppressWarnings("unchecked")
|
||
public GreenApplyList getParkCarInfo(GreenApplyList greenApplyList, String userid, Map<String, String> user, Result restult) throws MyException{
|
||
//获取临时停车的审批权限
|
||
List<Map<String, Object>> queryRoleList = greenUserInfoController.queryRoleById1(userid);
|
||
if (queryRoleList.size() <= 0) {
|
||
throw new MyException("该角色暂无任何权限,请联系管理员!");
|
||
}
|
||
GreenApplyList old = null;
|
||
// 切割查询的权限
|
||
|
||
if(queryRoleList.get(0).get("userRole") == null || "".equals(queryRoleList.get(0).get("userRole"))){
|
||
|
||
throw new MyException("该角色暂无审批权限,请联系管理员!");
|
||
}
|
||
long pk = greenApplyList.getId();
|
||
old = greenApplyListBizc.get(pk);
|
||
String[] userRoleArr = queryRoleList.get(0).get("userRole").toString().split(",");
|
||
List strsToList1= Arrays.asList(userRoleArr);
|
||
if(strsToList1.contains("temp_park_section") && greenApplyList.getFirstStatus().equals("0")){
|
||
if(restult.getStatus()!=null && restult.getStatus().equals("1")){
|
||
if(strsToList1.contains("temp_park_approve")){
|
||
if(strsToList1.contains("temp_park_authorize")){
|
||
//停车授权3级审批(当前人同时有123级权限)
|
||
String msgname1 = "授权通知";
|
||
old.setFirstStatus(restult.getStatus());
|
||
old.setFirstApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
////停车授权2级审批
|
||
old.setSecondStatus(restult.getStatus());
|
||
old.setSecondApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
old.setThirdStatus(ApplyRoleConstant.THIRDSTASTUS);
|
||
old.setThirdApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
GreenUserInfo userInfo = getUserInfo(greenApplyList.getUserId());
|
||
// 推送消息给申请人
|
||
try {
|
||
PushMessageUtil.getInstance().pushMessage(msgname1,"您有一个【临时停车申请】已授权", userInfo.getLoginName(),hibernateDao);
|
||
} catch (IOException e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
}else{
|
||
//同时有一二级权限
|
||
old.setFirstStatus(restult.getStatus());
|
||
old.setFirstApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
////停车授权2级审批
|
||
old.setSecondStatus(restult.getStatus());
|
||
old.setSecondApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
String userName = user.get("login_name");
|
||
// 推送消息给申请人
|
||
String msgname = "审批通知";
|
||
sendMsg("temp_park_authorize",msgname, "您有一个【临时停车申请】待审批", userName,hibernateDao);
|
||
}
|
||
}else if(strsToList1.contains("temp_park_authorize") && greenApplyList.getThirdStatus().equals("1")){
|
||
//停车授权3级审批
|
||
String msgname1 = "授权通知";
|
||
old.setThirdStatus(ApplyRoleConstant.THIRDSTASTUS);
|
||
old.setThirdApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
GreenUserInfo userInfo = getUserInfo(greenApplyList.getUserId());
|
||
// 推送消息给申请人
|
||
try {
|
||
PushMessageUtil.getInstance().pushMessage(msgname1,"您有一个【临时停车申请】待授权", userInfo.getLoginName(),hibernateDao);
|
||
} catch (IOException e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
}else{
|
||
//停车授权1级审批
|
||
old.setFirstStatus(restult.getStatus());
|
||
old.setFirstApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
String userName = user.get("login_name");
|
||
|
||
// 推送消息给申请人
|
||
String msgname = "审批通知";
|
||
try {
|
||
PushMessageUtil.getInstance().pushMessage(msgname, "您有一个【临时停车申请】待审批", userName,hibernateDao);
|
||
} catch (IOException e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}else{
|
||
String msgname = "申请通知";
|
||
String tm = "您提交的【临时停车申请】已被拒绝。";
|
||
old.setFirstStatus(restult.getStatus());
|
||
old.setFirstApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
GreenUserInfo userInfo = getUserInfo(greenApplyList.getUserId());
|
||
// 推送消息给申请人
|
||
try {
|
||
PushMessageUtil.getInstance().pushMessage(msgname, tm, userInfo.getLoginName(),hibernateDao);
|
||
} catch (IOException e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
|
||
}else if(strsToList1.contains("temp_park_approve") && greenApplyList.getFirstStatus().equals("1") &&greenApplyList.getSecondStatus().equals("0")){
|
||
if(restult.getStatus()!=null && restult.getStatus().equals("1")){
|
||
//停车授权3级审批
|
||
if(strsToList1.contains("temp_park_authorize")){
|
||
String msgname1 = "授权通知";
|
||
GreenUserInfo userInfo = getUserInfo(greenApplyList.getUserId());
|
||
old.setSecondStatus(restult.getStatus());
|
||
old.setSecondApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
old.setThirdStatus(ApplyRoleConstant.THIRDSTASTUS);
|
||
old.setThirdApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
// 推送消息给申请人
|
||
try {
|
||
PushMessageUtil.getInstance().pushMessage(msgname1, "您有一个【临时停车申请】已授权", userInfo.getLoginName(),hibernateDao);
|
||
} catch (IOException e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
}else{
|
||
////停车授权2级审批
|
||
String userName = user.get("login_name");
|
||
// 推送消息给申请人
|
||
String msgname = "审批通知";
|
||
old.setSecondStatus(restult.getStatus());
|
||
old.setSecondApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
sendMsg("temp_park_authorize",msgname, "您有一个【临时停车申请】待审批", userName,hibernateDao);
|
||
|
||
}
|
||
}else{
|
||
//二级审批被拒绝
|
||
String msgname = "申请通知";
|
||
String tm = "您提交的【临时停车申请】已被拒绝。";
|
||
old.setSecondStatus(restult.getStatus());
|
||
old.setSecondApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
GreenUserInfo userInfo = getUserInfo(greenApplyList.getUserId());
|
||
// 推送消息给申请人
|
||
try {
|
||
PushMessageUtil.getInstance().pushMessage(msgname, tm, userInfo.getLoginName(),hibernateDao);
|
||
} catch (IOException e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
else{
|
||
//停车授权3级审批
|
||
if(strsToList1.contains("temp_park_authorize")){
|
||
GreenUserInfo userInfo = getUserInfo(greenApplyList.getUserId());
|
||
String msgname1 = "授权通知";
|
||
old.setThirdStatus(ApplyRoleConstant.THIRDSTASTUS);
|
||
old.setThirdApproveTime(new SimpleDateFormat(DateUtil.Y_M_DH_MI_S).format(new Date()));
|
||
// 推送消息给申请人
|
||
try {
|
||
PushMessageUtil.getInstance().pushMessage(msgname1, "您的【临时停车申请】已授权", userInfo.getLoginName(),hibernateDao);
|
||
} catch (IOException e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
return old;
|
||
|
||
}
|
||
|
||
@SuppressWarnings("unchecked")
|
||
public void sendMsg(String role_code,String msgname, String tm, String users,IHibernateDao hibernateDao){
|
||
String sql = "SELECT ui.login_name FROM green_role role , green_user_role_rel roler LEFT JOIN green_user_info ui ON roler.user_id = ui.id where role.role_code = ? AND role.id = roler.role_id and roler.is_deleted='N' and ui.is_deleted='N'";
|
||
List<Map<String,Object>> queryList = hibernateDao.queryForListWithSql(sql.toString(),new Object[]{role_code});
|
||
for (int i = 0; i < queryList.size(); i++) {
|
||
try {
|
||
PushMessageUtil.getInstance().pushMessage(msgname, tm, queryList.get(i).get("login_name").toString(),hibernateDao);
|
||
} catch (IOException e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* 批量审批
|
||
*
|
||
* @param list
|
||
* @return
|
||
*/
|
||
@RequestMapping(value = "/batchUpdateStatus", method = RequestMethod.POST)
|
||
@Transactional(rollbackFor = Exception.class)
|
||
// public @ResponseBody RestResult batchUpdateStatus(@RequestBody
|
||
// List<Map<String, Object>> list) {
|
||
public @ResponseBody RestResult batchUpdateStatus(HttpServletRequest request) {
|
||
Map<String, String> str = getBodyStr(request);
|
||
/*if (Utils.list.contains("greenVisitorInfo/batchUpdateStatus" + str.get("checkTime"))) {
|
||
return new RestResult(Constant.FAILED, "您的请求存在异常!请重新请求...");
|
||
} else {
|
||
Utils.list.add("greenVisitorInfo/batchUpdateStatus" + str.get("checkTime"));
|
||
}*/
|
||
// Object object = JSONArray.parse(bodyData);
|
||
|
||
Map<String, Object> map = JSONUtil.json2Object(str.get("bodyData"), Map.class);
|
||
String userId = "";
|
||
try {
|
||
List<Map<String, Object>> list = (List<Map<String, Object>>) map.get("applications");
|
||
userId = map.get("userId").toString();
|
||
for (Map<String, Object> map1 : list) {
|
||
Result result = new Result();
|
||
result.setUserId(userId);
|
||
result.setApplyId(map1.get("applyId").toString());
|
||
result.setApplyType(map1.get("applyType").toString());
|
||
result.setStatus(map1.get("status").toString());
|
||
result.setFlag("1");
|
||
try {
|
||
updateStatus(result);
|
||
} catch (Exception e) {
|
||
|
||
}
|
||
}
|
||
addLog(Constant.MY_APPLY, Constant.APPROVAL, Constant.OPERATE_SUCCESS, "批量审批申请",
|
||
Constant.LOG_OPERATE, userId);
|
||
return new RestResult(Constant.SUCCESS, "处理成功");
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
addLog(Constant.MY_APPLY, Constant.APPROVAL, Constant.OPERATE_SUCCESS, "批量审批申请",
|
||
Constant.LOG_ERROR, userId);
|
||
// 设置手动回滚
|
||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||
return new RestResult(Constant.FAILED, "处理失败");
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 根据访客手机号获取访客详情
|
||
*
|
||
* @param stime
|
||
* @param etime
|
||
* @return
|
||
*/
|
||
@SuppressWarnings({ "unchecked", "unused" })
|
||
@RequestMapping(value = "/getVisitorInfoTel", method = RequestMethod.POST)
|
||
public @ResponseBody RestResult getVisitorInfoTel(@RequestBody Object requestBody) {
|
||
GreenVisitorInfo greenVisitorInfo = new ObjectMapper().convertValue(requestBody,
|
||
new TypeReference<GreenVisitorInfo>() {
|
||
});
|
||
try {
|
||
String visitorTel = (StringUtils.isBlank(greenVisitorInfo.getVisitorTel())) ? ""
|
||
: greenVisitorInfo.getVisitorTel();
|
||
|
||
if (greenVisitorInfo != null) {
|
||
String visitorInfoSql = "SELECT IDcard_pic1 pic1,IDcard_pic2 pic2 FROM GREEN_VISITOR_INFO WHERE visitor_tel=? limit 1";
|
||
List<Map<String, Object>> visitorInfolist = hibernateDao.queryForListWithSql(visitorInfoSql,
|
||
new Object[] { visitorTel });
|
||
|
||
for (Map<String, Object> info : visitorInfolist) {
|
||
String pic1name = String.valueOf(info.get("pic1"));
|
||
String pic2name = String.valueOf(info.get("pic2"));
|
||
String pic1Data = BaseService.getImageBase64(pic1name);
|
||
String pic2Data = BaseService.getImageBase64(pic2name);
|
||
info.put("pic1", pic1Data);
|
||
info.put("pic2", pic2Data);
|
||
System.out.println("======== pic1:" + pic1name + " pic2:" + pic2name);
|
||
}
|
||
|
||
return new RestResult(Constant.SUCCESS, "请求成功", visitorInfolist);
|
||
}
|
||
return new RestResult(Constant.FAILED, "手机号为空");
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
return new RestResult(Constant.FAILED, "请求失败");
|
||
}
|
||
}
|
||
|
||
public static List<String> getBetweenDays(String stime, String etime) {
|
||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
||
Date sdate = null;
|
||
Date eDate = null;
|
||
List<String> list = null;
|
||
try {
|
||
sdate = df.parse(stime);
|
||
eDate = df.parse(etime);
|
||
Calendar c = Calendar.getInstance();
|
||
list = new ArrayList<String>();
|
||
if (sdate != null & eDate != null) {
|
||
while (sdate.getTime() <= eDate.getTime()) {
|
||
list.add(df.format(sdate));
|
||
c.setTime(sdate);
|
||
c.add(Calendar.DATE, 1); // 日期加1天
|
||
sdate = c.getTime();
|
||
}
|
||
}
|
||
} catch (ParseException e) {
|
||
e.printStackTrace();
|
||
}
|
||
|
||
return list;
|
||
}
|
||
|
||
|
||
/**
|
||
* 获取用户历史来访人员信息列表
|
||
* @param requestBody
|
||
* @return
|
||
*/
|
||
@RequestMapping(value = "/listReason", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public RestResult listReason(@RequestBody Object requestBody){
|
||
String sql = "select * from green_visitor_reason ";
|
||
List list = hibernateDao.queryForListWithSql(sql);
|
||
return new RestResult(Constant.SUCCESS, list);
|
||
}
|
||
|
||
|
||
@SuppressWarnings({ "unchecked", "unused" })
|
||
@RequestMapping(value = "/getVisitorList", method = RequestMethod.POST)
|
||
public RestResult getVisitorList(@RequestBody Object requestBody,HttpServletRequest request){
|
||
|
||
GreenVisitorRetinueInfo greenVisitorRetinueInfo = new ObjectMapper().convertValue(requestBody,
|
||
new TypeReference<GreenVisitorRetinueInfo>() {
|
||
});
|
||
|
||
List<Map<String, Object>> dictionaryInfo = greenDictionaryInfoController.getDictionaryInfo("getVisitNum");
|
||
int getVisitNum = Integer.valueOf(dictionaryInfo.get(0).get("data_value")+"");
|
||
|
||
String visitorSql = "SELECT retion.retinue_name retinueName, retion.idcard,count(retion.idcard) FROM green_retinue_info retion WHERE "
|
||
+ " retion.visitor_id IN (SELECT visinfo.id FROM green_visitor_info visinfo WHERE 1 = 1 AND visinfo.is_deleted = 'N' "
|
||
+ " AND visinfo.visited_person_id = ? ) AND retion.is_deleted = 'N' GROUP BY retion.retinue_name ,retion.idcard ORDER BY COUNT(retion.idcard) DESC LIMIT 0,"+getVisitNum;
|
||
List<HashMap<String, String>> list = hibernateDao.queryForListWithSql(visitorSql,new Object[]{greenVisitorRetinueInfo.getUserId()});
|
||
|
||
for (int i = 0; i < list.size(); i++) {
|
||
|
||
String idcard = "";
|
||
try {
|
||
if(list.get(i).get("idcard")!=null && !list.get(i).get("idcard").equals("")){
|
||
idcard = AesEncryptUtil.desEncrypt(list.get(i).get("idcard"));
|
||
}
|
||
} catch (Exception e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
list.get(i).put("idcard", idcard.trim());
|
||
}
|
||
return new RestResult(Constant.SUCCESS, list);
|
||
}
|
||
|
||
|
||
/**
|
||
*
|
||
* @param userID 当前登录用户ID
|
||
* @param idcard 身份证号
|
||
* @param retinueName 拜访人姓名
|
||
* @param visitedPersonName 被访人姓名
|
||
* @param visitReason 拜访事由
|
||
* @param visitStartTime 开始时间
|
||
* @param visitEndTime 结束时间
|
||
* @param pkId uuid
|
||
* @param endTime 结束预约时间
|
||
* @return
|
||
*/
|
||
public boolean visitorMsg(String userID,String idcard,String retinueName,String visitedPersonName,
|
||
String visitReason,String visitStartTime,String visitEndTime,String pkId,String endTime ,String stayArea,String visitedPersonDepartmentName){
|
||
|
||
// HashMap<String, Object> content = new HashMap<String, Object>();
|
||
// content.put("name", retinueName);//必传字段
|
||
// content.put("gender", 0);//必传字段
|
||
// content.put("orgname", "");
|
||
// content.put("telephone","");
|
||
// content.put("credtype", 2);
|
||
// content.put("credentialnumber" ,idcard);//必传字段
|
||
// content.put("targetdep", "");
|
||
// content.put("targetperson", visitedPersonName);
|
||
// content.put("building", "");
|
||
// content.put("floor", "");
|
||
//
|
||
// content.put("purpose",visitReason);
|
||
// content.put("carrying", "");
|
||
// content.put("plate", "");
|
||
// content.put("validfrom", visitStartTime);//必传字段
|
||
// content.put("validto",visitEndTime);//必传字段
|
||
try{
|
||
List<Map<String, String>> dictionaryInfo = greenDictionaryInfoController.getDictionaryInfo("visitAddUserUrl","1");
|
||
|
||
Date startDate = new DateTime().strToDate(visitStartTime, "yyyy-MM-dd HH:mm");
|
||
|
||
List<Map<String, Object>> dictionaryInfo1= greenDictionaryInfoController.getDictionaryInfo("visitChageCardTime");
|
||
|
||
String putOffTime = dictionaryInfo1.get(0).get("data_value").toString();
|
||
|
||
visitStartTime = new DateTime(startDate).addMinutes(-Integer.valueOf(putOffTime)).toString();
|
||
System.out.println("visitStartTime===:"+visitStartTime);
|
||
OkHttpClient okHttpClient = new OkHttpClient();
|
||
okhttp3.RequestBody body = new FormBody.Builder()
|
||
.add("name", retinueName)
|
||
.add("gender", "0")
|
||
.add("orgName", "")
|
||
.add("telephone", "")
|
||
.add("credType", "2")
|
||
.add("credentialNumber", idcard.trim())
|
||
.add("targetDep", visitedPersonDepartmentName)
|
||
.add("targetPerson", visitedPersonName)
|
||
.add("building",stayArea)
|
||
.add("floor", "")
|
||
.add("purpose",visitReason)
|
||
.add("carrying", "")
|
||
.add("plate", "")
|
||
.add("fromTime", visitStartTime)
|
||
.add("toTime", visitEndTime)
|
||
.add("endTime", endTime)
|
||
.add("pkId", pkId)
|
||
.build();
|
||
String url = dictionaryInfo.get(0).get("data_value")+"";;
|
||
System.err.println(DateTime.dateToStr(new Date())+"-1111--->visitorMsg"+"--url-->"+url.toString());
|
||
Request request = new Request.Builder()
|
||
.url(url)
|
||
.post(body)
|
||
.build();
|
||
Call call = okHttpClient.newCall(request);
|
||
Response response = call.execute();
|
||
String responseContetn = response.body().string();
|
||
// {"errcode":0,"errmsg":"ok","totalcount":0,"data":null}
|
||
JSONObject responsejsonObject = new JSONObject().fromObject(responseContetn);
|
||
int code = responsejsonObject.getInt("returnCode");
|
||
System.err.println(DateTime.dateToStr(new Date())+"-222--->"+responsejsonObject.toString());
|
||
if(code == 0 ){
|
||
// JSONObject data = responsejsonObject.getJSONObject("data");
|
||
return true;
|
||
}else{
|
||
return false;
|
||
}
|
||
}catch (Exception e) {
|
||
// TODO: handle exception
|
||
System.err.println(DateTime.dateToStr(new Date())+"-333--->"+e.getMessage());
|
||
return false;
|
||
}
|
||
// return sendVisitorMes(content,userID);
|
||
}
|
||
|
||
/**
|
||
* 向门禁系统添加访客信息
|
||
* @param content
|
||
* @return
|
||
*/
|
||
public boolean sendVisitorMes(HashMap<String, Object> content,String userId){
|
||
try {
|
||
|
||
|
||
List<Map<String, Object>> dictionaryInfo = greenDictionaryInfoController.getDictionaryInfo("visitAddUserUrl");
|
||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||
map.put(dictionaryInfo.get(1).get("data_code")+"", dictionaryInfo.get(1).get("data_value")+"");
|
||
map.put("timestamp", Long.valueOf("636132491337817532"));
|
||
map.put("nonce", "0978730774");
|
||
map.put(dictionaryInfo.get(2).get("data_code")+"", dictionaryInfo.get(2).get("data_value")+"");
|
||
map.put(dictionaryInfo.get(3).get("data_code")+"", dictionaryInfo.get(3).get("data_value")+"");
|
||
map.put("accountname", "");
|
||
map.put("data", content);
|
||
String url = "http://36.33.24.132:19080/visitor/control/visitor/addRecord";
|
||
// dictionaryInfo.get(0).get("data_value")+"";
|
||
String contentJson = JSON.toJSONString(map);
|
||
OkHttpClient okHttpClient = new OkHttpClient();
|
||
|
||
okhttp3.RequestBody body = new FormBody.Builder()
|
||
.add("account", "administrator")
|
||
.add("password", "administrator")
|
||
.add("account", "administrator")
|
||
.add("account", "administrator")
|
||
.add("account", "administrator")
|
||
.add("account", "administrator")
|
||
.add("account", "administrator")
|
||
.add("account", "administrator")
|
||
.add("account", "administrator")
|
||
.add("account", "administrator")
|
||
.add("account", "administrator")
|
||
.add("account", "administrator")
|
||
.build();
|
||
|
||
// okhttp3.RequestBody body = new FormBody.Builder()
|
||
// .add("param", contentJson)
|
||
// .build();
|
||
Request request = new Request.Builder()
|
||
.url(url)
|
||
.post(body)
|
||
.build();
|
||
Call call = okHttpClient.newCall(request);
|
||
Response response = call.execute();
|
||
String responseContetn = response.body().string();
|
||
// {"errcode":0,"errmsg":"ok","totalcount":0,"data":null}
|
||
JSONObject responsejsonObject = new JSONObject().fromObject(responseContetn);
|
||
int code = responsejsonObject.getInt("errcode");
|
||
if(code == 0 ){
|
||
// JSONObject data = responsejsonObject.getJSONObject("data");
|
||
return true;
|
||
}else{
|
||
|
||
return false;
|
||
}
|
||
} catch (IOException e) {
|
||
e.printStackTrace();
|
||
saveErorrLog("门禁系统-新增访客", Constant.INSERT, Constant.OPERATE_FAIL,"调用门禁系统访客新增接口失败。","0",userId);
|
||
return false;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* 预约申请的审批
|
||
*
|
||
* @param restult
|
||
* @return
|
||
*/
|
||
@SuppressWarnings({ "unchecked", "deprecation", "rawtypes" })
|
||
@Transactional(rollbackFor = Exception.class)
|
||
@RequestMapping(value = "/updateVisitorStatus", method = RequestMethod.POST)
|
||
public @ResponseBody RestResult updateVisitorStatus(@RequestBody Object requestBody) {
|
||
Result restult = new ObjectMapper().convertValue(requestBody, new TypeReference<Result>() { });
|
||
try {
|
||
// 根据用户id查询该用户具有的权限
|
||
List<Map<String, Object>> queryRoleList = greenUserInfoController.queryRoleById(restult.getUserId());
|
||
|
||
// if (queryRoleList.size() <= 0) {
|
||
// return new RestResult(Constant.FAILED, "该角色暂无任何权限,请联系管理员!");
|
||
// }
|
||
// 切割查询的权限
|
||
// if(queryRoleList.get(0).get("userRole") == null || "".equals(queryRoleList.get(0).get("userRole"))){
|
||
// return new RestResult(Constant.FAILED, "该角色暂无审批权限,请联系管理员!");
|
||
// }
|
||
// String[] userRoleArr = queryRoleList.get(0).get("userRole").toString().split(",");
|
||
// GreenApplyList old = null;
|
||
// 根据申请详情id查询申请列表list
|
||
String applyListSql = "SELECT * from GREEN_APPLY_LIST WHERE detail_id = ? ";
|
||
// 执行查询sql
|
||
List<GreenApplyList> list = hibernateDao.queryForListWithSql(applyListSql, new Object[] { restult.getApplyId()},
|
||
new BeanPropertyRowMapper(GreenApplyList.class));
|
||
// String subSql = "SELECT ui.login_name submitter from GREEN_APPLY_LIST al "
|
||
// + "LEFT JOIN green_user_info ui on ui.is_deleted = 'N' AND ui.id = al.user_id "
|
||
// + "WHERE al.is_deleted = 'N' and al.detail_id = ? AND al.apply_type = ? ";
|
||
if (list.size() > 0) {
|
||
GreenApplyList greenApplyList = list.get(0);
|
||
|
||
String type = restult.getApplyType();
|
||
String userLevel = restult.getUserLevel();
|
||
String firstStatus = greenApplyList.getFirstStatus();
|
||
if("1".equals(userLevel)){
|
||
firstStatus = greenApplyList.getSecondStatus();
|
||
}else if("2".equals(userLevel)){
|
||
firstStatus = greenApplyList.getThirdStatus();
|
||
}else if("8".equals(userLevel)){
|
||
firstStatus = greenApplyList.getCurrentStatus().substring(1, 2);
|
||
}
|
||
|
||
if("3".equals(type)){//删除
|
||
String updateSql = "UPDATE green_apply_list t SET t.is_deleted = 'Y' WHERE t.detail_id = ? ";
|
||
String updateSql2 = "UPDATE GREEN_VISITOR_INFO v SET v.is_deleted = 'Y' WHERE v.id = ?";
|
||
String updateSql3 = "UPDATE green_retinue_info r SET r.is_deleted = 'Y' WHERE r.visitor_id = ?";
|
||
hibernateDao.executeSqlUpdate(updateSql,new Object[]{greenApplyList.getDetailId()});
|
||
hibernateDao.executeSqlUpdate(updateSql2,new Object[]{greenApplyList.getDetailId()});
|
||
hibernateDao.executeSqlUpdate(updateSql3,new Object[]{greenApplyList.getDetailId()});
|
||
return new RestResult(Constant.SUCCESS, "删除成功!");
|
||
} else {
|
||
if (!"0".equals(firstStatus)&&!"6".equals(firstStatus)) {// 判断一级审批状态是否已审批
|
||
return new RestResult(Constant.SUCCESS, "该记录已经审核完毕,不能取消");
|
||
} else {
|
||
String tip = "";
|
||
if("0".equals(type)){//取消
|
||
String updateSql = "UPDATE GREEN_APPLY_LIST SET first_status = 4 WHERE detail_id = ? ";
|
||
hibernateDao.executeSqlUpdate(updateSql,new Object[]{greenApplyList.getDetailId()});
|
||
}else if("1".equals(type)){//拒绝
|
||
String statusLevel="first_status";
|
||
String current_status="12";
|
||
if("1".equals(userLevel)){//uesrLevel 专责0 处长 1,主任2 审批中心 8
|
||
statusLevel = "second_status";
|
||
current_status="22";
|
||
}else if("2".equals(userLevel)){
|
||
statusLevel = "third_status";
|
||
current_status="32";
|
||
}else if("8".equals(userLevel)){
|
||
statusLevel = "ninth_status";
|
||
current_status="92";
|
||
}
|
||
String updateSql = "UPDATE GREEN_APPLY_LIST SET "+statusLevel+" = 2,current_status='"+current_status+"' WHERE detail_id = ? ";
|
||
hibernateDao.executeSqlUpdate(updateSql,new Object[]{greenApplyList.getDetailId()});
|
||
tip = "审批未通过";
|
||
}else if("2".equals(type)){//同意
|
||
String statusLevel="first_status";
|
||
String current_status="20";//专责审核同意后需要流转到下一级,所以当前状态应该是待审核
|
||
List<Map<String, String>> approvalCenterList = BaseService.getDictionaryInfo("approvalCenter", "001");
|
||
String approvalCenter = approvalCenterList.get(0).get("data_value");
|
||
String appointmentType = restult.getAppointmentType();//获取来访类型 0普通访客 1参会人员
|
||
if("0".equals(userLevel)){
|
||
if("1".equals(appointmentType)){
|
||
statusLevel="first_status";
|
||
//current_status="20";//专责审核同意后需要流转到下一级,所以当前状态应该是待审核
|
||
if("1".equals(approvalCenter)){
|
||
current_status="90";
|
||
}else{
|
||
current_status="11";
|
||
tip = "审批通过";
|
||
}
|
||
}else{
|
||
statusLevel="first_status";
|
||
current_status="20";//专责审核同意后需要流转到下一级,所以当前状态应该是待审核
|
||
}
|
||
|
||
}else if("1".equals(userLevel)){
|
||
statusLevel = "second_status";
|
||
if("1".equals(approvalCenter)){//处长审核同意后不可流转,所以判断审批中心是否开启
|
||
current_status="90";//开启,当前状态应该是待审批中心审核
|
||
}else{
|
||
current_status="21";//关闭,当前状态应该是同意
|
||
tip = "审批通过";
|
||
}
|
||
}else if("2".equals(userLevel)){//主任审批
|
||
statusLevel = "third_status";
|
||
if("1".equals(approvalCenter)){
|
||
current_status="90";
|
||
}else{
|
||
current_status="31";
|
||
tip = "审批通过";
|
||
}
|
||
|
||
}else if("8".equals(userLevel)){//审批中心审批
|
||
statusLevel = "ninth_status";
|
||
current_status="91";
|
||
tip = "审批通过";
|
||
}
|
||
String updateSql = "UPDATE GREEN_APPLY_LIST SET "+statusLevel+" = 1,current_status='"+current_status+"' WHERE detail_id = ? ";
|
||
hibernateDao.executeSqlUpdate(updateSql,new Object[]{greenApplyList.getDetailId()});
|
||
|
||
String visitorsql = "SELECT * from green_visitor_info WHERE id = ? ";
|
||
// 执行查询sql
|
||
List<Map<String,Object>> visitorlist = hibernateDao.queryForListWithSql(visitorsql, new Object[] { greenApplyList.getDetailId()});
|
||
String idnum = visitorlist.get(0).get("idcard").toString();
|
||
try {
|
||
idnum = AesEncryptUtil.desEncrypt(idnum);
|
||
} catch (Exception e1) {
|
||
// TODO Auto-generated catch block
|
||
e1.printStackTrace();
|
||
}
|
||
// String path = "D:\\tomcatWork\\apache-tomcat-7.0.47-test\\webapps\\";
|
||
String path = "/home/appImageDir/zhhq_gs/";
|
||
path = path+visitorlist.get(0).get("FACE_pic1").toString();
|
||
|
||
// path = path.replace("/", "\\");//Windows系统
|
||
//path = Base64Utils.ImageToBase64ByLocal(path);
|
||
path = Base64Utils.ImageToBase64ByLocal(path);
|
||
sendVisitorMsg(visitorlist.get(0).get("visitor_name").toString(),path,idnum);
|
||
|
||
// sendVisitorMsg(visitorlist.get(0).get("visitor_name").toString(),path,idnum,visitorlist.get(0).get("visit_start_time").toString(),visitorlist.get(0).get("visited_person_name").toString());
|
||
|
||
}
|
||
if (!tip.equals("")) {
|
||
// 通知用户
|
||
GreenUserInfo user = getUserInfo(greenApplyList.getUserId());
|
||
if (user != null) {
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||
Map<String, ContentVo> data = new HashMap<String, ContentVo>();
|
||
data.put("first", new ContentVo("尊敬的用户,您的访客申请审核结果已出", "#173177"));
|
||
data.put("keyword1", new ContentVo(tip, "#black"));
|
||
data.put("keyword2", new ContentVo(greenApplyList.getApplyTime(), "#black"));
|
||
data.put("remark", new ContentVo("感谢您的参与和支持", "#173177"));
|
||
wService.publishMsg(data, user.getWxOpenId(), 2);
|
||
}
|
||
}
|
||
return new RestResult(Constant.SUCCESS, "操作成功!");
|
||
}
|
||
}
|
||
}else{
|
||
return new RestResult(Constant.SUCCESS, "不存在该记录!");
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
return new RestResult(Constant.FAILED, "处理失败");
|
||
}
|
||
}
|
||
|
||
|
||
@SuppressWarnings("unchecked")
|
||
@Transactional(rollbackFor = Exception.class)
|
||
@RequestMapping(value = "/saveInviteInfo", method = RequestMethod.POST)
|
||
public @ResponseBody RestResult saveInviteInfo(@RequestBody Object requestBody, HttpServletRequest request) {
|
||
GreenVisitorRetinueInfo greenVisitorRetinueInfo = new ObjectMapper().convertValue(requestBody, new TypeReference<GreenVisitorRetinueInfo>() { });
|
||
String userId = greenVisitorRetinueInfo.getUserId();
|
||
Long id = greenVisitorRetinueInfo.getId();
|
||
|
||
GreenUserInfo info = getUserInfo(userId);
|
||
// GreenGrantAuth gaInfo = getGaInfo(userId);
|
||
if (info == null) {
|
||
return new RestResult(Constant.FAILED, "非法用户");
|
||
}
|
||
//确认状态
|
||
String state = "select t.first_status from green_apply_list t where t.detail_id = ?";
|
||
List<Map<String, String>> stateList = hibernateDao.queryForListWithSql(state, new Object[] { id });
|
||
if(stateList.size() <= 0){
|
||
return new RestResult(Constant.FAILED, "没有该记录!");
|
||
}else{
|
||
String first_status = stateList.get(0).get("first_status");
|
||
if(!"3".equals(first_status)){
|
||
return new RestResult(Constant.FAILED, "该记录已经提交!");
|
||
}
|
||
}
|
||
//本人确认,同时添加照片
|
||
String imgsql = "select t.iDcard_pic1,t.iDcard_pic1_data,t.iDcard_pic2,t.iDcard_pic2_data from green_visitor_info t where t.id = ?";
|
||
List<Map<String, String>> imglist = hibernateDao.queryForListWithSql(imgsql, new Object[] { id });
|
||
if(imglist.size() > 0){
|
||
// 身份证照片1
|
||
String picture1 = greenVisitorRetinueInfo.getIdcardPic1() == null ? "" : greenVisitorRetinueInfo.getIdcardPic1();
|
||
String picture2 = greenVisitorRetinueInfo.getIdcardPic2() == null ? "" : greenVisitorRetinueInfo.getIdcardPic2();
|
||
String pic1 = imglist.get(0).get("iDcard_pic1") == null ? "" : imglist.get(0).get("iDcard_pic1");
|
||
String pic2 = imglist.get(0).get("iDcard_pic2") == null ? "" : imglist.get(0).get("iDcard_pic2");
|
||
Boolean flag = true;
|
||
|
||
String picture = "";
|
||
String pictureData1 = "";
|
||
String picture22 = "";
|
||
String pictureData2 = "";
|
||
ArrayList<Object> params = new ArrayList<Object>();
|
||
if(!"".equals(picture1)){
|
||
// String uuid = "";
|
||
// try {
|
||
// uuid = greenImageInfoController.saveImage(picture1, userId);
|
||
// } catch (Exception e) {
|
||
// // TODO Auto-generated catch block
|
||
// e.printStackTrace();
|
||
// }
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||
String date = sdf.format(new Date()) + "/";
|
||
String uuid = date + UUID.randomUUID().toString().replaceAll("-","");
|
||
flag = baseService.saveImgToIO(uuid+Constant.IMG_SUFFIX, picture1);
|
||
picture = uuid+Constant.IMG_SUFFIX;
|
||
pictureData1 = uuid;
|
||
}
|
||
|
||
//清除图片地址信息
|
||
baseService.initImage();
|
||
|
||
params.add(picture);
|
||
params.add(pictureData1);
|
||
// 身份证照片2
|
||
if(!"".equals(picture2)){
|
||
// String uuid = "";
|
||
// try {
|
||
// uuid = greenImageInfoController.saveImage(picture2, userId);
|
||
// } catch (Exception e) {
|
||
// // TODO Auto-generated catch block
|
||
// e.printStackTrace();
|
||
// }
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||
String date = sdf.format(new Date()) + "/";
|
||
String uuid = date + UUID.randomUUID().toString().replaceAll("-","");
|
||
flag = baseService.saveImgToIO(uuid+Constant.IMG_SUFFIX, picture2);
|
||
picture22 = uuid+Constant.IMG_SUFFIX;
|
||
pictureData2 = uuid;
|
||
}
|
||
params.add(picture22);
|
||
params.add(pictureData2);
|
||
String updateSql = "UPDATE GREEN_VISITOR_INFO t SET t.iDcard_pic1 = ? ,t.iDcard_pic1_data = ? ,t.iDcard_pic2 = ? ,t.iDcard_pic2_data = ? WHERE t.id = ? ";
|
||
params.add(id);
|
||
hibernateDao.executeSqlUpdate(updateSql, params.toArray());
|
||
|
||
String updateState = "UPDATE GREEN_APPLY_LIST SET first_status = 1 WHERE detail_id = ? ";
|
||
hibernateDao.executeSqlUpdate(updateState,new Object[]{id});
|
||
return new RestResult(Constant.FAILED, "提交成功!");
|
||
}else {
|
||
return new RestResult(Constant.FAILED, "没有该记录!");
|
||
}
|
||
}
|
||
public boolean sendVisitorMsg(String name,String picPath,String idNum){
|
||
try {
|
||
System.err.println("消息推送");
|
||
OkHttpClient okHttpClient = new OkHttpClient();
|
||
okhttp3.RequestBody body = new FormBody.Builder()
|
||
.add("name", name)
|
||
.add("picPath", picPath)
|
||
.add("idNum", idNum)
|
||
.build();
|
||
// String url = "http://192.168.43.9:19001/zhhq/control/userInfo/queryPersonInfoByPage";
|
||
String url = "http://36.33.24.132:19001/zhhq/control/userInfo/queryPersonInfoByPage";
|
||
|
||
Request request = new Request.Builder()
|
||
.url(url)
|
||
.post(body)
|
||
.build();
|
||
Call call = okHttpClient.newCall(request);
|
||
Response response = call.execute();
|
||
|
||
/*String responseContetn = response.body().string();
|
||
JSONObject responsejsonObject = new JSONObject().fromObject(responseContetn);
|
||
int code = responsejsonObject.getInt("returnCode");
|
||
System.err.println(DateTime.dateToStr(new Date())+"-222--->"+responsejsonObject.toString());
|
||
if(code == 0 ){
|
||
return true;
|
||
}else{
|
||
return false;
|
||
}*/
|
||
} catch (Exception e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
return false;
|
||
}
|
||
public boolean sendVisitorMsg(String name,String picPath,String idNum,String time,String user){
|
||
try {
|
||
System.err.println("消息推送");
|
||
OkHttpClient okHttpClient = new OkHttpClient();
|
||
okhttp3.RequestBody body = new FormBody.Builder()
|
||
.add("name", name)
|
||
.add("picPath", picPath)
|
||
.add("idNum", idNum)
|
||
.build();
|
||
String url = "http://127.0.0.1:19001/zhhq/control/userInfo/queryPersonInfoByPage";
|
||
|
||
Request request = new Request.Builder()
|
||
.url(url)
|
||
.post(body)
|
||
.build();
|
||
Call call = okHttpClient.newCall(request);
|
||
Response response = call.execute();
|
||
String responseContetn = response.body().string();
|
||
// {"errcode":0,"errmsg":"ok","totalcount":0,"data":null}
|
||
|
||
|
||
|
||
JSONObject responsejsonObject = new JSONObject().fromObject(responseContetn);
|
||
int code = responsejsonObject.getInt("code");
|
||
System.err.println(DateTime.dateToStr(new Date())+"-222--->"+responsejsonObject.toString());
|
||
|
||
|
||
|
||
addLog(Constant.VISITOR, Constant.APPROVAL, Constant.OPERATE_FAIL,name+ "审批申请",
|
||
Constant.LOG_OPERATE,"");
|
||
if(code == 0 ){
|
||
|
||
// JSONObject data = responsejsonObject.getJSONObject("data"); 访客 刘雷 于 20202 拜访 刘雷 ,人员信息入库失败
|
||
addLog(Constant.VISITOR, Constant.APPROVAL, Constant.OPERATE_SUCCESS,"访客’"+name+"‘于"+time+"拜访‘"+user+"’,人员信息入库成功",
|
||
Constant.LOG_OPERATE,"");
|
||
|
||
// JSONObject data = responsejsonObject.getJSONObject("data");
|
||
|
||
|
||
return true;
|
||
}else{
|
||
addLog(Constant.VISITOR, Constant.APPROVAL, Constant.OPERATE_FAIL,"访客‘"+name+"’于"+time+"拜访‘"+user+"’,人员信息入库失败",
|
||
Constant.LOG_OPERATE,"");
|
||
return false;
|
||
}
|
||
} catch (Exception e) {
|
||
// TODO Auto-generated catch block
|
||
addLog(Constant.VISITOR, Constant.APPROVAL, Constant.OPERATE_FAIL,"访客‘"+name+"’于"+time+"拜访‘"+user+"’,人员信息入库失败",
|
||
Constant.LOG_OPERATE,"");
|
||
e.printStackTrace();
|
||
}
|
||
return false;
|
||
}
|
||
/**
|
||
* 查询我的预约申请列表和我的邀约列表
|
||
*
|
||
* @param result
|
||
* @return
|
||
*/
|
||
@SuppressWarnings("unchecked")
|
||
@RequestMapping(value = "/getMyVisitorList", method = RequestMethod.POST)
|
||
public @ResponseBody RestResult getMyVisitorList(@RequestBody Object requestBody) {
|
||
Result result = new ObjectMapper().convertValue(requestBody, new TypeReference<Result>() {
|
||
});
|
||
try {
|
||
String userId = result.getUserId();
|
||
String userLevel = result.getUserLevel()==null?"0":result.getUserLevel();
|
||
GreenUserInfo info = getUserInfo(userId);
|
||
// GreenGrantAuth gaInfo = getGaInfo(userId);
|
||
if (info == null) {
|
||
return new RestResult(Constant.FAILED, "非法用户");
|
||
}
|
||
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
|
||
StringBuffer myWaitHandleListSql = new StringBuffer("SELECT vi.push_state,al.user_id,al.detail_id, vi.visited_person_name,");
|
||
myWaitHandleListSql.append(" vi.visit_start_time, vi.visitor_name, vi.org_name orgName,vi.visit_reason,al.*,user.identityAuth,user.userLevel ");
|
||
myWaitHandleListSql.append(" FROM GREEN_APPLY_LIST al LEFT JOIN green_user_info user ON user.id = al.user_id ");
|
||
myWaitHandleListSql.append(" LEFT JOIN green_visitor_info vi ON vi.id = al.detail_id ");
|
||
myWaitHandleListSql.append(" LEFT JOIN green_department dp ON user.department_id = dp.id ");
|
||
myWaitHandleListSql.append(" WHERE al.apply_type = '02' ");
|
||
myWaitHandleListSql.append(" AND al.is_deleted = 'N' and vi.is_deleted = 'N'");
|
||
//判断是邀约记录还是审批授权
|
||
String flag = result.getFlag();
|
||
String page = result.getPage();
|
||
String pageSize = result.getPageSize();
|
||
ArrayList<Object> params = new ArrayList<Object>();
|
||
if ("03".equals(result.getType())) {
|
||
if("1".equals(flag)){//审批列表
|
||
String approval = "";
|
||
String current_status = "";
|
||
if("0".equals(userLevel)){
|
||
approval = " and al.first_approval =? ";
|
||
params.add(userId);
|
||
}else if("1".equals(userLevel)){
|
||
approval = " and al.second_approval =? ";
|
||
params.add(userId);
|
||
}else if("2".equals(userLevel)){
|
||
approval = " and al.third_approval =? ";
|
||
params.add(userId);
|
||
}else if("8".equals(userLevel)){
|
||
|
||
}
|
||
myWaitHandleListSql.append(approval +" and vi.user_id != vi.visited_person_id");
|
||
if ("1".equals(result.getTabType())){ // 未审批
|
||
if("0".equals(userLevel)){
|
||
myWaitHandleListSql.append(" and al.first_status = '0' ");
|
||
}else if("1".equals(userLevel)){
|
||
myWaitHandleListSql.append(" and al.second_status = '0' ");
|
||
}else if("2".equals(userLevel)){
|
||
myWaitHandleListSql.append(" and al.third_status = '0' ");
|
||
}else if("8".equals(userLevel)){
|
||
myWaitHandleListSql.append(" and al.current_status = '90' ");
|
||
}
|
||
} else if ("2".equals(result.getTabType())) { // 已审批
|
||
if("0".equals(userLevel)){
|
||
myWaitHandleListSql.append(" and al.first_status <> '0' ");
|
||
}else if("1".equals(userLevel)){
|
||
myWaitHandleListSql.append(" and al.second_status <> '0' ");
|
||
}else if("2".equals(userLevel)){
|
||
myWaitHandleListSql.append(" and al.third_status <> '0' ");
|
||
}else if("8".equals(userLevel)){
|
||
myWaitHandleListSql.append(" and al.current_status like '9%' and al.current_status not like '%0' ");
|
||
}
|
||
//myWaitHandleListSql.append(" and al.current_status not like '%0' ");
|
||
}
|
||
|
||
// params.add(userId);
|
||
// params.add(userId);
|
||
} else if ("2".equals(flag)){//邀请列表
|
||
myWaitHandleListSql.append(" and vi.user_id = ? and vi.user_id = vi.visited_person_id ");
|
||
params.add(userId);
|
||
} else if ("3".equals(flag)) {//预约列表
|
||
myWaitHandleListSql.append(" and vi.user_id = ? and vi.user_id != vi.visited_person_id");
|
||
params.add(userId);
|
||
} else if("4".equals(flag)){//被邀列表
|
||
myWaitHandleListSql.append(" and vi.visitor_name = ? and vi.visitor_tel = ? and al.user_id != ?");
|
||
// params.add(gaInfo.getUsername());
|
||
// params.add(gaInfo.getTelnumber());
|
||
params.add(info.getRealName());
|
||
params.add(info.getMobile());
|
||
params.add(userId);
|
||
}
|
||
// 排序
|
||
if(page.matches("\\d+") && pageSize.matches("\\d+")){
|
||
Integer x = Integer.valueOf(page);
|
||
Integer y = Integer.valueOf(pageSize);
|
||
params.add((x-1)*y);
|
||
params.add(y);
|
||
myWaitHandleListSql.append(" ORDER BY apply_time DESC LIMIT ?,?");
|
||
}
|
||
// 执行sql
|
||
list = hibernateDao.queryForListWithSql(myWaitHandleListSql.toString(), params.toArray());
|
||
}
|
||
return new RestResult(Constant.SUCCESS, "查询成功", list);
|
||
}catch (Exception e) {
|
||
e.printStackTrace();
|
||
return new RestResult(Constant.FAILED, "查询失败!");
|
||
}
|
||
}
|
||
/**
|
||
* 查询流转列表
|
||
*
|
||
* @param result
|
||
* @return
|
||
*/
|
||
@SuppressWarnings("unchecked")
|
||
@RequestMapping(value = "/getCirculationList", method = RequestMethod.POST)
|
||
public @ResponseBody RestResult getCirculationList(@RequestBody Result result) {
|
||
try {
|
||
String userLevel = result.getUserLevel();//当前登录用户的用户级别 0专责 1处长 2 主任
|
||
if("0".equals(userLevel)){
|
||
userLevel="1";
|
||
}else if("1".equals(userLevel)){
|
||
userLevel="2";
|
||
}
|
||
String deptName = result.getDeptName();
|
||
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
|
||
ArrayList<Object> params = new ArrayList<Object>();
|
||
String sql = "select id,real_name,mobile,department_name from green_user_info where userLevel=? and real_name is not null";//department_name = ? and
|
||
//params.add(deptName);
|
||
params.add(userLevel);
|
||
list = hibernateDao.queryForListWithSql(sql.toString(), params.toArray());
|
||
return new RestResult(Constant.SUCCESS, "查询成功", list);
|
||
}catch (Exception e) {
|
||
e.printStackTrace();
|
||
return new RestResult(Constant.FAILED, "查询失败!");
|
||
}
|
||
}
|
||
/**
|
||
* 提交流转申请
|
||
*
|
||
* @param result
|
||
* @return
|
||
*/
|
||
@SuppressWarnings("unchecked")
|
||
@RequestMapping(value = "/submitCirculation", method = RequestMethod.POST)
|
||
public @ResponseBody RestResult submitCirculation(@RequestBody Result result) {
|
||
try {
|
||
String userLevel = result.getUserLevel();//当前登录用户的用户级别 0专责 1处长 2 主任
|
||
String id = result.getId();//被流转人的id;
|
||
String applyId = result.getApplyId();//当前访客预约记录的id
|
||
Long applyIdLong = Long.parseLong(applyId);
|
||
|
||
GreenApplyList greenApplyList = greenApplyListBizc.get(applyIdLong);
|
||
if("0".equals(userLevel)){
|
||
greenApplyList.setFirstStatus("6");
|
||
greenApplyList.setSecondApproval(id);
|
||
greenApplyList.setSecondStatus("0");
|
||
greenApplyList.setCurrentStatus("20");
|
||
}else if("1".equals(userLevel)){
|
||
greenApplyList.setSecondStatus("6");
|
||
greenApplyList.setThirdApproval(id);
|
||
greenApplyList.setThirdStatus("0");
|
||
greenApplyList.setCurrentStatus("30");
|
||
}
|
||
greenApplyListBizc.update(greenApplyList, applyId);
|
||
return new RestResult(Constant.SUCCESS, "流转成功");
|
||
}catch (Exception e) {
|
||
e.printStackTrace();
|
||
return new RestResult(Constant.FAILED, "流转失败!");
|
||
}
|
||
}
|
||
|
||
public void remindTaskForVisitor(Map<String, Object> map){
|
||
String userId = (String) map.get("user_id");
|
||
String userName = (String) map.get("visitor_name");
|
||
Date date1 = new Date();
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||
String strDate1 = sdf.format(date1);
|
||
GreenUserInfo userInfo = getUserInfo(userId);
|
||
Map<String, ContentVo> dataMap = new HashMap<String, ContentVo>();
|
||
dataMap.put("first", new ContentVo("尊敬的访客,您好!您预约的访问时间即将到期", "#173177"));
|
||
dataMap.put("keyword1", new ContentVo(userName, "#black"));
|
||
dataMap.put("keyword2", new ContentVo(strDate1, "#black"));
|
||
dataMap.put("remark", new ContentVo("感谢您的参于与支持", "#173177"));
|
||
try {
|
||
wService.publishMsg(dataMap, userInfo.getWxOpenId(), 5);
|
||
} catch (Exception e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
}
|