LiGuang 2 yıl önce
ebeveyn
işleme
c798831280

+ 7 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

@@ -1162,8 +1162,13 @@ public class SysUserController {
                             });
                         }
                     }
-                    Map<String, Object> map = weixinUserService.U8Vacation(item.getId());
-                   if (map!=null&&map.size()>0){
+                    Map<String, Object> map = null;
+                    try {
+                        map = weixinUserService.U8Vacation(item.getId());
+                    } catch (ParseException e) {
+                        e.printStackTrace();
+                    }
+                    if (map!=null&&map.size()>0){
                        uv.setSyYear(map.get("syYearCount").toString());
                        uv.setSyTx(map.get("txCount").toString());
                    }

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysWeixinController.java

@@ -208,7 +208,7 @@ public class SysWeixinController {
 
 
     @RequestMapping("/myVacation")
-    public  Map<String,Object> U8Vacation(String userid)  {
+    public  Map<String,Object> U8Vacation(String userid) throws ParseException {
 
         return weixinUserService.U8Vacation(userid);
     }

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml

@@ -368,6 +368,7 @@ on a.depart_name=b.orgCodeTxt
 		<if test="name!=null and ''!=name">
 			and depart_name=#{name}
 		</if>
+		order by  parent_id asc
 	</select>
 
 	<select id="selectByPid" resultMap="BaseResultMap">
@@ -389,6 +390,7 @@ on a.depart_name=b.orgCodeTxt
 		<if test="ids==null or ids.size()==0">
 		and 	parent_id is not null and parent_id!=""
 		</if>
+	order by parent_id asc
 	</select>
     <select id="deptUser" resultType="org.jeecg.modules.system.entity.SysUser">
 		select DISTINCT a.*

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/IWeixinUserService.java

@@ -25,7 +25,7 @@ public interface IWeixinUserService {
         Map<String,Object>synchronizationSign() throws IOException, ParseException;
 
         //u8假期
-        Map<String,Object>U8Vacation(String id);
+        Map<String,Object>U8Vacation(String id) throws ParseException;
         //加班信息同步
         Map<String,Object>WeixinWork() throws IOException, ParseException;
 

+ 78 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/WeixinUserImpl.java

@@ -744,35 +744,82 @@ public class WeixinUserImpl implements IWeixinUserService{
         return yearCount;
     }
 
+
+    public  int getYearToWorkMoth(String workMoth){
+        int yearCount=0;
+        int i = Integer.parseInt(workMoth);
+        if (i>=12&&i<120){
+            yearCount=5;
+        }else if (i>=120&&i<240){
+            yearCount=10;
+        }else if (i>=240){
+            yearCount=15;
+        }
+        return yearCount;
+    }
+
+
     @Override
-    public Map<String, Object> U8Vacation(String id) {
+    public Map<String, Object> U8Vacation(String id) throws ParseException {
         Map<String,Object> map=new HashMap<>();
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");//日期格式化
+        SimpleDateFormat sdt = new SimpleDateFormat("yyyy");
         SysUser userByid = sysUserService.getUserByid(id);
         List<Vacation> vacationsBody=new ArrayList<>();
         Date newDate = new Date();
         int yearCount=0;
         int yearCounts=0;
+        int lyearCount=0;
         List<BdAnnualLeave> years = bdAnnualLeaveMapper.getYear(simpleDateFormat.format(newDate));
         if (years!=null&&years.size()>0&&userByid.getEntryDate()!=null){
             for (BdAnnualLeave ls:years){
                     if (userByid.getWorkMoth().equals("0")&&DateUtils.getDate().getTime()>userByid.getTrialEndDate().getTime()){
                         yearCount=5;
                     }else {
-                        yearCount += getYear(userByid.getEntryDate(), ls.getBeginDate(), userByid);
+                        if(oConvertUtils.isNotEmpty(userByid.getEntryDate())&&Integer.parseInt(sdt.format(userByid.getEntryDate()))<Integer.parseInt(ls.getYearName())) {
+                            yearCount += getYear(userByid.getEntryDate(), ls.getBeginDate(), userByid);
+                        } if(oConvertUtils.isNotEmpty(userByid.getEntryDate())&&Integer.parseInt(sdt.format(userByid.getEntryDate()))==Integer.parseInt(ls.getYearName())) {
+                            int i = daysBetween(userByid.getEntryDate(), DateUtils.parseDate(ls.getYearName() + "-12-31", "yyyy-MM-dd"));
+                            int yearToWorkMoth = getYearToWorkMoth(userByid.getWorkMoth());
+                            BigDecimal multiply = new BigDecimal(yearToWorkMoth).multiply(new BigDecimal(i));
+                            BigDecimal bigDecimal = multiply.divide(new BigDecimal("365"),0, BigDecimal.ROUND_DOWN);
+                            yearCount+=Integer.parseInt(bigDecimal.toString());
+                            yearCounts+=yearToWorkMoth;
+                        } if(oConvertUtils.isNotEmpty(userByid.getEntryDate())&&Integer.parseInt(sdt.format(newDate))-1==Integer.parseInt(ls.getYearName())) {
+                           lyearCount+=yearCount;
+                        }
                     }
-                vacationsBody.addAll(vacationMapper.queryListBody(id,ls.getYearName()));
             }
+            for (int is=years.size()-1;is>=0;is--){
+                vacationsBody.addAll(vacationMapper.queryListBody(id,years.get(is).getYearName()));
+            }
+
         }
         int moths=3;
         String syYearCount="0";
+        String lsyYearCount="0";
         String txCount="0";
-        if (vacationsBody!=null&&vacationsBody.size()>0){
-            for (Vacation vs:vacationsBody){
-                syYearCount=new BigDecimal(syYearCount).add(new BigDecimal(vs.getHolidayCount())).toString();
+        if (vacationsBody!=null&&vacationsBody.size()>0) {
+            for (int i = vacationsBody.size() - 1; i >= 0; i--) {
+                if (Integer.parseInt(sdt.format(vacationsBody.get(i).getYear())) < Integer.parseInt(sdt.format(newDate))) {
+                    lsyYearCount = new BigDecimal(lsyYearCount).add(new BigDecimal(vacationsBody.get(i).getHolidayCount())).toString();
+                }
             }
+
+            for (int it = vacationsBody.size() - 1; it >= 0; it--) {
+                syYearCount = new BigDecimal(syYearCount).add(new BigDecimal(vacationsBody.get(it).getHolidayCount())).toString();
+            }
+
+            vacationsBody=vacationMapper.queryListBody(id,sdt.format(newDate));
+
             syYearCount=new BigDecimal(syYearCount).divide(new BigDecimal("24"),1,BigDecimal.ROUND_DOWN).toString();
             syYearCount=new BigDecimal(yearCount).subtract(new BigDecimal(syYearCount)).toString();
+            if (!lsyYearCount.equals("0")) {
+                lsyYearCount = new BigDecimal(lsyYearCount).divide(new BigDecimal("24"), 1, BigDecimal.ROUND_DOWN).toString();
+                lsyYearCount = new BigDecimal(lyearCount).subtract(new BigDecimal(lsyYearCount)).toString();
+            }else {
+                lsyYearCount=String.valueOf(lyearCount);
+            }
         } else {
             syYearCount=String.valueOf(yearCount);
         }
@@ -792,7 +839,8 @@ public class WeixinUserImpl implements IWeixinUserService{
             txCount=new  BigDecimal(stringObjectMap.get("count").toString()).subtract(new BigDecimal(stringObjectMap.get("sycount").toString())).toString();
 
         }
-        map.put("yearCount",yearCount);
+        map.put("yearCount",yearCounts);
+        map.put("lsyYearCount",lsyYearCount);
         map.put("syYearCount",syYearCount);
         map.put("txCount",txCount);
         map.put("vacationsBody",vacationsBody);
@@ -1997,5 +2045,28 @@ public class WeixinUserImpl implements IWeixinUserService{
         }
         return listGroup;
     }
+
+
+    /**
+     * 计算两个日期之间相差的天数
+     * @param smdate 较小的时间
+     * @param bdate  较大的时间
+     * @return 相差天数
+     * @throws ParseException
+     */
+    public static int daysBetween(Date smdate,Date bdate) throws ParseException
+    {
+        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
+        smdate=sdf.parse(sdf.format(smdate));
+        bdate=sdf.parse(sdf.format(bdate));
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(smdate);
+        long time1 = cal.getTimeInMillis();
+        cal.setTime(bdate);
+        long time2 = cal.getTimeInMillis();
+        long between_days=(time2-time1)/(1000*3600*24);
+
+        return Integer.parseInt(String.valueOf(between_days));
+    }
 }