191 lines
8.7 KiB
Plaintext
191 lines
8.7 KiB
Plaintext
<%@ page contentType="text/html; charset=UTF-8" %>
|
||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||
<%@ page import="weaver.general.Util" %>
|
||
<%@ page import="weaver.hrm.*" %>
|
||
<%@ page import="com.cloudstore.dev.api.bean.MessageType" %>
|
||
<%@ page import="com.cloudstore.dev.api.bean.MessageBean" %>
|
||
<%@ page import="com.cloudstore.dev.api.util.Util_Message" %>
|
||
<%@ page import="java.util.*" %>
|
||
<%@ page import="weaver.general.TimeUtil" %>
|
||
<%@ page import="com.alibaba.fastjson.JSON" %>
|
||
<%@ page import="com.engine.kq.service.KQReportService" %>
|
||
<%@ page import="com.engine.common.util.ServiceUtil" %>
|
||
<%@ page import="com.engine.kq.service.impl.KQReportServiceImpl" %>
|
||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||
<%@ page import="java.time.LocalDate" %>
|
||
<%@ page import="java.time.format.DateTimeParseException" %>
|
||
<%@ page import="weaver.formmode.setup.ModeRightInfo" %>
|
||
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
|
||
<jsp:useBean id="rs1" class="weaver.conn.RecordSet" scope="page" />
|
||
<jsp:useBean id="rs2" class="weaver.conn.RecordSet" scope="page" />
|
||
<%
|
||
int kqbbsdtxjlb_formmodeid = Util.getIntValue(rs.getPropValue("wuyuan_hrminfo","kqbbsdtxjlb_formmodeid"));
|
||
JSONObject data = new JSONObject();
|
||
User user = HrmUserVarify.getUser(request, response);
|
||
int userid = user.getUID();
|
||
//发起审批按钮
|
||
boolean flag = false;
|
||
|
||
String parmm = Util.null2String(request.getParameter("parmm"));
|
||
rs.writeLog("=============== kqConfirmMessage.jsp parmm ==================="+ parmm);
|
||
|
||
JSONObject jsonObject = JSONObject.parseObject(parmm);
|
||
rs.writeLog("=============== kqConfirmMessage.jsp jsonObject ==================="+ jsonObject);
|
||
|
||
Map<String,Object> params = jsonObject.toJavaObject(Map.class);
|
||
rs.writeLog("=============== kqConfirmMessage.jsp params ==================="+ params);
|
||
|
||
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
|
||
String fromDate = Util.null2String(jsonObj.get("fromDate"));
|
||
String toDate = Util.null2String(jsonObj.get("toDate"));
|
||
String typeselect =Util.null2String(jsonObj.get("typeselect"));
|
||
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
|
||
String departmentId = Util.null2String(jsonObj.get("departmentId"));
|
||
String resourceId = Util.null2String(jsonObj.get("resourceId"));
|
||
|
||
if(typeselect.length()==0)typeselect = "3";
|
||
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
|
||
if(typeselect.equals("1")){
|
||
fromDate = TimeUtil.getCurrentDateString();
|
||
toDate = TimeUtil.getCurrentDateString();
|
||
}else{
|
||
fromDate = TimeUtil.getDateByOption(typeselect,"0");
|
||
toDate = TimeUtil.getDateByOption(typeselect,"1");
|
||
}
|
||
}
|
||
|
||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||
apidatas = getService(user).getKQReport(params, user);
|
||
|
||
rs.writeLog("apidatas:" + JSONObject.toJSONString(apidatas));
|
||
|
||
JSONArray jsonArray = JSON.parseArray(Util.null2String(JSONObject.toJSONString(apidatas.get("datas"))));
|
||
|
||
rs.writeLog("jsonArray:" + JSONObject.toJSONString(jsonArray));
|
||
|
||
Set<String> deptList = new HashSet<>();
|
||
for (Iterator<Object> iterator = jsonArray.iterator(); iterator.hasNext(); ) {
|
||
List<List<Object>> lsParams = new ArrayList<>();
|
||
List<List<Object>> lsDelParams = new ArrayList<>();
|
||
JSONObject next = (JSONObject) iterator.next();
|
||
|
||
String resourceid = next.getString("resourceId");
|
||
String departmentid = next.getString("departmentId");
|
||
deptList.add(departmentid);
|
||
}
|
||
|
||
rs.writeLog("=============== kqConfirmMessage.jsp deptList size ==================="+ deptList.size());
|
||
|
||
Set<String> userIdList = new HashSet<>(); // 消息接收人id 必填
|
||
|
||
String userids = "";
|
||
String deptids = "";
|
||
if(deptList.size() > 0){
|
||
for(String deptid : deptList){
|
||
deptids += deptid +",";
|
||
}
|
||
|
||
if(deptids.endsWith(",")){
|
||
deptids = deptids.substring(0,deptids.length()-1);
|
||
}
|
||
rs.writeLog("=============== kqConfirmMessage.jsp deptids ==================="+ deptids);
|
||
if(deptids!=null && !"".equals(deptids)){
|
||
rs1.executeQuery("select * from Matrixtable_2 where id in ("+deptids+")");
|
||
while(rs1.next()){
|
||
//部门负责人
|
||
String bmfzr = Util.null2String(rs1.getString("bmfzr"));
|
||
if(bmfzr!=null && !"".equals(bmfzr)) {
|
||
if (bmfzr.contains(",")) {
|
||
for (String useid : bmfzr.split(",")) {
|
||
userIdList.add(useid);
|
||
}
|
||
} else {
|
||
userIdList.add(bmfzr);
|
||
}
|
||
}
|
||
}
|
||
rs.writeLog("=============== kqConfirmMessage.jsp userIdList size ==================="+ userIdList.size());
|
||
if(userIdList.size() > 0){
|
||
for(String useridd:userIdList){
|
||
userids += useridd +",";
|
||
}
|
||
if(userids.endsWith(",")){
|
||
userids = userids.substring(0,userids.length()-1);
|
||
}
|
||
String xxnr = "有考勤数据需要确认,请关注查看!";
|
||
String requestname = "考勤数据确认提醒";
|
||
MessageType messageType = MessageType.newInstance(1306); // 消息来源(见文档第四点补充 必填)
|
||
String linkUrl = "/wui/index.html?#/main/attendance/report/month"; // PC端链接
|
||
String linkMobileUrl = "/wui/index.html?#/main/attendance/report/month"; // 移动端链接
|
||
MessageBean messageBean = Util_Message.createMessage(messageType, userIdList, requestname, "", linkUrl, linkMobileUrl);
|
||
messageBean.setCreater(1);// 创建人id
|
||
messageBean.setTitle("考勤数据确认提醒");
|
||
messageBean.setContext(xxnr);
|
||
Util_Message.store(messageBean);
|
||
|
||
String yearmonth = getMonthByDateStr(fromDate);
|
||
toDate = yearmonth + "-25";
|
||
//入库明细存档
|
||
String insertSql = " insert into uf_kqbbsdtxjlb(ksrq,fqr,bm,btxr,txrq,txsj," +
|
||
"modedatacreater,modedatacreatedate,modedatacreatetime,formmodeid,modeuuid) " +
|
||
"values(?,?,?,?,?,?,?,?,?,?,?)";
|
||
String currentdate = TimeUtil.getCurrentDateString();
|
||
String currenttime = TimeUtil.getOnlyCurrentTimeString();
|
||
String uuid = UUID.randomUUID().toString();
|
||
|
||
boolean exeRes = rs1.executeUpdate(insertSql, fromDate, userid, deptids, userids, currentdate, currenttime, userid, currentdate, currenttime, kqbbsdtxjlb_formmodeid, uuid);
|
||
int billid = -1;
|
||
if (exeRes) {
|
||
//重构权限
|
||
rs2.executeQuery(" select id from uf_kqbbsdtxjlb where modeuuid=? ", new Object[]{uuid});
|
||
rs2.next();
|
||
billid = rs2.getInt("id");
|
||
ModeRightInfo moderight = new ModeRightInfo();
|
||
moderight.editModeDataShare(userid, kqbbsdtxjlb_formmodeid, billid);
|
||
}
|
||
}
|
||
}
|
||
flag = true;
|
||
}
|
||
data.put("flag",flag);
|
||
out.print(data.toJSONString());
|
||
%>
|
||
|
||
<%!
|
||
/**
|
||
* 获取日期字符串中的年月份
|
||
* @param dateString
|
||
* @return
|
||
*/
|
||
public static String getMonthByDateStr(String dateString){
|
||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // 定义日期格式
|
||
String result = "";
|
||
try {
|
||
// 解析日期字符串并获取LocalDate对象
|
||
LocalDate date = LocalDate.parse(dateString, formatter);
|
||
int year = date.getYear();
|
||
System.out.println(year);
|
||
// 获取月份(1代表1月,...,12代表12月)
|
||
int month = date.getMonthValue(); // 或者使用date.getMonth().getValue()也是可以的,两者效果相同
|
||
System.out.println("月份: " + month); // 输出4,因为4月是第4个月份
|
||
result += year+"-";
|
||
System.out.println(result);
|
||
if(month > 10){
|
||
result += ""+month;
|
||
}else{
|
||
result += "0"+month;
|
||
}
|
||
} catch (DateTimeParseException e) {
|
||
System.out.println("日期格式错误"); // 如果日期字符串格式不正确,将抛出异常并打印错误信息
|
||
}
|
||
return result;
|
||
}
|
||
|
||
private KQReportService getService(User user) {
|
||
return (KQReportService) ServiceUtil.getService(KQReportServiceImpl.class, user);
|
||
}
|
||
%>
|
||
|
||
|