|
@@ -19,6 +19,8 @@ import org.jeecg.modules.geke.attendance.entity.Attendance;
|
|
|
import org.jeecg.modules.geke.attendance.service.IAttendanceService;
|
|
|
import org.jeecg.modules.geke.salary.entity.Salary;
|
|
|
import org.jeecg.modules.geke.salary.service.ISalaryService;
|
|
|
+import org.jeecg.modules.geke.userquit.entity.UserQuit;
|
|
|
+import org.jeecg.modules.geke.userquit.service.IUserQuitService;
|
|
|
import org.jeecg.modules.geke.vacation.entity.Vacation;
|
|
|
import org.jeecg.modules.geke.vacation.mapper.VacationMapper;
|
|
|
import org.jeecg.modules.geke.vacation.service.IVacationService;
|
|
@@ -90,6 +92,10 @@ public class WeixinUserImpl implements IWeixinUserService{
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IUserQuitService userQuitService;
|
|
|
+
|
|
|
+
|
|
|
private DepartmentService departmentService=new DepartmentService();
|
|
|
|
|
|
|
|
@@ -144,6 +150,7 @@ public class WeixinUserImpl implements IWeixinUserService{
|
|
|
String depids="";
|
|
|
SysUser sysUser = new SysUser();
|
|
|
String b="ok";
|
|
|
+ ObjectMapper mapper=new ObjectMapper();
|
|
|
try {
|
|
|
sysUser.setId(ls.getUserid());
|
|
|
sysUser.setRealname(ls.getName());
|
|
@@ -153,6 +160,19 @@ public class WeixinUserImpl implements IWeixinUserService{
|
|
|
}if (ls.getMobile()!=null&&!ls.getMobile().equals("")) {
|
|
|
sysUser.setPhone(ls.getMobile());
|
|
|
}
|
|
|
+ Map map=(Map)ls.getExtattr();
|
|
|
+ List<Map<String,Object>> list = (List)map.get("attrs");
|
|
|
+ String workNo=null;
|
|
|
+ if (list.size()>0&&list!=null){
|
|
|
+ for (Map o:list){
|
|
|
+ if (o.get("name").equals("工号")){
|
|
|
+ if (!o.get("value").equals("")&&o.get("value")!=null) {
|
|
|
+ workNo = o.get("value").toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
sysUser.setDelFlag(Integer.parseInt(CommonConstant.DEL_FLAG_0.toString()));
|
|
|
sysUser.setStatus(1);
|
|
|
sysUser.setCreateTime(new Date());
|
|
@@ -187,7 +207,7 @@ public class WeixinUserImpl implements IWeixinUserService{
|
|
|
}
|
|
|
sysUser.setCode(ls.getUserid());
|
|
|
sysUser.setUsername(ls.getUserid());
|
|
|
- sysUser.setWorkNo(ls.getUserid());
|
|
|
+ sysUser.setWorkNo(workNo);
|
|
|
sysUser.setDepartIds(depids);
|
|
|
Boolean add = sysUserService.add(sysUser,sysUserRole);
|
|
|
}catch (Exception e){
|
|
@@ -309,6 +329,10 @@ public class WeixinUserImpl implements IWeixinUserService{
|
|
|
String msg="ok";
|
|
|
UrlData.getToken();
|
|
|
Map<String, Object> map = Maps.newHashMap();
|
|
|
+ Map<String,Object>m=new HashMap<>();
|
|
|
+ Map<String,Object>ms=new HashMap<>();
|
|
|
+ List<Map<String,Object>>lstm=new ArrayList<>();
|
|
|
+ Map<String,Object>pm=new HashMap<>();
|
|
|
try{
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
|
|
|
Map<String, Object> params = Maps.newHashMap();
|
|
@@ -343,7 +367,17 @@ public class WeixinUserImpl implements IWeixinUserService{
|
|
|
params.put("telephone", ls.getTelephone());
|
|
|
params.put("enable", ls.getStatus());
|
|
|
params.put("is_leader_in_dept", idents);
|
|
|
+ pm.put("value",ls.getWorkNo());
|
|
|
+ m.put("type",0);
|
|
|
+ m.put("name","工号");
|
|
|
+ m.put("text",pm);
|
|
|
+ m.put("value",ls.getWorkNo());
|
|
|
+ lstm.add(m);
|
|
|
+ ms.put("attrs",lstm);
|
|
|
+ params.put("extattr",ms);
|
|
|
+ System.out.println(JSONObject.toJSONString(params));
|
|
|
String s = WeixinUser(params);
|
|
|
+
|
|
|
idents=new ArrayList<>();
|
|
|
}
|
|
|
}
|
|
@@ -595,6 +629,48 @@ public class WeixinUserImpl implements IWeixinUserService{
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 入职,转正,离职信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> WeixinQuit() throws IOException, ParseException {
|
|
|
+ Map<String,Object>map=new HashMap<>();
|
|
|
+ UrlData.getVacationToken();
|
|
|
+ UrlData.getToken();
|
|
|
+ String msg="ok";
|
|
|
+ List<UserQuit>lst=new ArrayList<>();
|
|
|
+ Calendar calendar = Calendar.getInstance();//获取系统时间实列
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");//日期格式化
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ int actualMaximum = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);//获取前端传过来的时间获取月份的总天数
|
|
|
+ String sDate = "";
|
|
|
+ String eDate = "";
|
|
|
+ Date stDate = null;
|
|
|
+ Date enDate = null;
|
|
|
+ long startDate;
|
|
|
+ long endDate;
|
|
|
+ sDate = simpleDateFormat.format(new Date()) + "-01 00:00:00";
|
|
|
+ eDate = simpleDateFormat.format(new Date()) + "-" + actualMaximum + " 23:59:59";
|
|
|
+ stDate = sdf.parse(sDate);
|
|
|
+ enDate = sdf.parse(eDate);
|
|
|
+ startDate = stDate.getTime() / 1000;
|
|
|
+ endDate = enDate.getTime() / 1000;
|
|
|
+ List<String> list = WeixinVacationList(String.valueOf(startDate), String.valueOf(endDate),null);
|
|
|
+ userQuitService.deleteQuit(sDate,eDate);
|
|
|
+ for (String ls:list){//循环审批id
|
|
|
+ UserQuit quit = WeixinUserQuit(ls);
|
|
|
+ if (quit!=null){
|
|
|
+ lst.add(quit);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (lst.size()>0){
|
|
|
+ userQuitService.saveQuits(lst);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取微信审批实列id
|
|
|
* @param startDate
|
|
@@ -785,6 +861,91 @@ public class WeixinUserImpl implements IWeixinUserService{
|
|
|
}
|
|
|
return work;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取微信审批实列-入职,转正,离职信息
|
|
|
+ * @param ls
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public UserQuit WeixinUserQuit(String ls) throws IOException {
|
|
|
+ Map<String, Object> headers = Maps.newHashMap();//请求头集合
|
|
|
+ headers.put("Content-Type", "application/json; charset=utf-8");
|
|
|
+ ObjectMapper mapper = new ObjectMapper();//json转换实列
|
|
|
+ Map<String, Object> params = Maps.newHashMap();
|
|
|
+ UserQuit quit=null;
|
|
|
+ String errcode = "";
|
|
|
+ Map mapTypes = null;
|
|
|
+ try {
|
|
|
+ String createUrl = "https://qyapi.weixin.qq.com/cgi-bin/oa/getapprovaldetail?access_token=" + UrlData.VacationToken;//调用企业微信审批详情接口
|
|
|
+ params.put("sp_no", ls);//审批id参数
|
|
|
+ String res = MyHttpUtils.httpPostRequestWithJson(createUrl, headers, params);//发送请求
|
|
|
+ mapTypes = JSON.parseObject(res);//json格式转换为map集合
|
|
|
+ errcode = mapTypes.get("errcode").toString();//获取接口返回的状态码
|
|
|
+ if (errcode.equals("0")) {//判断接口是否请求成功
|
|
|
+ WeixinApproval weixinApproval = JSONArray.parseObject(mapTypes.get("info").toString(), WeixinApproval.class);//字符串转实体类
|
|
|
+ if (weixinApproval != null && weixinApproval.getSp_status().equals("2")) {//获取数据库字段所需的数据
|
|
|
+ if (weixinApproval.getSp_name().equals("入职") || weixinApproval.getSp_name().equals("转正") || weixinApproval.getSp_name().equals("离职")) {
|
|
|
+ quit = new UserQuit();
|
|
|
+ quit.setSpNo(weixinApproval.getSp_no());
|
|
|
+ quit.setSpName(weixinApproval.getSp_name());
|
|
|
+ String us = weixinApproval.getApplyer().toString();
|
|
|
+ mapTypes = JSON.parseObject(us);
|
|
|
+ quit.setUserId(mapTypes.get("userid").toString());
|
|
|
+ quit.setDeptId(mapTypes.get("partyid").toString());
|
|
|
+ quit.setApplyTime(new Date(Long.valueOf(weixinApproval.getApply_time()) * 1000));
|
|
|
+ List<Object> apply_data = weixinApproval.getApply_data();
|
|
|
+ String o = apply_data.get(0).toString();
|
|
|
+ mapTypes = JSON.parseObject(o);
|
|
|
+ String contents = mapTypes.get("contents").toString();
|
|
|
+ List<Map<String, Object>> tl = mapper.readValue(contents, new TypeReference<List<Map<String, Object>>>() {
|
|
|
+ });
|
|
|
+ Map value = null;
|
|
|
+ Map types = null;
|
|
|
+ if (weixinApproval.getSp_name().equals("离职") || weixinApproval.getSp_name().equals("转正")) {
|
|
|
+ for (Map ll : tl) {
|
|
|
+ Object s = ll.get("control");
|
|
|
+ types = (Map) ll;
|
|
|
+ if (s.equals("Date")) {
|
|
|
+ List<Map<String, Object>> tt = (List<Map<String, Object>>) types.get("title");
|
|
|
+ for (Map m : tt) {
|
|
|
+ types = (Map) ll.get("value");
|
|
|
+ types = (Map) types.get("date");
|
|
|
+ if (m.get("text").equals("入职日期")) {
|
|
|
+ if (!types.get("s_timestamp").equals("") && types.get("s_timestamp") != null) {
|
|
|
+ quit.setWorkDate(new Date(Long.valueOf(types.get("s_timestamp").toString()) * 1000));
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (m.get("text").equals("申请离职日期")) {
|
|
|
+ if (!types.get("s_timestamp").equals("") && types.get("s_timestamp") != null) {
|
|
|
+ quit.setStartDate(new Date(Long.valueOf(types.get("s_timestamp").toString()) * 1000));
|
|
|
+ }
|
|
|
+ } else if (m.get("text").equals("预计离职日期")) {
|
|
|
+ if (!types.get("s_timestamp").equals("") && types.get("s_timestamp") != null) {
|
|
|
+ quit.setEndDate(new Date(Long.valueOf(types.get("s_timestamp").toString()) * 1000));
|
|
|
+ }
|
|
|
+ } else if (m.get("text").equals("转正日期")) {
|
|
|
+ if (!types.get("s_timestamp").equals("") && types.get("s_timestamp") != null) {
|
|
|
+ quit.setZzDate(new Date(Long.valueOf(types.get("s_timestamp").toString()) * 1000));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (s.equals("Textarea")) {
|
|
|
+ types = (Map) types.get("value");
|
|
|
+ quit.setRemarks(types.get("text").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return quit;
|
|
|
+ }
|
|
|
@Override
|
|
|
public Map<String, Object> synchronizationVacation() throws ParseException, IOException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException {
|
|
|
Map<String,Object>map=new HashMap<>();
|
|
@@ -859,7 +1020,6 @@ public class WeixinUserImpl implements IWeixinUserService{
|
|
|
if (!s1.equals("0")){
|
|
|
msg=s1;
|
|
|
}
|
|
|
- System.out.println("编码:"+depart.getOrgCode()+"名称:"+depart.getDepartName());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -915,9 +1075,11 @@ public class WeixinUserImpl implements IWeixinUserService{
|
|
|
if (!depart.getId().equals("1")){
|
|
|
map.put("cdept_num",depart.getOrgCode());
|
|
|
map.put("cdept_name", depart.getDepartName());
|
|
|
+ // map.put("cdepcode",depart.getOrgCode());
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ // map.put("bpsnperson","1");
|
|
|
map.put("code", ls.getWorkNo());
|
|
|
map.put("name", ls.getRealname());
|
|
|
map.put("rsex", ls.getSex());
|