浙文代码备份
This commit is contained in:
parent
d69db82a6d
commit
952f285f38
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,284 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String userid = request.getParameter("userid");
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
|
||||
// List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
// if(StringUtils.isNotBlank(cjrbm)) {
|
||||
// String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+
|
||||
// " union "+
|
||||
// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+
|
||||
// " union "+
|
||||
// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ;
|
||||
//
|
||||
// hrmList = queryListBySql(sql);
|
||||
// }
|
||||
//
|
||||
// if(hrmList !=null && hrmList.size() > 0){
|
||||
// userid = hrmList.get(0).get("id");
|
||||
// }
|
||||
|
||||
if(StringUtils.isBlank(userid)){
|
||||
userid = user.getUID()+"";
|
||||
}
|
||||
|
||||
String activeGroupId = "";
|
||||
int daysInMonth = 0;
|
||||
Map<String,String> weekMap = new HashMap<String,String>();
|
||||
List<Map<String,String>> weekList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
|
||||
activeGroupId = getUserActiveGroupId(userid);
|
||||
String fixedScheduleGroupId = "5";
|
||||
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(fixedScheduleGroupId,monthStartDate,monthEndDate);
|
||||
|
||||
int thisMonth = date.getMonthValue(); // 获取当前是哪月
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
|
||||
for (int i = 1; i <= daysInMonth; i++) {
|
||||
LocalDate currentDate = LocalDate.of(date.getYear(), thisMonth, i);
|
||||
System.out.println("currentDate:" + currentDate.toString());
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
System.out.println(i + "号是周 " + dayOfWeek.getValue());
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
String weekDayName = "";
|
||||
switch (weekValue) {
|
||||
case 1:
|
||||
weekDayName = "周一";
|
||||
break;
|
||||
case 2:
|
||||
weekDayName = "周二";
|
||||
break;
|
||||
case 3:
|
||||
weekDayName = "周三";
|
||||
break;
|
||||
case 4:
|
||||
weekDayName = "周四";
|
||||
break;
|
||||
case 5:
|
||||
weekDayName = "周五";
|
||||
break;
|
||||
case 6:
|
||||
weekDayName = "周六";
|
||||
break;
|
||||
case 7:
|
||||
weekDayName = "周日";
|
||||
break;
|
||||
}
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
weekMap = new HashMap<String,String>();
|
||||
weekMap.put("weekname", weekDayName);
|
||||
weekMap.put("changeType", changeType);
|
||||
weekMap.put("weekday", i+"");
|
||||
weekMap.put("weekdate", currentDate.toString());
|
||||
weekList.add(weekMap);
|
||||
}
|
||||
}
|
||||
|
||||
String serialids = "";
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql = " select serialids from kq_group where id = "+activeGroupId ;
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
serialids = Util.null2String(rs.getString("serialids"));
|
||||
}
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",weekList);
|
||||
jsonObject.put("count",daysInMonth);
|
||||
jsonObject.put("group",activeGroupId);
|
||||
jsonObject.put("serialids",serialids);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> getHolidayByGroupId(String activeGroupId,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
//String activeGroupId = getUserActiveGroupId(userid);
|
||||
// bb.writeLog("activeGroupId:"+activeGroupId);
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + activeGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
String changeTypename = "" ;
|
||||
if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
changeTypename += "公众假日";
|
||||
}else if("2".equals(changeType)){
|
||||
changeTypename += "调配工作日";
|
||||
}else if("3".equals(changeType)){
|
||||
changeTypename += "调配休息日";
|
||||
}
|
||||
holidayMap.put(holidayDate,changeTypename);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,221 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
|
||||
List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
Map<String,Object> valueMap = new HashMap<>();
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ;
|
||||
|
||||
|
||||
hrmList = queryListBySql(sql);
|
||||
valueMap = getMainUserDate(hrmList);
|
||||
dt1List = getDt1UserDate(hrmList);
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",valueMap);
|
||||
jsonObject.put("dt1",dt1List);
|
||||
|
||||
String userid = user.getUID()+"" ;
|
||||
// if(hrmList !=null && hrmList.size() > 0){
|
||||
// userid = hrmList.get(0).get("id");
|
||||
// }
|
||||
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
String activeGroupId = getUserActiveGroupId(userid);
|
||||
String serialids = "";
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql = " select serialids from kq_group where id = "+activeGroupId ;
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
serialids = Util.null2String(rs.getString("serialids"));
|
||||
}
|
||||
}
|
||||
jsonObject.put("group",activeGroupId);
|
||||
jsonObject.put("serialids",serialids);
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
public List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String yg = request.getParameter("yg");
|
||||
|
||||
String startdate = "";
|
||||
String enddate = "";
|
||||
String sfdd = "1";
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate dateTime = LocalDate.parse(pbyf+"-01", formatter);
|
||||
LocalDate firstDayOfMonth = dateTime.with(TemporalAdjusters.firstDayOfMonth());
|
||||
LocalDate lastDayOfMonth = dateTime.with(TemporalAdjusters.lastDayOfMonth());
|
||||
startdate = firstDayOfMonth.toString();
|
||||
enddate = lastDayOfMonth.toString();
|
||||
|
||||
// if(StringUtils.isNotBlank(cjrbm)) {
|
||||
// String sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " +
|
||||
// " from uf_ygddxx " +
|
||||
// " where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
// " and xm = "+ yg +
|
||||
// " and bm= "+ cjrbm+
|
||||
// " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) ";
|
||||
// rs.executeQuery(sql);
|
||||
// if(rs.next()){
|
||||
// String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
// if(StringUtils.isNotBlank(ydsxrq)){
|
||||
// enddate = ydsxrq;
|
||||
// sfdd = "0";
|
||||
// }
|
||||
// }
|
||||
// sql =" select ydsxrq " +
|
||||
// " from uf_ygddxx " +
|
||||
// " where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
// " and xm ="+ yg +
|
||||
// " and ydhbm="+cjrbm+
|
||||
// " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) ";
|
||||
// rs.executeQuery(sql);
|
||||
// if(rs.next()){
|
||||
// String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
// if(StringUtils.isNotBlank(ydsxrq)){
|
||||
// startdate = ydsxrq;
|
||||
// sfdd = "0";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
String sql =" select ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm ="+ yg +
|
||||
" and ydhbm="+cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " +
|
||||
" order by id desc ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
startdate = ydsxrq;
|
||||
sfdd = "0";
|
||||
}
|
||||
}
|
||||
|
||||
sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm = "+ yg +
|
||||
" and bm= "+ cjrbm+
|
||||
" and ydsxrq > "+startdate +
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " +
|
||||
" order by id desc ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
enddate = ydsxrq;
|
||||
sfdd = "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("startdate",startdate);
|
||||
jsonObject.put("enddate",enddate);
|
||||
jsonObject.put("sfdd",sfdd);
|
||||
|
||||
%>
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,282 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String userid = request.getParameter("userid");
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
|
||||
// List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
// if(StringUtils.isNotBlank(cjrbm)) {
|
||||
// String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+
|
||||
// " union "+
|
||||
// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+
|
||||
// " union "+
|
||||
// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ;
|
||||
//
|
||||
// hrmList = queryListBySql(sql);
|
||||
// }
|
||||
//
|
||||
// if(hrmList !=null && hrmList.size() > 0){
|
||||
// userid = hrmList.get(0).get("id");
|
||||
// }
|
||||
if(StringUtils.isBlank(userid)){
|
||||
userid = user.getUID()+"";
|
||||
}
|
||||
String activeGroupId = "";
|
||||
int daysInMonth = 0;
|
||||
Map<String,String> weekMap = new HashMap<String,String>();
|
||||
List<Map<String,String>> weekList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
|
||||
activeGroupId = getUserActiveGroupId(userid);
|
||||
String fixedScheduleGroupId = "5";
|
||||
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(fixedScheduleGroupId,monthStartDate,monthEndDate);
|
||||
|
||||
int thisMonth = date.getMonthValue(); // 获取当前是哪月
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
|
||||
for (int i = 1; i <= daysInMonth; i++) {
|
||||
LocalDate currentDate = LocalDate.of(date.getYear(), thisMonth, i);
|
||||
System.out.println("currentDate:" + currentDate.toString());
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
System.out.println(i + "号是周 " + dayOfWeek.getValue());
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
String weekDayName = "";
|
||||
switch (weekValue) {
|
||||
case 1:
|
||||
weekDayName = "周一";
|
||||
break;
|
||||
case 2:
|
||||
weekDayName = "周二";
|
||||
break;
|
||||
case 3:
|
||||
weekDayName = "周三";
|
||||
break;
|
||||
case 4:
|
||||
weekDayName = "周四";
|
||||
break;
|
||||
case 5:
|
||||
weekDayName = "周五";
|
||||
break;
|
||||
case 6:
|
||||
weekDayName = "周六";
|
||||
break;
|
||||
case 7:
|
||||
weekDayName = "周日";
|
||||
break;
|
||||
}
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
weekMap = new HashMap<String,String>();
|
||||
weekMap.put("weekname", weekDayName);
|
||||
weekMap.put("changeType", changeType);
|
||||
weekMap.put("weekday", i+"");
|
||||
weekMap.put("weekdate", currentDate.toString());
|
||||
weekList.add(weekMap);
|
||||
}
|
||||
}
|
||||
|
||||
String serialids = "";
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql = " select serialids from kq_group where id = "+activeGroupId ;
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
serialids = Util.null2String(rs.getString("serialids"));
|
||||
}
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",weekList);
|
||||
jsonObject.put("count",daysInMonth);
|
||||
jsonObject.put("group",activeGroupId);
|
||||
jsonObject.put("serialids",serialids);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> getHolidayByGroupId(String activeGroupId,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
//String activeGroupId = getUserActiveGroupId(userid);
|
||||
// bb.writeLog("activeGroupId:"+activeGroupId);
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + activeGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
String changeTypename = "" ;
|
||||
if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
changeTypename += "公众假日";
|
||||
}else if("2".equals(changeType)){
|
||||
changeTypename += "调配工作日";
|
||||
}else if("3".equals(changeType)){
|
||||
changeTypename += "调配休息日";
|
||||
}
|
||||
holidayMap.put(holidayDate,changeTypename);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,221 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
|
||||
List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
Map<String,Object> valueMap = new HashMap<>();
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ;
|
||||
|
||||
hrmList = queryListBySql(sql);
|
||||
valueMap = getMainUserDate(hrmList);
|
||||
dt1List = getDt1UserDate(hrmList);
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",valueMap);
|
||||
jsonObject.put("dt1",dt1List);
|
||||
|
||||
String userid =user.getUID()+"" ;
|
||||
// if(hrmList !=null && hrmList.size() > 0){
|
||||
// userid = hrmList.get(0).get("id");
|
||||
// }
|
||||
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
String activeGroupId = getUserActiveGroupId(userid);
|
||||
String serialids = "";
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql = " select serialids from kq_group where id = "+activeGroupId ;
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
serialids = Util.null2String(rs.getString("serialids"));
|
||||
}
|
||||
}
|
||||
jsonObject.put("group",activeGroupId);
|
||||
jsonObject.put("serialids",serialids);
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
public List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,840 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String yg = request.getParameter("yg");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
|
||||
List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") "+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") " ;
|
||||
|
||||
hrmList = queryListBySql(sql);
|
||||
}
|
||||
String userid = user.getUID()+"";
|
||||
|
||||
String activeGroupId = getUserActiveGroupId(userid);
|
||||
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = firstDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
|
||||
String startDate = monthStartDate;
|
||||
String endDate = monthEndDate ;
|
||||
|
||||
String sql =" select ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm ="+ yg +
|
||||
" and ydhbm="+cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " +
|
||||
" order by id desc ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
startDate = ydsxrq;
|
||||
}
|
||||
}
|
||||
|
||||
sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm = "+ yg +
|
||||
" and bm= "+ cjrbm+
|
||||
" and ydsxrq > "+startDate +
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " +
|
||||
" order by id desc ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
endDate = ydsxrq;
|
||||
}
|
||||
}
|
||||
|
||||
sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
" and t.kqdate >='"+startDate+"' " +
|
||||
" and t.kqdate <= '"+endDate+"'" +
|
||||
" and t.groupid="+activeGroupId+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + yg +
|
||||
" order by kqdate ";
|
||||
|
||||
bb.writeLog("sql:"+sql);
|
||||
List<Map<String,String>> sqlList = queryListBySql(sql);
|
||||
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> map = sqlList.get(i);
|
||||
|
||||
String serialid = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",serialid);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("serialid",serialid);
|
||||
valueMap.put("kqdate",kqdate);
|
||||
valueMap.put("xh",xh);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
scheduleList.add(valueMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("schedule",scheduleList);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate,activeGroupId);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate,String activeGroupId){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + activeGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getDt1UserMap(String ry,String lastname){
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
if(StringUtils.isNotBlank(ry)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",ry);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
valueMap.put("id",ry);
|
||||
valueMap.put("name",lastname);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
}
|
||||
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param pbyf
|
||||
* @param groupid
|
||||
* @param resourceid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid,Map<String,String> dateEffectiveMap){
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
try{
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){
|
||||
String startDate = "" ;
|
||||
String endDate = "";
|
||||
if(dateEffectiveMap.containsKey(resourceid)){
|
||||
String effectiveDate = dateEffectiveMap.get(resourceid);
|
||||
if(effectiveDate.contains(";")){
|
||||
String[] effective_Date = effectiveDate.split(";");
|
||||
startDate = effective_Date[0];
|
||||
endDate = effective_Date[1];
|
||||
}
|
||||
}
|
||||
|
||||
String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
" and t.kqdate >='"+startDate+"' " +
|
||||
" and t.kqdate <= '"+endDate+"'" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + resourceid +
|
||||
" order by kqdate ";
|
||||
bb.writeLog("sql:"+sql);
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> map = sqlList.get(i);
|
||||
|
||||
String serialid = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",serialid);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("serialid",serialid);
|
||||
valueMap.put("kqdate",kqdate);
|
||||
valueMap.put("xh",xh);
|
||||
|
||||
|
||||
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
|
||||
scheduleList.add(valueMap);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getSchedulingRestData(){
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql =" select id " +
|
||||
" from kq_ShiftManagement \n" +
|
||||
" where is_rest = 1 \n" +
|
||||
" and (isdelete is null or isdelete = 0) ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
list.add(id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param restList
|
||||
* @param daysList
|
||||
* @param weekMap
|
||||
* @param serialList
|
||||
*/
|
||||
public Map<String,String> queryCountWorkTime(List<String> restList,List<String> daysList,Map<String,String> weekMap,List<Map<String,Object>> serialList ){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String,String> countMap = new HashMap<>();
|
||||
String worktime = "0";
|
||||
String totalworktime = "0";
|
||||
int restcount = 0;
|
||||
int weekrestcount = 0;
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql = "";
|
||||
for (int i = 0; i < serialList.size(); i++) {
|
||||
Map<String,Object> serialMap = serialList.get(i);
|
||||
String kqdate = Util.null2String(serialMap.get("kqdate"));
|
||||
String serialid = Util.null2String(serialMap.get("serialid"));
|
||||
if (daysList.contains(kqdate)) {
|
||||
if (StringUtils.isNotBlank(serialid)) {
|
||||
if (restList.contains(serialid)) {
|
||||
restcount++;
|
||||
}
|
||||
|
||||
if(!restList.contains(serialid)){
|
||||
String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ;
|
||||
sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ;
|
||||
}
|
||||
}
|
||||
|
||||
if (weekMap.containsKey(kqdate)) {
|
||||
String value = weekMap.get(kqdate);
|
||||
//6 = 周六 7 = 周日 11 = 公众假日、调配休息日
|
||||
if ("6".equals(value) || "7".equals(value) || "11".equals(value)) {
|
||||
if (restList.contains(serialid)) {
|
||||
weekrestcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
worktime = Util.null2String(rs.getString("worktime"));
|
||||
totalworktime = Util.null2String(rs.getString("totalworktime"));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
countMap.put("worktime",worktime);
|
||||
countMap.put("totalworktime",totalworktime);
|
||||
countMap.put("restcount",restcount+"");
|
||||
countMap.put("weekrestcount",weekrestcount+"");
|
||||
|
||||
return countMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param daysList
|
||||
* @param holidayMap
|
||||
* @param yjl
|
||||
* @param workSchedule
|
||||
* @param hrmList
|
||||
* @param groupid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleStatusByDay(List<String> daysList,Map<String,String> holidayMap,String yjl,String[] workSchedule,List<Map<String,String>> hrmList,String groupid,Map<String,String> dateEffectiveMap){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> resultList = new ArrayList<Map<String,String>>();
|
||||
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try{
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(String pbrq:daysList){
|
||||
|
||||
String resourceids = "";
|
||||
for(int i=0;i<hrmList.size();i++) {
|
||||
Map<String, String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
if(dateEffectiveMap.containsKey(userid)){
|
||||
String effectiveDate = dateEffectiveMap.get(userid);
|
||||
if(effectiveDate.contains(";")){
|
||||
String[] effective_Date = effectiveDate.split(";");
|
||||
if(pbrq.compareTo(effective_Date[0])>=0 && pbrq.compareTo(effective_Date[1])<=0){
|
||||
resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(yjl)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{yjl,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){
|
||||
|
||||
String sql =" select t.serialid,t.resourceid,t.kqdate \n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" where t.kqdate='"+pbrq+"' \n" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid in( " + resourceids + ") "+
|
||||
" order by kqdate ";
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
Map<String,String> resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq);
|
||||
resultList.add(resultMap);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sqlList
|
||||
* @param workScheduleList
|
||||
* @param defaultScheduleMap
|
||||
* @param kqdate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> queryScheduleStatusByUser(List<Map<String,String>> sqlList,List<Map<String,String>> workScheduleList,Map<String,Integer> defaultScheduleMap,String kqdate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
String yxrys = "" ;
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String resourceid = Util.null2String(sqlMap.get("resourceid"));
|
||||
yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(yxrys)) {
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3,4)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3,4) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String pbry = sqlMap.get("resourceid");
|
||||
String serialid = sqlMap.get("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) ";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String,String> resultMap = new HashMap<>();
|
||||
String status = "0";
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
status = "0";
|
||||
}else{
|
||||
status = "1";
|
||||
}
|
||||
}
|
||||
resultMap.put("kqdate",kqdate);
|
||||
resultMap.put("status",status);
|
||||
resultMap.put("xh",xh);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,848 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String yg = request.getParameter("yg");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
|
||||
List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") "+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") " ;
|
||||
out.print("sql:"+sql+"</br>");
|
||||
hrmList = queryListBySql(sql);
|
||||
}
|
||||
String userid = "" ;
|
||||
if(hrmList !=null && hrmList.size() > 0){
|
||||
userid = hrmList.get(0).get("id");
|
||||
}
|
||||
out.print("userid:"+userid+"</br>");
|
||||
String activeGroupId = getUserActiveGroupId(userid);
|
||||
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = firstDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
|
||||
String startDate = monthStartDate;
|
||||
String endDate = monthEndDate ;
|
||||
out.print("startDate:"+startDate+"</br>");
|
||||
out.print("endDate:"+endDate+"</br>");
|
||||
|
||||
String sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm = "+ yg +
|
||||
" and bm= "+ cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) ";
|
||||
|
||||
out.print("sql:"+sql+"</br>");
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
endDate = ydsxrq;
|
||||
}
|
||||
}
|
||||
|
||||
sql =" select ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm ="+ yg +
|
||||
" and ydhbm="+cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) ";
|
||||
rs.executeQuery(sql);
|
||||
out.print("sql:"+sql+"</br>");
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
startDate = ydsxrq;
|
||||
}
|
||||
}
|
||||
|
||||
out.print("startDate:"+startDate+"</br>");
|
||||
out.print("endDate:"+endDate+"</br>");
|
||||
|
||||
sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
" and t.kqdate >='"+startDate+"' " +
|
||||
" and t.kqdate <= '"+endDate+"'" +
|
||||
" and t.groupid="+activeGroupId+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + yg +
|
||||
" order by kqdate ";
|
||||
out.print("sql:"+sql+"</br>");
|
||||
bb.writeLog("sql:"+sql);
|
||||
List<Map<String,String>> sqlList = queryListBySql(sql);
|
||||
out.print("sqlList:"+sqlList.size()+"</br>");
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> map = sqlList.get(i);
|
||||
|
||||
String serialid = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",serialid);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("serialid",serialid);
|
||||
valueMap.put("kqdate",kqdate);
|
||||
valueMap.put("xh",xh);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
scheduleList.add(valueMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("schedule",scheduleList);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate,activeGroupId);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate,String activeGroupId){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + activeGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getDt1UserMap(String ry,String lastname){
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
if(StringUtils.isNotBlank(ry)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",ry);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
valueMap.put("id",ry);
|
||||
valueMap.put("name",lastname);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
}
|
||||
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param pbyf
|
||||
* @param groupid
|
||||
* @param resourceid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid,Map<String,String> dateEffectiveMap){
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
try{
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){
|
||||
String startDate = "" ;
|
||||
String endDate = "";
|
||||
if(dateEffectiveMap.containsKey(resourceid)){
|
||||
String effectiveDate = dateEffectiveMap.get(resourceid);
|
||||
if(effectiveDate.contains(";")){
|
||||
String[] effective_Date = effectiveDate.split(";");
|
||||
startDate = effective_Date[0];
|
||||
endDate = effective_Date[1];
|
||||
}
|
||||
}
|
||||
|
||||
String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
" and t.kqdate >='"+startDate+"' " +
|
||||
" and t.kqdate <= '"+endDate+"'" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + resourceid +
|
||||
" order by kqdate ";
|
||||
bb.writeLog("sql:"+sql);
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> map = sqlList.get(i);
|
||||
|
||||
String serialid = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",serialid);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("serialid",serialid);
|
||||
valueMap.put("kqdate",kqdate);
|
||||
valueMap.put("xh",xh);
|
||||
|
||||
|
||||
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
|
||||
scheduleList.add(valueMap);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getSchedulingRestData(){
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql =" select id " +
|
||||
" from kq_ShiftManagement \n" +
|
||||
" where is_rest = 1 \n" +
|
||||
" and (isdelete is null or isdelete = 0) ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
list.add(id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param restList
|
||||
* @param daysList
|
||||
* @param weekMap
|
||||
* @param serialList
|
||||
*/
|
||||
public Map<String,String> queryCountWorkTime(List<String> restList,List<String> daysList,Map<String,String> weekMap,List<Map<String,Object>> serialList ){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String,String> countMap = new HashMap<>();
|
||||
String worktime = "0";
|
||||
String totalworktime = "0";
|
||||
int restcount = 0;
|
||||
int weekrestcount = 0;
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql = "";
|
||||
for (int i = 0; i < serialList.size(); i++) {
|
||||
Map<String,Object> serialMap = serialList.get(i);
|
||||
String kqdate = Util.null2String(serialMap.get("kqdate"));
|
||||
String serialid = Util.null2String(serialMap.get("serialid"));
|
||||
if (daysList.contains(kqdate)) {
|
||||
if (StringUtils.isNotBlank(serialid)) {
|
||||
if (restList.contains(serialid)) {
|
||||
restcount++;
|
||||
}
|
||||
|
||||
if(!restList.contains(serialid)){
|
||||
String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ;
|
||||
sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ;
|
||||
}
|
||||
}
|
||||
|
||||
if (weekMap.containsKey(kqdate)) {
|
||||
String value = weekMap.get(kqdate);
|
||||
//6 = 周六 7 = 周日 11 = 公众假日、调配休息日
|
||||
if ("6".equals(value) || "7".equals(value) || "11".equals(value)) {
|
||||
if (restList.contains(serialid)) {
|
||||
weekrestcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
worktime = Util.null2String(rs.getString("worktime"));
|
||||
totalworktime = Util.null2String(rs.getString("totalworktime"));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
countMap.put("worktime",worktime);
|
||||
countMap.put("totalworktime",totalworktime);
|
||||
countMap.put("restcount",restcount+"");
|
||||
countMap.put("weekrestcount",weekrestcount+"");
|
||||
|
||||
return countMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param daysList
|
||||
* @param holidayMap
|
||||
* @param yjl
|
||||
* @param workSchedule
|
||||
* @param hrmList
|
||||
* @param groupid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleStatusByDay(List<String> daysList,Map<String,String> holidayMap,String yjl,String[] workSchedule,List<Map<String,String>> hrmList,String groupid,Map<String,String> dateEffectiveMap){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> resultList = new ArrayList<Map<String,String>>();
|
||||
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try{
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(String pbrq:daysList){
|
||||
|
||||
String resourceids = "";
|
||||
for(int i=0;i<hrmList.size();i++) {
|
||||
Map<String, String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
if(dateEffectiveMap.containsKey(userid)){
|
||||
String effectiveDate = dateEffectiveMap.get(userid);
|
||||
if(effectiveDate.contains(";")){
|
||||
String[] effective_Date = effectiveDate.split(";");
|
||||
if(pbrq.compareTo(effective_Date[0])>=0 && pbrq.compareTo(effective_Date[1])<=0){
|
||||
resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(yjl)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{yjl,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){
|
||||
|
||||
String sql =" select t.serialid,t.resourceid,t.kqdate \n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" where t.kqdate='"+pbrq+"' \n" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid in( " + resourceids + ") "+
|
||||
" order by kqdate ";
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
Map<String,String> resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq);
|
||||
resultList.add(resultMap);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sqlList
|
||||
* @param workScheduleList
|
||||
* @param defaultScheduleMap
|
||||
* @param kqdate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> queryScheduleStatusByUser(List<Map<String,String>> sqlList,List<Map<String,String>> workScheduleList,Map<String,Integer> defaultScheduleMap,String kqdate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
String yxrys = "" ;
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String resourceid = Util.null2String(sqlMap.get("resourceid"));
|
||||
yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(yxrys)) {
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3,4)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3,4) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String pbry = sqlMap.get("resourceid");
|
||||
String serialid = sqlMap.get("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) ";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String,String> resultMap = new HashMap<>();
|
||||
String status = "0";
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
status = "0";
|
||||
}else{
|
||||
status = "1";
|
||||
}
|
||||
}
|
||||
resultMap.put("kqdate",kqdate);
|
||||
resultMap.put("status",status);
|
||||
resultMap.put("xh",xh);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,264 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
RecordSet rs = new RecordSet();
|
||||
String serialids = request.getParameter("serialids");
|
||||
|
||||
String userid = request.getParameter("userid");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String serdata = request.getParameter("serdata");
|
||||
List<String> restList = getSchedulingRestData();
|
||||
|
||||
String worktime = "0";
|
||||
String totalworktime = "0";
|
||||
if(StringUtils.isNotBlank(serialids)){
|
||||
String sql = "";
|
||||
String[] serialidArray = serialids.split(",");
|
||||
for(int i=0;i<serialidArray.length;i++){
|
||||
String serialid = serialidArray[i];
|
||||
if(StringUtils.isNotBlank(serialid)){
|
||||
if(!restList.contains(serialid)){
|
||||
String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (isdelete = 0 or isdelete is null) " ;
|
||||
sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
worktime = Util.null2String(rs.getString("worktime"));
|
||||
totalworktime = Util.null2String(rs.getString("totalworktime"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int restcount = 0;
|
||||
int weekrestcount = 0;
|
||||
|
||||
Map<String,String> weekMap = queryWeekTypeByMonth(userid,pbyf);
|
||||
if(StringUtils.isNotBlank(serdata)){
|
||||
JSONArray jsonArray = JSONArray.parseArray(serdata);
|
||||
for(int i=0;i<jsonArray.size();i++){
|
||||
JSONObject dataJSON = jsonArray.getJSONObject(i);
|
||||
String date = dataJSON.getString("date");
|
||||
String serialid = dataJSON.getString("serialid");
|
||||
if(StringUtils.isNotBlank(serialid)){
|
||||
if(restList.contains(serialid)){
|
||||
restcount++;
|
||||
}
|
||||
}
|
||||
|
||||
if(weekMap.containsKey(date)){
|
||||
String value = weekMap.get(date);
|
||||
//6 = 周六 7 = 周日 11 = 公众假日、调配休息日
|
||||
if("6".equals(value) || "7".equals(value) || "11".equals(value)){
|
||||
if(restList.contains(serialid)){
|
||||
weekrestcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",worktime);
|
||||
jsonObject.put("total",totalworktime);
|
||||
jsonObject.put("restcount",restcount+"");
|
||||
jsonObject.put("weekrestcount",weekrestcount+"");
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
<%!
|
||||
public Map<String,String> queryWeekTypeByMonth(String userid,String pbyf){
|
||||
|
||||
Map<String,String> weekMap = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate);
|
||||
|
||||
int thisMonth = date.getMonthValue(); // 获取当前是哪月
|
||||
int daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
|
||||
for (int i = 1; i <= daysInMonth; i++) {
|
||||
LocalDate currentDate = LocalDate.of(date.getYear(), thisMonth, i);
|
||||
System.out.println("currentDate:" + currentDate.toString());
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
System.out.println(i + "号是周 " + dayOfWeek.getValue());
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
weekValue = 11;
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(changeType)){
|
||||
weekMap.put(currentDate.toString(), weekValue+"");
|
||||
}else{
|
||||
weekMap.put(currentDate.toString(), weekValue+"");
|
||||
}
|
||||
}
|
||||
}
|
||||
return weekMap;
|
||||
}
|
||||
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
String activeGroupId = getUserActiveGroupId(userid);
|
||||
bb.writeLog("activeGroupId:"+activeGroupId);
|
||||
|
||||
String fixedScheduleGroupId = "5";
|
||||
|
||||
if(StringUtils.isNotBlank(fixedScheduleGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + fixedScheduleGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
public List<String> getSchedulingRestData(){
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql =" select id " +
|
||||
" from kq_ShiftManagement \n" +
|
||||
" where is_rest = 1 \n" +
|
||||
" and (isdelete is null or isdelete = 0) ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
list.add(id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,285 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String userid = request.getParameter("userid");
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
|
||||
// List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
// if(StringUtils.isNotBlank(cjrbm)) {
|
||||
// String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+
|
||||
// " union "+
|
||||
// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+
|
||||
// " union "+
|
||||
// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ;
|
||||
//
|
||||
// hrmList = queryListBySql(sql);
|
||||
// }
|
||||
|
||||
// if(hrmList !=null && hrmList.size() > 0){
|
||||
// userid = hrmList.get(0).get("id");
|
||||
// }
|
||||
|
||||
if(StringUtils.isBlank(userid)){
|
||||
userid = user.getUID()+"";
|
||||
}
|
||||
|
||||
String activeGroupId = "";
|
||||
int daysInMonth = 0;
|
||||
Map<String,String> weekMap = new HashMap<String,String>();
|
||||
List<Map<String,String>> weekList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
|
||||
activeGroupId = getUserActiveGroupId(userid);
|
||||
String fixedScheduleGroupId = "5";
|
||||
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(fixedScheduleGroupId,monthStartDate,monthEndDate);
|
||||
|
||||
int thisMonth = date.getMonthValue(); // 获取当前是哪月
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
|
||||
for (int i = 1; i <= daysInMonth; i++) {
|
||||
LocalDate currentDate = LocalDate.of(date.getYear(), thisMonth, i);
|
||||
System.out.println("currentDate:" + currentDate.toString());
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
System.out.println(i + "号是周 " + dayOfWeek.getValue());
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
String weekDayName = "";
|
||||
switch (weekValue) {
|
||||
case 1:
|
||||
weekDayName = "周一";
|
||||
break;
|
||||
case 2:
|
||||
weekDayName = "周二";
|
||||
break;
|
||||
case 3:
|
||||
weekDayName = "周三";
|
||||
break;
|
||||
case 4:
|
||||
weekDayName = "周四";
|
||||
break;
|
||||
case 5:
|
||||
weekDayName = "周五";
|
||||
break;
|
||||
case 6:
|
||||
weekDayName = "周六";
|
||||
break;
|
||||
case 7:
|
||||
weekDayName = "周日";
|
||||
break;
|
||||
}
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
weekMap = new HashMap<String,String>();
|
||||
weekMap.put("weekname", weekDayName);
|
||||
weekMap.put("changeType", changeType);
|
||||
weekMap.put("weekday", i+"");
|
||||
weekMap.put("weekdate", currentDate.toString());
|
||||
weekList.add(weekMap);
|
||||
}
|
||||
}
|
||||
|
||||
String serialids = "";
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql = " select serialids from kq_group where id = "+activeGroupId ;
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
serialids = Util.null2String(rs.getString("serialids"));
|
||||
}
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",weekList);
|
||||
jsonObject.put("count",daysInMonth);
|
||||
jsonObject.put("group",activeGroupId);
|
||||
jsonObject.put("serialids",serialids);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> getHolidayByGroupId(String activeGroupId,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
//String activeGroupId = getUserActiveGroupId(userid);
|
||||
// bb.writeLog("activeGroupId:"+activeGroupId);
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + activeGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
String changeTypename = "" ;
|
||||
if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
changeTypename += "公众假日";
|
||||
}else if("2".equals(changeType)){
|
||||
changeTypename += "调配工作日";
|
||||
}else if("3".equals(changeType)){
|
||||
changeTypename += "调配休息日";
|
||||
}
|
||||
holidayMap.put(holidayDate,changeTypename);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,221 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
|
||||
List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
Map<String,Object> valueMap = new HashMap<>();
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ;
|
||||
|
||||
hrmList = queryListBySql(sql);
|
||||
valueMap = getMainUserDate(hrmList);
|
||||
dt1List = getDt1UserDate(hrmList);
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",valueMap);
|
||||
jsonObject.put("dt1",dt1List);
|
||||
|
||||
String userid = user.getUID()+"" ;
|
||||
// if(hrmList !=null && hrmList.size() > 0){
|
||||
// userid = hrmList.get(0).get("id");
|
||||
// }
|
||||
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
String activeGroupId = getUserActiveGroupId(userid);
|
||||
String serialids = "";
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql = " select serialids from kq_group where id = "+activeGroupId ;
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
serialids = Util.null2String(rs.getString("serialids"));
|
||||
}
|
||||
}
|
||||
jsonObject.put("group",activeGroupId);
|
||||
jsonObject.put("serialids",serialids);
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
public List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,842 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String yg = request.getParameter("yg");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
|
||||
// List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
// if(StringUtils.isNotBlank(cjrbm)) {
|
||||
// String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+
|
||||
// " union "+
|
||||
// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+
|
||||
// " union "+
|
||||
// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ;
|
||||
//
|
||||
// hrmList = queryListBySql(sql);
|
||||
// }
|
||||
String userid = user.getUID()+"";
|
||||
// if(hrmList !=null && hrmList.size() > 0){
|
||||
// userid = hrmList.get(hrmList.size()-1).get("id");
|
||||
// }
|
||||
|
||||
String activeGroupId = getUserActiveGroupId(userid);
|
||||
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = firstDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
|
||||
String startDate = monthStartDate;
|
||||
String endDate = monthEndDate ;
|
||||
|
||||
String sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm = "+ yg +
|
||||
" and bm= "+ cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "+
|
||||
" order by id desc ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
endDate = ydsxrq;
|
||||
}
|
||||
}
|
||||
|
||||
sql =" select ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm ="+ yg +
|
||||
" and ydhbm="+cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "+
|
||||
" order by id desc ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
startDate = ydsxrq;
|
||||
}
|
||||
}
|
||||
|
||||
sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
// " and t.kqdate >='"+startDate+"' " +
|
||||
// " and t.kqdate <= '"+endDate+"'" +
|
||||
" and t.groupid="+activeGroupId+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + yg +
|
||||
" order by kqdate ";
|
||||
|
||||
bb.writeLog("sql:"+sql);
|
||||
List<Map<String,String>> sqlList = queryListBySql(sql);
|
||||
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> map = sqlList.get(i);
|
||||
|
||||
String serialid = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",serialid);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("serialid",serialid);
|
||||
valueMap.put("kqdate",kqdate);
|
||||
valueMap.put("xh",xh);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
scheduleList.add(valueMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("schedule",scheduleList);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate,activeGroupId);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate,String activeGroupId){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + activeGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getDt1UserMap(String ry,String lastname){
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
if(StringUtils.isNotBlank(ry)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",ry);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
valueMap.put("id",ry);
|
||||
valueMap.put("name",lastname);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
}
|
||||
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param pbyf
|
||||
* @param groupid
|
||||
* @param resourceid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid,Map<String,String> dateEffectiveMap){
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
try{
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){
|
||||
String startDate = "" ;
|
||||
String endDate = "";
|
||||
if(dateEffectiveMap.containsKey(resourceid)){
|
||||
String effectiveDate = dateEffectiveMap.get(resourceid);
|
||||
if(effectiveDate.contains(";")){
|
||||
String[] effective_Date = effectiveDate.split(";");
|
||||
startDate = effective_Date[0];
|
||||
endDate = effective_Date[1];
|
||||
}
|
||||
}
|
||||
|
||||
String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
" and t.kqdate >='"+startDate+"' " +
|
||||
" and t.kqdate <= '"+endDate+"'" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + resourceid +
|
||||
" order by kqdate ";
|
||||
bb.writeLog("sql:"+sql);
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> map = sqlList.get(i);
|
||||
|
||||
String serialid = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",serialid);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("serialid",serialid);
|
||||
valueMap.put("kqdate",kqdate);
|
||||
valueMap.put("xh",xh);
|
||||
|
||||
|
||||
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
|
||||
scheduleList.add(valueMap);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getSchedulingRestData(){
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql =" select id " +
|
||||
" from kq_ShiftManagement \n" +
|
||||
" where is_rest = 1 \n" +
|
||||
" and (isdelete is null or isdelete = 0) ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
list.add(id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param restList
|
||||
* @param daysList
|
||||
* @param weekMap
|
||||
* @param serialList
|
||||
*/
|
||||
public Map<String,String> queryCountWorkTime(List<String> restList,List<String> daysList,Map<String,String> weekMap,List<Map<String,Object>> serialList ){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String,String> countMap = new HashMap<>();
|
||||
String worktime = "0";
|
||||
String totalworktime = "0";
|
||||
int restcount = 0;
|
||||
int weekrestcount = 0;
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql = "";
|
||||
for (int i = 0; i < serialList.size(); i++) {
|
||||
Map<String,Object> serialMap = serialList.get(i);
|
||||
String kqdate = Util.null2String(serialMap.get("kqdate"));
|
||||
String serialid = Util.null2String(serialMap.get("serialid"));
|
||||
if (daysList.contains(kqdate)) {
|
||||
if (StringUtils.isNotBlank(serialid)) {
|
||||
if (restList.contains(serialid)) {
|
||||
restcount++;
|
||||
}
|
||||
|
||||
if(!restList.contains(serialid)){
|
||||
String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ;
|
||||
sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ;
|
||||
}
|
||||
}
|
||||
|
||||
if (weekMap.containsKey(kqdate)) {
|
||||
String value = weekMap.get(kqdate);
|
||||
//6 = 周六 7 = 周日 11 = 公众假日、调配休息日
|
||||
if ("6".equals(value) || "7".equals(value) || "11".equals(value)) {
|
||||
if (restList.contains(serialid)) {
|
||||
weekrestcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
worktime = Util.null2String(rs.getString("worktime"));
|
||||
totalworktime = Util.null2String(rs.getString("totalworktime"));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
countMap.put("worktime",worktime);
|
||||
countMap.put("totalworktime",totalworktime);
|
||||
countMap.put("restcount",restcount+"");
|
||||
countMap.put("weekrestcount",weekrestcount+"");
|
||||
|
||||
return countMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param daysList
|
||||
* @param holidayMap
|
||||
* @param yjl
|
||||
* @param workSchedule
|
||||
* @param hrmList
|
||||
* @param groupid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleStatusByDay(List<String> daysList,Map<String,String> holidayMap,String yjl,String[] workSchedule,List<Map<String,String>> hrmList,String groupid,Map<String,String> dateEffectiveMap){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> resultList = new ArrayList<Map<String,String>>();
|
||||
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try{
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(String pbrq:daysList){
|
||||
|
||||
String resourceids = "";
|
||||
for(int i=0;i<hrmList.size();i++) {
|
||||
Map<String, String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
if(dateEffectiveMap.containsKey(userid)){
|
||||
String effectiveDate = dateEffectiveMap.get(userid);
|
||||
if(effectiveDate.contains(";")){
|
||||
String[] effective_Date = effectiveDate.split(";");
|
||||
if(pbrq.compareTo(effective_Date[0])>=0 && pbrq.compareTo(effective_Date[1])<=0){
|
||||
resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(yjl)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{yjl,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){
|
||||
|
||||
String sql =" select t.serialid,t.resourceid,t.kqdate \n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" where t.kqdate='"+pbrq+"' \n" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid in( " + resourceids + ") "+
|
||||
" order by kqdate ";
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
Map<String,String> resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq);
|
||||
resultList.add(resultMap);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sqlList
|
||||
* @param workScheduleList
|
||||
* @param defaultScheduleMap
|
||||
* @param kqdate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> queryScheduleStatusByUser(List<Map<String,String>> sqlList,List<Map<String,String>> workScheduleList,Map<String,Integer> defaultScheduleMap,String kqdate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
String yxrys = "" ;
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String resourceid = Util.null2String(sqlMap.get("resourceid"));
|
||||
yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(yxrys)) {
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3,4)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3,4) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String pbry = sqlMap.get("resourceid");
|
||||
String serialid = sqlMap.get("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) ";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String,String> resultMap = new HashMap<>();
|
||||
String status = "0";
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
status = "0";
|
||||
}else{
|
||||
status = "1";
|
||||
}
|
||||
}
|
||||
resultMap.put("kqdate",kqdate);
|
||||
resultMap.put("status",status);
|
||||
resultMap.put("xh",xh);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,851 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String yg = request.getParameter("yg");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
|
||||
// List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
// if(StringUtils.isNotBlank(cjrbm)) {
|
||||
// String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+
|
||||
// " union "+
|
||||
// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+
|
||||
// " union "+
|
||||
// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ;
|
||||
// out.print("sql:"+sql+"</br>");
|
||||
// hrmList = queryListBySql(sql);
|
||||
// }
|
||||
String userid = user.getUID()+"" ;
|
||||
// if(hrmList !=null && hrmList.size() > 0){
|
||||
// userid = hrmList.get(hrmList.size()-1).get("id");
|
||||
// }
|
||||
out.print("userid:"+userid+"</br>");
|
||||
String activeGroupId = getUserActiveGroupId(userid);
|
||||
out.print("activeGroupId:"+activeGroupId+"</br>");
|
||||
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = firstDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
|
||||
String startDate = monthStartDate;
|
||||
String endDate = monthEndDate ;
|
||||
|
||||
|
||||
|
||||
String sql =" select ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm ="+ yg +
|
||||
" and ydhbm="+cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " +
|
||||
" order by id desc ";
|
||||
out.print("sql:"+sql+"</br>");
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
startDate = ydsxrq;
|
||||
}
|
||||
}
|
||||
out.print("startDate:"+startDate+"</br>");
|
||||
|
||||
sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm = "+ yg +
|
||||
" and bm= "+ cjrbm+
|
||||
" and ydsxrq > "+startDate +
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "+
|
||||
" order by id desc ";
|
||||
out.print("sql:"+sql+"</br>");
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
endDate = ydsxrq;
|
||||
}
|
||||
}
|
||||
out.print("endDate:"+endDate+"</br>");
|
||||
|
||||
sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
// " and t.kqdate >='"+startDate+"' " +
|
||||
// " and t.kqdate <= '"+endDate+"'" +
|
||||
" and t.groupid="+activeGroupId+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + yg +
|
||||
" order by kqdate ";
|
||||
out.print("sql:"+sql+"</br>");
|
||||
|
||||
bb.writeLog("sql:"+sql);
|
||||
List<Map<String,String>> sqlList = queryListBySql(sql);
|
||||
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> map = sqlList.get(i);
|
||||
|
||||
String serialid = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",serialid);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("serialid",serialid);
|
||||
valueMap.put("kqdate",kqdate);
|
||||
valueMap.put("xh",xh);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
scheduleList.add(valueMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("schedule",scheduleList);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate,activeGroupId);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate,String activeGroupId){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + activeGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getDt1UserMap(String ry,String lastname){
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
if(StringUtils.isNotBlank(ry)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",ry);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
valueMap.put("id",ry);
|
||||
valueMap.put("name",lastname);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
}
|
||||
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param pbyf
|
||||
* @param groupid
|
||||
* @param resourceid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid,Map<String,String> dateEffectiveMap){
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
try{
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){
|
||||
String startDate = "" ;
|
||||
String endDate = "";
|
||||
if(dateEffectiveMap.containsKey(resourceid)){
|
||||
String effectiveDate = dateEffectiveMap.get(resourceid);
|
||||
if(effectiveDate.contains(";")){
|
||||
String[] effective_Date = effectiveDate.split(";");
|
||||
startDate = effective_Date[0];
|
||||
endDate = effective_Date[1];
|
||||
}
|
||||
}
|
||||
|
||||
String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
" and t.kqdate >='"+startDate+"' " +
|
||||
" and t.kqdate <= '"+endDate+"'" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + resourceid +
|
||||
" order by kqdate ";
|
||||
bb.writeLog("sql:"+sql);
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> map = sqlList.get(i);
|
||||
|
||||
String serialid = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",serialid);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("serialid",serialid);
|
||||
valueMap.put("kqdate",kqdate);
|
||||
valueMap.put("xh",xh);
|
||||
|
||||
|
||||
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
|
||||
scheduleList.add(valueMap);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getSchedulingRestData(){
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql =" select id " +
|
||||
" from kq_ShiftManagement \n" +
|
||||
" where is_rest = 1 \n" +
|
||||
" and (isdelete is null or isdelete = 0) ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
list.add(id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param restList
|
||||
* @param daysList
|
||||
* @param weekMap
|
||||
* @param serialList
|
||||
*/
|
||||
public Map<String,String> queryCountWorkTime(List<String> restList,List<String> daysList,Map<String,String> weekMap,List<Map<String,Object>> serialList ){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String,String> countMap = new HashMap<>();
|
||||
String worktime = "0";
|
||||
String totalworktime = "0";
|
||||
int restcount = 0;
|
||||
int weekrestcount = 0;
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql = "";
|
||||
for (int i = 0; i < serialList.size(); i++) {
|
||||
Map<String,Object> serialMap = serialList.get(i);
|
||||
String kqdate = Util.null2String(serialMap.get("kqdate"));
|
||||
String serialid = Util.null2String(serialMap.get("serialid"));
|
||||
if (daysList.contains(kqdate)) {
|
||||
if (StringUtils.isNotBlank(serialid)) {
|
||||
if (restList.contains(serialid)) {
|
||||
restcount++;
|
||||
}
|
||||
|
||||
if(!restList.contains(serialid)){
|
||||
String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ;
|
||||
sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ;
|
||||
}
|
||||
}
|
||||
|
||||
if (weekMap.containsKey(kqdate)) {
|
||||
String value = weekMap.get(kqdate);
|
||||
//6 = 周六 7 = 周日 11 = 公众假日、调配休息日
|
||||
if ("6".equals(value) || "7".equals(value) || "11".equals(value)) {
|
||||
if (restList.contains(serialid)) {
|
||||
weekrestcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
worktime = Util.null2String(rs.getString("worktime"));
|
||||
totalworktime = Util.null2String(rs.getString("totalworktime"));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
countMap.put("worktime",worktime);
|
||||
countMap.put("totalworktime",totalworktime);
|
||||
countMap.put("restcount",restcount+"");
|
||||
countMap.put("weekrestcount",weekrestcount+"");
|
||||
|
||||
return countMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param daysList
|
||||
* @param holidayMap
|
||||
* @param yjl
|
||||
* @param workSchedule
|
||||
* @param hrmList
|
||||
* @param groupid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleStatusByDay(List<String> daysList,Map<String,String> holidayMap,String yjl,String[] workSchedule,List<Map<String,String>> hrmList,String groupid,Map<String,String> dateEffectiveMap){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> resultList = new ArrayList<Map<String,String>>();
|
||||
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try{
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(String pbrq:daysList){
|
||||
|
||||
String resourceids = "";
|
||||
for(int i=0;i<hrmList.size();i++) {
|
||||
Map<String, String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
if(dateEffectiveMap.containsKey(userid)){
|
||||
String effectiveDate = dateEffectiveMap.get(userid);
|
||||
if(effectiveDate.contains(";")){
|
||||
String[] effective_Date = effectiveDate.split(";");
|
||||
if(pbrq.compareTo(effective_Date[0])>=0 && pbrq.compareTo(effective_Date[1])<=0){
|
||||
resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(yjl)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{yjl,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){
|
||||
|
||||
String sql =" select t.serialid,t.resourceid,t.kqdate \n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" where t.kqdate='"+pbrq+"' \n" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid in( " + resourceids + ") "+
|
||||
" order by kqdate ";
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
Map<String,String> resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq);
|
||||
resultList.add(resultMap);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sqlList
|
||||
* @param workScheduleList
|
||||
* @param defaultScheduleMap
|
||||
* @param kqdate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> queryScheduleStatusByUser(List<Map<String,String>> sqlList,List<Map<String,String>> workScheduleList,Map<String,Integer> defaultScheduleMap,String kqdate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
String yxrys = "" ;
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String resourceid = Util.null2String(sqlMap.get("resourceid"));
|
||||
yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(yxrys)) {
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3,4)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3,4) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String pbry = sqlMap.get("resourceid");
|
||||
String serialid = sqlMap.get("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) ";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String,String> resultMap = new HashMap<>();
|
||||
String status = "0";
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
status = "0";
|
||||
}else{
|
||||
status = "1";
|
||||
}
|
||||
}
|
||||
resultMap.put("kqdate",kqdate);
|
||||
resultMap.put("status",status);
|
||||
resultMap.put("xh",xh);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String yg = request.getParameter("yg");
|
||||
|
||||
String startdate = "";
|
||||
String enddate = "";
|
||||
String sfdd = "1";
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate dateTime = LocalDate.parse(pbyf+"-01", formatter);
|
||||
LocalDate firstDayOfMonth = dateTime.with(TemporalAdjusters.firstDayOfMonth());
|
||||
LocalDate lastDayOfMonth = dateTime.with(TemporalAdjusters.lastDayOfMonth());
|
||||
startdate = firstDayOfMonth.toString();
|
||||
enddate = lastDayOfMonth.toString();
|
||||
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
String sql =" select ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm ="+ yg +
|
||||
" and ydhbm="+cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " +
|
||||
" order by id desc ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
startdate = ydsxrq;
|
||||
sfdd = "0";
|
||||
}
|
||||
}
|
||||
|
||||
sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm = "+ yg +
|
||||
" and bm= "+ cjrbm+
|
||||
" and ydsxrq > '"+startdate + "'"+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " +
|
||||
" order by id desc ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
enddate = ydsxrq;
|
||||
sfdd = "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("startdate",startdate);
|
||||
jsonObject.put("enddate",enddate);
|
||||
jsonObject.put("sfdd",sfdd);
|
||||
|
||||
%>
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String yg = request.getParameter("yg");
|
||||
|
||||
String startdate = "";
|
||||
String enddate = "";
|
||||
String sfdd = "1";
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate dateTime = LocalDate.parse(pbyf+"-01", formatter);
|
||||
LocalDate firstDayOfMonth = dateTime.with(TemporalAdjusters.firstDayOfMonth());
|
||||
LocalDate lastDayOfMonth = dateTime.with(TemporalAdjusters.lastDayOfMonth());
|
||||
startdate = firstDayOfMonth.toString();
|
||||
enddate = lastDayOfMonth.toString();
|
||||
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
String sql =" select ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm ="+ yg +
|
||||
" and ydhbm="+cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " +
|
||||
" order by id desc ";
|
||||
out.print("sql:"+sql+"</br>");
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
out.print("ydsxrq:"+ydsxrq+"</br>");
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
startdate = ydsxrq;
|
||||
sfdd = "0";
|
||||
}
|
||||
}
|
||||
|
||||
sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm = "+ yg +
|
||||
" and bm= "+ cjrbm+
|
||||
" and ydsxrq > "+startdate +
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " +
|
||||
" order by id desc ";
|
||||
rs.executeQuery(sql);
|
||||
out.print("sql:"+sql+"</br>");
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
out.print("ydsxrq:"+ydsxrq+"</br>");
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
enddate = ydsxrq;
|
||||
sfdd = "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("startdate",startdate);
|
||||
jsonObject.put("enddate",enddate);
|
||||
jsonObject.put("sfdd",sfdd);
|
||||
|
||||
%>
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,440 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"};
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
int userid = user.getUID();
|
||||
RecordSet rs = new RecordSet();
|
||||
String pbdata = request.getParameter("pbdata");
|
||||
String bp = request.getParameter("bp");
|
||||
// String yjl = request.getParameter("yjl");
|
||||
|
||||
String ry = "";
|
||||
if(StringUtils.isNotBlank(pbdata)) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(pbdata);
|
||||
if(jsonArray.size()>0){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(0);
|
||||
ry = jsonObject.getString("userid");
|
||||
}
|
||||
}
|
||||
if(StringUtils.isBlank(ry)){
|
||||
ry = userid+"";
|
||||
}
|
||||
|
||||
String pbrq = request.getParameter("pbrq");
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
dateType = getWeekTypeByDate(pbrq,ry);
|
||||
}
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(bp)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where bprs = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{bp,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(k==0){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start","");
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}else if(k==(workSchedule.length-1)){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end","");
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(pbdata)) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(pbdata);
|
||||
|
||||
String yxrys = "" ;
|
||||
for(int i = 0;i<jsonArray.size();i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
yxrys+= StringUtils.isBlank(yxrys) ? pbry : ","+pbry ;
|
||||
}
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
|
||||
String serialid = jsonObject.getString("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) and serialid in( select id from kq_ShiftManagement where (is_rest is null or is_rest = 0) )";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(StringUtils.isNotBlank(scheduleStartTime)){
|
||||
|
||||
if(endTime.compareTo(scheduleStartTime) >=0 ){
|
||||
String define_scheduleEndTime = "21:30";
|
||||
String defWorkSchedule = scheduleStartTime+"-"+define_scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}else if(StringUtils.isNotBlank(scheduleEndTime)){
|
||||
|
||||
if(startTime.compareTo(scheduleEndTime) <=0){
|
||||
String define_scheduleStartTime = "09:00";
|
||||
String defWorkSchedule = define_scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
jsonObject.put("pbcode","1");
|
||||
}else{
|
||||
jsonObject.put("pbcode","2");
|
||||
}
|
||||
}else{
|
||||
jsonObject.put("pbcode","0");
|
||||
}
|
||||
|
||||
jsonObject.put("pbinfo",userScheduleDayMap);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("2".equals(changeType)){
|
||||
dateType = "0";
|
||||
}else if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
// String activeGroupId = getUserActiveGroupId(userid);
|
||||
// bb.writeLog("activeGroupId:"+activeGroupId);
|
||||
|
||||
String fixedScheduleGroupId = "5";
|
||||
if(StringUtils.isNotBlank(fixedScheduleGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + fixedScheduleGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,263 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
RecordSet rs = new RecordSet();
|
||||
String serialids = request.getParameter("serialids");
|
||||
|
||||
String userid = request.getParameter("userid");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String serdata = request.getParameter("serdata");
|
||||
List<String> restList = getSchedulingRestData();
|
||||
|
||||
String worktime = "0";
|
||||
String totalworktime = "0";
|
||||
if(StringUtils.isNotBlank(serialids)){
|
||||
String sql = "";
|
||||
String[] serialidArray = serialids.split(",");
|
||||
for(int i=0;i<serialidArray.length;i++){
|
||||
String serialid = serialidArray[i];
|
||||
if(StringUtils.isNotBlank(serialid)){
|
||||
if(!restList.contains(serialid)){
|
||||
String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (isdelete = 0 or isdelete is null) " ;
|
||||
sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
worktime = Util.null2String(rs.getString("worktime"));
|
||||
totalworktime = Util.null2String(rs.getString("totalworktime"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int restcount = 0;
|
||||
int weekrestcount = 0;
|
||||
|
||||
Map<String,String> weekMap = queryWeekTypeByMonth(userid,pbyf);
|
||||
if(StringUtils.isNotBlank(serdata)){
|
||||
JSONArray jsonArray = JSONArray.parseArray(serdata);
|
||||
for(int i=0;i<jsonArray.size();i++){
|
||||
JSONObject dataJSON = jsonArray.getJSONObject(i);
|
||||
String date = dataJSON.getString("date");
|
||||
String serialid = dataJSON.getString("serialid");
|
||||
if(StringUtils.isNotBlank(serialid)){
|
||||
if(restList.contains(serialid)){
|
||||
restcount++;
|
||||
}
|
||||
}
|
||||
|
||||
if(weekMap.containsKey(date)){
|
||||
String value = weekMap.get(date);
|
||||
//6 = 周六 7 = 周日 11 = 公众假日、调配休息日
|
||||
if("6".equals(value) || "7".equals(value) || "11".equals(value)){
|
||||
if(restList.contains(serialid)){
|
||||
weekrestcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",worktime);
|
||||
jsonObject.put("total",totalworktime);
|
||||
jsonObject.put("restcount",restcount+"");
|
||||
jsonObject.put("weekrestcount",weekrestcount+"");
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
<%!
|
||||
public Map<String,String> queryWeekTypeByMonth(String userid,String pbyf){
|
||||
|
||||
Map<String,String> weekMap = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate);
|
||||
|
||||
int thisMonth = date.getMonthValue(); // 获取当前是哪月
|
||||
int daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
|
||||
for (int i = 1; i <= daysInMonth; i++) {
|
||||
LocalDate currentDate = LocalDate.of(date.getYear(), thisMonth, i);
|
||||
System.out.println("currentDate:" + currentDate.toString());
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
System.out.println(i + "号是周 " + dayOfWeek.getValue());
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
weekValue = 11;
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(changeType)){
|
||||
weekMap.put(currentDate.toString(), weekValue+"");
|
||||
}else{
|
||||
weekMap.put(currentDate.toString(), weekValue+"");
|
||||
}
|
||||
}
|
||||
}
|
||||
return weekMap;
|
||||
}
|
||||
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
// String activeGroupId = getUserActiveGroupId(userid);
|
||||
|
||||
String fixedScheduleGroupId = "5";
|
||||
bb.writeLog("activeGroupId:"+fixedScheduleGroupId);
|
||||
if(StringUtils.isNotBlank(fixedScheduleGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + fixedScheduleGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
public List<String> getSchedulingRestData(){
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql =" select id " +
|
||||
" from kq_ShiftManagement \n" +
|
||||
" where is_rest = 1 \n" +
|
||||
" and (isdelete is null or isdelete = 0) ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
list.add(id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,306 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String userid = user.getUID()+"";
|
||||
Set<String> groupSet = new HashSet<String>();
|
||||
|
||||
List<Map<String,String>> userGroupList = getUserKqGroupData(userid);
|
||||
String activeGroupId = getUserActiveGroupId(userid);
|
||||
int daysInMonth = 0;
|
||||
Map<String,String> weekMap = new HashMap<String,String>();
|
||||
List<Map<String,String>> weekList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
|
||||
String fixedScheduleGroupId = "5";
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(fixedScheduleGroupId,monthStartDate,monthEndDate);
|
||||
|
||||
int thisMonth = date.getMonthValue(); // 获取当前是哪月
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
|
||||
|
||||
for (int i = 1; i <= daysInMonth; i++) {
|
||||
LocalDate currentDate = LocalDate.of(date.getYear(), thisMonth, i);
|
||||
System.out.println("currentDate:" + currentDate.toString());
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
System.out.println(i + "号是周 " + dayOfWeek.getValue());
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
String weekDayName = "";
|
||||
switch (weekValue) {
|
||||
case 1:
|
||||
weekDayName = "周一";
|
||||
break;
|
||||
case 2:
|
||||
weekDayName = "周二";
|
||||
break;
|
||||
case 3:
|
||||
weekDayName = "周三";
|
||||
break;
|
||||
case 4:
|
||||
weekDayName = "周四";
|
||||
break;
|
||||
case 5:
|
||||
weekDayName = "周五";
|
||||
break;
|
||||
case 6:
|
||||
weekDayName = "周六";
|
||||
break;
|
||||
case 7:
|
||||
weekDayName = "周日";
|
||||
break;
|
||||
}
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
weekMap = new HashMap<String,String>();
|
||||
weekMap.put("weekname", weekDayName);
|
||||
weekMap.put("changeType", changeType);
|
||||
weekMap.put("weekday", i+"");
|
||||
weekMap.put("weekdate", currentDate.toString());
|
||||
weekList.add(weekMap);
|
||||
|
||||
String kqdate = currentDate.toString();
|
||||
for(int n=0;n<userGroupList.size();n++){
|
||||
Map<String,String> userGrupMap = userGroupList.get(n);
|
||||
String validatefrom = userGrupMap.get("validatefrom");
|
||||
String validateto = userGrupMap.get("validateto");
|
||||
if(kqdate.compareTo(validatefrom)>=0 && kqdate.compareTo(validateto) < 0){
|
||||
String groupid = userGrupMap.get("groupid");
|
||||
groupSet.add(groupid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String serialids = "";
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql = " select serialids from kq_group where id = "+activeGroupId ;
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
serialids = Util.null2String(rs.getString("serialids"));
|
||||
}
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",weekList);
|
||||
jsonObject.put("count",daysInMonth);
|
||||
jsonObject.put("group",activeGroupId);
|
||||
jsonObject.put("serialids",serialids);
|
||||
jsonObject.put("size",groupSet.size());
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> getHolidayByGroupId(String activeGroupId,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
//String activeGroupId = getUserActiveGroupId(userid);
|
||||
// bb.writeLog("activeGroupId:"+activeGroupId);
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + activeGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
String changeTypename = "" ;
|
||||
if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
changeTypename += "公众假日";
|
||||
}else if("2".equals(changeType)){
|
||||
changeTypename += "调配工作日";
|
||||
}else if("3".equals(changeType)){
|
||||
changeTypename += "调配休息日";
|
||||
}
|
||||
holidayMap.put(holidayDate,changeTypename);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getUserKqGroupData(String userid){
|
||||
|
||||
List<Map<String,String>> userGroupList = new ArrayList<Map<String,String>>();
|
||||
|
||||
try{
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
String sql =" select distinct resourceid, groupid,status,validatefrom,validateto FROM ( \n" +
|
||||
" select a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" where a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') \n" +
|
||||
" union all \n" +
|
||||
" select a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" where a.subcompanyid1 = b.typevalue and b.type=2 and a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') \n" +
|
||||
" union all \n" +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" WHERE a.departmentid = b.typevalue AND b.type=3 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') \n" +
|
||||
" UNION ALL \n" +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" WHERE a.jobtitle = b.typevalue AND b.type=5 \n" +
|
||||
" AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))) \n" +
|
||||
" and (b.isdelete is null or b.isdelete <> '1') \n" +
|
||||
" UNION ALL \n" +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') ) t\n" +
|
||||
" where resourceid="+userid ;
|
||||
userGroupList = queryListBySql(sql);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return userGroupList;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Map<String,Object>> mainList = new ArrayList<Map<String,Object>>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String pbry = request.getParameter("pbry");
|
||||
if(StringUtils.isNotBlank(pbry)) {
|
||||
String sql = "select id,lastname from hrmresource where id in("+pbry+")";
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String userid = Util.null2String(rs.getString("id"));
|
||||
String lastname = Util.null2String(rs.getString("lastname"));
|
||||
|
||||
Map<String,Object> mainMap = new HashMap<String,Object>();
|
||||
mainMap.put("id",userid);
|
||||
mainMap.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userid);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
mainMap.put("value",valueMap);
|
||||
mainList.add(mainMap);
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("main",mainList);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,222 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
|
||||
List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
Map<String,Object> valueMap = new HashMap<>();
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
// String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('督导','营运经理'))"+
|
||||
// " union "+
|
||||
// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('督导','营运经理')) " ;
|
||||
|
||||
String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ;
|
||||
|
||||
hrmList = queryListBySql(sql);
|
||||
valueMap = getMainUserDate(hrmList);
|
||||
dt1List = getDt1UserDate(hrmList);
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",valueMap);
|
||||
jsonObject.put("dt1",dt1List);
|
||||
|
||||
String userid = user.getUID()+"";
|
||||
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
String activeGroupId = getUserActiveGroupId(userid);
|
||||
String serialids = "";
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql = " select serialids from kq_group where id = "+activeGroupId ;
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
serialids = Util.null2String(rs.getString("serialids"));
|
||||
}
|
||||
}
|
||||
jsonObject.put("group",activeGroupId);
|
||||
jsonObject.put("serialids",serialids);
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
public List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,225 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
|
||||
List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
Map<String,Object> valueMap = new HashMap<>();
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
// String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('督导','营运经理'))"+
|
||||
// " union "+
|
||||
// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('督导','营运经理')) " ;
|
||||
|
||||
String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))"+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ;
|
||||
|
||||
|
||||
hrmList = queryListBySql(sql);
|
||||
valueMap = getMainUserDate(hrmList);
|
||||
dt1List = getDt1UserDate(hrmList);
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",valueMap);
|
||||
jsonObject.put("dt1",dt1List);
|
||||
|
||||
|
||||
String userid = "" ;
|
||||
if(hrmList !=null && hrmList.size() > 0){
|
||||
userid = hrmList.get(0).get("id");
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
String activeGroupId = getUserActiveGroupId(userid);
|
||||
String serialids = "";
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql = " select serialids from kq_group where id = "+activeGroupId ;
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
serialids = Util.null2String(rs.getString("serialids"));
|
||||
}
|
||||
}
|
||||
jsonObject.put("group",activeGroupId);
|
||||
jsonObject.put("serialids",serialids);
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
public List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String yg = request.getParameter("yg");
|
||||
|
||||
String startdate = "";
|
||||
String enddate = "";
|
||||
String sfdd = "1";
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate dateTime = LocalDate.parse(pbyf+"-01", formatter);
|
||||
LocalDate firstDayOfMonth = dateTime.with(TemporalAdjusters.firstDayOfMonth());
|
||||
LocalDate lastDayOfMonth = dateTime.with(TemporalAdjusters.lastDayOfMonth());
|
||||
startdate = firstDayOfMonth.toString();
|
||||
enddate = lastDayOfMonth.toString();
|
||||
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
String sql =" select ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm ="+ yg +
|
||||
" and ydhbm="+cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " +
|
||||
" order by id desc ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
startdate = ydsxrq;
|
||||
sfdd = "0";
|
||||
}
|
||||
}
|
||||
|
||||
sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm = "+ yg +
|
||||
" and bm= "+ cjrbm+
|
||||
" and ydsxrq > '"+startdate +"'"+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " +
|
||||
" order by id desc ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
enddate = ydsxrq;
|
||||
sfdd = "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("startdate",startdate);
|
||||
jsonObject.put("enddate",enddate);
|
||||
jsonObject.put("sfdd",sfdd);
|
||||
|
||||
%>
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String yg = request.getParameter("yg");
|
||||
out.print("cjrbm:"+cjrbm+"</br>");
|
||||
out.print("pbyf:"+pbyf+"</br>");
|
||||
out.print("yg:"+yg+"</br>");
|
||||
|
||||
String startdate = "";
|
||||
String enddate = "";
|
||||
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
|
||||
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
// LocalDate dateTime = LocalDate.parse(pbyf+"-01", formatter);
|
||||
// LocalDate firstDayOfMonth = dateTime.with(TemporalAdjusters.firstDayOfMonth());
|
||||
// LocalDate lastDayOfMonth = dateTime.with(TemporalAdjusters.lastDayOfMonth());
|
||||
// startdate = firstDayOfMonth.toString();
|
||||
// enddate = lastDayOfMonth.toString();
|
||||
// out.print("startdate:"+startdate+"</br>");
|
||||
// out.print("enddate:"+enddate+"</br>");
|
||||
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
|
||||
String sql =" select ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm = "+ yg +
|
||||
" and ydhbm= "+ cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) ";
|
||||
out.print("sql:"+sql+"</br>");
|
||||
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
enddate = ydsxrq;
|
||||
}
|
||||
}
|
||||
out.print("enddate:"+enddate+"</br>");
|
||||
sql =" select ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm ="+ yg +
|
||||
" and ydhbm="+cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) ";
|
||||
rs.executeQuery(sql);
|
||||
out.print("sql:"+sql+"</br>");
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
startdate = ydsxrq;
|
||||
}
|
||||
}
|
||||
|
||||
out.print("startdate:"+startdate+"</br>");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("startdate",startdate);
|
||||
jsonObject.put("enddate",enddate);
|
||||
|
||||
%>
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String yg = request.getParameter("yg");
|
||||
|
||||
String startdate = "";
|
||||
String enddate = "";
|
||||
String sfdd = "1";
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate dateTime = LocalDate.parse(pbyf+"-01", formatter);
|
||||
LocalDate firstDayOfMonth = dateTime.with(TemporalAdjusters.firstDayOfMonth());
|
||||
LocalDate lastDayOfMonth = dateTime.with(TemporalAdjusters.lastDayOfMonth());
|
||||
startdate = firstDayOfMonth.toString();
|
||||
enddate = lastDayOfMonth.toString();
|
||||
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
String sql =" select ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm ="+ yg +
|
||||
" and ydhbm="+cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " +
|
||||
" order by id desc ";
|
||||
out.print("sql:"+sql+"</br>");
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
out.print("ydsxrq:"+ydsxrq+"</br>");
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
startdate = ydsxrq;
|
||||
sfdd = "0";
|
||||
}
|
||||
}
|
||||
|
||||
sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm = "+ yg +
|
||||
" and bm= "+ cjrbm+
|
||||
" and ydsxrq > '"+startdate +"'"+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " +
|
||||
" order by id desc ";
|
||||
rs.executeQuery(sql);
|
||||
out.print("sql:"+sql+"</br>");
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
out.print("ydsxrq:"+ydsxrq+"</br>");
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
enddate = ydsxrq;
|
||||
sfdd = "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("startdate",startdate);
|
||||
jsonObject.put("enddate",enddate);
|
||||
jsonObject.put("sfdd",sfdd);
|
||||
|
||||
%>
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,381 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"};
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
int userid = user.getUID();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String pbdata = request.getParameter("pbdata");
|
||||
// if(StringUtils.isBlank(pb)){
|
||||
//
|
||||
// JSONArray jsonArray = new JSONArray();
|
||||
// JSONObject userObject = new JSONObject();
|
||||
// userObject.put("userid","3039");
|
||||
// userObject.put("serialid","10");
|
||||
// jsonArray.add(userObject);
|
||||
//
|
||||
// userObject = new JSONObject();
|
||||
// userObject.put("userid","3373");
|
||||
// userObject.put("serialid","7");
|
||||
// jsonArray.add(userObject);
|
||||
//
|
||||
// userObject = new JSONObject();
|
||||
// userObject.put("userid","3661");
|
||||
// userObject.put("serialid","9");
|
||||
// jsonArray.add(userObject);
|
||||
// pb = jsonArray.toJSONString();
|
||||
// }
|
||||
String yjl = request.getParameter("yjl");
|
||||
String pbrq = request.getParameter("pbrq");
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
dateType = getWeekTypeByDate(pbrq,userid+"");
|
||||
}
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(yjl)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{yjl,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(pbdata)) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(pbdata);
|
||||
|
||||
String yxrys = "" ;
|
||||
for(int i = 0;i<jsonArray.size();i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
yxrys+= StringUtils.isBlank(yxrys) ? pbry : ","+pbry ;
|
||||
}
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3,4)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3,4) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
|
||||
String serialid = jsonObject.getString("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) ";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
jsonObject.put("pbcode","1");
|
||||
}else{
|
||||
jsonObject.put("pbcode","2");
|
||||
}
|
||||
}else{
|
||||
jsonObject.put("pbcode","0");
|
||||
}
|
||||
|
||||
jsonObject.put("pbinfo",userScheduleDayMap);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
// String activeGroupId = getUserActiveGroupId(userid);
|
||||
// bb.writeLog("activeGroupId:"+activeGroupId);
|
||||
|
||||
String fixedScheduleGroupId = "5";
|
||||
|
||||
if(StringUtils.isNotBlank(fixedScheduleGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + fixedScheduleGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,385 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"};
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
int userid = user.getUID();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String pbdata = request.getParameter("pbdata");
|
||||
// if(StringUtils.isBlank(pb)){
|
||||
//
|
||||
// JSONArray jsonArray = new JSONArray();
|
||||
// JSONObject userObject = new JSONObject();
|
||||
// userObject.put("userid","3039");
|
||||
// userObject.put("serialid","10");
|
||||
// jsonArray.add(userObject);
|
||||
//
|
||||
// userObject = new JSONObject();
|
||||
// userObject.put("userid","3373");
|
||||
// userObject.put("serialid","7");
|
||||
// jsonArray.add(userObject);
|
||||
//
|
||||
// userObject = new JSONObject();
|
||||
// userObject.put("userid","3661");
|
||||
// userObject.put("serialid","9");
|
||||
// jsonArray.add(userObject);
|
||||
// pb = jsonArray.toJSONString();
|
||||
// }
|
||||
String yjl = request.getParameter("yjl");
|
||||
String pbrq = request.getParameter("pbrq");
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
dateType = getWeekTypeByDate(pbrq,userid+"");
|
||||
}
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(yjl)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{yjl,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(pbdata)) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(pbdata);
|
||||
|
||||
String yxrys = "" ;
|
||||
for(int i = 0;i<jsonArray.size();i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
yxrys+= StringUtils.isBlank(yxrys) ? pbry : ","+pbry ;
|
||||
}
|
||||
out.println("yxrys:"+yxrys+"</br>");
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3,4)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3,4) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
out.println("sql:"+sql+"</br>");
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
out.println("id:"+id+"</br>");
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
|
||||
String serialid = jsonObject.getString("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) ";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
out.println("necessaryMap:"+necessaryMap.size());
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
jsonObject.put("pbcode","1");
|
||||
}else{
|
||||
jsonObject.put("pbcode","2");
|
||||
}
|
||||
}else{
|
||||
jsonObject.put("pbcode","0");
|
||||
}
|
||||
|
||||
jsonObject.put("pbinfo",userScheduleDayMap);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
// String activeGroupId = getUserActiveGroupId(userid);
|
||||
// bb.writeLog("activeGroupId:"+activeGroupId);
|
||||
|
||||
String fixedScheduleGroupId = "5";
|
||||
if(StringUtils.isNotBlank(fixedScheduleGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + fixedScheduleGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,450 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"};
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
int userid = user.getUID();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String pbdata = request.getParameter("pbdata");
|
||||
String bp = request.getParameter("bp");
|
||||
|
||||
// if(StringUtils.isBlank(pb)){
|
||||
//
|
||||
// JSONArray jsonArray = new JSONArray();
|
||||
// JSONObject userObject = new JSONObject();
|
||||
// userObject.put("userid","3039");
|
||||
// userObject.put("serialid","10");
|
||||
// jsonArray.add(userObject);
|
||||
//
|
||||
// userObject = new JSONObject();
|
||||
// userObject.put("userid","3373");
|
||||
// userObject.put("serialid","7");
|
||||
// jsonArray.add(userObject);
|
||||
//
|
||||
// userObject = new JSONObject();
|
||||
// userObject.put("userid","3661");
|
||||
// userObject.put("serialid","9");
|
||||
// jsonArray.add(userObject);
|
||||
// pb = jsonArray.toJSONString();
|
||||
// }
|
||||
|
||||
String yjl = request.getParameter("yjl");
|
||||
String pbrq = request.getParameter("pbrq");
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
dateType = getWeekTypeByDate(pbrq,userid+"");
|
||||
}
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(bp)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where bprs = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{bp,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(k==0){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start","");
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}else if(k==(workSchedule.length-1)){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end","");
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(pbdata)) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(pbdata);
|
||||
|
||||
String yxrys = "" ;
|
||||
for(int i = 0;i<jsonArray.size();i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
yxrys+= StringUtils.isBlank(yxrys) ? pbry : ","+pbry ;
|
||||
}
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
|
||||
String serialid = jsonObject.getString("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) and serialid in( select id from kq_ShiftManagement where (is_rest is null or is_rest = 0) )";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(StringUtils.isNotBlank(scheduleStartTime)){
|
||||
|
||||
if(endTime.compareTo(scheduleStartTime) >=0 ){
|
||||
String define_scheduleEndTime = "21:30";
|
||||
String defWorkSchedule = scheduleStartTime+"-"+define_scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}else if(StringUtils.isNotBlank(scheduleEndTime)){
|
||||
|
||||
if(startTime.compareTo(scheduleEndTime) <=0){
|
||||
String define_scheduleStartTime = "09:00";
|
||||
String defWorkSchedule = define_scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
jsonObject.put("pbcode","1");
|
||||
}else{
|
||||
jsonObject.put("pbcode","2");
|
||||
}
|
||||
}else{
|
||||
jsonObject.put("pbcode","0");
|
||||
}
|
||||
|
||||
jsonObject.put("pbinfo",userScheduleDayMap);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("2".equals(changeType)){
|
||||
dateType = "0";
|
||||
}else if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
// String activeGroupId = getUserActiveGroupId(userid);
|
||||
// bb.writeLog("activeGroupId:"+activeGroupId);
|
||||
|
||||
String fixedScheduleGroupId = "5";
|
||||
if(StringUtils.isNotBlank(fixedScheduleGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + fixedScheduleGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,450 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"};
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
int userid = user.getUID();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String pbdata = request.getParameter("pbdata");
|
||||
String bp = request.getParameter("bp");
|
||||
|
||||
// if(StringUtils.isBlank(pb)){
|
||||
//
|
||||
// JSONArray jsonArray = new JSONArray();
|
||||
// JSONObject userObject = new JSONObject();
|
||||
// userObject.put("userid","3039");
|
||||
// userObject.put("serialid","10");
|
||||
// jsonArray.add(userObject);
|
||||
//
|
||||
// userObject = new JSONObject();
|
||||
// userObject.put("userid","3373");
|
||||
// userObject.put("serialid","7");
|
||||
// jsonArray.add(userObject);
|
||||
//
|
||||
// userObject = new JSONObject();
|
||||
// userObject.put("userid","3661");
|
||||
// userObject.put("serialid","9");
|
||||
// jsonArray.add(userObject);
|
||||
// pb = jsonArray.toJSONString();
|
||||
// }
|
||||
|
||||
String yjl = request.getParameter("yjl");
|
||||
String pbrq = request.getParameter("pbrq");
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
dateType = getWeekTypeByDate(pbrq,userid+"");
|
||||
}
|
||||
out.print("dateType:"+dateType);
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(bp)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where bprs = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{bp,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(k==0){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start","");
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}else if(k==(workSchedule.length-1)){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end","");
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(pbdata)) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(pbdata);
|
||||
|
||||
String yxrys = "" ;
|
||||
for(int i = 0;i<jsonArray.size();i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
yxrys+= StringUtils.isBlank(yxrys) ? pbry : ","+pbry ;
|
||||
}
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
|
||||
String serialid = jsonObject.getString("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) and serialid in( select id from kq_ShiftManagement where (is_rest is null or is_rest = 0) )";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(StringUtils.isNotBlank(scheduleStartTime)){
|
||||
|
||||
if(endTime.compareTo(scheduleStartTime) >=0 ){
|
||||
String define_scheduleEndTime = "21:30";
|
||||
String defWorkSchedule = scheduleStartTime+"-"+define_scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}else if(StringUtils.isNotBlank(scheduleEndTime)){
|
||||
|
||||
if(startTime.compareTo(scheduleEndTime) <=0){
|
||||
String define_scheduleStartTime = "09:00";
|
||||
String defWorkSchedule = define_scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
jsonObject.put("pbcode","1");
|
||||
}else{
|
||||
jsonObject.put("pbcode","2");
|
||||
}
|
||||
}else{
|
||||
jsonObject.put("pbcode","0");
|
||||
}
|
||||
|
||||
jsonObject.put("pbinfo",userScheduleDayMap);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}else if("2".equals(changeType)){
|
||||
dateType = "0";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
// String activeGroupId = getUserActiveGroupId(userid);
|
||||
// bb.writeLog("activeGroupId:"+activeGroupId);
|
||||
|
||||
String fixedScheduleGroupId = "5";
|
||||
if(StringUtils.isNotBlank(fixedScheduleGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + fixedScheduleGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,248 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"};
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
int userid = user.getUID();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String pbrq = request.getParameter("pbrq");
|
||||
String bp = request.getParameter("bp");
|
||||
|
||||
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid+"",monthStartDate,monthEndDate);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
out.print("changeType:"+changeType+"</br>");
|
||||
}
|
||||
|
||||
if("2".equals(changeType)){
|
||||
dateType = "0";
|
||||
}else if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
|
||||
out.print("dateType:"+dateType+"</br>");
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(bp)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where bprs = ? and pblx = ?" ;
|
||||
out.print("sql:"+sql+"</br>");
|
||||
rs.executeQuery(sql,new Object[]{bp,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}else if("2".equals(changeType)){
|
||||
dateType = "0";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
// String activeGroupId = getUserActiveGroupId(userid);
|
||||
// bb.writeLog("activeGroupId:"+activeGroupId);
|
||||
|
||||
String fixedScheduleGroupId = "5";
|
||||
if(StringUtils.isNotBlank(fixedScheduleGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + fixedScheduleGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,470 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"};
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
int userid = user.getUID();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String pbdata = request.getParameter("pbdata");
|
||||
String bp = request.getParameter("bp");
|
||||
|
||||
// if(StringUtils.isBlank(pb)){
|
||||
//
|
||||
// JSONArray jsonArray = new JSONArray();
|
||||
// JSONObject userObject = new JSONObject();
|
||||
// userObject.put("userid","3039");
|
||||
// userObject.put("serialid","10");
|
||||
// jsonArray.add(userObject);
|
||||
//
|
||||
// userObject = new JSONObject();
|
||||
// userObject.put("userid","3373");
|
||||
// userObject.put("serialid","7");
|
||||
// jsonArray.add(userObject);
|
||||
//
|
||||
// userObject = new JSONObject();
|
||||
// userObject.put("userid","3661");
|
||||
// userObject.put("serialid","9");
|
||||
// jsonArray.add(userObject);
|
||||
// pb = jsonArray.toJSONString();
|
||||
// }
|
||||
|
||||
String yjl = request.getParameter("yjl");
|
||||
String pbrq = request.getParameter("pbrq");
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
dateType = getWeekTypeByDate(pbrq,userid+"");
|
||||
}
|
||||
|
||||
out.print("bp:"+bp+"</br>");
|
||||
out.print("dateType:"+dateType+"</br>");
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(bp)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where bprs = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{bp,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
out.print("dysd:"+dateType+"</br>");
|
||||
out.print("pzrs:"+pzrs+"</br>");
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(k==0){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start","");
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}else if(k==(workSchedule.length-1)){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end","");
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(pbdata)) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(pbdata);
|
||||
|
||||
String yxrys = "" ;
|
||||
for(int i = 0;i<jsonArray.size();i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
yxrys+= StringUtils.isBlank(yxrys) ? pbry : ","+pbry ;
|
||||
}
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
out.print("sql:"+sql+"</br>");
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
out.print("userList:"+userList.size()+"</br>");
|
||||
|
||||
for(int i = 0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
|
||||
String serialid = jsonObject.getString("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) and serialid in( select id from kq_ShiftManagement where (is_rest is null or is_rest = 0) )";
|
||||
out.print("sql:"+sql+"</br>");
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
out.print("startTime:"+startTime+"</br>");
|
||||
out.print("endTime:"+endTime+"</br>");
|
||||
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(StringUtils.isNotBlank(scheduleStartTime)){
|
||||
|
||||
if(endTime.compareTo(scheduleStartTime) >=0 ){
|
||||
String define_scheduleEndTime = "21:30";
|
||||
String defWorkSchedule = scheduleStartTime+"-"+define_scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}else if(StringUtils.isNotBlank(scheduleEndTime)){
|
||||
|
||||
if(startTime.compareTo(scheduleEndTime) <=0){
|
||||
String define_scheduleStartTime = "09:00";
|
||||
String defWorkSchedule = define_scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
out.print("userScheduleDayMap:"+userScheduleDayMap.size()+"</br>");
|
||||
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
out.print("value:"+value+"</br>");
|
||||
out.print("key:"+key+"</br>");
|
||||
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
out.print("useValue:"+useValue+"</br>");
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
out.print("datacount:"+datacount+"</br>");
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
jsonObject.put("pbcode","1");
|
||||
}else{
|
||||
jsonObject.put("pbcode","2");
|
||||
}
|
||||
}else{
|
||||
jsonObject.put("pbcode","0");
|
||||
}
|
||||
|
||||
jsonObject.put("pbinfo",userScheduleDayMap);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("2".equals(changeType)){
|
||||
dateType = "0";
|
||||
}else if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
// String activeGroupId = getUserActiveGroupId(userid);
|
||||
// bb.writeLog("activeGroupId:"+activeGroupId);
|
||||
|
||||
String fixedScheduleGroupId = "5";
|
||||
if(StringUtils.isNotBlank(fixedScheduleGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + fixedScheduleGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,514 @@
|
|||
<%@page import="com.alibaba.fastjson.JSON"%>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"};
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
int userid = user.getUID();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String pbdata = request.getParameter("pbdata");
|
||||
String bp = request.getParameter("bp");
|
||||
|
||||
// if(StringUtils.isBlank(pb)){
|
||||
//
|
||||
// JSONArray jsonArray = new JSONArray();
|
||||
// JSONObject userObject = new JSONObject();
|
||||
// userObject.put("userid","3039");
|
||||
// userObject.put("serialid","10");
|
||||
// jsonArray.add(userObject);
|
||||
//
|
||||
// userObject = new JSONObject();
|
||||
// userObject.put("userid","3373");
|
||||
// userObject.put("serialid","7");
|
||||
// jsonArray.add(userObject);
|
||||
//
|
||||
// userObject = new JSONObject();
|
||||
// userObject.put("userid","3661");
|
||||
// userObject.put("serialid","9");
|
||||
// jsonArray.add(userObject);
|
||||
// pb = jsonArray.toJSONString();
|
||||
// }
|
||||
|
||||
String yjl = request.getParameter("yjl");
|
||||
String pbrq = request.getParameter("pbrq");
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
dateType = getWeekTypeByDate(pbrq,userid+"");
|
||||
}
|
||||
out.println("dateType1:"+dateType+"</br>");
|
||||
|
||||
// if(StringUtils.isNoneBlank(dateType)){
|
||||
// String dateType2 = "0";
|
||||
// DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
// LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
//
|
||||
// DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
// int weekValue = dayOfWeek.getValue();
|
||||
//
|
||||
// LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
// LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
// String monthStartDate = startDayOfMonth.toString();
|
||||
// String monthEndDate = lastDayOfMonth.toString();
|
||||
// Map<String,String> holidayMap = getHolidayByGroupId(userid+"", monthStartDate, monthEndDate);
|
||||
//
|
||||
// String changeType = "" ;
|
||||
// if(holidayMap.containsKey(currentDate.toString())){
|
||||
// changeType = holidayMap.get(currentDate.toString());
|
||||
// }
|
||||
// out.println("monthStartDate:"+monthStartDate+"</br>");
|
||||
// out.println("monthEndDate:"+monthEndDate+"</br>");
|
||||
// out.println("userid:"+userid+"</br>");
|
||||
// out.println("changeType:"+changeType+"</br>");
|
||||
// out.println("weekValue:"+weekValue+"</br>");
|
||||
//
|
||||
// if("1".equals(changeType) || "3".equals(changeType)){
|
||||
// dateType2 = "1";
|
||||
// }else if(weekValue == 6 || weekValue == 7){
|
||||
// dateType2 = "1";
|
||||
// }
|
||||
// }
|
||||
|
||||
out.println("dateType2:"+dateType+"</br>");
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(bp)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where bprs = ? and pblx = ?" ;
|
||||
out.println("sql:"+sql+"</br>");
|
||||
rs.executeQuery(sql,new Object[]{bp,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(k==0){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start","");
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}else if(k==(workSchedule.length-1)){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end","");
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(pbdata)) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(pbdata);
|
||||
|
||||
String yxrys = "" ;
|
||||
for(int i = 0;i<jsonArray.size();i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
yxrys+= StringUtils.isBlank(yxrys) ? pbry : ","+pbry ;
|
||||
}
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
|
||||
String serialid = jsonObject.getString("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) and serialid in( select id from kq_ShiftManagement where (is_rest is null or is_rest = 0) )";
|
||||
out.print("sql:"+sql+"</br>");
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(StringUtils.isNotBlank(scheduleStartTime)){
|
||||
|
||||
if(endTime.compareTo(scheduleStartTime) >=0 ){
|
||||
String define_scheduleEndTime = "21:30";
|
||||
String defWorkSchedule = scheduleStartTime+"-"+define_scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}else if(StringUtils.isNotBlank(scheduleEndTime)){
|
||||
|
||||
if(startTime.compareTo(scheduleEndTime) <=0){
|
||||
String define_scheduleStartTime = "09:00";
|
||||
String defWorkSchedule = define_scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Iterator<Map.Entry<String, Integer>> iterator3 = userScheduleMap.entrySet().iterator();
|
||||
while (iterator3.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator3.next();
|
||||
int value = entry.getValue();
|
||||
String key = entry.getKey();
|
||||
|
||||
out.println("userScheduleMap--value:"+value+" key:"+key+"</br>");
|
||||
}
|
||||
|
||||
|
||||
/* Iterator<Map.Entry<String, Map<String,String>>> iterator2 = userScheduleDayMap.entrySet().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Map.Entry<String, Map<String,String>> entry = iterator2.next();
|
||||
Map<String,String> valMap = entry.getValue();
|
||||
String key = entry.getKey();
|
||||
|
||||
String valJson = JSONObject.toJSONString(valMap);
|
||||
out.println("userScheduleDayMap--value:"+valJson+" key:"+key+"</br>");
|
||||
} */
|
||||
|
||||
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value = entry.getValue();
|
||||
String key = entry.getKey();
|
||||
out.println("defaultScheduleMap-value:"+value+" key:"+key+"</br>");
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
jsonObject.put("pbcode","1");
|
||||
}else{
|
||||
jsonObject.put("pbcode","2");
|
||||
}
|
||||
}else{
|
||||
jsonObject.put("pbcode","0");
|
||||
}
|
||||
|
||||
jsonObject.put("pbinfo",userScheduleDayMap);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
// String activeGroupId = getUserActiveGroupId(userid);
|
||||
// bb.writeLog("activeGroupId:"+activeGroupId);
|
||||
|
||||
String fixedScheduleGroupId = "5";
|
||||
|
||||
if(StringUtils.isNotBlank(fixedScheduleGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + fixedScheduleGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,857 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"};
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
// int userid = user.getUID();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjr = request.getParameter("cjr");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String yjl = request.getParameter("yjl"); //mdyj
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
|
||||
|
||||
String activeGroupId = getUserActiveGroupId(cjr+"");
|
||||
// List<Map<String,Object>> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,cjr);
|
||||
// out.println("scheduleList"+ JSON.toJSON(scheduleList));
|
||||
|
||||
List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
|
||||
// out.println("cjrbm:"+cjrbm+"</br>");
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
String sql = "select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) ";
|
||||
hrmList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
int daysInMonth = 0;
|
||||
Map<String, String> holidayMap = new HashMap<String, String>();
|
||||
List<String> daysList = new ArrayList<String>();
|
||||
Map<String,String> weekMap = new HashMap<String,String>();
|
||||
|
||||
List<Map<String,String>> weekList = new ArrayList<Map<String,String>>();
|
||||
|
||||
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
|
||||
// for (LocalDate date = firstDayOfMonth; !date.isAfter(lastDayOfMonth); date = date.plusDays(1)) {
|
||||
// daysList.add(date.toString());
|
||||
// }
|
||||
|
||||
String monthStartDate = firstDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
holidayMap = getHolidayByGroupId(monthStartDate, monthEndDate,activeGroupId);
|
||||
|
||||
daysInMonth = localDate.lengthOfMonth(); // 获取本月有多少天
|
||||
int thisMonth = localDate.getMonthValue(); // 获取当前是哪月
|
||||
|
||||
for (int i = 1; i <= daysInMonth; i++) {
|
||||
LocalDate currentDate = LocalDate.of(localDate.getYear(), thisMonth, i);
|
||||
|
||||
daysList.add(currentDate.toString());
|
||||
|
||||
// System.out.println("currentDate:" + currentDate.toString());
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
// System.out.println(i + "号是周 " + dayOfWeek.getValue());
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String weekDayName = "";
|
||||
switch (weekValue) {
|
||||
case 1:
|
||||
weekDayName = "周一";
|
||||
break;
|
||||
case 2:
|
||||
weekDayName = "周二";
|
||||
break;
|
||||
case 3:
|
||||
weekDayName = "周三";
|
||||
break;
|
||||
case 4:
|
||||
weekDayName = "周四";
|
||||
break;
|
||||
case 5:
|
||||
weekDayName = "周五";
|
||||
break;
|
||||
case 6:
|
||||
weekDayName = "周六";
|
||||
break;
|
||||
case 7:
|
||||
weekDayName = "周日";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
Map<String,String> weekMap2 = new HashMap<String,String>();
|
||||
weekMap2.put("weekname", weekDayName);
|
||||
String changeTypename= "" ;
|
||||
if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
changeTypename += "[公众假日]";
|
||||
}else if("2".equals(changeType)){
|
||||
changeTypename += "[调配工作日]";
|
||||
}else if("3".equals(changeType)){
|
||||
changeTypename += "[调配休息日]";
|
||||
}
|
||||
weekMap2.put("changeType", changeTypename);
|
||||
weekMap2.put("weekday", i+"");
|
||||
weekMap2.put("weekdate", currentDate.toString());
|
||||
weekList.add(weekMap2);
|
||||
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
weekValue = 11;
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(changeType)){
|
||||
weekMap.put(currentDate.toString(), weekValue+"");
|
||||
}else{
|
||||
weekMap.put(currentDate.toString(), weekValue+"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,Object>> dt1DataList = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String ry = hrmMap.get("id");
|
||||
String lastname = hrmMap.get("lastname");
|
||||
|
||||
Map<String,Object> dt1DataMap = new HashMap<String,Object>();
|
||||
Map<String,Object> ryMap = getDt1UserMap(ry,lastname);
|
||||
dt1DataMap.put("ry",ryMap);
|
||||
|
||||
List<Map<String,Object>> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,ry);
|
||||
|
||||
dt1DataMap.put("schedule",scheduleList);
|
||||
|
||||
List<String> restList = getSchedulingRestData();
|
||||
Map<String,String> countMap = queryCountWorkTime(restList,daysList,weekMap,scheduleList);
|
||||
dt1DataMap.put("count",countMap);
|
||||
|
||||
dt1DataList.add(dt1DataMap);
|
||||
}
|
||||
// out.println("dt1DataList"+ JSON.toJSON(dt1DataList)+"</br>");
|
||||
|
||||
|
||||
List<Map<String,String>> resultList = queryScheduleStatusByDay(daysList,holidayMap,yjl,workSchedule,hrmList,activeGroupId);
|
||||
|
||||
// out.println("resultList"+ JSON.toJSON(resultList)+"</br>");
|
||||
|
||||
Map<String,Object> valueMap = getMainUserDate(hrmList);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",valueMap);
|
||||
jsonObject.put("dt1day",resultList);
|
||||
jsonObject.put("dt1user",dt1DataList);
|
||||
jsonObject.put("days",daysInMonth);
|
||||
jsonObject.put("head",weekList);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(monthStartDate,monthEndDate,activeGroupId);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String monthStartDate,String monthEndDate,String activeGroupId){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
|
||||
String fixedScheduleGroupId = "5";
|
||||
|
||||
if(StringUtils.isNotBlank(fixedScheduleGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + fixedScheduleGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getDt1UserMap(String ry,String lastname){
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
if(StringUtils.isNotBlank(ry)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",ry);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
valueMap.put("id",ry);
|
||||
valueMap.put("name",lastname);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
}
|
||||
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param pbyf
|
||||
* @param groupid
|
||||
* @param resourceid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid){
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
try{
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){
|
||||
String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + resourceid +
|
||||
" order by kqdate ";
|
||||
bb.writeLog("sql:"+sql);
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> map = sqlList.get(i);
|
||||
|
||||
String serialid = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",serialid);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("serialid",serialid);
|
||||
valueMap.put("kqdate",kqdate);
|
||||
valueMap.put("xh",xh);
|
||||
|
||||
|
||||
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
|
||||
scheduleList.add(valueMap);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getSchedulingRestData(){
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql =" select id " +
|
||||
" from kq_ShiftManagement \n" +
|
||||
" where is_rest = 1 \n" +
|
||||
" and (isdelete is null or isdelete = 0) ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
list.add(id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param restList
|
||||
* @param daysList
|
||||
* @param weekMap
|
||||
* @param serialList
|
||||
*/
|
||||
public Map<String,String> queryCountWorkTime(List<String> restList,List<String> daysList,Map<String,String> weekMap,List<Map<String,Object>> serialList ){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String,String> countMap = new HashMap<>();
|
||||
String worktime = "0";
|
||||
String totalworktime = "0";
|
||||
int restcount = 0;
|
||||
int weekrestcount = 0;
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql = "";
|
||||
for (int i = 0; i < serialList.size(); i++) {
|
||||
Map<String,Object> serialMap = serialList.get(i);
|
||||
String kqdate = Util.null2String(serialMap.get("kqdate"));
|
||||
String serialid = Util.null2String(serialMap.get("serialid"));
|
||||
if (daysList.contains(kqdate)) {
|
||||
if (StringUtils.isNotBlank(serialid)) {
|
||||
if (restList.contains(serialid)) {
|
||||
restcount++;
|
||||
}
|
||||
|
||||
if(!restList.contains(serialid)){
|
||||
String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ;
|
||||
sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ;
|
||||
}
|
||||
}
|
||||
|
||||
if (weekMap.containsKey(kqdate)) {
|
||||
String value = weekMap.get(kqdate);
|
||||
//6 = 周六 7 = 周日 11 = 公众假日、调配休息日
|
||||
if ("6".equals(value) || "7".equals(value) || "11".equals(value)) {
|
||||
if (restList.contains(serialid)) {
|
||||
weekrestcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
worktime = Util.null2String(rs.getString("worktime"));
|
||||
totalworktime = Util.null2String(rs.getString("totalworktime"));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
countMap.put("worktime",worktime);
|
||||
countMap.put("totalworktime",totalworktime);
|
||||
countMap.put("restcount",restcount+"");
|
||||
countMap.put("weekrestcount",weekrestcount+"");
|
||||
|
||||
return countMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param daysList
|
||||
* @param holidayMap
|
||||
* @param yjl
|
||||
* @param workSchedule
|
||||
* @param hrmList
|
||||
* @param groupid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleStatusByDay(List<String> daysList,Map<String,String> holidayMap,String yjl,String[] workSchedule,List<Map<String,String>> hrmList,String groupid){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> resultList = new ArrayList<Map<String,String>>();
|
||||
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try{
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String resourceids = "";
|
||||
for(int i=0;i<hrmList.size();i++) {
|
||||
Map<String, String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ;
|
||||
}
|
||||
|
||||
for(String pbrq:daysList){
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(yjl)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{yjl,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){
|
||||
|
||||
String sql =" select t.serialid,t.resourceid,t.kqdate \n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" where t.kqdate='"+pbrq+"' \n" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid in( " + resourceids + ") "+
|
||||
" order by kqdate ";
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
Map<String,String> resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq);
|
||||
resultList.add(resultMap);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sqlList
|
||||
* @param workScheduleList
|
||||
* @param defaultScheduleMap
|
||||
* @param kqdate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> queryScheduleStatusByUser(List<Map<String,String>> sqlList,List<Map<String,String>> workScheduleList,Map<String,Integer> defaultScheduleMap,String kqdate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
String yxrys = "" ;
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String resourceid = Util.null2String(sqlMap.get("resourceid"));
|
||||
yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(yxrys)) {
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3,4)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3,4) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String pbry = sqlMap.get("resourceid");
|
||||
String serialid = sqlMap.get("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) ";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String,String> resultMap = new HashMap<>();
|
||||
String status = "";
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
status = "0";
|
||||
}else{
|
||||
status = "1";
|
||||
}
|
||||
}
|
||||
resultMap.put("kqdate",kqdate);
|
||||
resultMap.put("status",status);
|
||||
resultMap.put("xh",xh);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,849 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"};
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
// int userid = user.getUID();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjr = request.getParameter("cjr");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String yjl = request.getParameter("yjl"); //mdyj
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
|
||||
|
||||
String activeGroupId = getUserActiveGroupId(cjr+"");
|
||||
// List<Map<String,Object>> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,cjr);
|
||||
// out.println("scheduleList"+ JSON.toJSON(scheduleList));
|
||||
|
||||
List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
|
||||
// out.println("cjrbm:"+cjrbm+"</br>");
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
String sql = "select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) ";
|
||||
hrmList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
int daysInMonth = 0;
|
||||
Map<String, String> holidayMap = new HashMap<String, String>();
|
||||
List<String> daysList = new ArrayList<String>();
|
||||
Map<String,String> weekMap = new HashMap<String,String>();
|
||||
|
||||
List<Map<String,String>> weekList = new ArrayList<Map<String,String>>();
|
||||
|
||||
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
|
||||
// for (LocalDate date = firstDayOfMonth; !date.isAfter(lastDayOfMonth); date = date.plusDays(1)) {
|
||||
// daysList.add(date.toString());
|
||||
// }
|
||||
|
||||
String monthStartDate = firstDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
holidayMap = getHolidayByGroupId(cjr, monthStartDate, monthEndDate,activeGroupId);
|
||||
|
||||
daysInMonth = localDate.lengthOfMonth(); // 获取本月有多少天
|
||||
int thisMonth = localDate.getMonthValue(); // 获取当前是哪月
|
||||
|
||||
for (int i = 1; i <= daysInMonth; i++) {
|
||||
LocalDate currentDate = LocalDate.of(localDate.getYear(), thisMonth, i);
|
||||
|
||||
daysList.add(currentDate.toString());
|
||||
|
||||
// System.out.println("currentDate:" + currentDate.toString());
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
// System.out.println(i + "号是周 " + dayOfWeek.getValue());
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String weekDayName = "";
|
||||
switch (weekValue) {
|
||||
case 1:
|
||||
weekDayName = "周一";
|
||||
break;
|
||||
case 2:
|
||||
weekDayName = "周二";
|
||||
break;
|
||||
case 3:
|
||||
weekDayName = "周三";
|
||||
break;
|
||||
case 4:
|
||||
weekDayName = "周四";
|
||||
break;
|
||||
case 5:
|
||||
weekDayName = "周五";
|
||||
break;
|
||||
case 6:
|
||||
weekDayName = "周六";
|
||||
break;
|
||||
case 7:
|
||||
weekDayName = "周日";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
Map<String,String> weekMap2 = new HashMap<String,String>();
|
||||
weekMap2.put("weekname", weekDayName);
|
||||
weekMap2.put("changeType", changeType);
|
||||
weekMap2.put("weekday", i+"");
|
||||
weekMap2.put("weekdate", currentDate.toString());
|
||||
weekList.add(weekMap2);
|
||||
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
weekValue = 11;
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(changeType)){
|
||||
weekMap.put(currentDate.toString(), weekValue+"");
|
||||
}else{
|
||||
weekMap.put(currentDate.toString(), weekValue+"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,Object>> dt1DataList = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String ry = hrmMap.get("id");
|
||||
String lastname = hrmMap.get("lastname");
|
||||
|
||||
Map<String,Object> dt1DataMap = new HashMap<String,Object>();
|
||||
Map<String,Object> ryMap = getDt1UserMap(ry,lastname);
|
||||
dt1DataMap.put("ry",ryMap);
|
||||
|
||||
List<Map<String,Object>> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,ry);
|
||||
|
||||
dt1DataMap.put("schedule",scheduleList);
|
||||
|
||||
List<String> restList = getSchedulingRestData();
|
||||
Map<String,String> countMap = queryCountWorkTime(restList,daysList,weekMap,scheduleList);
|
||||
dt1DataMap.put("count",countMap);
|
||||
|
||||
dt1DataList.add(dt1DataMap);
|
||||
}
|
||||
// out.println("dt1DataList"+ JSON.toJSON(dt1DataList)+"</br>");
|
||||
|
||||
|
||||
List<Map<String,String>> resultList = queryScheduleStatusByDay(daysList,holidayMap,yjl,workSchedule,hrmList,activeGroupId);
|
||||
|
||||
// out.println("resultList"+ JSON.toJSON(resultList)+"</br>");
|
||||
|
||||
Map<String,Object> valueMap = getMainUserDate(hrmList);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",valueMap);
|
||||
jsonObject.put("dt1day",resultList);
|
||||
jsonObject.put("dt1user",dt1DataList);
|
||||
jsonObject.put("days",daysInMonth);
|
||||
jsonObject.put("head",weekList);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(monthStartDate,monthEndDate,activeGroupId);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String monthStartDate,String monthEndDate,String activeGroupId){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
|
||||
String fixedScheduleGroupId = "5";
|
||||
|
||||
if(StringUtils.isNotBlank(fixedScheduleGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + fixedScheduleGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getDt1UserMap(String ry,String lastname){
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
if(StringUtils.isNotBlank(ry)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",ry);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
valueMap.put("id",ry);
|
||||
valueMap.put("name",lastname);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
}
|
||||
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param pbyf
|
||||
* @param groupid
|
||||
* @param resourceid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid){
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
try{
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){
|
||||
String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + resourceid +
|
||||
" order by kqdate ";
|
||||
bb.writeLog("sql:"+sql);
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> map = sqlList.get(i);
|
||||
|
||||
String serialid = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",serialid);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("serialid",serialid);
|
||||
valueMap.put("kqdate",kqdate);
|
||||
valueMap.put("xh",xh);
|
||||
|
||||
|
||||
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
|
||||
scheduleList.add(valueMap);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getSchedulingRestData(){
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql =" select id " +
|
||||
" from kq_ShiftManagement \n" +
|
||||
" where is_rest = 1 \n" +
|
||||
" and (isdelete is null or isdelete = 0) ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
list.add(id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param restList
|
||||
* @param daysList
|
||||
* @param weekMap
|
||||
* @param serialList
|
||||
*/
|
||||
public Map<String,String> queryCountWorkTime(List<String> restList,List<String> daysList,Map<String,String> weekMap,List<Map<String,Object>> serialList ){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String,String> countMap = new HashMap<>();
|
||||
String worktime = "0";
|
||||
String totalworktime = "0";
|
||||
int restcount = 0;
|
||||
int weekrestcount = 0;
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql = "";
|
||||
for (int i = 0; i < serialList.size(); i++) {
|
||||
Map<String,Object> serialMap = serialList.get(i);
|
||||
String kqdate = Util.null2String(serialMap.get("kqdate"));
|
||||
String serialid = Util.null2String(serialMap.get("serialid"));
|
||||
if (daysList.contains(kqdate)) {
|
||||
if (StringUtils.isNotBlank(serialid)) {
|
||||
if (restList.contains(serialid)) {
|
||||
restcount++;
|
||||
}
|
||||
|
||||
if(!restList.contains(serialid)){
|
||||
String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ;
|
||||
sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ;
|
||||
}
|
||||
}
|
||||
|
||||
if (weekMap.containsKey(kqdate)) {
|
||||
String value = weekMap.get(kqdate);
|
||||
//6 = 周六 7 = 周日 11 = 公众假日、调配休息日
|
||||
if ("6".equals(value) || "7".equals(value) || "11".equals(value)) {
|
||||
if (restList.contains(serialid)) {
|
||||
weekrestcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
worktime = Util.null2String(rs.getString("worktime"));
|
||||
totalworktime = Util.null2String(rs.getString("totalworktime"));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
countMap.put("worktime",worktime);
|
||||
countMap.put("totalworktime",totalworktime);
|
||||
countMap.put("restcount",restcount+"");
|
||||
countMap.put("weekrestcount",weekrestcount+"");
|
||||
|
||||
return countMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param daysList
|
||||
* @param holidayMap
|
||||
* @param yjl
|
||||
* @param workSchedule
|
||||
* @param hrmList
|
||||
* @param groupid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleStatusByDay(List<String> daysList,Map<String,String> holidayMap,String yjl,String[] workSchedule,List<Map<String,String>> hrmList,String groupid){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> resultList = new ArrayList<Map<String,String>>();
|
||||
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try{
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String resourceids = "";
|
||||
for(int i=0;i<hrmList.size();i++) {
|
||||
Map<String, String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ;
|
||||
}
|
||||
|
||||
for(String pbrq:daysList){
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(yjl)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{yjl,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){
|
||||
|
||||
String sql =" select t.serialid,t.resourceid,t.kqdate \n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" where t.kqdate='"+pbrq+"' \n" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid in( " + resourceids + ") "+
|
||||
" order by kqdate ";
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
Map<String,String> resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq);
|
||||
resultList.add(resultMap);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sqlList
|
||||
* @param workScheduleList
|
||||
* @param defaultScheduleMap
|
||||
* @param kqdate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> queryScheduleStatusByUser(List<Map<String,String>> sqlList,List<Map<String,String>> workScheduleList,Map<String,Integer> defaultScheduleMap,String kqdate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
String yxrys = "" ;
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String resourceid = Util.null2String(sqlMap.get("resourceid"));
|
||||
yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(yxrys)) {
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3,4)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3,4) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String pbry = sqlMap.get("resourceid");
|
||||
String serialid = sqlMap.get("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) ";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String,String> resultMap = new HashMap<>();
|
||||
String status = "";
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
status = "0";
|
||||
}else{
|
||||
status = "1";
|
||||
}
|
||||
}
|
||||
resultMap.put("kqdate",kqdate);
|
||||
resultMap.put("status",status);
|
||||
resultMap.put("xh",xh);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,599 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"};
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
int userid = user.getUID();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String ry = request.getParameter("ry");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String bp = request.getParameter("bp");
|
||||
String activeGroupId = getUserActiveGroupId(userid+"");
|
||||
List<Map<String,String>> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,ry);
|
||||
|
||||
|
||||
String pbdata = request.getParameter("pbdata");
|
||||
String pbrq = request.getParameter("pbrq");
|
||||
String yjl = request.getParameter("yjl");
|
||||
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
dateType = getWeekTypeByDate(pbrq,userid+"");
|
||||
}
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(yjl)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where bp = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{bp,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(k==0){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start","");
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}else if(k==(workSchedule.length-1)){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end","");
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(pbdata)) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(pbdata);
|
||||
|
||||
String yxrys = "" ;
|
||||
for(int i = 0;i<jsonArray.size();i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
yxrys+= StringUtils.isBlank(yxrys) ? pbry : ","+pbry ;
|
||||
}
|
||||
out.println("yxrys:"+yxrys+"</br>");
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3,4)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3,4) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
out.println("sql:"+sql+"</br>");
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
out.println("id:"+id+"</br>");
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String pbry = jsonObject.getString("userid");
|
||||
|
||||
String serialid = jsonObject.getString("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) ";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(StringUtils.isNotBlank(scheduleStartTime)){
|
||||
|
||||
if(endTime.compareTo(scheduleStartTime) >=0 ){
|
||||
String define_scheduleEndTime = "21:30";
|
||||
String defWorkSchedule = scheduleStartTime+"-"+define_scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}else if(StringUtils.isNotBlank(scheduleEndTime)){
|
||||
|
||||
if(startTime.compareTo(scheduleEndTime) <=0){
|
||||
String define_scheduleStartTime = "09:00";
|
||||
String defWorkSchedule = define_scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
out.println("necessaryMap:"+necessaryMap.size());
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
jsonObject.put("pbcode","1");
|
||||
}else{
|
||||
jsonObject.put("pbcode","2");
|
||||
}
|
||||
}else{
|
||||
jsonObject.put("pbcode","0");
|
||||
}
|
||||
|
||||
jsonObject.put("pbinfo",userScheduleDayMap);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
// String activeGroupId = getUserActiveGroupId(userid);
|
||||
// bb.writeLog("activeGroupId:"+activeGroupId);
|
||||
|
||||
String fixedScheduleGroupId = "5";
|
||||
|
||||
if(StringUtils.isNotBlank(fixedScheduleGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + fixedScheduleGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param pbyf
|
||||
* @param groupid
|
||||
* @param resourceid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid){
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){
|
||||
String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + resourceid +
|
||||
" order by kqdate ";
|
||||
|
||||
bb.writeLog("sql:"+sql);
|
||||
list = queryListBySql(sql);
|
||||
}
|
||||
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<list.size();i++){
|
||||
Map<String,String> map = list.get(i);
|
||||
|
||||
String id = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
|
||||
}
|
||||
|
||||
|
||||
Map<String,Object> scheduleMap = new HashMap<String,Object>();
|
||||
scheduleMap.put("kqdate",kqdate);
|
||||
scheduleMap.put("kqdate",kqdate);
|
||||
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",id);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",id);
|
||||
valueMap2.put("specialobj",specialobjList);
|
||||
scheduleMap.put("value",valueMap2);
|
||||
scheduleList.add(scheduleMap);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,309 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="weaver.hrm.resource.ResourceComInfo" %>
|
||||
<%@ page import="com.engine.kq.service.KQShiftScheduleService" %>
|
||||
<%@ page import="com.engine.common.util.ServiceUtil" %>
|
||||
<%@ page import="com.engine.kq.service.impl.KQShiftScheduleServiceImpl" %>
|
||||
<%@ page import="com.engine.common.util.ParamUtil" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
out.println("333333</br>");
|
||||
|
||||
String requestid = request.getParameter("requestid");
|
||||
out.println("requestid:"+requestid+"</br>");
|
||||
String workflowid = request.getParameter("workflowid");
|
||||
out.println("workflowid:"+workflowid+"</br>");
|
||||
String billtable = getFormtableByRequestId(requestid);
|
||||
|
||||
out.println("billtable:"+billtable+"</br>");
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
String mainid = "";
|
||||
String cjr = "";
|
||||
String pbyf = "";
|
||||
String cjrbm = "";
|
||||
String sql = " select id,cjr,pbyf,cjrbm from " + billtable + " where requestid=" + requestid;
|
||||
out.println("sql:"+sql+"</br>");
|
||||
rs.execute(sql);
|
||||
if (rs.next()) {
|
||||
mainid = Util.null2String(rs.getString("id"));
|
||||
cjr = Util.null2String(rs.getString("cjr"));
|
||||
pbyf = Util.null2String(rs.getString("pbyf"));
|
||||
cjrbm = Util.null2String(rs.getString("cjrbm"));
|
||||
}
|
||||
out.println("mainid:"+mainid+"</br>");
|
||||
out.println("pbyf:"+pbyf+"</br>");
|
||||
out.println("cjrbm:"+cjrbm+"</br>");
|
||||
|
||||
sql = " select t.requestid,r.currentnodetype,r.requestname " +
|
||||
" from " + billtable + " t " +
|
||||
" inner join workflow_requestbase r on r.requestid = t.requestid " +
|
||||
" where t.pbyf ='" + pbyf + "' " +
|
||||
" and t.cjrbm ='" + cjrbm + "' " +
|
||||
" and r.currentnodetype in(1,2,3) " +
|
||||
" and r.workflowid = " + workflowid +
|
||||
" and t.requestid <> " + requestid;
|
||||
|
||||
out.println("sql:"+sql+"</br>");
|
||||
|
||||
List<Map<String, String>> requestList = queryListBySql(sql);
|
||||
out.println("requestList:"+requestList.size()+"</br>");
|
||||
if (!requestList.isEmpty() && requestList.size() > 0) {
|
||||
Map<String, String> requestMap = requestList.get(0);
|
||||
String requestname = requestMap.get("requestname");
|
||||
String currentnodetype = requestMap.get("currentnodetype");
|
||||
String requesttypename = "";
|
||||
if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) {
|
||||
requesttypename = "正在审批";
|
||||
} else if ("3".equals(currentnodetype)) {
|
||||
requesttypename = "已归档";
|
||||
}
|
||||
out.println("已存在" + requesttypename + "流程:" + requestname + "");
|
||||
} else {
|
||||
List<Map<String, String>> scheduleList = new ArrayList<Map<String, String>>();
|
||||
String userids = "";
|
||||
sql = " select yg from " + billtable + "_dt1 where mainid=" + mainid;
|
||||
out.println("sql:"+sql+"</br>");
|
||||
|
||||
List<Map<String, String>> dt1List2 = queryListBySql(sql);
|
||||
for (int i = 0; i < dt1List2.size(); i++) {
|
||||
Map<String, String> dt1Map = dt1List2.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : "," + resourceid;
|
||||
}
|
||||
if (StringUtils.isNotBlank(userids)) {
|
||||
sql = " select kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '" + pbyf + "' and resourceid in(" + userids + ") and (isdelete is null or isdelete = 0)";
|
||||
out.println("sql:"+sql+"</br>");
|
||||
scheduleList = queryListBySql(sql);
|
||||
}
|
||||
if (!scheduleList.isEmpty() && scheduleList.size() > 0) {
|
||||
String lastnames = "";
|
||||
for(int i=0;i<scheduleList.size();i++){
|
||||
Map<String, String> scheduleMap = scheduleList.get(i);
|
||||
if(i<2){
|
||||
String resourceid = scheduleMap.get("resourceid");
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
String lastname = resourceComInfo.getLastname(resourceid);
|
||||
lastnames += StringUtils.isBlank(lastnames) ? lastname : ","+lastname;
|
||||
}
|
||||
}
|
||||
}
|
||||
out.println(lastnames+"等已存在"+pbyf+"的排班数据,无法新增排班");
|
||||
} else {
|
||||
int daysInMonth = 0;
|
||||
if (StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
// LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
// LocalDate startDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
// String monthStartDate = startDayOfMonth.toString();
|
||||
// String monthEndDate = lastDayOfMonth.toString();
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(mainid)) {
|
||||
|
||||
String groupid = getUserActiveGroupId(user.getUID()+"");
|
||||
JSONObject datasJSON = new JSONObject();
|
||||
JSONArray datasArray = new JSONArray();
|
||||
sql = " select * from " + billtable + "_dt1 where mainid=" + mainid;
|
||||
List<Map<String, String>> dt1List = queryListBySql(sql);
|
||||
for (int i = 0; i < dt1List.size(); i++) {
|
||||
Map<String, String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
|
||||
JSONArray kqdata = new JSONArray();
|
||||
JSONObject userJSON = new JSONObject();
|
||||
userJSON.put("id","");
|
||||
String loginid = resourceComInfo.getLoginID(resourceid);
|
||||
userJSON.put("serialid",loginid);
|
||||
userJSON.put("oldValue",loginid);
|
||||
userJSON.put("date","workcode");
|
||||
kqdata.add(userJSON);
|
||||
for (int k = 1; k <= daysInMonth; k++) {
|
||||
String bc = Util.null2String(dt1Map.get("bc" + k));
|
||||
if(StringUtils.isNotBlank(bc)){
|
||||
JSONObject bcJSON = new JSONObject();
|
||||
bcJSON.put("id", "");
|
||||
bcJSON.put("serialid", bc);
|
||||
if (k < 10) {
|
||||
bcJSON.put("date", pbyf + "-0" + k);
|
||||
} else {
|
||||
bcJSON.put("date", pbyf + "-" + k);
|
||||
}
|
||||
kqdata.add(bcJSON);
|
||||
}
|
||||
}
|
||||
JSONObject dataJSON = new JSONObject();
|
||||
dataJSON.put("resourceid", resourceid);
|
||||
dataJSON.put("kqdata", kqdata);
|
||||
datasArray.add(dataJSON);
|
||||
}
|
||||
}
|
||||
datasJSON.put("datas", datasArray);
|
||||
datasJSON.put("groupId", groupid);
|
||||
out.println("datasJSON:" + datasJSON.toJSONString() + "</br>");
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("data",datasJSON.toJSONString());
|
||||
Map<String, Object> apidatas = getService(user).save(params, user);
|
||||
|
||||
out.println("apidatas:" + JSONObject.toJSONString(apidatas)+ "</br>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
<%!
|
||||
/**
|
||||
*
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public String getFormtableByRequestId(String requestid){
|
||||
String formtable = "" ;
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(requestid)){
|
||||
String sql =" select abs(formid) as formid from workflow_base t \n" +
|
||||
" inner join workflow_requestbase h on h.workflowid = t.id \n" +
|
||||
" where h.requestid= "+requestid ;
|
||||
bb.writeLog("sql2:"+sql);
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String formid = Util.null2String(rs.getString("formid"));
|
||||
if(StringUtils.isNotBlank(formid)){
|
||||
formtable = "formtable_main_"+formid ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("getFormtableByRequestId:"+e);
|
||||
}
|
||||
return formtable;
|
||||
}
|
||||
|
||||
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
%>
|
||||
|
||||
<%!
|
||||
|
||||
private KQShiftScheduleService getService(User user) {
|
||||
return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
%>
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="weaver.systeminfo.SystemEnv" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) {
|
||||
map.put("status", "-1");
|
||||
map.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
|
||||
}else{
|
||||
map.put("status", "1");
|
||||
map.put("message", "22222");
|
||||
}
|
||||
|
||||
out.println("list:"+JSONObject.toJSONString(map));
|
||||
%>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
/**
|
||||
*
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public static String getFormtableByRequestId(String requestid){
|
||||
String formtable = "" ;
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(requestid)){
|
||||
String sql =" select abs(formid) from workflow_base t \n" +
|
||||
" inner join workflow_requestbase h on h.workflowid = t.id \n" +
|
||||
" where requestid= "+requestid ;
|
||||
bb.writeLog("sql2:"+sql);
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String formid = Util.null2String(rs.getString("formid"));
|
||||
if(StringUtils.isNotBlank(formid)){
|
||||
formtable = "formtable_main_"+formid ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("getFormtableByRequestId:"+e);
|
||||
}
|
||||
|
||||
return formtable;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,840 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String yg = request.getParameter("yg");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
|
||||
List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ;
|
||||
|
||||
hrmList = queryListBySql(sql);
|
||||
}
|
||||
String userid = "" ;
|
||||
if(hrmList !=null && hrmList.size() > 0){
|
||||
userid = hrmList.get(0).get("id");
|
||||
}
|
||||
|
||||
String activeGroupId = getUserActiveGroupId(userid);
|
||||
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = firstDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
|
||||
String startDate = monthStartDate;
|
||||
String endDate = monthEndDate ;
|
||||
|
||||
String sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm = "+ yg +
|
||||
" and bm= "+ cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
endDate = ydsxrq;
|
||||
}
|
||||
}
|
||||
|
||||
sql =" select ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm ="+ yg +
|
||||
" and ydhbm="+cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
startDate = ydsxrq;
|
||||
}
|
||||
}
|
||||
|
||||
sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
" and t.kqdate >='"+startDate+"' " +
|
||||
" and t.kqdate <= '"+endDate+"'" +
|
||||
" and t.groupid="+activeGroupId+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + yg +
|
||||
" order by kqdate ";
|
||||
|
||||
bb.writeLog("sql:"+sql);
|
||||
List<Map<String,String>> sqlList = queryListBySql(sql);
|
||||
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> map = sqlList.get(i);
|
||||
|
||||
String serialid = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",serialid);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("serialid",serialid);
|
||||
valueMap.put("kqdate",kqdate);
|
||||
valueMap.put("xh",xh);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
scheduleList.add(valueMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("schedule",scheduleList);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate,activeGroupId);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate,String activeGroupId){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + activeGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getDt1UserMap(String ry,String lastname){
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
if(StringUtils.isNotBlank(ry)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",ry);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
valueMap.put("id",ry);
|
||||
valueMap.put("name",lastname);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
}
|
||||
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param pbyf
|
||||
* @param groupid
|
||||
* @param resourceid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid,Map<String,String> dateEffectiveMap){
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
try{
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){
|
||||
String startDate = "" ;
|
||||
String endDate = "";
|
||||
if(dateEffectiveMap.containsKey(resourceid)){
|
||||
String effectiveDate = dateEffectiveMap.get(resourceid);
|
||||
if(effectiveDate.contains(";")){
|
||||
String[] effective_Date = effectiveDate.split(";");
|
||||
startDate = effective_Date[0];
|
||||
endDate = effective_Date[1];
|
||||
}
|
||||
}
|
||||
|
||||
String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
" and t.kqdate >='"+startDate+"' " +
|
||||
" and t.kqdate <= '"+endDate+"'" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + resourceid +
|
||||
" order by kqdate ";
|
||||
bb.writeLog("sql:"+sql);
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> map = sqlList.get(i);
|
||||
|
||||
String serialid = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",serialid);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("serialid",serialid);
|
||||
valueMap.put("kqdate",kqdate);
|
||||
valueMap.put("xh",xh);
|
||||
|
||||
|
||||
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
|
||||
scheduleList.add(valueMap);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getSchedulingRestData(){
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql =" select id " +
|
||||
" from kq_ShiftManagement \n" +
|
||||
" where is_rest = 1 \n" +
|
||||
" and (isdelete is null or isdelete = 0) ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
list.add(id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param restList
|
||||
* @param daysList
|
||||
* @param weekMap
|
||||
* @param serialList
|
||||
*/
|
||||
public Map<String,String> queryCountWorkTime(List<String> restList,List<String> daysList,Map<String,String> weekMap,List<Map<String,Object>> serialList ){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String,String> countMap = new HashMap<>();
|
||||
String worktime = "0";
|
||||
String totalworktime = "0";
|
||||
int restcount = 0;
|
||||
int weekrestcount = 0;
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql = "";
|
||||
for (int i = 0; i < serialList.size(); i++) {
|
||||
Map<String,Object> serialMap = serialList.get(i);
|
||||
String kqdate = Util.null2String(serialMap.get("kqdate"));
|
||||
String serialid = Util.null2String(serialMap.get("serialid"));
|
||||
if (daysList.contains(kqdate)) {
|
||||
if (StringUtils.isNotBlank(serialid)) {
|
||||
if (restList.contains(serialid)) {
|
||||
restcount++;
|
||||
}
|
||||
|
||||
if(!restList.contains(serialid)){
|
||||
String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ;
|
||||
sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ;
|
||||
}
|
||||
}
|
||||
|
||||
if (weekMap.containsKey(kqdate)) {
|
||||
String value = weekMap.get(kqdate);
|
||||
//6 = 周六 7 = 周日 11 = 公众假日、调配休息日
|
||||
if ("6".equals(value) || "7".equals(value) || "11".equals(value)) {
|
||||
if (restList.contains(serialid)) {
|
||||
weekrestcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
worktime = Util.null2String(rs.getString("worktime"));
|
||||
totalworktime = Util.null2String(rs.getString("totalworktime"));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
countMap.put("worktime",worktime);
|
||||
countMap.put("totalworktime",totalworktime);
|
||||
countMap.put("restcount",restcount+"");
|
||||
countMap.put("weekrestcount",weekrestcount+"");
|
||||
|
||||
return countMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param daysList
|
||||
* @param holidayMap
|
||||
* @param yjl
|
||||
* @param workSchedule
|
||||
* @param hrmList
|
||||
* @param groupid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleStatusByDay(List<String> daysList,Map<String,String> holidayMap,String yjl,String[] workSchedule,List<Map<String,String>> hrmList,String groupid,Map<String,String> dateEffectiveMap){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> resultList = new ArrayList<Map<String,String>>();
|
||||
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try{
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(String pbrq:daysList){
|
||||
|
||||
String resourceids = "";
|
||||
for(int i=0;i<hrmList.size();i++) {
|
||||
Map<String, String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
if(dateEffectiveMap.containsKey(userid)){
|
||||
String effectiveDate = dateEffectiveMap.get(userid);
|
||||
if(effectiveDate.contains(";")){
|
||||
String[] effective_Date = effectiveDate.split(";");
|
||||
if(pbrq.compareTo(effective_Date[0])>=0 && pbrq.compareTo(effective_Date[1])<=0){
|
||||
resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(yjl)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{yjl,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){
|
||||
|
||||
String sql =" select t.serialid,t.resourceid,t.kqdate \n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" where t.kqdate='"+pbrq+"' \n" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid in( " + resourceids + ") "+
|
||||
" order by kqdate ";
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
Map<String,String> resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq);
|
||||
resultList.add(resultMap);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sqlList
|
||||
* @param workScheduleList
|
||||
* @param defaultScheduleMap
|
||||
* @param kqdate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> queryScheduleStatusByUser(List<Map<String,String>> sqlList,List<Map<String,String>> workScheduleList,Map<String,Integer> defaultScheduleMap,String kqdate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
String yxrys = "" ;
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String resourceid = Util.null2String(sqlMap.get("resourceid"));
|
||||
yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(yxrys)) {
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3,4)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3,4) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String pbry = sqlMap.get("resourceid");
|
||||
String serialid = sqlMap.get("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) ";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String,String> resultMap = new HashMap<>();
|
||||
String status = "0";
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
status = "0";
|
||||
}else{
|
||||
status = "1";
|
||||
}
|
||||
}
|
||||
resultMap.put("kqdate",kqdate);
|
||||
resultMap.put("status",status);
|
||||
resultMap.put("xh",xh);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,916 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"};
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
// int userid = user.getUID();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjr = request.getParameter("cjr");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String yjl = request.getParameter("yjl"); //mdyj
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
|
||||
|
||||
String activeGroupId = getUserActiveGroupId(cjr+"");
|
||||
// List<Map<String,Object>> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,cjr);
|
||||
// out.println("scheduleList"+ JSON.toJSON(scheduleList));
|
||||
|
||||
List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
|
||||
// out.println("cjrbm:"+cjrbm+"</br>");
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
// String sql = "select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) ";
|
||||
String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ;
|
||||
|
||||
hrmList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
|
||||
int daysInMonth = 0;
|
||||
Map<String, String> holidayMap = new HashMap<String, String>();
|
||||
List<String> daysList = new ArrayList<String>();
|
||||
Map<String,String> weekMap = new HashMap<String,String>();
|
||||
|
||||
List<Map<String,String>> weekList = new ArrayList<Map<String,String>>();
|
||||
|
||||
Map<String,String> dateEffectiveMap = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
|
||||
|
||||
// for (LocalDate date = firstDayOfMonth; !date.isAfter(lastDayOfMonth); date = date.plusDays(1)) {
|
||||
// daysList.add(date.toString());
|
||||
// }
|
||||
|
||||
String monthStartDate = firstDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String id = hrmMap.get("id");
|
||||
String startDate = monthStartDate;
|
||||
String endDate = monthEndDate ;
|
||||
|
||||
String sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm = "+ id +
|
||||
" and bm= "+ cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
endDate = ydsxrq;
|
||||
}
|
||||
}
|
||||
|
||||
sql =" select ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm ="+ id +
|
||||
" and ydhbm="+cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
startDate = ydsxrq;
|
||||
}
|
||||
}
|
||||
dateEffectiveMap.put(id,startDate+";"+endDate);
|
||||
}
|
||||
|
||||
|
||||
holidayMap = getHolidayByGroupId(cjr, monthStartDate, monthEndDate,activeGroupId);
|
||||
|
||||
daysInMonth = localDate.lengthOfMonth(); // 获取本月有多少天
|
||||
int thisMonth = localDate.getMonthValue(); // 获取当前是哪月
|
||||
|
||||
for (int i = 1; i <= daysInMonth; i++) {
|
||||
LocalDate currentDate = LocalDate.of(localDate.getYear(), thisMonth, i);
|
||||
|
||||
daysList.add(currentDate.toString());
|
||||
|
||||
// System.out.println("currentDate:" + currentDate.toString());
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
// System.out.println(i + "号是周 " + dayOfWeek.getValue());
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String weekDayName = "";
|
||||
switch (weekValue) {
|
||||
case 1:
|
||||
weekDayName = "周一";
|
||||
break;
|
||||
case 2:
|
||||
weekDayName = "周二";
|
||||
break;
|
||||
case 3:
|
||||
weekDayName = "周三";
|
||||
break;
|
||||
case 4:
|
||||
weekDayName = "周四";
|
||||
break;
|
||||
case 5:
|
||||
weekDayName = "周五";
|
||||
break;
|
||||
case 6:
|
||||
weekDayName = "周六";
|
||||
break;
|
||||
case 7:
|
||||
weekDayName = "周日";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
Map<String,String> weekMap2 = new HashMap<String,String>();
|
||||
weekMap2.put("weekname", weekDayName);
|
||||
weekMap2.put("changeType", changeType);
|
||||
weekMap2.put("weekday", i+"");
|
||||
weekMap2.put("weekdate", currentDate.toString());
|
||||
weekList.add(weekMap2);
|
||||
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
weekValue = 11;
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(changeType)){
|
||||
weekMap.put(currentDate.toString(), weekValue+"");
|
||||
}else{
|
||||
weekMap.put(currentDate.toString(), weekValue+"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,Object>> dt1DataList = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String ry = hrmMap.get("id");
|
||||
String lastname = hrmMap.get("lastname");
|
||||
|
||||
Map<String,Object> dt1DataMap = new HashMap<String,Object>();
|
||||
Map<String,Object> ryMap = getDt1UserMap(ry,lastname);
|
||||
dt1DataMap.put("ry",ryMap);
|
||||
|
||||
List<Map<String,Object>> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,ry,dateEffectiveMap);
|
||||
|
||||
dt1DataMap.put("schedule",scheduleList);
|
||||
|
||||
List<String> restList = getSchedulingRestData();
|
||||
Map<String,String> countMap = queryCountWorkTime(restList,daysList,weekMap,scheduleList);
|
||||
dt1DataMap.put("count",countMap);
|
||||
|
||||
dt1DataList.add(dt1DataMap);
|
||||
}
|
||||
// out.println("dt1DataList"+ JSON.toJSON(dt1DataList)+"</br>");
|
||||
|
||||
|
||||
List<Map<String,String>> resultList = queryScheduleStatusByDay(daysList,holidayMap,yjl,workSchedule,hrmList,activeGroupId,dateEffectiveMap);
|
||||
|
||||
// out.println("resultList"+ JSON.toJSON(resultList)+"</br>");
|
||||
|
||||
Map<String,Object> valueMap = getMainUserDate(hrmList);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",valueMap);
|
||||
jsonObject.put("dt1day",resultList);
|
||||
jsonObject.put("dt1user",dt1DataList);
|
||||
jsonObject.put("days",daysInMonth);
|
||||
jsonObject.put("head",weekList);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate,activeGroupId);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate,String activeGroupId){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + activeGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getDt1UserMap(String ry,String lastname){
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
if(StringUtils.isNotBlank(ry)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",ry);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
valueMap.put("id",ry);
|
||||
valueMap.put("name",lastname);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
}
|
||||
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param pbyf
|
||||
* @param groupid
|
||||
* @param resourceid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid,Map<String,String> dateEffectiveMap){
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
try{
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){
|
||||
String startDate = "" ;
|
||||
String endDate = "";
|
||||
if(dateEffectiveMap.containsKey(resourceid)){
|
||||
String effectiveDate = dateEffectiveMap.get(resourceid);
|
||||
if(effectiveDate.contains(";")){
|
||||
String[] effective_Date = effectiveDate.split(";");
|
||||
startDate = effective_Date[0];
|
||||
endDate = effective_Date[1];
|
||||
}
|
||||
}
|
||||
|
||||
String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
" and t.kqdate >='"+startDate+"' " +
|
||||
" and t.kqdate <= '"+endDate+"'" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + resourceid +
|
||||
" order by kqdate ";
|
||||
bb.writeLog("sql:"+sql);
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> map = sqlList.get(i);
|
||||
|
||||
String serialid = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",serialid);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("serialid",serialid);
|
||||
valueMap.put("kqdate",kqdate);
|
||||
valueMap.put("xh",xh);
|
||||
|
||||
|
||||
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
|
||||
scheduleList.add(valueMap);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getSchedulingRestData(){
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql =" select id " +
|
||||
" from kq_ShiftManagement \n" +
|
||||
" where is_rest = 1 \n" +
|
||||
" and (isdelete is null or isdelete = 0) ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
list.add(id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param restList
|
||||
* @param daysList
|
||||
* @param weekMap
|
||||
* @param serialList
|
||||
*/
|
||||
public Map<String,String> queryCountWorkTime(List<String> restList,List<String> daysList,Map<String,String> weekMap,List<Map<String,Object>> serialList ){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String,String> countMap = new HashMap<>();
|
||||
String worktime = "0";
|
||||
String totalworktime = "0";
|
||||
int restcount = 0;
|
||||
int weekrestcount = 0;
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql = "";
|
||||
for (int i = 0; i < serialList.size(); i++) {
|
||||
Map<String,Object> serialMap = serialList.get(i);
|
||||
String kqdate = Util.null2String(serialMap.get("kqdate"));
|
||||
String serialid = Util.null2String(serialMap.get("serialid"));
|
||||
if (daysList.contains(kqdate)) {
|
||||
if (StringUtils.isNotBlank(serialid)) {
|
||||
if (restList.contains(serialid)) {
|
||||
restcount++;
|
||||
}
|
||||
|
||||
if(!restList.contains(serialid)){
|
||||
String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ;
|
||||
sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ;
|
||||
}
|
||||
}
|
||||
|
||||
if (weekMap.containsKey(kqdate)) {
|
||||
String value = weekMap.get(kqdate);
|
||||
//6 = 周六 7 = 周日 11 = 公众假日、调配休息日
|
||||
if ("6".equals(value) || "7".equals(value) || "11".equals(value)) {
|
||||
if (restList.contains(serialid)) {
|
||||
weekrestcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
worktime = Util.null2String(rs.getString("worktime"));
|
||||
totalworktime = Util.null2String(rs.getString("totalworktime"));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
countMap.put("worktime",worktime);
|
||||
countMap.put("totalworktime",totalworktime);
|
||||
countMap.put("restcount",restcount+"");
|
||||
countMap.put("weekrestcount",weekrestcount+"");
|
||||
|
||||
return countMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param daysList
|
||||
* @param holidayMap
|
||||
* @param yjl
|
||||
* @param workSchedule
|
||||
* @param hrmList
|
||||
* @param groupid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleStatusByDay(List<String> daysList,Map<String,String> holidayMap,String yjl,String[] workSchedule,List<Map<String,String>> hrmList,String groupid,Map<String,String> dateEffectiveMap){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> resultList = new ArrayList<Map<String,String>>();
|
||||
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try{
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(String pbrq:daysList){
|
||||
|
||||
String resourceids = "";
|
||||
for(int i=0;i<hrmList.size();i++) {
|
||||
Map<String, String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
if(dateEffectiveMap.containsKey(userid)){
|
||||
String effectiveDate = dateEffectiveMap.get(userid);
|
||||
if(effectiveDate.contains(";")){
|
||||
String[] effective_Date = effectiveDate.split(";");
|
||||
if(pbrq.compareTo(effective_Date[0])>=0 && pbrq.compareTo(effective_Date[1])<=0){
|
||||
resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(yjl)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{yjl,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){
|
||||
|
||||
String sql =" select t.serialid,t.resourceid,t.kqdate \n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" where t.kqdate='"+pbrq+"' \n" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid in( " + resourceids + ") "+
|
||||
" order by kqdate ";
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
Map<String,String> resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq);
|
||||
resultList.add(resultMap);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sqlList
|
||||
* @param workScheduleList
|
||||
* @param defaultScheduleMap
|
||||
* @param kqdate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> queryScheduleStatusByUser(List<Map<String,String>> sqlList,List<Map<String,String>> workScheduleList,Map<String,Integer> defaultScheduleMap,String kqdate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
String yxrys = "" ;
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String resourceid = Util.null2String(sqlMap.get("resourceid"));
|
||||
yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(yxrys)) {
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3,4)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3,4) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String pbry = sqlMap.get("resourceid");
|
||||
String serialid = sqlMap.get("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) ";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String,String> resultMap = new HashMap<>();
|
||||
String status = "0";
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
status = "0";
|
||||
}else{
|
||||
status = "1";
|
||||
}
|
||||
}
|
||||
resultMap.put("kqdate",kqdate);
|
||||
resultMap.put("status",status);
|
||||
resultMap.put("xh",xh);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,939 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="java.time.temporal.TemporalAdjusters" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"};
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
// int userid = user.getUID();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String cjr = request.getParameter("cjr");
|
||||
String pbyf = request.getParameter("pbyf");
|
||||
String yjl = request.getParameter("yjl"); //mdyj
|
||||
String cjrbm = request.getParameter("cjrbm");
|
||||
String bp = request.getParameter("bp");
|
||||
|
||||
String activeGroupId = getUserActiveGroupId(cjr+"");
|
||||
// List<Map<String,Object>> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,cjr);
|
||||
// out.println("scheduleList"+ JSON.toJSON(scheduleList));
|
||||
|
||||
List<Map<String,String>> hrmList = new ArrayList<Map<String,String>>();
|
||||
|
||||
// out.println("cjrbm:"+cjrbm+"</br>");
|
||||
if(StringUtils.isNotBlank(cjrbm)) {
|
||||
// String sql = "select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) ";
|
||||
String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+
|
||||
" union "+
|
||||
" select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ;
|
||||
out.print("sql:"+sql+"</br>");
|
||||
hrmList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
int daysInMonth = 0;
|
||||
Map<String, String> holidayMap = new HashMap<String, String>();
|
||||
List<String> daysList = new ArrayList<String>();
|
||||
Map<String,String> weekMap = new HashMap<String,String>();
|
||||
|
||||
List<Map<String,String>> weekList = new ArrayList<Map<String,String>>();
|
||||
|
||||
Map<String,String> dateEffectiveMap = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) {
|
||||
LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
|
||||
|
||||
// for (LocalDate date = firstDayOfMonth; !date.isAfter(lastDayOfMonth); date = date.plusDays(1)) {
|
||||
// daysList.add(date.toString());
|
||||
// }
|
||||
|
||||
String monthStartDate = firstDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String id = hrmMap.get("id");
|
||||
String startDate = monthStartDate;
|
||||
String endDate = monthEndDate ;
|
||||
|
||||
String sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm = "+ id +
|
||||
" and bm= "+ cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
endDate = ydsxrq;
|
||||
}
|
||||
}
|
||||
|
||||
sql =" select ydsxrq " +
|
||||
" from uf_ygddxx " +
|
||||
" where left(ydsxrq,7) = '"+pbyf+"' "+
|
||||
" and xm ="+ id +
|
||||
" and ydhbm="+cjrbm+
|
||||
" and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String ydsxrq = Util.null2String(rs.getString("ydsxrq"));
|
||||
if(StringUtils.isNotBlank(ydsxrq)){
|
||||
startDate = ydsxrq;
|
||||
}
|
||||
}
|
||||
|
||||
out.print("startDate:"+startDate+"</br>");
|
||||
out.print("endDate:"+endDate+"</br>");
|
||||
dateEffectiveMap.put(id,startDate+";"+endDate);
|
||||
}
|
||||
out.print("dateEffectiveMap:"+dateEffectiveMap.size()+"</br>");
|
||||
|
||||
holidayMap = getHolidayByGroupId(cjr, monthStartDate, monthEndDate,activeGroupId);
|
||||
|
||||
daysInMonth = localDate.lengthOfMonth(); // 获取本月有多少天
|
||||
int thisMonth = localDate.getMonthValue(); // 获取当前是哪月
|
||||
|
||||
for (int i = 1; i <= daysInMonth; i++) {
|
||||
LocalDate currentDate = LocalDate.of(localDate.getYear(), thisMonth, i);
|
||||
|
||||
daysList.add(currentDate.toString());
|
||||
|
||||
// System.out.println("currentDate:" + currentDate.toString());
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
// System.out.println(i + "号是周 " + dayOfWeek.getValue());
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String weekDayName = "";
|
||||
switch (weekValue) {
|
||||
case 1:
|
||||
weekDayName = "周一";
|
||||
break;
|
||||
case 2:
|
||||
weekDayName = "周二";
|
||||
break;
|
||||
case 3:
|
||||
weekDayName = "周三";
|
||||
break;
|
||||
case 4:
|
||||
weekDayName = "周四";
|
||||
break;
|
||||
case 5:
|
||||
weekDayName = "周五";
|
||||
break;
|
||||
case 6:
|
||||
weekDayName = "周六";
|
||||
break;
|
||||
case 7:
|
||||
weekDayName = "周日";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
Map<String,String> weekMap2 = new HashMap<String,String>();
|
||||
weekMap2.put("weekname", weekDayName);
|
||||
weekMap2.put("changeType", changeType);
|
||||
weekMap2.put("weekday", i+"");
|
||||
weekMap2.put("weekdate", currentDate.toString());
|
||||
weekList.add(weekMap2);
|
||||
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
weekValue = 11;
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(changeType)){
|
||||
weekMap.put(currentDate.toString(), weekValue+"");
|
||||
}else{
|
||||
weekMap.put(currentDate.toString(), weekValue+"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,Object>> dt1DataList = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String ry = hrmMap.get("id");
|
||||
String lastname = hrmMap.get("lastname");
|
||||
|
||||
Map<String,Object> dt1DataMap = new HashMap<String,Object>();
|
||||
Map<String,Object> ryMap = getDt1UserMap(ry,lastname);
|
||||
dt1DataMap.put("ry",ryMap);
|
||||
|
||||
List<Map<String,Object>> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,ry,dateEffectiveMap);
|
||||
|
||||
dt1DataMap.put("schedule",scheduleList);
|
||||
|
||||
List<String> restList = getSchedulingRestData();
|
||||
Map<String,String> countMap = queryCountWorkTime(restList,daysList,weekMap,scheduleList);
|
||||
dt1DataMap.put("count",countMap);
|
||||
|
||||
dt1DataList.add(dt1DataMap);
|
||||
}
|
||||
// out.println("dt1DataList"+ JSON.toJSON(dt1DataList)+"</br>");
|
||||
|
||||
|
||||
List<Map<String,String>> resultList = queryScheduleStatusByDay(daysList,holidayMap,bp,workSchedule,hrmList,activeGroupId,dateEffectiveMap);
|
||||
|
||||
// out.println("resultList"+ JSON.toJSON(resultList)+"</br>");
|
||||
|
||||
Map<String,Object> valueMap = getMainUserDate(hrmList);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",valueMap);
|
||||
jsonObject.put("dt1day",resultList);
|
||||
jsonObject.put("dt1user",dt1DataList);
|
||||
jsonObject.put("days",daysInMonth);
|
||||
jsonObject.put("head",weekList);
|
||||
%>
|
||||
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
<%!
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){
|
||||
|
||||
String dateType = "0";
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天
|
||||
LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天
|
||||
String monthStartDate = startDayOfMonth.toString();
|
||||
String monthEndDate = lastDayOfMonth.toString();
|
||||
Map<String,String> holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate,activeGroupId);
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
return dateType;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @param monthStartDate
|
||||
* @param monthEndDate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate,String activeGroupId){
|
||||
|
||||
Map<String,String> holidayMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql =" select holidayDate,changeType from KQ_HolidaySet\n" +
|
||||
" where groupid = " + activeGroupId+
|
||||
" and holidayDate >='"+monthStartDate+"'\n" +
|
||||
" and holidayDate <='"+monthEndDate+"' " ;
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||||
String changeType = Util.null2String(rs.getString("changeType"));
|
||||
// String changeTypename = "" ;
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// changeTypename += "公众假日";
|
||||
// }else if("2".equals(changeType)){
|
||||
// changeTypename += "调配工作日";
|
||||
// }else if("3".equals(changeType)){
|
||||
// changeTypename += "调配休息日";
|
||||
// }
|
||||
holidayMap.put(holidayDate,changeType);
|
||||
|
||||
// if(weekMap.containsKey(holidayDate)){
|
||||
// String holidayDate_new = weekMap.get(holidayDate);
|
||||
// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日
|
||||
// holidayDate_new += "[公众假日]";
|
||||
// }else if("1".equals(changeType)){
|
||||
// holidayDate_new += "[调配工作日]";
|
||||
// }else if("2".equals(changeType)){
|
||||
// holidayDate_new += "[调配休息日]";
|
||||
// }
|
||||
// weekMap.put(holidayDate,holidayDate_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return holidayMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getDt1UserMap(String ry,String lastname){
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
if(StringUtils.isNotBlank(ry)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",ry);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
valueMap.put("id",ry);
|
||||
valueMap.put("name",lastname);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
}
|
||||
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param pbyf
|
||||
* @param groupid
|
||||
* @param resourceid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid,Map<String,String> dateEffectiveMap){
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,Object>> scheduleList = new ArrayList<Map<String,Object>>();
|
||||
try{
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){
|
||||
String startDate = "" ;
|
||||
String endDate = "";
|
||||
if(dateEffectiveMap.containsKey(resourceid)){
|
||||
String effectiveDate = dateEffectiveMap.get(resourceid);
|
||||
if(effectiveDate.contains(";")){
|
||||
String[] effective_Date = effectiveDate.split(";");
|
||||
startDate = effective_Date[0];
|
||||
endDate = effective_Date[1];
|
||||
}
|
||||
}
|
||||
|
||||
bb.writeLog("queryShiftScheduleByUser-startDate:"+startDate);
|
||||
bb.writeLog("queryShiftScheduleByUser-endDate:"+endDate);
|
||||
|
||||
String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid\n" +
|
||||
" where left(t.kqdate,7)='"+pbyf+"' \n" +
|
||||
" and t.kqdate >='"+startDate+"' " +
|
||||
" and t.kqdate <= '"+endDate+"'" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid = " + resourceid +
|
||||
" order by kqdate ";
|
||||
bb.writeLog("queryShiftScheduleByUser-sql:"+sql);
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> map = sqlList.get(i);
|
||||
|
||||
String serialid = Util.null2String(map.get("serialid"));
|
||||
String name = Util.null2String(map.get("serial"));
|
||||
String kqdate = Util.null2String(map.get("kqdate"));
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",serialid);
|
||||
specialobjMap.put("name",name);
|
||||
specialobjList.add(specialobjMap);
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("serialid",serialid);
|
||||
valueMap.put("kqdate",kqdate);
|
||||
valueMap.put("xh",xh);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
scheduleList.add(valueMap);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getSchedulingRestData(){
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql =" select id " +
|
||||
" from kq_ShiftManagement \n" +
|
||||
" where is_rest = 1 \n" +
|
||||
" and (isdelete is null or isdelete = 0) ";
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
list.add(id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param restList
|
||||
* @param daysList
|
||||
* @param weekMap
|
||||
* @param serialList
|
||||
*/
|
||||
public Map<String,String> queryCountWorkTime(List<String> restList,List<String> daysList,Map<String,String> weekMap,List<Map<String,Object>> serialList ){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String,String> countMap = new HashMap<>();
|
||||
String worktime = "0";
|
||||
String totalworktime = "0";
|
||||
int restcount = 0;
|
||||
int weekrestcount = 0;
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
String sql = "";
|
||||
for (int i = 0; i < serialList.size(); i++) {
|
||||
Map<String,Object> serialMap = serialList.get(i);
|
||||
String kqdate = Util.null2String(serialMap.get("kqdate"));
|
||||
String serialid = Util.null2String(serialMap.get("serialid"));
|
||||
if (daysList.contains(kqdate)) {
|
||||
if (StringUtils.isNotBlank(serialid)) {
|
||||
if (restList.contains(serialid)) {
|
||||
restcount++;
|
||||
}
|
||||
|
||||
if(!restList.contains(serialid)){
|
||||
String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ;
|
||||
sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ;
|
||||
}
|
||||
}
|
||||
|
||||
if (weekMap.containsKey(kqdate)) {
|
||||
String value = weekMap.get(kqdate);
|
||||
//6 = 周六 7 = 周日 11 = 公众假日、调配休息日
|
||||
if ("6".equals(value) || "7".equals(value) || "11".equals(value)) {
|
||||
if (restList.contains(serialid)) {
|
||||
weekrestcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w ";
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
worktime = Util.null2String(rs.getString("worktime"));
|
||||
totalworktime = Util.null2String(rs.getString("totalworktime"));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
countMap.put("worktime",worktime);
|
||||
countMap.put("totalworktime",totalworktime);
|
||||
countMap.put("restcount",restcount+"");
|
||||
countMap.put("weekrestcount",weekrestcount+"");
|
||||
|
||||
return countMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param daysList
|
||||
* @param holidayMap
|
||||
* @param bp
|
||||
* @param workSchedule
|
||||
* @param hrmList
|
||||
* @param groupid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleStatusByDay(List<String> daysList,Map<String,String> holidayMap,String bp,String[] workSchedule,List<Map<String,String>> hrmList,String groupid,Map<String,String> dateEffectiveMap){
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> resultList = new ArrayList<Map<String,String>>();
|
||||
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try{
|
||||
List<Map<String,String>> workScheduleList = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> workScheduleMap = null;
|
||||
for(int k=0;k<workSchedule.length;k++){
|
||||
if(workSchedule[k].indexOf("-")>0){
|
||||
String[] schedule = workSchedule[k].split("-");
|
||||
String scheduleStartTime = schedule[0];
|
||||
String scheduleEndTime = schedule[1];
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
workScheduleMap = new HashMap<String,String>();
|
||||
workScheduleMap.put("start",scheduleStartTime);
|
||||
workScheduleMap.put("end",scheduleEndTime);
|
||||
workScheduleList.add(workScheduleMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(String pbrq:daysList){
|
||||
bb.writeLog("queryScheduleStatusByDay--pbrq:"+pbrq);
|
||||
String resourceids = "";
|
||||
for(int i=0;i<hrmList.size();i++) {
|
||||
Map<String, String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
// if(dateEffectiveMap.containsKey(userid)){
|
||||
// String effectiveDate = dateEffectiveMap.get(userid);
|
||||
// if(effectiveDate.contains(";")){
|
||||
// String[] effective_Date = effectiveDate.split(";");
|
||||
// if(pbrq.compareTo(effective_Date[0])>=0 && pbrq.compareTo(effective_Date[1])<=0){
|
||||
// resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ;
|
||||
}
|
||||
}
|
||||
|
||||
bb.writeLog("queryScheduleStatusByDay-resourceids:"+resourceids);
|
||||
String dateType = "0";
|
||||
if(StringUtils.isNotBlank(pbrq)){
|
||||
LocalDate currentDate = LocalDate.parse(pbrq, df);
|
||||
DayOfWeek dayOfWeek = currentDate.getDayOfWeek();
|
||||
int weekValue = dayOfWeek.getValue();
|
||||
|
||||
String changeType = "" ;
|
||||
if(holidayMap.containsKey(currentDate.toString())){
|
||||
changeType = holidayMap.get(currentDate.toString());
|
||||
}
|
||||
|
||||
if("1".equals(changeType) || "3".equals(changeType)){
|
||||
dateType = "1";
|
||||
}else if(weekValue == 6 || weekValue == 7){
|
||||
dateType = "1";
|
||||
}
|
||||
}
|
||||
|
||||
bb.writeLog("queryScheduleStatusByDay-dateType:"+dateType);
|
||||
|
||||
Map<String,Integer> defaultScheduleMap = new HashMap<String,Integer>();
|
||||
if(StringUtils.isNotBlank(bp)){
|
||||
String sql = " select dysjd,pzrs from uf_pbjcsj where bprs = ? and pblx = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{bp,dateType});
|
||||
while (rs.next()){
|
||||
int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd")));
|
||||
int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs")));
|
||||
|
||||
String sjd = "";
|
||||
if(dysd < workSchedule.length){
|
||||
sjd = workSchedule[dysd];
|
||||
if(StringUtils.isNotBlank(sjd)){
|
||||
defaultScheduleMap.put(sjd,pzrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String,String>> sqlList = new ArrayList<Map<String,String>>();
|
||||
if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){
|
||||
|
||||
String sql =" select t.serialid,t.resourceid,t.kqdate \n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" where t.kqdate='"+pbrq+"' \n" +
|
||||
" and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and resourceid in( " + resourceids + ") "+
|
||||
" order by kqdate ";
|
||||
sqlList = queryListBySql(sql);
|
||||
}
|
||||
|
||||
Map<String,String> resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq);
|
||||
resultList.add(resultMap);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sqlList
|
||||
* @param workScheduleList
|
||||
* @param defaultScheduleMap
|
||||
* @param kqdate
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> queryScheduleStatusByUser(List<Map<String,String>> sqlList,List<Map<String,String>> workScheduleList,Map<String,Integer> defaultScheduleMap,String kqdate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String,Map<String,String>> userScheduleDayMap = new HashMap<String,Map<String,String>>();
|
||||
Map<String,Integer> userScheduleMap = new HashMap<String,Integer>();
|
||||
Map<String,Integer> necessaryMap = new HashMap<String,Integer>();
|
||||
String yxrys = "" ;
|
||||
for(int i=0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String resourceid = Util.null2String(sqlMap.get("resourceid"));
|
||||
yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ;
|
||||
}
|
||||
|
||||
bb.writeLog("queryScheduleStatusByUser-yxrys:"+yxrys);
|
||||
|
||||
if(StringUtils.isNotBlank(yxrys)) {
|
||||
List<String> userList = new ArrayList<String>();
|
||||
String sql =" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join hrmjobtitles k on k.id = h.jobtitle\n" +
|
||||
" where h.id in("+yxrys+")\n" +
|
||||
" and k.jobtitlename in('店长','验光师')\n" +
|
||||
" and h.status in(0,1,2,3,4)\n" +
|
||||
" union \n" +
|
||||
" select h.id \n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id\n" +
|
||||
" where k.field39 = 2 \n" +
|
||||
" and k.scopeid=3 \n" +
|
||||
" and k.scope='HrmCustomFieldByInfoType' " +
|
||||
" and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " +
|
||||
" union " +
|
||||
" select h.id\n" +
|
||||
" from hrmresource h \n" +
|
||||
" inner join cus_fielddata k on k.id = h.id \n" +
|
||||
" where k.scopeid=-1 " +
|
||||
" and k.scope='HrmCustomFieldByInfoType'\n" +
|
||||
" and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" +
|
||||
" and h.status in(0,1,2,3,4) "+
|
||||
" and h.id in("+yxrys+") ";
|
||||
|
||||
bb.writeLog("queryScheduleStatusByUser-sql:"+sql);
|
||||
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
userList.add(id);
|
||||
}
|
||||
|
||||
for(int i = 0;i<sqlList.size();i++){
|
||||
Map<String,String> sqlMap = sqlList.get(i);
|
||||
String pbry = sqlMap.get("resourceid");
|
||||
String serialid = sqlMap.get("serialid");
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
|
||||
sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) ";
|
||||
rs.executeQuery(sql,new Object[]{serialid});
|
||||
while(rs.next()){
|
||||
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
|
||||
if("start".equals(onoffworktype)){
|
||||
startTime = Util.null2String(rs.getString("times"));
|
||||
}else if("end".equals(onoffworktype)){
|
||||
endTime = Util.null2String(rs.getString("times"));
|
||||
}
|
||||
}
|
||||
|
||||
bb.writeLog("queryScheduleStatusByUser-startTime:"+startTime);
|
||||
bb.writeLog("queryScheduleStatusByUser-endTime:"+endTime);
|
||||
|
||||
Map<String,String> userSchedule_Map = new HashMap<String,String>();
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
userSchedule_Map.put("startTime",startTime);
|
||||
userSchedule_Map.put("endTime",endTime);
|
||||
|
||||
for(int k=0;k<workScheduleList.size();k++){
|
||||
Map<String,String> workSchedule_Map = workScheduleList.get(k);
|
||||
String scheduleStartTime = workSchedule_Map.get("start");
|
||||
String scheduleEndTime = workSchedule_Map.get("end");
|
||||
if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){
|
||||
if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){
|
||||
|
||||
String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ;
|
||||
if(userScheduleMap.containsKey(defWorkSchedule)){
|
||||
int count = userScheduleMap.get(defWorkSchedule);
|
||||
count++;
|
||||
userScheduleMap.put(defWorkSchedule,count);
|
||||
}else{
|
||||
userScheduleMap.put(defWorkSchedule,1);
|
||||
}
|
||||
|
||||
if(userList.contains(pbry)){
|
||||
necessaryMap.put(defWorkSchedule,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userScheduleDayMap.put(pbry,userSchedule_Map);
|
||||
}
|
||||
}
|
||||
|
||||
userScheduleMap.forEach((key, value) -> bb.writeLog("queryScheduleStatusByUser--Key = " + key + ", Value = " + value));
|
||||
|
||||
int defaultcount = 0;
|
||||
int datacount = 0;
|
||||
Iterator<Map.Entry<String, Integer>> iterator = defaultScheduleMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = iterator.next();
|
||||
int value =entry.getValue();
|
||||
String key = entry.getKey();
|
||||
bb.writeLog("defaultScheduleMap--value = "+value);
|
||||
bb.writeLog("defaultScheduleMap--key = "+key);
|
||||
|
||||
if(userScheduleMap.containsKey(key)){
|
||||
int useValue = userScheduleMap.get(key);
|
||||
bb.writeLog("defaultScheduleMap--useValue = "+useValue);
|
||||
if(useValue < value){
|
||||
datacount++;
|
||||
}
|
||||
}else{
|
||||
datacount++;
|
||||
}
|
||||
defaultcount++;
|
||||
}
|
||||
|
||||
bb.writeLog("queryScheduleStatusByUser--datacount = "+datacount);
|
||||
bb.writeLog("queryScheduleStatusByUser--defaultcount = "+defaultcount);
|
||||
|
||||
String xh = "";
|
||||
if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){
|
||||
xh = kqdate.substring(8);
|
||||
if(StringUtils.isNotBlank(xh)){
|
||||
if(xh.startsWith("0")){
|
||||
xh = xh.substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String,String> resultMap = new HashMap<>();
|
||||
String status = "";
|
||||
if(defaultcount >0 && datacount == 0){
|
||||
if(necessaryMap.size() == 4){
|
||||
status = "0";
|
||||
}else{
|
||||
status = "1";
|
||||
}
|
||||
}else{
|
||||
bb.writeLog("queryScheduleStatusByUser--status = "+status);
|
||||
}
|
||||
resultMap.put("kqdate",kqdate);
|
||||
resultMap.put("status",status);
|
||||
resultMap.put("xh",xh);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package weaver.interfaces.zw.cron;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
public class EmployeeDataSnapshotCron extends BaseCronJob {
|
||||
@Override
|
||||
public void execute() {
|
||||
updateEmployeeSnapshot();
|
||||
}
|
||||
public void updateEmployeeSnapshot(){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
boolean istrue = rs.executeProc("HR_RYKZ","");
|
||||
}catch (Exception e){
|
||||
bb.writeLog("updateEmployeeSnapshot:"+e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package weaver.interfaces.zw.cron;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
public class EmployeeDataSnapshotDayCron extends BaseCronJob {
|
||||
@Override
|
||||
public void execute() {
|
||||
updateEmployeeSnapshot();
|
||||
}
|
||||
public void updateEmployeeSnapshot(){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
boolean istrue = rs.executeProc("HR_RYKZ_Day","");
|
||||
bb.writeLog("EmployeeDataSnapshotDayCron:"+istrue);
|
||||
}catch (Exception e){
|
||||
bb.writeLog("EmployeeDataSnapshotDayCron:"+e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package weaver.interfaces.zw.cron;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
public class EmployeeDataSnapshotMonthCron extends BaseCronJob {
|
||||
@Override
|
||||
public void execute() {
|
||||
updateEmployeeSnapshot();
|
||||
}
|
||||
public void updateEmployeeSnapshot(){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
boolean istrue = rs.executeProc("HR_RYKZ","");
|
||||
bb.writeLog("EmployeeDataSnapshotMonthCron:"+istrue);
|
||||
}catch (Exception e){
|
||||
bb.writeLog("EmployeeDataSnapshotMonthCron:"+e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package weaver.interfaces.zw.cron;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
public class EmployeeTransferCron extends BaseCronJob {
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
⑥更新“调动人”的【考勤组】为:新考勤组;
|
||||
⑦更新“调动人”的新考勤组中的“生效日期”=调动生效日期(如下图);
|
||||
⑧更新“调动人”的原考勤组中的“失效日期”=调动生效日期 - 1天;
|
||||
⑨如果“调动人”的二级部门是:四川一区(部门id=264)的,且“调动人”【职务】是督导、经理、总监的,要把“调动人”加入【四川一区】考勤组;
|
||||
⑩如果“调动人”的二级部门是:四川二区(部门id=258)的,且“调动人”【职务】是督导、经理、总监的,要把“调动人”加入【四川二区】考勤组;
|
||||
⑪更新“调动人”的矩阵:
|
||||
>>如果“调动人”是“调出部门”的部门矩阵中的“店长/直接主管”,则更新“调出门店”的部门矩阵中的“店长/直接主管”为:职务交接人;即,更新部门矩阵中我是店长的数据为:职务交接人,别人顶替我;
|
||||
>>如果“调动人”的“是否为新店店长==是”,则更新“调入门店”的部门矩阵中的“店长/直接主管”为:调动人;即,更新我为新门店的店长;
|
||||
*/
|
||||
|
||||
// ①更新“调动人”的【部门】为:调入门店;
|
||||
public void updateDepartment(String ddr,String drmd){
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = " update hrmresource set departmentid = "+drmd+" where id = "+ddr;
|
||||
rs.executeUpdate(sql);
|
||||
|
||||
}
|
||||
|
||||
// ②更新“调动人”的【岗位】为:调动后岗位;
|
||||
public void updateJobTitle(){
|
||||
|
||||
}
|
||||
|
||||
// ③更新“调动人”的【岗位等级】为:调动后岗级;
|
||||
public void updateJobTitleGrade(){
|
||||
|
||||
}
|
||||
|
||||
// ④更新“调动人”的【直接上级】为:新直接上级;
|
||||
public void updateManager(){
|
||||
|
||||
}
|
||||
|
||||
// ⑤更新“调动人”的所有下属的直接上级为:职务交接人,即:代替“调动人”当领导的;
|
||||
public void updateSubordinate(){
|
||||
|
||||
}
|
||||
|
||||
// ⑥更新“调动人”的【考勤组】为:新考勤组;
|
||||
// ⑦更新“调动人”的新考勤组中的“生效日期”=调动生效日期(如下图);
|
||||
// ⑧更新“调动人”的原考勤组中的“失效日期”=调动生效日期 - 1天;
|
||||
|
||||
//⑨如果“调动人”的二级部门是:四川一区(部门id=264)的,且“调动人”【职务】是督导、经理、总监的,要把“调动人”加入【四川一区】考勤组;
|
||||
//⑩如果“调动人”的二级部门是:四川二区(部门id=258)的,且“调动人”【职务】是督导、经理、总监的,要把“调动人”加入【四川二区】考勤组;
|
||||
|
||||
|
||||
// ⑪更新“调动人”的矩阵:
|
||||
// >>如果“调动人”是“调出部门”的部门矩阵中的“店长/直接主管”,则更新“调出门店”的部门矩阵中的“店长/直接主管”为:职务交接人;即,更新部门矩阵中我是店长的数据为:职务交接人,别人顶替我;
|
||||
// >>如果“调动人”的“是否为新店店长==是”,则更新“调入门店”的部门矩阵中的“店长/直接主管”为:调动人;即,更新我为新门店的店长;
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
package weaver.interfaces.zw.utils;
|
||||
|
||||
import weaver.general.BaseBean;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommonUtil {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
public static List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
public static Map<String,String> queryMapBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
if (rs.next()){
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryMapBySql-e:"+e);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param workflowid
|
||||
* @return
|
||||
*/
|
||||
public static String getFormtableByWorkflowId(String workflowid){
|
||||
|
||||
String formtable = "" ;
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(workflowid)){
|
||||
String sql = "select abs(formid) as formid from workflow_base where id= "+workflowid ;
|
||||
bb.writeLog("sql:"+sql);
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String formid = Util.null2String(rs.getString("formid"));
|
||||
bb.writeLog("formid:"+formid);
|
||||
if(StringUtils.isNotBlank(formid)){
|
||||
formtable = "formtable_main_"+formid ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("getFormtableByWorkflowId:"+e);
|
||||
}
|
||||
|
||||
return formtable;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public static String getFormtableByRequestId(String requestid){
|
||||
String formtable = "" ;
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(requestid)){
|
||||
String sql =" select abs(formid) from workflow_base t \n" +
|
||||
" inner join workflow_requestbase h on h.workflowid = t.id \n" +
|
||||
" where requestid= "+requestid ;
|
||||
bb.writeLog("sql2:"+sql);
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
String formid = Util.null2String(rs.getString("formid"));
|
||||
if(StringUtils.isNotBlank(formid)){
|
||||
formtable = "formtable_main_"+formid ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("getFormtableByRequestId:"+e);
|
||||
}
|
||||
|
||||
return formtable;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,373 @@
|
|||
package weaver.interfaces.zw.workflow.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.kq.service.KQShiftScheduleService;
|
||||
import com.engine.kq.service.impl.KQShiftScheduleServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.interfaces.zw.utils.CommonUtil;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author shil
|
||||
* @date 2024/8/1
|
||||
* 流程生成排班
|
||||
*/
|
||||
public class Htpblc2SchedulingEditAction implements Action {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
BaseBean bb = new BaseBean();
|
||||
String requestid = requestInfo.getRequestid();
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String billtable = requestInfo.getRequestManager().getBillTableName();
|
||||
|
||||
int creator = requestInfo.getRequestManager().getCreater();
|
||||
bb.writeLog("creator:"+creator);
|
||||
User creatorUser = new User(creator);
|
||||
bb.writeLog("creatorUser:"+creatorUser.getLastname());
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
bb.writeLog("----Htpblc2SchedulingEditAction------");
|
||||
DepartmentComInfo departmentComInfo = null;
|
||||
ResourceComInfo resourceComInfo = null;
|
||||
try {
|
||||
departmentComInfo = new DepartmentComInfo();
|
||||
resourceComInfo = new ResourceComInfo();
|
||||
String mainid = "" ;
|
||||
String pbyf = "" ;
|
||||
String cjrbm = "" ;
|
||||
String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
mainid = Util.null2String(rs.getString("id"));
|
||||
pbyf = Util.null2String(rs.getString("pbyf"));
|
||||
cjrbm = Util.null2String(rs.getString("cjrbm"));
|
||||
}
|
||||
|
||||
List<Map<String,String>> requestList = queryRequestList(billtable,cjrbm,pbyf,workflowid,requestid);
|
||||
if(!requestList.isEmpty() && requestList.size() >0){
|
||||
String requestname = requestList.get(0).get("requestname");
|
||||
String cjrbmmc = departmentComInfo.getDepartmentname(cjrbm);
|
||||
String currentnodetype = requestList.get(0).get("currentnodetype");
|
||||
String requesttypename = "";
|
||||
if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) {
|
||||
requesttypename = "正在审批";
|
||||
} else if ("3".equals(currentnodetype)) {
|
||||
requesttypename = "已归档";
|
||||
}
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(cjrbmmc+"已存在"+pbyf+"的排班申请"+requesttypename+"流程:<"+requestname+">,无法提交当前流程");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
|
||||
String message = "";
|
||||
int daysInMonth = 0;
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
}
|
||||
bb.writeLog("----mainid------"+mainid);
|
||||
bb.writeLog("----daysInMonth------"+daysInMonth);
|
||||
if(StringUtils.isNotBlank(mainid))
|
||||
{
|
||||
int errcount = 0;
|
||||
Map<String,String> groupNameMap = queryGroupData();
|
||||
|
||||
sql = " select * from "+billtable+"_dt1 where mainid="+mainid;
|
||||
bb.writeLog("----sql------"+sql);
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
|
||||
Map<String,Set<String>> userGroupsMap = getUsergroupByDate(dt1Map, pbyf,daysInMonth);
|
||||
for (Map.Entry<String, Set<String>> entry : userGroupsMap.entrySet()) {
|
||||
String userActiveGroupId = entry.getKey();
|
||||
Set<String> dateSet = entry.getValue();
|
||||
|
||||
bb.writeLog("----userActiveGroupId------"+userActiveGroupId);
|
||||
bb.writeLog("----dateSet------"+dateSet.size());
|
||||
dateSet.forEach(element ->bb.writeLog("date:"+element));
|
||||
|
||||
String status = getUserScheduleData(dt1Map,pbyf,userActiveGroupId,dateSet,creatorUser,daysInMonth);
|
||||
if(!"".equals(status)){
|
||||
message += resourceComInfo.getLastname(resourceid)+"在考勤组:<"+groupNameMap.get(userActiveGroupId)+">的排班异常;";
|
||||
errcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(errcount > 0){
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("获取流程数据异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("流程提交接口异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,Set<String>> getUsergroupByDate(Map<String,String> dt1Map,String pbyf,int daysInMonth){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
Map<String,Set<String>> userGroupsMap = new HashMap<String,Set<String>>();
|
||||
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
List<Map<String,String>> userGroupList = getUserKqGroupData(resourceid);
|
||||
for(int k=1;k<=daysInMonth;k++){
|
||||
String kqdate = "";
|
||||
if(k<10){
|
||||
kqdate = pbyf+"-0"+k;
|
||||
}else{
|
||||
kqdate = pbyf+"-"+k;
|
||||
}
|
||||
String userActiveGroupId = "";
|
||||
for(int p = 0;p<userGroupList.size();p++){
|
||||
Map<String,String> userGroupMap = userGroupList.get(p);
|
||||
|
||||
String validatefrom = userGroupMap.get("validatefrom");
|
||||
String validateto = userGroupMap.get("validateto");
|
||||
bb.writeLog("resourceid:"+resourceid+" validatefrom:"+validatefrom);
|
||||
bb.writeLog("resourceid:"+resourceid+" validateto:"+validateto);
|
||||
|
||||
if(kqdate.compareTo(validatefrom) >= 0 && kqdate.compareTo(validateto) <=0){
|
||||
userActiveGroupId = userGroupMap.get("groupid");
|
||||
}
|
||||
}
|
||||
if(userGroupsMap.containsKey(userActiveGroupId)){
|
||||
Set<String> dataSet = userGroupsMap.get(userActiveGroupId);
|
||||
dataSet.add(kqdate);
|
||||
userGroupsMap.put(userActiveGroupId,dataSet);
|
||||
}else{
|
||||
Set<String> dataSet = new HashSet<String>();
|
||||
dataSet.add(kqdate);
|
||||
userGroupsMap.put(userActiveGroupId,dataSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return userGroupsMap;
|
||||
}
|
||||
|
||||
|
||||
public String getUserScheduleData(Map<String,String> dt1Map,String pbyf,String userActiveGroupId,Set<String> dateSet,User creatorUser,int daysInMonth){
|
||||
BaseBean bb = new BaseBean();
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
|
||||
String status = "";
|
||||
Map<String,String> scheduleMap = queryScheduleDataByActiveGroupId(resourceid,pbyf,userActiveGroupId);
|
||||
|
||||
|
||||
JSONArray datasArray = new JSONArray();
|
||||
|
||||
JSONArray kqdata = new JSONArray();
|
||||
for(int k=1;k<=daysInMonth;k++){
|
||||
String kqdate = "";
|
||||
if(k<10){
|
||||
kqdate = pbyf+"-0"+k;
|
||||
}else{
|
||||
kqdate = pbyf+"-"+k;
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(userActiveGroupId)){
|
||||
if(dateSet.contains(kqdate)){
|
||||
String serialid = Util.null2String(dt1Map.get("bc"+k));
|
||||
if(StringUtils.isNotBlank(serialid)){
|
||||
JSONObject bcJSON = new JSONObject();
|
||||
String id = "";
|
||||
if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+userActiveGroupId+"_"+kqdate)){
|
||||
id = scheduleMap.get(resourceid+"_"+serialid+"_"+userActiveGroupId+"_"+kqdate);
|
||||
}
|
||||
bb.writeLog(resourceid+":id:"+id);
|
||||
bcJSON.put("id",id);
|
||||
bcJSON.put("serialid",serialid);
|
||||
bcJSON.put("date",kqdate);
|
||||
kqdata.add(bcJSON);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject dataJSON = new JSONObject();
|
||||
dataJSON.put("resourceid",resourceid);
|
||||
dataJSON.put("kqdata",kqdata);
|
||||
datasArray.add(dataJSON);
|
||||
|
||||
JSONObject datasJSON = new JSONObject();
|
||||
datasJSON.put("datas",datasArray);
|
||||
datasJSON.put("groupId", userActiveGroupId);
|
||||
bb.writeLog("data:"+datasJSON.toJSONString());
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("data",datasJSON.toJSONString());
|
||||
Map<String, Object> apidatas = getService(creatorUser).save(params, creatorUser);
|
||||
bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas));
|
||||
if(apidatas.containsKey("status")){
|
||||
status = Util.null2String(apidatas.get("status"));
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> queryScheduleDataByActiveGroupId(String userid,String pbyf,String activeGroupid){
|
||||
Map<String,String> dataMap = new HashMap<String,String>();
|
||||
BaseBean bb = new BaseBean();
|
||||
try {
|
||||
String sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userid+") and isdelete =0 and groupid="+activeGroupid;
|
||||
bb.writeLog("sql:"+sql);
|
||||
List<Map<String,String>> scheduleList = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<scheduleList.size();i++){
|
||||
Map<String,String> scheduleMap = scheduleList.get(i);
|
||||
String kqdate = scheduleMap.get("kqdate");
|
||||
String resourceid = scheduleMap.get("resourceid");
|
||||
String serialid = scheduleMap.get("serialid");
|
||||
String groupid = scheduleMap.get("groupid");
|
||||
String id = scheduleMap.get("id");
|
||||
|
||||
bb.writeLog("kqdate:"+kqdate);
|
||||
bb.writeLog("resourceid:"+resourceid);
|
||||
bb.writeLog("serialid:"+serialid);
|
||||
bb.writeLog("groupid:"+groupid);
|
||||
bb.writeLog("id:"+id);
|
||||
dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param billtable
|
||||
* @param cjrbm
|
||||
* @param pbyf
|
||||
* @param workflowid
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){
|
||||
|
||||
List<Map<String,String>> requestList = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " +
|
||||
" from "+billtable+" t " +
|
||||
" inner join workflow_requestbase r on r.requestid = t.requestid " +
|
||||
" where t.pbyf ='"+pbyf+"' " +
|
||||
" and t.cjrbm ='"+cjrbm+"' " +
|
||||
" and r.currentnodetype in(1,2,3) " +
|
||||
" and r.workflowid = "+workflowid +
|
||||
" and t.requestid <> "+requestid;
|
||||
requestList = CommonUtil.queryListBySql(sql);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return requestList;
|
||||
}
|
||||
|
||||
|
||||
private KQShiftScheduleService getService(User user) {
|
||||
return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Map<String,String>> getUserKqGroupData(String userid){
|
||||
|
||||
List<Map<String,String>> userGroupList = new ArrayList<Map<String,String>>();
|
||||
|
||||
try{
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
String sql =" select distinct resourceid, groupid,status,validatefrom,validateto FROM ( \n" +
|
||||
" select a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" where a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') \n" +
|
||||
" union all \n" +
|
||||
" select a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" where a.subcompanyid1 = b.typevalue and b.type=2 and a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') \n" +
|
||||
" union all \n" +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" WHERE a.departmentid = b.typevalue AND b.type=3 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') \n" +
|
||||
" UNION ALL \n" +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" WHERE a.jobtitle = b.typevalue AND b.type=5 \n" +
|
||||
" AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))) \n" +
|
||||
" and (b.isdelete is null or b.isdelete <> '1') \n" +
|
||||
" UNION ALL \n" +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') ) t\n" +
|
||||
" where resourceid="+userid ;
|
||||
userGroupList = queryListBySql(sql);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return userGroupList;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Map<String,String> queryGroupData(){
|
||||
Map<String,String> groupNameMap = new HashMap<String,String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = " select id,groupname from kq_group ";
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
String groupname = Util.null2String(rs.getString("groupname"));
|
||||
groupNameMap.put(id,groupname);
|
||||
}
|
||||
return groupNameMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,496 @@
|
|||
package weaver.interfaces.zw.workflow.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.kq.biz.KQGroupBiz;
|
||||
import com.engine.kq.biz.KQGroupComInfo;
|
||||
import com.engine.kq.biz.KQGroupMemberComInfo;
|
||||
import com.engine.kq.service.KQShiftScheduleService;
|
||||
import com.engine.kq.service.impl.KQShiftScheduleServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.interfaces.zw.utils.CommonUtil;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author shil
|
||||
* @date 2024/8/1
|
||||
* 流程生成排班
|
||||
*/
|
||||
public class Htpblc2SchedulingEditActionbak implements Action {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
BaseBean bb = new BaseBean();
|
||||
String requestid = requestInfo.getRequestid();
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String billtable = requestInfo.getRequestManager().getBillTableName();
|
||||
|
||||
int creator = requestInfo.getRequestManager().getCreater();
|
||||
bb.writeLog("creator:"+creator);
|
||||
User creatorUser = new User(creator);
|
||||
bb.writeLog("creatorUser:"+creatorUser.getLastname());
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
bb.writeLog("----Htpblc2SchedulingEditAction------");
|
||||
DepartmentComInfo departmentComInfo = null;
|
||||
ResourceComInfo resourceComInfo = null;
|
||||
try {
|
||||
departmentComInfo = new DepartmentComInfo();
|
||||
resourceComInfo = new ResourceComInfo();
|
||||
String mainid = "" ;
|
||||
String cjr = "" ;
|
||||
String pbyf = "" ;
|
||||
String cjrbm = "" ;
|
||||
String pbmd = "";
|
||||
String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
mainid = Util.null2String(rs.getString("id"));
|
||||
cjr = Util.null2String(rs.getString("cjr"));
|
||||
pbyf = Util.null2String(rs.getString("pbyf"));
|
||||
cjrbm = Util.null2String(rs.getString("cjrbm"));
|
||||
pbmd = Util.null2String(rs.getString("pbmd"));
|
||||
}
|
||||
|
||||
List<Map<String,String>> requestList = queryRequestList(billtable,cjrbm,pbyf,workflowid,requestid);
|
||||
if(!requestList.isEmpty() && requestList.size() >0){
|
||||
String requestname = requestList.get(0).get("requestname");
|
||||
String lcid = requestList.get(0).get("requestid");
|
||||
String cjrbmmc = departmentComInfo.getDepartmentname(cjrbm);
|
||||
String currentnodetype = requestList.get(0).get("currentnodetype");
|
||||
String requesttypename = "";
|
||||
if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) {
|
||||
requesttypename = "正在审批";
|
||||
} else if ("3".equals(currentnodetype)) {
|
||||
requesttypename = "已归档";
|
||||
}
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(cjrbmmc+"已存在"+pbyf+"的排班申请"+requesttypename+"流程:<"+requestname+">,无法提交当前流程");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
|
||||
int daysInMonth = 0;
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
}
|
||||
bb.writeLog("----mainid------"+mainid);
|
||||
if(StringUtils.isNotBlank(mainid))
|
||||
{
|
||||
String cjrGroupid = getUserActiveGroupId(cjr);
|
||||
bb.writeLog("cjrGroupid:"+cjrGroupid);
|
||||
|
||||
Map<String,String> scheduleMap = queryScheduleDataMap(billtable,mainid,pbyf);
|
||||
|
||||
JSONObject datasJSON = new JSONObject();
|
||||
JSONArray datasArray = new JSONArray();
|
||||
|
||||
sql = " select * from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
|
||||
|
||||
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
List<Map<String,String>> userGroupList = getUserKqGroupData(resourceid);
|
||||
JSONArray kqdata = new JSONArray();
|
||||
for(int k=1;k<=daysInMonth;k++){
|
||||
String serialid = Util.null2String(dt1Map.get("bc"+k));
|
||||
if(StringUtils.isNotBlank(serialid)){
|
||||
String kqdate = "";
|
||||
if(k<10){
|
||||
kqdate = pbyf+"-0"+k;
|
||||
}else{
|
||||
kqdate = pbyf+"-"+k;
|
||||
}
|
||||
|
||||
String groupid = "";
|
||||
for(int n=0;n<userGroupList.size();n++){
|
||||
Map<String,String> userGrupMap = userGroupList.get(n);
|
||||
String validatefrom = userGrupMap.get("validatefrom");
|
||||
String validateto = userGrupMap.get("validateto");
|
||||
if(kqdate.compareTo(validatefrom)>=0 && kqdate.compareTo(validateto) < 0){
|
||||
groupid = userGrupMap.get("groupid");
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(groupid)){
|
||||
if(cjrGroupid.equals(groupid)){
|
||||
JSONObject bcJSON = new JSONObject();
|
||||
String id = "";
|
||||
if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate)){
|
||||
id = scheduleMap.get(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate);
|
||||
}
|
||||
bb.writeLog(resourceid+":id:"+id);
|
||||
bcJSON.put("id",id);
|
||||
bcJSON.put("serialid",serialid);
|
||||
bcJSON.put("date",kqdate);
|
||||
kqdata.add(bcJSON);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// List<Map<String,String>> userGroupList = getUserKqGroupData(resourceid);
|
||||
// Set<String> groupSet = new HashSet<String>();
|
||||
// for(int k=1;k<=daysInMonth;k++){
|
||||
// String kqdate = "";
|
||||
// if(k<10){
|
||||
// kqdate = pbyf+"-0"+k;
|
||||
// }else{
|
||||
// kqdate = pbyf+"-"+k;
|
||||
// }
|
||||
// for(int n=0;n<userGroupList.size();n++){
|
||||
// Map<String,String> userGrupMap = userGroupList.get(n);
|
||||
// String validatefrom = userGrupMap.get("validatefrom");
|
||||
// String validateto = userGrupMap.get("validateto");
|
||||
// if(kqdate.compareTo(validatefrom)>=0 && kqdate.compareTo(validateto) < 0){
|
||||
// String groupid = userGrupMap.get("groupid");
|
||||
// groupSet.add(groupid);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// for(String activeGroup : groupSet){
|
||||
// JSONObject datasJSON = new JSONObject();
|
||||
// JSONArray datasArray = new JSONArray();
|
||||
//
|
||||
// JSONArray kqdata = new JSONArray();
|
||||
// for(int k=1;k<=daysInMonth;k++){
|
||||
// String serialid = Util.null2String(dt1Map.get("bc"+k));
|
||||
// if(StringUtils.isNotBlank(serialid)){
|
||||
// String kqdate = "";
|
||||
// if(k<10){
|
||||
// kqdate = pbyf+"-0"+k;
|
||||
// }else{
|
||||
// kqdate = pbyf+"-"+k;
|
||||
// }
|
||||
//
|
||||
// String groupid = "";
|
||||
// // resourceid, groupid,status,validatefrom,validateto
|
||||
//
|
||||
//
|
||||
// for(int n=0;n<userGroupList.size();n++){
|
||||
// Map<String,String> userGrupMap = userGroupList.get(n);
|
||||
// String validatefrom = userGrupMap.get("validatefrom");
|
||||
// String validateto = userGrupMap.get("validateto");
|
||||
// if(kqdate.compareTo(validatefrom)>=0 && kqdate.compareTo(validateto) < 0){
|
||||
// groupid = userGrupMap.get("groupid");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(StringUtils.isNotBlank(groupid)){
|
||||
// JSONObject bcJSON = new JSONObject();
|
||||
// String id = "";
|
||||
// if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate)){
|
||||
// id = scheduleMap.get(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate);
|
||||
// }
|
||||
// bb.writeLog(resourceid+":id:"+id);
|
||||
// bcJSON.put("id",id);
|
||||
// bcJSON.put("serialid",serialid);
|
||||
// bcJSON.put("date",kqdate);
|
||||
// kqdata.add(bcJSON);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
JSONObject dataJSON = new JSONObject();
|
||||
dataJSON.put("resourceid",resourceid);
|
||||
dataJSON.put("kqdata",kqdata);
|
||||
datasArray.add(dataJSON);
|
||||
}
|
||||
}
|
||||
|
||||
datasJSON.put("datas",datasArray);
|
||||
datasJSON.put("groupId", cjrGroupid);
|
||||
|
||||
bb.writeLog("data:"+datasJSON.toJSONString());
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("data",datasJSON.toJSONString());
|
||||
Map<String, Object> apidatas = getService(creatorUser).save(params, creatorUser);
|
||||
|
||||
bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas));
|
||||
|
||||
if(apidatas.containsKey("status")){
|
||||
String status = Util.null2String(apidatas.get("status"));
|
||||
if(!"1".equals(status)){
|
||||
String message = Util.null2String(apidatas.get("message"));
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("排班接口异常:"+message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("排班保存异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("获取流程数据异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("流程提交接口异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param billtable
|
||||
* @param mainid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleData(String billtable,String mainid,String pbyf){
|
||||
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)";
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> queryScheduleDataMap(String billtable,String mainid,String pbyf){
|
||||
Map<String,String> dataMap = new HashMap<String,String>();
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
BaseBean bb = new BaseBean();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and isdelete = 0 ";
|
||||
bb.writeLog("sql:"+sql);
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<scheduleList.size();i++){
|
||||
Map<String,String> scheduleMap = scheduleList.get(i);
|
||||
String kqdate = scheduleMap.get("kqdate");
|
||||
String resourceid = scheduleMap.get("resourceid");
|
||||
String serialid = scheduleMap.get("serialid");
|
||||
String groupid = scheduleMap.get("groupid");
|
||||
String id = scheduleMap.get("id");
|
||||
|
||||
bb.writeLog("kqdate:"+kqdate);
|
||||
bb.writeLog("resourceid:"+resourceid);
|
||||
bb.writeLog("serialid:"+serialid);
|
||||
bb.writeLog("groupid:"+groupid);
|
||||
bb.writeLog("id:"+id);
|
||||
|
||||
dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param billtable
|
||||
* @param cjrbm
|
||||
* @param pbyf
|
||||
* @param workflowid
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){
|
||||
|
||||
List<Map<String,String>> requestList = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " +
|
||||
" from "+billtable+" t " +
|
||||
" inner join workflow_requestbase r on r.requestid = t.requestid " +
|
||||
" where t.pbyf ='"+pbyf+"' " +
|
||||
" and t.cjrbm ='"+cjrbm+"' " +
|
||||
" and r.currentnodetype in(1,2,3) " +
|
||||
" and r.workflowid = "+workflowid +
|
||||
" and t.requestid <> "+requestid;
|
||||
requestList = CommonUtil.queryListBySql(sql);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return requestList;
|
||||
}
|
||||
|
||||
|
||||
private KQShiftScheduleService getService(User user) {
|
||||
return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> getUserKqGroupData(String userid){
|
||||
|
||||
List<Map<String,String>> userGroupList = new ArrayList<Map<String,String>>();
|
||||
|
||||
try{
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
String sql =" select distinct resourceid, groupid,status,validatefrom,validateto FROM ( \n" +
|
||||
" select a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" where a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') \n" +
|
||||
" union all \n" +
|
||||
" select a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" where a.subcompanyid1 = b.typevalue and b.type=2 and a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') \n" +
|
||||
" union all \n" +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" WHERE a.departmentid = b.typevalue AND b.type=3 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') \n" +
|
||||
" UNION ALL \n" +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" WHERE a.jobtitle = b.typevalue AND b.type=5 \n" +
|
||||
" AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))) \n" +
|
||||
" and (b.isdelete is null or b.isdelete <> '1') \n" +
|
||||
" UNION ALL \n" +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" +
|
||||
" WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') ) t\n" +
|
||||
" where resourceid="+userid ;
|
||||
userGroupList = queryListBySql(sql);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return userGroupList;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,331 @@
|
|||
package weaver.interfaces.zw.workflow.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.kq.biz.KQGroupBiz;
|
||||
import com.engine.kq.biz.KQGroupComInfo;
|
||||
import com.engine.kq.biz.KQGroupMemberComInfo;
|
||||
import com.engine.kq.service.KQShiftScheduleService;
|
||||
import com.engine.kq.service.impl.KQShiftScheduleServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.interfaces.zw.utils.CommonUtil;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author shil
|
||||
* @date 2024/8/1
|
||||
* 流程生成排班
|
||||
*/
|
||||
public class Httblc2SchedulingEditAction implements Action {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
BaseBean bb = new BaseBean();
|
||||
String requestid = requestInfo.getRequestid();
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String billtable = requestInfo.getRequestManager().getBillTableName();
|
||||
|
||||
int creator = requestInfo.getRequestManager().getCreater();
|
||||
bb.writeLog("creator:"+creator);
|
||||
User creatorUser = new User(creator);
|
||||
bb.writeLog("creatorUser:"+creatorUser.getLastname());
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
bb.writeLog("----Httblc2SchedulingEditAction------");
|
||||
try {
|
||||
String mainid = "" ;
|
||||
String cjr = "" ;
|
||||
String pbyf = "" ;
|
||||
String cjrbm = "" ;
|
||||
String pbmd = "";
|
||||
String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
mainid = Util.null2String(rs.getString("id"));
|
||||
cjr = Util.null2String(rs.getString("cjr"));
|
||||
pbyf = Util.null2String(rs.getString("pbyf"));
|
||||
cjrbm = Util.null2String(rs.getString("cjrbm"));
|
||||
pbmd = Util.null2String(rs.getString("pbmd"));
|
||||
}
|
||||
|
||||
|
||||
int daysInMonth = 0;
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
}
|
||||
bb.writeLog("----mainid------"+mainid);
|
||||
if(StringUtils.isNotBlank(mainid))
|
||||
{
|
||||
|
||||
|
||||
String cjrGroupid = getUserActiveGroupId(cjr);
|
||||
bb.writeLog("cjrGroupid:"+cjrGroupid);
|
||||
Map<String,String> scheduleMap = queryScheduleDataMap(billtable,mainid,pbyf,cjrGroupid);
|
||||
|
||||
JSONObject datasJSON = new JSONObject();
|
||||
JSONArray datasArray = new JSONArray();
|
||||
sql = " select * from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
JSONArray kqdata = new JSONArray();
|
||||
for(int k=1;k<=daysInMonth;k++){
|
||||
String serialid = Util.null2String(dt1Map.get("bc"+k));
|
||||
if(StringUtils.isNotBlank(serialid)){
|
||||
JSONObject bcJSON = new JSONObject();
|
||||
String id = "";
|
||||
String kqdate = "";
|
||||
if(k<10){
|
||||
kqdate = pbyf+"-0"+k;
|
||||
}else{
|
||||
kqdate = pbyf+"-"+k;
|
||||
}
|
||||
if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+cjrGroupid+"_"+kqdate)){
|
||||
id = scheduleMap.get(resourceid+"_"+serialid+"_"+cjrGroupid+"_"+kqdate);
|
||||
}
|
||||
|
||||
bb.writeLog(resourceid+":id:"+id);
|
||||
bcJSON.put("id",id);
|
||||
bcJSON.put("serialid",serialid);
|
||||
bcJSON.put("date",kqdate);
|
||||
kqdata.add(bcJSON);
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject dataJSON = new JSONObject();
|
||||
dataJSON.put("resourceid",resourceid);
|
||||
dataJSON.put("kqdata",kqdata);
|
||||
datasArray.add(dataJSON);
|
||||
}
|
||||
}
|
||||
|
||||
datasJSON.put("datas",datasArray);
|
||||
datasJSON.put("groupId", cjrGroupid);
|
||||
|
||||
bb.writeLog("data:"+datasJSON.toJSONString());
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("data",datasJSON.toJSONString());
|
||||
Map<String, Object> apidatas = getService(creatorUser).save(params, creatorUser);
|
||||
|
||||
bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas));
|
||||
|
||||
if(apidatas.containsKey("status")){
|
||||
String status = Util.null2String(apidatas.get("status"));
|
||||
if(!"1".equals(status)){
|
||||
String message = Util.null2String(apidatas.get("message"));
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("排班接口异常:"+message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("排班保存异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("获取流程数据异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}catch (Exception e){
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("流程提交接口异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param billtable
|
||||
* @param mainid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleData(String billtable,String mainid,String pbyf){
|
||||
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)";
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> queryScheduleDataMap(String billtable,String mainid,String pbyf,String activeGroupid){
|
||||
Map<String,String> dataMap = new HashMap<String,String>();
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
BaseBean bb = new BaseBean();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and isdelete =0 and groupid="+activeGroupid;
|
||||
bb.writeLog("sql:"+sql);
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<scheduleList.size();i++){
|
||||
Map<String,String> scheduleMap = scheduleList.get(i);
|
||||
String kqdate = scheduleMap.get("kqdate");
|
||||
String resourceid = scheduleMap.get("resourceid");
|
||||
String serialid = scheduleMap.get("serialid");
|
||||
String groupid = scheduleMap.get("groupid");
|
||||
String id = scheduleMap.get("id");
|
||||
|
||||
bb.writeLog("kqdate:"+kqdate);
|
||||
bb.writeLog("resourceid:"+resourceid);
|
||||
bb.writeLog("serialid:"+serialid);
|
||||
bb.writeLog("groupid:"+groupid);
|
||||
bb.writeLog("id:"+id);
|
||||
|
||||
dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param billtable
|
||||
* @param cjrbm
|
||||
* @param pbyf
|
||||
* @param workflowid
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){
|
||||
|
||||
List<Map<String,String>> requestList = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " +
|
||||
" from "+billtable+" t " +
|
||||
" inner join workflow_requestbase r on r.requestid = t.requestid " +
|
||||
" where t.pbyf ='"+pbyf+"' " +
|
||||
" and t.cjrbm ='"+cjrbm+"' " +
|
||||
" and r.currentnodetype in(1,2,3) " +
|
||||
" and r.workflowid = "+workflowid +
|
||||
" and t.requestid <> "+requestid;
|
||||
requestList = CommonUtil.queryListBySql(sql);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return requestList;
|
||||
}
|
||||
|
||||
|
||||
private KQShiftScheduleService getService(User user) {
|
||||
return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,351 @@
|
|||
package weaver.interfaces.zw.workflow.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.kq.biz.KQGroupBiz;
|
||||
import com.engine.kq.biz.KQGroupComInfo;
|
||||
import com.engine.kq.biz.KQGroupMemberComInfo;
|
||||
import com.engine.kq.service.KQShiftScheduleService;
|
||||
import com.engine.kq.service.impl.KQShiftScheduleServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.interfaces.zw.utils.CommonUtil;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author shil
|
||||
* @date 2024/8/1
|
||||
* 流程生成排班
|
||||
*/
|
||||
public class Mdpblc2SchedulingEditAction implements Action {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
BaseBean bb = new BaseBean();
|
||||
String requestid = requestInfo.getRequestid();
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String billtable = requestInfo.getRequestManager().getBillTableName();
|
||||
|
||||
int creator = requestInfo.getRequestManager().getCreater();
|
||||
bb.writeLog("creator:"+creator);
|
||||
User creatorUser = new User(creator);
|
||||
bb.writeLog("creatorUser:"+creatorUser.getLastname());
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
bb.writeLog("----Mdpblc2SchedulingEditAction------");
|
||||
DepartmentComInfo departmentComInfo = null;
|
||||
try {
|
||||
departmentComInfo = new DepartmentComInfo();
|
||||
String mainid = "" ;
|
||||
String cjr = "" ;
|
||||
String pbyf = "" ;
|
||||
String cjrbm = "" ;
|
||||
String pbmd = "";
|
||||
String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
mainid = Util.null2String(rs.getString("id"));
|
||||
cjr = Util.null2String(rs.getString("cjr"));
|
||||
pbyf = Util.null2String(rs.getString("pbyf"));
|
||||
cjrbm = Util.null2String(rs.getString("cjrbm"));
|
||||
pbmd = Util.null2String(rs.getString("pbmd"));
|
||||
}
|
||||
|
||||
List<Map<String,String>> requestList = queryRequestList(billtable,cjrbm,pbyf,workflowid,requestid);
|
||||
if(!requestList.isEmpty() && requestList.size() >0){
|
||||
String requestname = requestList.get(0).get("requestname");
|
||||
String lcid = requestList.get(0).get("requestid");
|
||||
String cjrbmmc = departmentComInfo.getDepartmentname(cjrbm);
|
||||
String currentnodetype = requestList.get(0).get("currentnodetype");
|
||||
String requesttypename = "";
|
||||
if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) {
|
||||
requesttypename = "正在审批";
|
||||
} else if ("3".equals(currentnodetype)) {
|
||||
requesttypename = "已归档";
|
||||
}
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(cjrbmmc+"已存在"+pbyf+"的排班申请"+requesttypename+"流程:<"+requestname+">,无法提交当前流程");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
|
||||
int daysInMonth = 0;
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
}
|
||||
bb.writeLog("----mainid------"+mainid);
|
||||
if(StringUtils.isNotBlank(mainid))
|
||||
{
|
||||
String cjrGroupid = getUserActiveGroupId(cjr);
|
||||
bb.writeLog("cjrGroupid:"+cjrGroupid);
|
||||
|
||||
Map<String,String> scheduleMap = queryScheduleDataMap(billtable,mainid,pbyf,cjrGroupid);
|
||||
|
||||
JSONObject datasJSON = new JSONObject();
|
||||
JSONArray datasArray = new JSONArray();
|
||||
sql = " select * from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
JSONArray kqdata = new JSONArray();
|
||||
for(int k=1;k<=daysInMonth;k++){
|
||||
String serialid = Util.null2String(dt1Map.get("bc"+k));
|
||||
|
||||
if(StringUtils.isNotBlank(serialid)){
|
||||
|
||||
JSONObject bcJSON = new JSONObject();
|
||||
String id = "";
|
||||
String kqdate = "";
|
||||
if(k<10){
|
||||
kqdate = pbyf+"-0"+k;
|
||||
}else{
|
||||
kqdate = pbyf+"-"+k;
|
||||
}
|
||||
if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+cjrGroupid+"_"+kqdate)){
|
||||
id = scheduleMap.get(resourceid+"_"+serialid+"_"+cjrGroupid+"_"+kqdate);
|
||||
}
|
||||
|
||||
bb.writeLog(resourceid+":id:"+id);
|
||||
bcJSON.put("id",id);
|
||||
bcJSON.put("serialid",serialid);
|
||||
bcJSON.put("date",kqdate);
|
||||
kqdata.add(bcJSON);
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject dataJSON = new JSONObject();
|
||||
dataJSON.put("resourceid",resourceid);
|
||||
dataJSON.put("kqdata",kqdata);
|
||||
datasArray.add(dataJSON);
|
||||
}
|
||||
}
|
||||
|
||||
datasJSON.put("datas",datasArray);
|
||||
datasJSON.put("groupId", cjrGroupid);
|
||||
|
||||
bb.writeLog("data:"+datasJSON.toJSONString());
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("data",datasJSON.toJSONString());
|
||||
Map<String, Object> apidatas = getService(creatorUser).save(params, creatorUser);
|
||||
|
||||
bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas));
|
||||
|
||||
if(apidatas.containsKey("status")){
|
||||
String status = Util.null2String(apidatas.get("status"));
|
||||
if(!"1".equals(status)){
|
||||
String message = Util.null2String(apidatas.get("message"));
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("排班接口异常:"+message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("排班保存异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("获取流程数据异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("流程提交接口异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param billtable
|
||||
* @param mainid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleData(String billtable,String mainid,String pbyf){
|
||||
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)";
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> queryScheduleDataMap(String billtable,String mainid,String pbyf,String activeGroupid){
|
||||
Map<String,String> dataMap = new HashMap<String,String>();
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
BaseBean bb = new BaseBean();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and isdelete = 0 and groupid ="+activeGroupid;
|
||||
bb.writeLog("sql:"+sql);
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<scheduleList.size();i++){
|
||||
Map<String,String> scheduleMap = scheduleList.get(i);
|
||||
String kqdate = scheduleMap.get("kqdate");
|
||||
String resourceid = scheduleMap.get("resourceid");
|
||||
String serialid = scheduleMap.get("serialid");
|
||||
String groupid = scheduleMap.get("groupid");
|
||||
String id = scheduleMap.get("id");
|
||||
|
||||
bb.writeLog("kqdate:"+kqdate);
|
||||
bb.writeLog("resourceid:"+resourceid);
|
||||
bb.writeLog("serialid:"+serialid);
|
||||
bb.writeLog("groupid:"+groupid);
|
||||
bb.writeLog("id:"+id);
|
||||
dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param billtable
|
||||
* @param cjrbm
|
||||
* @param pbyf
|
||||
* @param workflowid
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){
|
||||
|
||||
List<Map<String,String>> requestList = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " +
|
||||
" from "+billtable+" t " +
|
||||
" inner join workflow_requestbase r on r.requestid = t.requestid " +
|
||||
" where t.pbyf ='"+pbyf+"' " +
|
||||
" and t.cjrbm ='"+cjrbm+"' " +
|
||||
" and r.currentnodetype in(1,2,3) " +
|
||||
" and r.workflowid = "+workflowid +
|
||||
" and t.requestid <> "+requestid;
|
||||
requestList = CommonUtil.queryListBySql(sql);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return requestList;
|
||||
}
|
||||
|
||||
|
||||
private KQShiftScheduleService getService(User user) {
|
||||
return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,331 @@
|
|||
package weaver.interfaces.zw.workflow.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.kq.biz.KQGroupBiz;
|
||||
import com.engine.kq.biz.KQGroupComInfo;
|
||||
import com.engine.kq.biz.KQGroupMemberComInfo;
|
||||
import com.engine.kq.service.KQShiftScheduleService;
|
||||
import com.engine.kq.service.impl.KQShiftScheduleServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.interfaces.zw.utils.CommonUtil;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author shil
|
||||
* @date 2024/8/1
|
||||
* 流程生成排班
|
||||
*/
|
||||
public class Mdtblc2SchedulingEditAction implements Action {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
BaseBean bb = new BaseBean();
|
||||
String requestid = requestInfo.getRequestid();
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String billtable = requestInfo.getRequestManager().getBillTableName();
|
||||
|
||||
int creator = requestInfo.getRequestManager().getCreater();
|
||||
bb.writeLog("creator:"+creator);
|
||||
User creatorUser = new User(creator);
|
||||
bb.writeLog("creatorUser:"+creatorUser.getLastname());
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
bb.writeLog("----Mdtblc2SchedulingEditAction------");
|
||||
|
||||
try {
|
||||
|
||||
String mainid = "" ;
|
||||
String cjr = "" ;
|
||||
String pbyf = "" ;
|
||||
String cjrbm = "" ;
|
||||
String pbmd = "";
|
||||
String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
mainid = Util.null2String(rs.getString("id"));
|
||||
cjr = Util.null2String(rs.getString("cjr"));
|
||||
pbyf = Util.null2String(rs.getString("pbyf"));
|
||||
cjrbm = Util.null2String(rs.getString("cjrbm"));
|
||||
pbmd = Util.null2String(rs.getString("pbmd"));
|
||||
}
|
||||
|
||||
int daysInMonth = 0;
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
}
|
||||
bb.writeLog("----mainid------"+mainid);
|
||||
if(StringUtils.isNotBlank(mainid))
|
||||
{
|
||||
String cjrGroupid = getUserActiveGroupId(cjr);
|
||||
bb.writeLog("cjrGroupid:"+cjrGroupid);
|
||||
Map<String,String> scheduleMap = queryScheduleDataMap(billtable,mainid,pbyf,cjrGroupid);
|
||||
|
||||
JSONObject datasJSON = new JSONObject();
|
||||
JSONArray datasArray = new JSONArray();
|
||||
sql = " select * from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
JSONArray kqdata = new JSONArray();
|
||||
for(int k=1;k<=daysInMonth;k++){
|
||||
String serialid = Util.null2String(dt1Map.get("bc"+k));
|
||||
|
||||
if(StringUtils.isNotBlank(serialid)){
|
||||
JSONObject bcJSON = new JSONObject();
|
||||
String id = "";
|
||||
String kqdate = "";
|
||||
if(k<10){
|
||||
kqdate = pbyf+"-0"+k;
|
||||
}else{
|
||||
kqdate = pbyf+"-"+k;
|
||||
}
|
||||
if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+cjrGroupid+"_"+kqdate)){
|
||||
id = scheduleMap.get(resourceid+"_"+serialid+"_"+cjrGroupid+"_"+kqdate);
|
||||
}
|
||||
bb.writeLog(resourceid+":id:"+id);
|
||||
|
||||
bcJSON.put("id",id);
|
||||
bcJSON.put("serialid",serialid);
|
||||
bcJSON.put("date",kqdate);
|
||||
kqdata.add(bcJSON);
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject dataJSON = new JSONObject();
|
||||
dataJSON.put("resourceid",resourceid);
|
||||
dataJSON.put("kqdata",kqdata);
|
||||
datasArray.add(dataJSON);
|
||||
}
|
||||
}
|
||||
|
||||
datasJSON.put("datas",datasArray);
|
||||
datasJSON.put("groupId", cjrGroupid);
|
||||
|
||||
bb.writeLog("data:"+datasJSON.toJSONString());
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("data",datasJSON.toJSONString());
|
||||
Map<String, Object> apidatas = getService(creatorUser).save(params, creatorUser);
|
||||
|
||||
bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas));
|
||||
|
||||
if(apidatas.containsKey("status")){
|
||||
String status = Util.null2String(apidatas.get("status"));
|
||||
if(!"1".equals(status)){
|
||||
String message = Util.null2String(apidatas.get("message"));
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("排班接口异常:"+message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("排班保存异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("获取流程数据异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}catch (Exception e){
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("流程提交接口异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param billtable
|
||||
* @param mainid
|
||||
* @return
|
||||
*/
|
||||
// public List<Map<String,String>> queryScheduleData(String billtable,String mainid,String pbyf){
|
||||
//
|
||||
// List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
// try {
|
||||
// String userids = "" ;
|
||||
// String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
// List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
// for(int i=0;i<dt1List.size();i++)
|
||||
// {
|
||||
// Map<String,String> dt1Map = dt1List.get(i);
|
||||
// String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
// userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
// }
|
||||
// if(StringUtils.isNotBlank(userids)){
|
||||
// sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)";
|
||||
// scheduleList = CommonUtil.queryListBySql(sql);
|
||||
// }
|
||||
//
|
||||
// }catch (Exception e){
|
||||
//
|
||||
// }
|
||||
// return scheduleList;
|
||||
// }
|
||||
|
||||
|
||||
public Map<String,String> queryScheduleDataMap(String billtable,String mainid,String pbyf,String activeGroupId){
|
||||
Map<String,String> dataMap = new HashMap<String,String>();
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
BaseBean bb = new BaseBean();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and isdelete = 0 and groupid="+activeGroupId;
|
||||
bb.writeLog("sql:"+sql);
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<scheduleList.size();i++){
|
||||
Map<String,String> scheduleMap = scheduleList.get(i);
|
||||
String kqdate = scheduleMap.get("kqdate");
|
||||
String resourceid = scheduleMap.get("resourceid");
|
||||
String serialid = scheduleMap.get("serialid");
|
||||
String groupid = scheduleMap.get("groupid");
|
||||
String id = scheduleMap.get("id");
|
||||
|
||||
bb.writeLog("kqdate:"+kqdate);
|
||||
bb.writeLog("resourceid:"+resourceid);
|
||||
bb.writeLog("serialid:"+serialid);
|
||||
bb.writeLog("groupid:"+groupid);
|
||||
bb.writeLog("id:"+id);
|
||||
|
||||
dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param billtable
|
||||
* @param cjrbm
|
||||
* @param pbyf
|
||||
* @param workflowid
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){
|
||||
|
||||
List<Map<String,String>> requestList = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " +
|
||||
" from "+billtable+" t " +
|
||||
" inner join workflow_requestbase r on r.requestid = t.requestid " +
|
||||
" where t.pbyf ='"+pbyf+"' " +
|
||||
" and t.cjrbm ='"+cjrbm+"' " +
|
||||
" and r.currentnodetype in(1,2,3) " +
|
||||
" and r.workflowid = "+workflowid +
|
||||
" and t.requestid <> "+requestid;
|
||||
requestList = CommonUtil.queryListBySql(sql);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return requestList;
|
||||
}
|
||||
|
||||
|
||||
private KQShiftScheduleService getService(User user) {
|
||||
return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,261 @@
|
|||
package weaver.interfaces.zw.workflow.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.kq.biz.KQGroupBiz;
|
||||
import com.engine.kq.biz.KQGroupComInfo;
|
||||
import com.engine.kq.biz.KQGroupMemberComInfo;
|
||||
import com.engine.kq.service.KQShiftScheduleService;
|
||||
import com.engine.kq.service.impl.KQShiftScheduleServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.interfaces.zw.utils.CommonUtil;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author shil
|
||||
* @date 2024/8/1
|
||||
* 流程生成排班
|
||||
*/
|
||||
public class SchedulingDataCheckAction implements Action {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
BaseBean bb = new BaseBean();
|
||||
String requestid = requestInfo.getRequestid();
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String billtable = requestInfo.getRequestManager().getBillTableName();
|
||||
RecordSet rs = new RecordSet();
|
||||
bb.writeLog("----SchedulingDataCheckAction------");
|
||||
try {
|
||||
int uncount = 0;
|
||||
String datas = "";
|
||||
String sql = " select * from "+billtable+" where requestid="+requestid;
|
||||
bb.writeLog("SchedulingDataCheckAction-sql:"+sql);
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
String pbyf = rs.getString("pbyf");
|
||||
|
||||
for(int i=0;i<31;i++){
|
||||
String bc = "bcjg"+i;
|
||||
String day = "";
|
||||
if(i<10){
|
||||
day = "0"+i ;
|
||||
}else{
|
||||
day = ""+i ;
|
||||
}
|
||||
|
||||
String errDay = pbyf + "-"+ day;
|
||||
String bcjg = Util.null2String(rs.getString(bc));
|
||||
bb.writeLog("errDay:"+errDay+" bcjg:"+bcjg);
|
||||
if("1".equals(bcjg)){
|
||||
uncount++;
|
||||
datas+= StringUtils.isBlank(datas) ? errDay : ","+errDay ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(uncount > 0){
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(datas+"等排班数据不合理,无法提交");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}catch (Exception e){
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("流程提交接口异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param billtable
|
||||
* @param mainid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleData(String billtable,String mainid,String pbyf){
|
||||
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)";
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> queryScheduleDataMap(String billtable,String mainid,String pbyf){
|
||||
Map<String,String> dataMap = new HashMap<String,String>();
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
BaseBean bb = new BaseBean();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)";
|
||||
|
||||
|
||||
bb.writeLog("sql:"+sql);
|
||||
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<scheduleList.size();i++){
|
||||
Map<String,String> scheduleMap = scheduleList.get(i);
|
||||
String kqdate = scheduleMap.get("kqdate");
|
||||
String resourceid = scheduleMap.get("resourceid");
|
||||
String serialid = scheduleMap.get("serialid");
|
||||
String groupid = scheduleMap.get("groupid");
|
||||
String id = scheduleMap.get("id");
|
||||
|
||||
bb.writeLog("kqdate:"+kqdate);
|
||||
bb.writeLog("resourceid:"+resourceid);
|
||||
bb.writeLog("serialid:"+serialid);
|
||||
bb.writeLog("groupid:"+groupid);
|
||||
bb.writeLog("id:"+id);
|
||||
|
||||
dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param billtable
|
||||
* @param cjrbm
|
||||
* @param pbyf
|
||||
* @param workflowid
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){
|
||||
|
||||
List<Map<String,String>> requestList = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " +
|
||||
" from "+billtable+" t " +
|
||||
" inner join workflow_requestbase r on r.requestid = t.requestid " +
|
||||
" where t.pbyf ='"+pbyf+"' " +
|
||||
" and t.cjrbm ='"+cjrbm+"' " +
|
||||
" and r.currentnodetype in(1,2,3) " +
|
||||
" and r.workflowid = "+workflowid +
|
||||
" and t.requestid <> "+requestid;
|
||||
requestList = CommonUtil.queryListBySql(sql);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return requestList;
|
||||
}
|
||||
|
||||
|
||||
private KQShiftScheduleService getService(User user) {
|
||||
return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,317 @@
|
|||
package weaver.interfaces.zw.workflow.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.kq.biz.KQGroupBiz;
|
||||
import com.engine.kq.biz.KQGroupComInfo;
|
||||
import com.engine.kq.biz.KQGroupMemberComInfo;
|
||||
import com.engine.kq.service.KQShiftScheduleService;
|
||||
import com.engine.kq.service.impl.KQShiftScheduleServiceImpl;
|
||||
import com.weaver.general.BaseBean;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.interfaces.zw.utils.CommonUtil;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author shil
|
||||
* @date 2024/8/1
|
||||
* 流程生成排班
|
||||
*/
|
||||
public class WorkflowToSchedulingAction implements Action {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
BaseBean bb = new BaseBean();
|
||||
String requestid = requestInfo.getRequestid();
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String billtable = requestInfo.getRequestManager().getBillTableName();
|
||||
User user = requestInfo.getRequestManager().getUser();
|
||||
RecordSet rs = new RecordSet();
|
||||
bb.writeLog("----WorkflowToSchedulingAction------");
|
||||
DepartmentComInfo departmentComInfo = null;
|
||||
ResourceComInfo resourceComInfo = null;
|
||||
try {
|
||||
departmentComInfo = new DepartmentComInfo();
|
||||
resourceComInfo = new ResourceComInfo();
|
||||
String mainid = "" ;
|
||||
String cjr = "" ;
|
||||
String pbyf = "" ;
|
||||
String cjrbm = "" ;
|
||||
String pbmd = "";
|
||||
String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
mainid = Util.null2String(rs.getString("id"));
|
||||
cjr = Util.null2String(rs.getString("cjr"));
|
||||
pbyf = Util.null2String(rs.getString("pbyf"));
|
||||
cjrbm = Util.null2String(rs.getString("cjrbm"));
|
||||
pbmd = Util.null2String(rs.getString("pbmd"));
|
||||
}
|
||||
|
||||
List<Map<String,String>> requestList = queryRequestList(billtable,cjrbm,pbyf,workflowid,requestid);
|
||||
if(!requestList.isEmpty() && requestList.size() >0){
|
||||
String requestname = requestList.get(0).get("requestname");
|
||||
String lcid = requestList.get(0).get("requestid");
|
||||
String cjrbmmc = departmentComInfo.getDepartmentname(cjrbm);
|
||||
String currentnodetype = requestList.get(0).get("currentnodetype");
|
||||
String requesttypename = "";
|
||||
if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) {
|
||||
requesttypename = "正在审批";
|
||||
} else if ("3".equals(currentnodetype)) {
|
||||
requesttypename = "已归档";
|
||||
}
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(cjrbmmc+"已存在"+pbyf+"的排班申请"+requesttypename+"流程:<"+requestname+">,无法提交当前流程");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
List<Map<String,String>> scheduleList = queryScheduleData(billtable,mainid,pbyf);
|
||||
if(!scheduleList.isEmpty() && scheduleList.size()>0){
|
||||
String lastnames = "";
|
||||
for(int i=0;i<scheduleList.size();i++){
|
||||
Map<String, String> scheduleMap = scheduleList.get(i);
|
||||
String resourceid = scheduleMap.get("resourceid");
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
if(i==0){
|
||||
String lastname = resourceComInfo.getLastname(resourceid);
|
||||
lastnames += StringUtils.isBlank(lastnames) ? lastname : ","+lastname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(lastnames+"等人已存在"+pbyf+"的排班,无法提交排班流程");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
int daysInMonth = 0;
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
}
|
||||
bb.writeLog("----mainid------"+mainid);
|
||||
if(StringUtils.isNotBlank(mainid))
|
||||
{
|
||||
if(StringUtils.isNotBlank(pbmd)){
|
||||
if(pbmd.contains(",")){
|
||||
pbmd = pbmd.split(",")[0];
|
||||
}
|
||||
}else{
|
||||
pbmd = cjr;
|
||||
}
|
||||
String groupid = getUserActiveGroupId(pbmd);
|
||||
bb.writeLog("groupid:"+groupid);
|
||||
|
||||
JSONObject datasJSON = new JSONObject();
|
||||
JSONArray datasArray = new JSONArray();
|
||||
sql = " select * from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
JSONArray kqdata = new JSONArray();
|
||||
for(int k=1;k<=daysInMonth;k++){
|
||||
String bc = Util.null2String(dt1Map.get("bc"+k));
|
||||
JSONObject bcJSON = new JSONObject();
|
||||
bcJSON.put("id","");
|
||||
bcJSON.put("serialid",bc);
|
||||
if(k<10){
|
||||
bcJSON.put("date",pbyf+"-0"+k);
|
||||
}else{
|
||||
bcJSON.put("date",pbyf+"-"+k);
|
||||
}
|
||||
kqdata.add(bcJSON);
|
||||
}
|
||||
|
||||
JSONObject dataJSON = new JSONObject();
|
||||
dataJSON.put("resourceid",resourceid);
|
||||
dataJSON.put("kqdata",kqdata);
|
||||
datasArray.add(dataJSON);
|
||||
}
|
||||
}
|
||||
|
||||
datasJSON.put("datas",datasArray);
|
||||
datasJSON.put("groupId", groupid);
|
||||
|
||||
bb.writeLog("data:"+datasJSON.toJSONString());
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("data",datasJSON.toJSONString());
|
||||
Map<String, Object> apidatas = getService(user).save(params, user);
|
||||
|
||||
bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas));
|
||||
|
||||
if(apidatas.containsKey("status")){
|
||||
String status = Util.null2String(apidatas.get("status"));
|
||||
if(!"1".equals(status)){
|
||||
String message = Util.null2String(apidatas.get("message"));
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("排班保存异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("获取流程数据异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("流程提交接口异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param billtable
|
||||
* @param mainid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleData(String billtable,String mainid,String pbyf){
|
||||
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)";
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param billtable
|
||||
* @param cjrbm
|
||||
* @param pbyf
|
||||
* @param workflowid
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){
|
||||
|
||||
List<Map<String,String>> requestList = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " +
|
||||
" from "+billtable+" t " +
|
||||
" inner join workflow_requestbase r on r.requestid = t.requestid " +
|
||||
" where t.pbyf ='"+pbyf+"' " +
|
||||
" and t.cjrbm ='"+cjrbm+"' " +
|
||||
" and r.currentnodetype in(1,2,3) " +
|
||||
" and r.workflowid = "+workflowid +
|
||||
" and t.requestid <> "+requestid;
|
||||
requestList = CommonUtil.queryListBySql(sql);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return requestList;
|
||||
}
|
||||
|
||||
|
||||
private KQShiftScheduleService getService(User user) {
|
||||
return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
318
浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingAddAction.java
Executable file
318
浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingAddAction.java
Executable file
|
|
@ -0,0 +1,318 @@
|
|||
package weaver.interfaces.zw.workflow.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.kq.biz.KQGroupBiz;
|
||||
import com.engine.kq.biz.KQGroupComInfo;
|
||||
import com.engine.kq.biz.KQGroupMemberComInfo;
|
||||
import com.engine.kq.service.KQShiftScheduleService;
|
||||
import com.engine.kq.service.impl.KQShiftScheduleServiceImpl;
|
||||
import com.weaver.general.BaseBean;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.interfaces.zw.utils.CommonUtil;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author shil
|
||||
* @date 2024/8/1
|
||||
* 流程生成排班
|
||||
*/
|
||||
public class WorkflowToSchedulingAddAction implements Action {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
BaseBean bb = new BaseBean();
|
||||
String requestid = requestInfo.getRequestid();
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String billtable = requestInfo.getRequestManager().getBillTableName();
|
||||
User user = requestInfo.getRequestManager().getUser();
|
||||
RecordSet rs = new RecordSet();
|
||||
bb.writeLog("----WorkflowToSchedulingAddAction------");
|
||||
DepartmentComInfo departmentComInfo = null;
|
||||
ResourceComInfo resourceComInfo = null;
|
||||
try {
|
||||
departmentComInfo = new DepartmentComInfo();
|
||||
resourceComInfo = new ResourceComInfo();
|
||||
String mainid = "" ;
|
||||
String cjr = "" ;
|
||||
String pbyf = "" ;
|
||||
String cjrbm = "" ;
|
||||
String pbmd = "";
|
||||
String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
mainid = Util.null2String(rs.getString("id"));
|
||||
cjr = Util.null2String(rs.getString("cjr"));
|
||||
pbyf = Util.null2String(rs.getString("pbyf"));
|
||||
cjrbm = Util.null2String(rs.getString("cjrbm"));
|
||||
pbmd = Util.null2String(rs.getString("pbmd"));
|
||||
}
|
||||
|
||||
List<Map<String,String>> requestList = queryRequestList(billtable,cjrbm,pbyf,workflowid,requestid);
|
||||
if(!requestList.isEmpty() && requestList.size() >0){
|
||||
String requestname = requestList.get(0).get("requestname");
|
||||
String lcid = requestList.get(0).get("requestid");
|
||||
String cjrbmmc = departmentComInfo.getDepartmentname(cjrbm);
|
||||
String currentnodetype = requestList.get(0).get("currentnodetype");
|
||||
String requesttypename = "";
|
||||
if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) {
|
||||
requesttypename = "正在审批";
|
||||
} else if ("3".equals(currentnodetype)) {
|
||||
requesttypename = "已归档";
|
||||
}
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(cjrbmmc+"已存在"+pbyf+"的排班申请"+requesttypename+"流程:<"+requestname+">,无法提交当前流程");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
List<Map<String,String>> scheduleList = queryScheduleData(billtable,mainid,pbyf);
|
||||
if(!scheduleList.isEmpty() && scheduleList.size()>0){
|
||||
String lastnames = "";
|
||||
for(int i=0;i<scheduleList.size();i++){
|
||||
Map<String, String> scheduleMap = scheduleList.get(i);
|
||||
if(i<2){
|
||||
String resourceid = scheduleMap.get("resourceid");
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
String lastname = resourceComInfo.getLastname(resourceid);
|
||||
lastnames += StringUtils.isBlank(lastnames) ? lastname : ","+lastname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(lastnames+"等人已存在"+pbyf+"的排班,无法提交排班流程");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
int daysInMonth = 0;
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
}
|
||||
bb.writeLog("----mainid------"+mainid);
|
||||
if(StringUtils.isNotBlank(mainid))
|
||||
{
|
||||
if(StringUtils.isNotBlank(pbmd)){
|
||||
if(pbmd.contains(",")){
|
||||
pbmd = pbmd.split(",")[0];
|
||||
}
|
||||
}else{
|
||||
pbmd = cjr;
|
||||
}
|
||||
String groupid = getUserActiveGroupId(pbmd);
|
||||
bb.writeLog("groupid:"+groupid);
|
||||
|
||||
JSONObject datasJSON = new JSONObject();
|
||||
JSONArray datasArray = new JSONArray();
|
||||
sql = " select * from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
JSONArray kqdata = new JSONArray();
|
||||
for(int k=1;k<=daysInMonth;k++){
|
||||
String bc = Util.null2String(dt1Map.get("bc"+k));
|
||||
JSONObject bcJSON = new JSONObject();
|
||||
bcJSON.put("id","");
|
||||
bcJSON.put("serialid",bc);
|
||||
if(k<10){
|
||||
bcJSON.put("date",pbyf+"-0"+k);
|
||||
}else{
|
||||
bcJSON.put("date",pbyf+"-"+k);
|
||||
}
|
||||
kqdata.add(bcJSON);
|
||||
}
|
||||
|
||||
JSONObject dataJSON = new JSONObject();
|
||||
dataJSON.put("resourceid",resourceid);
|
||||
dataJSON.put("kqdata",kqdata);
|
||||
datasArray.add(dataJSON);
|
||||
}
|
||||
}
|
||||
|
||||
datasJSON.put("datas",datasArray);
|
||||
datasJSON.put("groupId", groupid);
|
||||
|
||||
bb.writeLog("data:"+datasJSON.toJSONString());
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("data",datasJSON.toJSONString());
|
||||
Map<String, Object> apidatas = getService(user).save(params, user);
|
||||
|
||||
bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas));
|
||||
|
||||
if(apidatas.containsKey("status")){
|
||||
String status = Util.null2String(apidatas.get("status"));
|
||||
if(!"1".equals(status)){
|
||||
String message = Util.null2String(apidatas.get("message"));
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("排班保存异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("获取流程数据异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("流程提交接口异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param billtable
|
||||
* @param mainid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleData(String billtable,String mainid,String pbyf){
|
||||
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)";
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param billtable
|
||||
* @param cjrbm
|
||||
* @param pbyf
|
||||
* @param workflowid
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){
|
||||
|
||||
List<Map<String,String>> requestList = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " +
|
||||
" from "+billtable+" t " +
|
||||
" inner join workflow_requestbase r on r.requestid = t.requestid " +
|
||||
" where t.pbyf ='"+pbyf+"' " +
|
||||
" and t.cjrbm ='"+cjrbm+"' " +
|
||||
" and r.currentnodetype in(1,2,3) " +
|
||||
" and r.workflowid = "+workflowid +
|
||||
" and t.requestid <> "+requestid;
|
||||
requestList = CommonUtil.queryListBySql(sql);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return requestList;
|
||||
}
|
||||
|
||||
|
||||
private KQShiftScheduleService getService(User user) {
|
||||
return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,334 @@
|
|||
package weaver.interfaces.zw.workflow.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.kq.biz.KQGroupBiz;
|
||||
import com.engine.kq.biz.KQGroupComInfo;
|
||||
import com.engine.kq.biz.KQGroupMemberComInfo;
|
||||
import com.engine.kq.service.KQShiftScheduleService;
|
||||
import com.engine.kq.service.impl.KQShiftScheduleServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.interfaces.zw.utils.CommonUtil;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author shil
|
||||
* @date 2024/8/1
|
||||
* 流程生成排班
|
||||
*/
|
||||
public class WorkflowToSchedulingEditAction implements Action {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
BaseBean bb = new BaseBean();
|
||||
String requestid = requestInfo.getRequestid();
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String billtable = requestInfo.getRequestManager().getBillTableName();
|
||||
User user = requestInfo.getRequestManager().getUser();
|
||||
RecordSet rs = new RecordSet();
|
||||
bb.writeLog("----WorkflowToSchedulingEditAction------");
|
||||
DepartmentComInfo departmentComInfo = null;
|
||||
ResourceComInfo resourceComInfo = null;
|
||||
try {
|
||||
departmentComInfo = new DepartmentComInfo();
|
||||
resourceComInfo = new ResourceComInfo();
|
||||
String mainid = "" ;
|
||||
String cjr = "" ;
|
||||
String pbyf = "" ;
|
||||
String cjrbm = "" ;
|
||||
String pbmd = "";
|
||||
String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
mainid = Util.null2String(rs.getString("id"));
|
||||
cjr = Util.null2String(rs.getString("cjr"));
|
||||
pbyf = Util.null2String(rs.getString("pbyf"));
|
||||
cjrbm = Util.null2String(rs.getString("cjrbm"));
|
||||
pbmd = Util.null2String(rs.getString("pbmd"));
|
||||
}
|
||||
|
||||
|
||||
int daysInMonth = 0;
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
}
|
||||
bb.writeLog("----mainid------"+mainid);
|
||||
if(StringUtils.isNotBlank(mainid))
|
||||
{
|
||||
if(StringUtils.isNotBlank(pbmd)){
|
||||
if(pbmd.contains(",")){
|
||||
pbmd = pbmd.split(",")[0];
|
||||
}
|
||||
}else{
|
||||
pbmd = cjr;
|
||||
}
|
||||
bb.writeLog("pbmd:"+pbmd);
|
||||
String groupid = getUserActiveGroupId(pbmd);
|
||||
bb.writeLog("groupid:"+groupid);
|
||||
Map<String,String> scheduleMap = queryScheduleDataMap(billtable,mainid,pbyf,groupid);
|
||||
JSONObject datasJSON = new JSONObject();
|
||||
JSONArray datasArray = new JSONArray();
|
||||
sql = " select * from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
JSONArray kqdata = new JSONArray();
|
||||
for(int k=1;k<=daysInMonth;k++){
|
||||
String serialid = Util.null2String(dt1Map.get("bc"+k));
|
||||
JSONObject bcJSON = new JSONObject();
|
||||
|
||||
String id = "";
|
||||
String kqdate = "";
|
||||
if(k<10){
|
||||
kqdate = pbyf+"-0"+k;
|
||||
}else{
|
||||
kqdate = pbyf+"-"+k;
|
||||
}
|
||||
if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate)){
|
||||
id = scheduleMap.get(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate);
|
||||
}
|
||||
bb.writeLog("id:"+id);
|
||||
bcJSON.put("id",id);
|
||||
bcJSON.put("serialid",serialid);
|
||||
bcJSON.put("date",kqdate);
|
||||
kqdata.add(bcJSON);
|
||||
}
|
||||
|
||||
JSONObject dataJSON = new JSONObject();
|
||||
dataJSON.put("resourceid",resourceid);
|
||||
dataJSON.put("kqdata",kqdata);
|
||||
datasArray.add(dataJSON);
|
||||
}
|
||||
}
|
||||
|
||||
datasJSON.put("datas",datasArray);
|
||||
datasJSON.put("groupId", groupid);
|
||||
|
||||
bb.writeLog("data:"+datasJSON.toJSONString());
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("data",datasJSON.toJSONString());
|
||||
Map<String, Object> apidatas = getService(user).save(params, user);
|
||||
|
||||
bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas));
|
||||
|
||||
if(apidatas.containsKey("status")){
|
||||
String status = Util.null2String(apidatas.get("status"));
|
||||
if(!"1".equals(status)){
|
||||
String message = Util.null2String(apidatas.get("message"));
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("排班保存异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("获取流程数据异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}catch (Exception e){
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("流程提交接口异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param billtable
|
||||
* @param mainid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleData(String billtable,String mainid,String pbyf){
|
||||
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)";
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> queryScheduleDataMap(String billtable,String mainid,String pbyf,String activeGroupid){
|
||||
Map<String,String> dataMap = new HashMap<String,String>();
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
BaseBean bb = new BaseBean();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and isdelete = 0 and groupid = "+activeGroupid;
|
||||
bb.writeLog("sql:"+sql);
|
||||
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<scheduleList.size();i++){
|
||||
Map<String,String> scheduleMap = scheduleList.get(i);
|
||||
String kqdate = scheduleMap.get("kqdate");
|
||||
String resourceid = scheduleMap.get("resourceid");
|
||||
String serialid = scheduleMap.get("serialid");
|
||||
String groupid = scheduleMap.get("groupid");
|
||||
String id = scheduleMap.get("id");
|
||||
|
||||
bb.writeLog("kqdate:"+kqdate);
|
||||
bb.writeLog("resourceid:"+resourceid);
|
||||
bb.writeLog("serialid:"+serialid);
|
||||
bb.writeLog("groupid:"+groupid);
|
||||
bb.writeLog("id:"+id);
|
||||
|
||||
dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param billtable
|
||||
* @param cjrbm
|
||||
* @param pbyf
|
||||
* @param workflowid
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){
|
||||
|
||||
List<Map<String,String>> requestList = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " +
|
||||
" from "+billtable+" t " +
|
||||
" inner join workflow_requestbase r on r.requestid = t.requestid " +
|
||||
" where t.pbyf ='"+pbyf+"' " +
|
||||
" and t.cjrbm ='"+cjrbm+"' " +
|
||||
" and r.currentnodetype in(1,2,3) " +
|
||||
" and r.workflowid = "+workflowid +
|
||||
" and t.requestid <> "+requestid;
|
||||
requestList = CommonUtil.queryListBySql(sql);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return requestList;
|
||||
}
|
||||
|
||||
|
||||
private KQShiftScheduleService getService(User user) {
|
||||
return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,350 @@
|
|||
package weaver.interfaces.zw.workflow.action;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.kq.biz.KQGroupBiz;
|
||||
import com.engine.kq.biz.KQGroupComInfo;
|
||||
import com.engine.kq.biz.KQGroupMemberComInfo;
|
||||
import com.engine.kq.service.KQShiftScheduleService;
|
||||
import com.engine.kq.service.impl.KQShiftScheduleServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.interfaces.zw.utils.CommonUtil;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author shil
|
||||
* @date 2024/8/1
|
||||
* 流程生成排班
|
||||
*/
|
||||
public class WorkflowToSchedulingUpdateAction implements Action {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
BaseBean bb = new BaseBean();
|
||||
String requestid = requestInfo.getRequestid();
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String billtable = requestInfo.getRequestManager().getBillTableName();
|
||||
User user = requestInfo.getRequestManager().getUser();
|
||||
RecordSet rs = new RecordSet();
|
||||
bb.writeLog("----WorkflowToSchedulingUpdateAction------");
|
||||
DepartmentComInfo departmentComInfo = null;
|
||||
ResourceComInfo resourceComInfo = null;
|
||||
try {
|
||||
departmentComInfo = new DepartmentComInfo();
|
||||
resourceComInfo = new ResourceComInfo();
|
||||
String mainid = "" ;
|
||||
String cjr = "" ;
|
||||
String pbyf = "" ;
|
||||
String cjrbm = "" ;
|
||||
String pbmd = "";
|
||||
String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
mainid = Util.null2String(rs.getString("id"));
|
||||
cjr = Util.null2String(rs.getString("cjr"));
|
||||
pbyf = Util.null2String(rs.getString("pbyf"));
|
||||
cjrbm = Util.null2String(rs.getString("cjrbm"));
|
||||
pbmd = Util.null2String(rs.getString("pbmd"));
|
||||
}
|
||||
|
||||
List<Map<String,String>> requestList = queryRequestList(billtable,cjrbm,pbyf,workflowid,requestid);
|
||||
if(!requestList.isEmpty() && requestList.size() >0){
|
||||
String requestname = requestList.get(0).get("requestname");
|
||||
String lcid = requestList.get(0).get("requestid");
|
||||
String cjrbmmc = departmentComInfo.getDepartmentname(cjrbm);
|
||||
String currentnodetype = requestList.get(0).get("currentnodetype");
|
||||
String requesttypename = "";
|
||||
if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) {
|
||||
requesttypename = "正在审批";
|
||||
} else if ("3".equals(currentnodetype)) {
|
||||
requesttypename = "已归档";
|
||||
}
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(cjrbmmc+"已存在"+pbyf+"的排班申请"+requesttypename+"流程:<"+requestname+">,无法提交当前流程");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
|
||||
Map<String,String> scheduleMap = queryScheduleDataMap(billtable,mainid,pbyf);
|
||||
int daysInMonth = 0;
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
}
|
||||
bb.writeLog("----mainid------"+mainid);
|
||||
if(StringUtils.isNotBlank(mainid))
|
||||
{
|
||||
if(StringUtils.isNotBlank(pbmd)){
|
||||
if(pbmd.contains(",")){
|
||||
pbmd = pbmd.split(",")[0];
|
||||
}
|
||||
}else{
|
||||
pbmd = cjr;
|
||||
}
|
||||
String groupid = getUserActiveGroupId(pbmd);
|
||||
bb.writeLog("groupid:"+groupid);
|
||||
|
||||
JSONObject datasJSON = new JSONObject();
|
||||
JSONArray datasArray = new JSONArray();
|
||||
sql = " select * from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
JSONArray kqdata = new JSONArray();
|
||||
for(int k=1;k<=daysInMonth;k++){
|
||||
String serialid = Util.null2String(dt1Map.get("bc"+k));
|
||||
JSONObject bcJSON = new JSONObject();
|
||||
|
||||
String id = "";
|
||||
String kqdate = "";
|
||||
if(k<10){
|
||||
kqdate = pbyf+"-0"+k;
|
||||
}else{
|
||||
kqdate = pbyf+"-"+k;
|
||||
}
|
||||
if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate)){
|
||||
id = scheduleMap.get(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate);
|
||||
}
|
||||
bcJSON.put("id",id);
|
||||
bcJSON.put("serialid",serialid);
|
||||
bcJSON.put("date",kqdate);
|
||||
kqdata.add(bcJSON);
|
||||
}
|
||||
|
||||
JSONObject dataJSON = new JSONObject();
|
||||
dataJSON.put("resourceid",resourceid);
|
||||
dataJSON.put("kqdata",kqdata);
|
||||
datasArray.add(dataJSON);
|
||||
}
|
||||
}
|
||||
|
||||
datasJSON.put("datas",datasArray);
|
||||
datasJSON.put("groupId", groupid);
|
||||
|
||||
bb.writeLog("data:"+datasJSON.toJSONString());
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("data",datasJSON.toJSONString());
|
||||
Map<String, Object> apidatas = getService(user).save(params, user);
|
||||
|
||||
bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas));
|
||||
|
||||
if(apidatas.containsKey("status")){
|
||||
String status = Util.null2String(apidatas.get("status"));
|
||||
if(!"1".equals(status)){
|
||||
String message = Util.null2String(apidatas.get("message"));
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("排班保存异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("获取流程数据异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("流程提交接口异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param billtable
|
||||
* @param mainid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleData(String billtable,String mainid,String pbyf){
|
||||
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)";
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> queryScheduleDataMap(String billtable,String mainid,String pbyf){
|
||||
Map<String,String> dataMap = new HashMap<String,String>();
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
BaseBean bb = new BaseBean();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)";
|
||||
|
||||
|
||||
bb.writeLog("sql:"+sql);
|
||||
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<scheduleList.size();i++){
|
||||
Map<String,String> scheduleMap = scheduleList.get(i);
|
||||
String kqdate = scheduleMap.get("kqdate");
|
||||
String resourceid = scheduleMap.get("resourceid");
|
||||
String serialid = scheduleMap.get("serialid");
|
||||
String groupid = scheduleMap.get("groupid");
|
||||
String id = scheduleMap.get("id");
|
||||
|
||||
bb.writeLog("kqdate:"+kqdate);
|
||||
bb.writeLog("resourceid:"+resourceid);
|
||||
bb.writeLog("serialid:"+serialid);
|
||||
bb.writeLog("groupid:"+groupid);
|
||||
bb.writeLog("id:"+id);
|
||||
|
||||
dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param billtable
|
||||
* @param cjrbm
|
||||
* @param pbyf
|
||||
* @param workflowid
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){
|
||||
|
||||
List<Map<String,String>> requestList = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " +
|
||||
" from "+billtable+" t " +
|
||||
" inner join workflow_requestbase r on r.requestid = t.requestid " +
|
||||
" where t.pbyf ='"+pbyf+"' " +
|
||||
" and t.cjrbm ='"+cjrbm+"' " +
|
||||
" and r.currentnodetype in(1,2,3) " +
|
||||
" and r.workflowid = "+workflowid +
|
||||
" and t.requestid <> "+requestid;
|
||||
requestList = CommonUtil.queryListBySql(sql);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return requestList;
|
||||
}
|
||||
|
||||
|
||||
private KQShiftScheduleService getService(User user) {
|
||||
return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,350 @@
|
|||
package weaver.interfaces.zw.workflow.xygrzlc;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.kq.biz.KQGroupBiz;
|
||||
import com.engine.kq.biz.KQGroupComInfo;
|
||||
import com.engine.kq.biz.KQGroupMemberComInfo;
|
||||
import com.engine.kq.service.KQShiftScheduleService;
|
||||
import com.engine.kq.service.impl.KQShiftScheduleServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.interfaces.zw.utils.CommonUtil;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author shil
|
||||
* @date 2024/8/1
|
||||
* 流程生成排班
|
||||
*/
|
||||
public class NewEmployee2HrmResoyeceAction implements Action {
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
BaseBean bb = new BaseBean();
|
||||
String requestid = requestInfo.getRequestid();
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String billtable = requestInfo.getRequestManager().getBillTableName();
|
||||
User user = requestInfo.getRequestManager().getUser();
|
||||
RecordSet rs = new RecordSet();
|
||||
bb.writeLog("----WorkflowToSchedulingAction------");
|
||||
DepartmentComInfo departmentComInfo = null;
|
||||
ResourceComInfo resourceComInfo = null;
|
||||
try {
|
||||
departmentComInfo = new DepartmentComInfo();
|
||||
resourceComInfo = new ResourceComInfo();
|
||||
String mainid = "" ;
|
||||
String cjr = "" ;
|
||||
String pbyf = "" ;
|
||||
String cjrbm = "" ;
|
||||
String pbmd = "";
|
||||
String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid;
|
||||
rs.execute(sql);
|
||||
if(rs.next()){
|
||||
mainid = Util.null2String(rs.getString("id"));
|
||||
cjr = Util.null2String(rs.getString("cjr"));
|
||||
pbyf = Util.null2String(rs.getString("pbyf"));
|
||||
cjrbm = Util.null2String(rs.getString("cjrbm"));
|
||||
pbmd = Util.null2String(rs.getString("pbmd"));
|
||||
}
|
||||
|
||||
List<Map<String,String>> requestList = queryRequestList(billtable,cjrbm,pbyf,workflowid,requestid);
|
||||
if(!requestList.isEmpty() && requestList.size() >0){
|
||||
String requestname = requestList.get(0).get("requestname");
|
||||
String lcid = requestList.get(0).get("requestid");
|
||||
String cjrbmmc = departmentComInfo.getDepartmentname(cjrbm);
|
||||
String currentnodetype = requestList.get(0).get("currentnodetype");
|
||||
String requesttypename = "";
|
||||
if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) {
|
||||
requesttypename = "正在审批";
|
||||
} else if ("3".equals(currentnodetype)) {
|
||||
requesttypename = "已归档";
|
||||
}
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(cjrbmmc+"已存在"+pbyf+"的排班申请"+requesttypename+"流程:<"+requestname+">,无法提交当前流程");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}else{
|
||||
|
||||
Map<String,String> scheduleMap = queryScheduleDataMap(billtable,mainid,pbyf);
|
||||
int daysInMonth = 0;
|
||||
if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){
|
||||
LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期
|
||||
daysInMonth = date.lengthOfMonth(); // 获取本月有多少天
|
||||
}
|
||||
bb.writeLog("----mainid------"+mainid);
|
||||
if(StringUtils.isNotBlank(mainid))
|
||||
{
|
||||
if(StringUtils.isNotBlank(pbmd)){
|
||||
if(pbmd.contains(",")){
|
||||
pbmd = pbmd.split(",")[0];
|
||||
}
|
||||
}else{
|
||||
pbmd = cjr;
|
||||
}
|
||||
String groupid = getUserActiveGroupId(pbmd);
|
||||
bb.writeLog("groupid:"+groupid);
|
||||
|
||||
JSONObject datasJSON = new JSONObject();
|
||||
JSONArray datasArray = new JSONArray();
|
||||
sql = " select * from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
if(StringUtils.isNotBlank(resourceid)){
|
||||
JSONArray kqdata = new JSONArray();
|
||||
for(int k=1;k<=daysInMonth;k++){
|
||||
String serialid = Util.null2String(dt1Map.get("bc"+k));
|
||||
JSONObject bcJSON = new JSONObject();
|
||||
|
||||
String id = "";
|
||||
String kqdate = "";
|
||||
if(k<10){
|
||||
kqdate = pbyf+"-0"+k;
|
||||
}else{
|
||||
kqdate = pbyf+"-"+k;
|
||||
}
|
||||
if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate)){
|
||||
id = scheduleMap.get(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate);
|
||||
}
|
||||
bcJSON.put("id",id);
|
||||
bcJSON.put("serialid",serialid);
|
||||
bcJSON.put("date",kqdate);
|
||||
kqdata.add(bcJSON);
|
||||
}
|
||||
|
||||
JSONObject dataJSON = new JSONObject();
|
||||
dataJSON.put("resourceid",resourceid);
|
||||
dataJSON.put("kqdata",kqdata);
|
||||
datasArray.add(dataJSON);
|
||||
}
|
||||
}
|
||||
|
||||
datasJSON.put("datas",datasArray);
|
||||
datasJSON.put("groupId", groupid);
|
||||
|
||||
bb.writeLog("data:"+datasJSON.toJSONString());
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("data",datasJSON.toJSONString());
|
||||
Map<String, Object> apidatas = getService(user).save(params, user);
|
||||
|
||||
bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas));
|
||||
|
||||
if(apidatas.containsKey("status")){
|
||||
String status = Util.null2String(apidatas.get("status"));
|
||||
if(!"1".equals(status)){
|
||||
String message = Util.null2String(apidatas.get("message"));
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent(message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("排班保存异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("获取流程数据异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
requestInfo.getRequestManager().setMessageid("1000");
|
||||
requestInfo.getRequestManager().setMessagecontent("流程提交接口异常");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param billtable
|
||||
* @param mainid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryScheduleData(String billtable,String mainid,String pbyf){
|
||||
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)";
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return scheduleList;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> queryScheduleDataMap(String billtable,String mainid,String pbyf){
|
||||
Map<String,String> dataMap = new HashMap<String,String>();
|
||||
List<Map<String,String>> scheduleList = new ArrayList<Map<String,String>>();
|
||||
BaseBean bb = new BaseBean();
|
||||
try {
|
||||
String userids = "" ;
|
||||
String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid;
|
||||
List<Map<String,String>> dt1List = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<dt1List.size();i++)
|
||||
{
|
||||
Map<String,String> dt1Map = dt1List.get(i);
|
||||
String resourceid = Util.null2String(dt1Map.get("yg"));
|
||||
userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ;
|
||||
}
|
||||
if(StringUtils.isNotBlank(userids)){
|
||||
sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)";
|
||||
|
||||
|
||||
bb.writeLog("sql:"+sql);
|
||||
|
||||
scheduleList = CommonUtil.queryListBySql(sql);
|
||||
for(int i=0;i<scheduleList.size();i++){
|
||||
Map<String,String> scheduleMap = scheduleList.get(i);
|
||||
String kqdate = scheduleMap.get("kqdate");
|
||||
String resourceid = scheduleMap.get("resourceid");
|
||||
String serialid = scheduleMap.get("serialid");
|
||||
String groupid = scheduleMap.get("groupid");
|
||||
String id = scheduleMap.get("id");
|
||||
|
||||
bb.writeLog("kqdate:"+kqdate);
|
||||
bb.writeLog("resourceid:"+resourceid);
|
||||
bb.writeLog("serialid:"+serialid);
|
||||
bb.writeLog("groupid:"+groupid);
|
||||
bb.writeLog("id:"+id);
|
||||
|
||||
dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param billtable
|
||||
* @param cjrbm
|
||||
* @param pbyf
|
||||
* @param workflowid
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,String>> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){
|
||||
|
||||
List<Map<String,String>> requestList = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " +
|
||||
" from "+billtable+" t " +
|
||||
" inner join workflow_requestbase r on r.requestid = t.requestid " +
|
||||
" where t.pbyf ='"+pbyf+"' " +
|
||||
" and t.cjrbm ='"+cjrbm+"' " +
|
||||
" and r.currentnodetype in(1,2,3) " +
|
||||
" and r.workflowid = "+workflowid +
|
||||
" and t.requestid <> "+requestid;
|
||||
requestList = CommonUtil.queryListBySql(sql);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return requestList;
|
||||
}
|
||||
|
||||
|
||||
private KQShiftScheduleService getService(User user) {
|
||||
return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue