1216 lines
57 KiB
Plaintext
1216 lines
57 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.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.po.GreenApplyList;
|
|
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;
|
|
|
|
|
|
|
|
|
|
@Controller
|
|
@RequestMapping("/getParkThirdApprove")
|
|
public class GreenParkThirdApproveController extends GreenBaseController{
|
|
@Autowired
|
|
private BaseServiceImpl BaseService;
|
|
/**
|
|
* 访客预约service
|
|
*/
|
|
@Resource
|
|
private IGreenVisitorInfoBizc greenvisitorinfoBizc;
|
|
/**
|
|
* 我的申请service
|
|
*/
|
|
@Resource
|
|
private IGreenApplyListBizc greenApplyListBizc;
|
|
/**
|
|
* 员工卡controller
|
|
*/
|
|
@Resource
|
|
private GreenStaffCardInfoController greenStaffCardInfoController;
|
|
/**
|
|
* 临时停车三级审批
|
|
*/
|
|
@Resource
|
|
private GreenParkThirdController greenParkThirdController;
|
|
/**
|
|
* 临时停车
|
|
*/
|
|
@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" };
|
|
|
|
|
|
|
|
|
|
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);
|
|
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", "3");
|
|
// }
|
|
}
|
|
}
|
|
} 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.third_status AS statusCode,al.comment_status,"
|
|
+ " al.third_approval AS approvalDept,'' AS entry_order_pic FROM GREEN_APPLY_LIST al"
|
|
+ " WHERE 1=1 AND al.first_status = '1' AND al.second_status = '1' AND al.third_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 + " 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)))";
|
|
if(Arrays.asList(userRoleArr).contains(ApplyRoleConstant.TEMP_PARK_APPROVE)){
|
|
myWaitHandleListSql += " WHEN '04' THEN IF(al.first_status = '1',al.second_status,al.first_status)";
|
|
}else{
|
|
myWaitHandleListSql += " WHEN '04' THEN IF(al.first_status = '1',first_status,al.first_status)";
|
|
|
|
}
|
|
myWaitHandleListSql += " 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)))";
|
|
|
|
if(Arrays.asList(userRoleArr).contains(ApplyRoleConstant.TEMP_PARK_AUTHORIZE)){
|
|
myWaitHandleListSql += " WHEN '04' THEN IF(al.first_status = '1',al.first_status,al.first_status)";
|
|
|
|
}else if(Arrays.asList(userRoleArr).contains(ApplyRoleConstant.TEMP_PARK_APPROVE)){
|
|
myWaitHandleListSql += " WHEN '04' THEN IF(al.first_status = '1',al.second_status,al.first_status)";
|
|
}else{
|
|
myWaitHandleListSql += " WHEN '04' THEN IF(al.first_status = '1',al.third_status,al.first_status)";
|
|
|
|
}
|
|
myWaitHandleListSql += " 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')";
|
|
paramList.add(userId);
|
|
paramList.add(ApplyRoleConstant.TEMP_PARK_CZ);
|
|
}
|
|
if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.TEMP_PARK_APPROVE)) {
|
|
tmpSQL += " OR (al.second_approval = ? AND al.apply_type = '04' and al.first_status = '1')";
|
|
paramList.add(ApplyRoleConstant.TEMP_PARK_APPROVE);
|
|
}
|
|
/*// 临时停车申请二级审批
|
|
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 + ")";
|
|
}
|
|
}
|
|
}
|
|
// 排序
|
|
myWaitHandleListSql = myWaitHandleListSql + " ORDER BY apply_time DESC LIMIT 0,100";
|
|
// 执行sql
|
|
list = hibernateDao.queryForListWithSql(myWaitHandleListSql, paramList.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","3");
|
|
// }
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
* 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, "查询失败!");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 根据id和申请类型查询申请详情
|
|
*
|
|
* @param result
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/getApplyInfo", method = RequestMethod.POST)
|
|
public @ResponseBody RestResult getApplyInfo(@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, "非法用户");
|
|
}
|
|
// 判断申请类型
|
|
if (Constant.MEAL_TICKET_APPLY.equals(result.getApplyType())) {// 餐券申请
|
|
return new RestResult(Constant.SUCCESS, "",
|
|
greenMealTicketApplyController.getMealTicketApplyInfo(result.getId(), result.getApplyType()));
|
|
} 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, "",
|
|
greenParkThirdController.getTempParkInfo(result.getId(), Constant.TEMP_PARK_APPLY, userId));
|
|
} 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) {
|
|
System.out.println("ffgasgsdgsdgsdfg");
|
|
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 (Constant.APPROVAL_YES.equals(firstStatus)) {
|
|
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 (Constant.APPROVAL_YES.equals(secondStatus)) {
|
|
if ("1".equals(secondStatus)) {
|
|
// 判断用户角色
|
|
if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.STAFF_CARD_SECURITY)) {
|
|
throw new MyException("该申请已经同意");
|
|
}
|
|
// if (Constant.MAKE_CARD_FINISH.equals(restult.getStatus())) {
|
|
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 (Constant.APPROVAL_CANCEL.equals(secondStatus)) {
|
|
} else if ("3".equals(secondStatus)) {
|
|
throw new MyException("该申请已经被取消");
|
|
// } else if (Constant.APPROVAL_NO.equals(secondStatus)) {
|
|
} 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())
|
|
// && Constant.AUTHORIZE_YES.equals(restult.getStatus())) {
|
|
&& "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)) { //Constant.APPROVAL_YES
|
|
// 判断用户角色
|
|
if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_DEFEND)) {
|
|
throw new MyException("该申请已经同意");
|
|
}
|
|
if ("1".equals(thirdStatus)) { // Constant.APPROVAL_YES
|
|
// 判断用户角色
|
|
if (Arrays.asList(userRoleArr).contains(ApplyRoleConstant.CONSTRUCT_APPROVE_DIRECTOR)) {
|
|
throw new MyException("该申请已经同意");
|
|
}
|
|
if ("1".equals(fourthStatus)) { //Constant.APPROVAL_YES
|
|
// 判断用户角色
|
|
if (Arrays.asList(userRoleArr)
|
|
.contains(ApplyRoleConstant.CONSTRUCT_APPROVE_GENERAL)) {
|
|
throw new MyException("该申请已经同意");
|
|
}
|
|
if ("3".equals(fourthStatus)) { //Constant.APPROVAL_CANCEL
|
|
throw new MyException("该申请已经被取消");
|
|
} else if ("2".equals(fourthStatus)) { //Constant.APPROVAL_NO
|
|
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)) { //Constant.APPROVAL_CANCEL
|
|
throw new MyException("该申请已经被取消");
|
|
} else if ("2".equals(fourthStatus)) { //Constant.APPROVAL_NO
|
|
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)) { //Constant.APPROVAL_NO
|
|
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 visited_person_name,visit_start_time,visit_end_time,visitor_name,"
|
|
+ " visitor_tel,idcard,visit_reason FROM green_visitor_info WHERE 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, String>> visitorInfoList = hibernateDao.queryForListWithSql(visitorsql, new Object[] { restult.getApplyId() });
|
|
String idcard = AesEncryptUtil.desEncrypt(visitorInfoList.get(0).get("idcard"));
|
|
if(visitAddUserSwitch == 1){
|
|
String startTime = visitorInfoList.get(0).get("visit_start_time");
|
|
String endTime = visitorInfoList.get(0).get("visit_end_time");
|
|
String reason = visitorInfoList.get(0).get("visit_reason");
|
|
String personName = visitorInfoList.get(0).get("visited_person_name");
|
|
// 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.visitor_id = ?";
|
|
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);
|
|
/* visitorMsg(restult.getUserId(), cardNo, retinueName,
|
|
personName, reason,
|
|
startTime, endTime,uuid,endTime);*/
|
|
|
|
String updateRemainSql2 = "UPDATE GREEN_RETINUE_INFO SET push_state = 1,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 });
|
|
}
|
|
addLog(Constant.MY_APPLY, Constant.APPROVAL, Constant.OPERATE_SUCCESS, "审批申请",
|
|
Constant.LOG_OPERATE, restult.getUserId());
|
|
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级审批发消息给2级审批人员
|
|
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 = "审批通知";
|
|
sendMsg("temp_park_approve",msgname, "您有一个【临时停车申请】待审批", userName,hibernateDao);
|
|
}
|
|
}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();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
}
|