LiGuang hace 2 años
padre
commit
cc546b63c3

+ 9 - 0
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/geke/vacation/controller/VacationController.java

@@ -115,6 +115,15 @@ public class VacationController extends JeecgController<Vacation, IVacationServi
 	@ApiOperation(value="假期表-添加", notes="假期表-添加")
 	@PostMapping(value = "/add")
 	public Result<?> add(@RequestBody Vacation vacation) {
+		vacation.setState("2");
+		vacation.setUserDate(new Date());
+		if (oConvertUtils.isNotEmpty(vacation.getStartDate())&&oConvertUtils.isNotEmpty(vacation.getEndDate())){
+			double v = Double.parseDouble(String.valueOf(vacation.getStartDate().getTime()));
+			double vs = Double.parseDouble(String.valueOf(vacation.getEndDate().getTime()));
+			double ms=vs-v;
+			double day=ms/1000/(60 * 60);
+			vacation.setHolidayCount(String.valueOf(day));
+		}
 		vacationService.save(vacation);
 		return Result.OK("添加成功!");
 	}

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/schedulingInformation/mapper/xml/BdAnnualLeaveMapper.xml

@@ -5,7 +5,7 @@
     <select id="getYear" resultType="org.jeecg.modules.schedulingInformation.entity.BdAnnualLeave">
         select *from bd_annual_leave where 1=1
         <if test="date!=null and ''!=date">
-            and date_format(#{date},'%Y-%m-%d')  between date_format(begin_date,'%Y-%m-%d') and date_format(end_date,'%Y-%m-%d')
+            and #{date} between date_format(begin_date,'%Y') and date_format(end_date,'%Y')
         </if>
         order by year_name asc
     </select>

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

@@ -1164,7 +1164,7 @@ public class SysUserController {
                     }
                     Map<String, Object> map = null;
                     try {
-                        map = weixinUserService.U8Vacation(item.getId());
+                        map = weixinUserService.U8Vacation(item.getId(),"2022");
                     } catch (ParseException e) {
                         e.printStackTrace();
                     }

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

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

+ 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) throws ParseException;
+        Map<String,Object>U8Vacation(String id,String year) throws ParseException;
         //加班信息同步
         Map<String,Object>WeixinWork() throws IOException, ParseException;
 

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

