package com.api.tjbk; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.api.tjbk.Result.Result; import com.engine.common.util.ParamUtil; import com.icbc.api.internal.apache.http.impl.cookie.S; import weaver.conn.RecordSet; import weaver.general.StringUtil; import weaver.general.Util; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.HashMap; import java.util.Map; /** * 移动端接口类 * * @author wangj * @version 1.00版本 * @Date 2022/8/22 */ @Path("/tjbk/yearReport") public class TJBKYearReport { @GET @Path("/getDetail") public String getVersionInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { Map apidatas = new HashMap(); Map paramMap = ParamUtil.request2Map(request); RecordSet recordSet = new RecordSet(); String userId = (String) paramMap.get("userId"); // if (StringUtil.isEmpty(userId)){ // return JSONObject.toJSONString(new Result(500,"人员id为空")); // } String sql = "select * from uf_personreport where ry = ? and nd = ? order by id desc"; LocalDate now = LocalDate.now(); int year = now.getYear(); recordSet.executeQuery(sql,userId,year); HashMap firstMap = new HashMap<>(); String inputDateStr = "2023-08-07"; // 解析输入日期 LocalDate inputDate = LocalDate.parse(inputDateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd")); // 转换格式 String outputDateStr = inputDate.format(DateTimeFormatter.ofPattern("yyyy年M月d日")); // 计算距离今天的天数 LocalDate today = LocalDate.now(); long daysBetween = ChronoUnit.DAYS.between(inputDate, today); // firstMap.put("ksrq",outputDateStr); // firstMap.put("jjts",daysBetween+""); System.out.println("距离今天的天数: " + daysBetween); HashMap secondMap = new HashMap<>(); HashMap thirdMap = new HashMap<>(); HashMap fourthMap = new HashMap<>(); HashMap fifthMap = new HashMap<>(); HashMap sixthMap = new HashMap<>(); HashMap seventhMap = new HashMap<>(); HashMap eighthMap = new HashMap<>(); HashMap ninthMap = new HashMap<>(); if(recordSet.next()){ secondMap.put("ksrq",outputDateStr); secondMap.put("jjts",daysBetween+""); secondMap.put("ddcs",Util.null2String(recordSet.getString("ddcs"))); secondMap.put("yygs",Util.null2String(recordSet.getString("yygs"))); secondMap.put("gwbllcxs",Util.null2String(recordSet.getString("gwbllcxs"))); secondMap.put("swsplcxs",Util.null2String(recordSet.getString("swsplcxs"))); thirdMap.put("tgwzzs",Util.null2String(recordSet.getString("tgwzzs"))); thirdMap.put("zshywz1",Util.null2String(recordSet.getString("zshywz1"))); thirdMap.put("zshywz2",Util.null2String(recordSet.getString("zshywz2"))); thirdMap.put("zshywz3",Util.null2String(recordSet.getString("zshywz3"))); fourthMap.put("jsxxzongshu",Util.null2String(recordSet.getString("jsxxzongshu"))); fourthMap.put("ysxljfqhycs",Util.null2String(recordSet.getString("ysxljfqhycs"))); fourthMap.put("grhycycs",Util.null2String(recordSet.getString("grhycycs"))); fourthMap.put("zjgxwd",Util.null2String(recordSet.getString("zjgxwd"))); fourthMap.put("grwdgx",Util.null2String(recordSet.getString("grwdgx"))); fourthMap.put("xwhycs",Util.null2String(recordSet.getString("xwhycs"))); fifthMap.put("sktxysfxs",Util.null2String(recordSet.getString("sktxysfxs"))); fifthMap.put("sktxcycs",Util.null2String(recordSet.getString("sktxysfxs"))); sixthMap.put("gczgw",Util.null2String(recordSet.getString("gczgw"))); sixthMap.put("ljjyzz",Util.null2String(recordSet.getString("ljjyzz"))); sixthMap.put("ljjp",Util.null2String(recordSet.getString("ljjp"))); sixthMap.put("jjrclgw",Util.null2String(recordSet.getString("jjrclgw"))); sixthMap.put("qnljclgw",Util.null2String(recordSet.getString("qnljclgw"))); sixthMap.put("cgbl",Util.null2String(recordSet.getString("cgbl"))); sixthMap.put("dycclgwrq",Util.null2String(recordSet.getString("dycclgwrq"))); seventhMap.put("ljsyslcs",Util.null2String(recordSet.getString("ljsyslcs"))); seventhMap.put("qgzydf",Util.null2String(recordSet.getString("qgzydf"))); seventhMap.put("swsplcgs",Util.null2String(recordSet.getString("swsplcgs"))); seventhMap.put("nddjlzgyy",Util.null2String(recordSet.getString("nddjlzgyy"))); seventhMap.put("ljdjcs",Util.null2String(recordSet.getString("ljdjcs"))); seventhMap.put("zaydyy",Util.null2String(recordSet.getString("zaydyy"))); eighthMap.put("pjmrzxrs",Util.null2String(recordSet.getString("pjmrzxrs"))); eighthMap.put("pjmrzxrszb",Util.null2String(recordSet.getString("pjmrzxrszb"))); eighthMap.put("ljdloacs",Util.null2String(recordSet.getString("ljdloacs"))); // eighthMap.put("dlcscgrszb",Util.null2String(recordSet.getString("dlcscgrszb"))); } String gjc = Util.null2String(recordSet.getString("gjc")); if ("统帅全局".equals(gjc)){ ninthMap.put("gjc","统帅全局"); ninthMap.put("filed1",Util.null2String(recordSet.getString("sktxcycs"))); ninthMap.put("filed2","2023-12-05 23:24:45"); }else if("天行守护者".equals(gjc)){ ninthMap.put("gjc","天行守护者"); ninthMap.put("filed1",Util.null2String(recordSet.getString("qnljclgw"))); ninthMap.put("filed2","2023-12-05"); ninthMap.put("filed3","27"); }else if("勇担重担实干家".equals(gjc)){ ninthMap.put("gjc","勇担重担实干家"); ninthMap.put("filed1",1356); ninthMap.put("filed2","2023-12-05 23:24:45"); }else if("智慧OA最亲密的朋友".equals(gjc)){ ninthMap.put("gjc","智慧OA最亲密的朋友"); ninthMap.put("filed1",112); ninthMap.put("filed2","90%"); }else if("社交天花板".equals(gjc)){ ninthMap.put("gjc","社交天花板"); ninthMap.put("filed1",112); ninthMap.put("filed2","39"); ninthMap.put("filed3","90%"); }else if("人形公文处理机".equals(gjc)){ ninthMap.put("gjc","人形公文处理机"); ninthMap.put("filed1","547"); ninthMap.put("filed2","90%"); }else if("宝藏事务挖掘机".equals(gjc)){ ninthMap.put("gjc","宝藏事务挖掘机"); ninthMap.put("filed1","547"); ninthMap.put("filed2","90%"); } ninthMap.put("url",getGJCUrl(gjc)); apidatas.put("first",firstMap); apidatas.put("second",secondMap); apidatas.put("third",thirdMap); apidatas.put("fourth",fourthMap); apidatas.put("fifth",fifthMap); apidatas.put("sixth",sixthMap); apidatas.put("seventh",seventhMap); apidatas.put("eighth",eighthMap); apidatas.put("ninth",ninthMap); return JSONObject.toJSONString(new Result(apidatas)) ; } private String getGJCUrl(String gjc) { RecordSet recordSet = new RecordSet(); recordSet.executeQuery("select * from uf_reportkeyword where name = ?" ,gjc); recordSet.next(); return recordSet.getString("url"); } }