@@ -760,7 +760,7 @@ public class WeixinUserImpl implements IWeixinUserService{
 
 
     @Override
-    public Map<String, Object> U8Vacation(String id) throws ParseException {
+    public Map<String, Object> U8Vacation(String id,String year) throws ParseException {
         Map<String,Object> map=new HashMap<>();
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");//日期格式化
         SimpleDateFormat sdt = new SimpleDateFormat("yyyy");
@@ -770,28 +770,54 @@ public class WeixinUserImpl implements IWeixinUserService{
         int yearCount=0;
         int yearCounts=0;
         int lyearCount=0;
-        List<BdAnnualLeave> years = bdAnnualLeaveMapper.getYear(simpleDateFormat.format(newDate));
+        int lyearCounts=0;
+        List<BdAnnualLeave> years = bdAnnualLeaveMapper.getYear(year);
         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 {
-                        if(oConvertUtils.isNotEmpty(userByid.getEntryDate())&&Integer.parseInt(sdt.format(userByid.getEntryDate()))<Integer.parseInt(ls.getYearName())) {
+                    if (Integer.parseInt(year)==Integer.parseInt(ls.getYearName())){
+                        if (oConvertUtils.isNotEmpty(userByid.getEntryDate())&&Integer.parseInt(sdt.format(userByid.getEntryDate()))==Integer.parseInt(year)){
+                            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);
+                            yearCounts+=Integer.parseInt(bigDecimal.toString());
+                            yearCount+=Integer.parseInt(bigDecimal.toString());
+                        }else {
+                            yearCount += getYear(userByid.getEntryDate(), ls.getBeginDate(), userByid);
+                            yearCounts += getYear(userByid.getEntryDate(), ls.getBeginDate(), userByid);
+                        }
+                    }else if (Integer.parseInt(ls.getYearName())<Integer.parseInt(year)&&Integer.parseInt(year)-1!=Integer.parseInt(ls.getYearName())&&oConvertUtils.isNotEmpty(userByid.getEntryDate())&&Integer.parseInt(sdt.format(userByid.getEntryDate()))<=Integer.parseInt(ls.getYearName())){
+                        if (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())) {
+                            lyearCounts += getYear(userByid.getEntryDate(), ls.getBeginDate(), userByid);
+                        }else {
+                            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());
+                            lyearCounts+=Integer.parseInt(bigDecimal.toString());
+                        }
+                    }else if (Integer.parseInt(ls.getYearName())<Integer.parseInt(year)&&Integer.parseInt(year)-1==Integer.parseInt(ls.getYearName())){
+                        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);
+                            lyearCount+=Integer.parseInt(bigDecimal.toString());
                             yearCount+=Integer.parseInt(bigDecimal.toString());
-                            yearCounts+=yearToWorkMoth;
-                        } if(oConvertUtils.isNotEmpty(userByid.getEntryDate())&&Integer.parseInt(sdt.format(newDate))-1==Integer.parseInt(ls.getYearName())) {
-                           lyearCount+=yearCount;
+                            lyearCounts+=Integer.parseInt(bigDecimal.toString());
+                        }else if (oConvertUtils.isNotEmpty(userByid.getEntryDate())&&Integer.parseInt(sdt.format(userByid.getEntryDate()))<Integer.parseInt(ls.getYearName())){
+                            lyearCount += getYear(userByid.getEntryDate(), ls.getBeginDate(), userByid);
+                            yearCount += getYear(userByid.getEntryDate(), ls.getBeginDate(), userByid);
+                            lyearCounts += getYear(userByid.getEntryDate(), ls.getBeginDate(), userByid);
                         }
                     }
             }
             for (int is=years.size()-1;is>=0;is--){
-                vacationsBody.addAll(vacationMapper.queryListBody(id,years.get(is).getYearName()));
+                if (Integer.parseInt(years.get(is).getYearName())<=Integer.parseInt(year)) {
+                    vacationsBody.addAll(vacationMapper.queryListBody(id, years.get(is).getYearName()));
+                }
             }
 
         }
@@ -801,24 +827,29 @@ public class WeixinUserImpl implements IWeixinUserService{
         String txCount="0";
         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))) {
+                if (Integer.parseInt(sdt.format(vacationsBody.get(i).getYear())) < Integer.parseInt(year)) {
                     lsyYearCount = new BigDecimal(lsyYearCount).add(new BigDecimal(vacationsBody.get(i).getHolidayCount())).toString();
+                    syYearCount = new BigDecimal(syYearCount).add(new BigDecimal(vacationsBody.get(i).getHolidayCount())).toString();
+
+                }else if (Integer.parseInt(sdt.format(vacationsBody.get(i).getYear()))==Integer.parseInt(year)){
+                    syYearCount = new BigDecimal(syYearCount).add(new BigDecimal(vacationsBody.get(i).getHolidayCount())).toString();
+
                 }
             }
 
-            for (int it = vacationsBody.size() - 1; it >= 0; it--) {
+           /* 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));
+            vacationsBody=vacationMapper.queryListBody(id,year);
 
             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();
+                lsyYearCount = new BigDecimal(lyearCounts).subtract(new BigDecimal(lsyYearCount)).toString();
             }else {
-                lsyYearCount=String.valueOf(lyearCount);
+                lsyYearCount=String.valueOf(lyearCounts);
             }
         } else {
             syYearCount=String.valueOf(yearCount);
@@ -844,6 +875,7 @@ public class WeixinUserImpl implements IWeixinUserService{
         map.put("syYearCount",syYearCount);
         map.put("txCount",txCount);
         map.put("vacationsBody",vacationsBody);
+        map.put("entry",userByid.getEntryDate());
         return map;
     }