Bläddra i källkod

申请补卡逻辑完善

fllmoyu 5 år sedan
förälder
incheckning
1ae86ad563

+ 31 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dto/WorkDTO.java

@@ -0,0 +1,31 @@
+package com.jpsoft.smart.modules.base.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2020-4-27 18:54
+ */
+@Data
+public class WorkDTO {
+
+    private String id;
+
+    private String status;
+
+    private String statusN;
+
+    @DateTimeFormat(pattern = "MM-dd HH:mm")
+    @JsonFormat(pattern = "MM-dd HH:mm", timezone = "GMT+8")
+    @ApiModelProperty(value = "记录时间")
+    private Date recordTime;
+
+    private String result;
+
+
+}

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/business/dao/FillAttendanceDAO.java

@@ -16,4 +16,6 @@ public interface FillAttendanceDAO {
 	int delete(String id);
 	List<FillAttendance> list();
 	List<FillAttendance> search(Map<String, Object> searchParams, List<Sort> sortList);
+
+    FillAttendance findByBusinessWorkAttendanceId(String businessWorkAttendanceId);
 }

+ 3 - 0
common/src/main/java/com/jpsoft/smart/modules/business/entity/FillAttendance.java

@@ -29,6 +29,9 @@ public class FillAttendance {
 	 */
 	@ApiModelProperty(value = "申请人姓名")
 	private String personName;
+
+	@ApiModelProperty(value = "申请人照片")
+	private String faceImageUrl;
 	/**
 	 *申请人ID
 	 */

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/business/service/FillAttendanceService.java

@@ -19,4 +19,6 @@ public interface FillAttendanceService {
 
 
 	void updateAndWorkAtten(PersonInfo personInfo, String content, FillAttendance fillAttendance);
+
+    FillAttendance findByBusinessWorkAttendanceId(String id);
 }

+ 71 - 29
common/src/main/java/com/jpsoft/smart/modules/business/service/impl/FillAttendanceServiceImpl.java

@@ -101,39 +101,76 @@ public class FillAttendanceServiceImpl implements FillAttendanceService {
 
         }
         //新增外勤打卡、补卡申请记录
-        FillAttendance fillAttendance = new FillAttendance();
-        fillAttendance.setId(UUID.randomUUID().toString());
-        fillAttendance.setPersonId(personId);
-        fillAttendance.setType(type);
-        fillAttendance.setFillDay(workAttendanceDate);
-        fillAttendance.setFillAttendanceTime(workAttendanceTime);
-        fillAttendance.setContent(content);
-        fillAttendance.setApprovalPersonId(Long.valueOf(approvalPersonId));
-        fillAttendance.setStatus(type);
-        fillAttendance.setBusinessWorkAttendanceId(workAttendanceId);
-        String approvalNo = com.jpsoft.smart.modules.common.utils.StringUtils.getApprovalNo();
-        fillAttendance.setApprovalNo(approvalNo);
-        fillAttendance.setCreateTime(new Date());
-        fillAttendance.setDelFlag(false);
-        fillAttendanceDAO.insert(fillAttendance);
-
-
-		if (photoFile != null) {
-			FillAttendanceFiles fillAttendanceFiles = new FillAttendanceFiles();
-			fillAttendanceFiles.setId(UUID.randomUUID().toString());
-			fillAttendanceFiles.setFillAttendanceId(fillAttendance.getId());
-			fillAttendanceFiles.setFileUrl(photoFile);
-			fillAttendanceFiles.setCreateTime(new Date());
-			fillAttendanceFiles.setDelFlag(false);
-			fillAttendanceFilesDAO.insert(fillAttendanceFiles);
-		}
-
-        return fillAttendance;
+        FillAttendance fillAttendance0 = fillAttendanceDAO.findByBusinessWorkAttendanceId(workAttendanceId);
+        if (fillAttendance0 !=null){
+            fillAttendance0.setContent(content);
+            fillAttendance0.setStatus("0");
+            fillAttendance0.setUpdateTime(new Date());
+            fillAttendanceDAO.update(fillAttendance0);
+            if (photoFile != null) {
+                FillAttendanceFiles fillAttendanceFiles = fillAttendanceFilesDAO.findByFillAttendanceId(fillAttendance0.getId());
+                if (fillAttendanceFiles != null){
+                    fillAttendanceFiles.setFileUrl(photoFile);
+                    fillAttendanceFiles.setUpdateTime(new Date());
+                    fillAttendanceFilesDAO.update(fillAttendanceFiles);
+                }else {
+                    FillAttendanceFiles fillAttendanceFiles1 = new FillAttendanceFiles();
+                    fillAttendanceFiles1.setId(UUID.randomUUID().toString());
+                    fillAttendanceFiles1.setFillAttendanceId(fillAttendance0.getId());
+                    fillAttendanceFiles1.setFileUrl(photoFile);
+                    fillAttendanceFiles1.setCreateTime(new Date());
+                    fillAttendanceFiles1.setDelFlag(false);
+                    fillAttendanceFilesDAO.insert(fillAttendanceFiles1);
+                }
+//                fillAttendanceFiles.setFillAttendanceId(fillAttendance.getId());
+//                fillAttendanceFiles.setFileUrl(photoFile);
+//                fillAttendanceFiles.setCreateTime(new Date());
+//                fillAttendanceFiles.setDelFlag(false);
+//                fillAttendanceFilesDAO.insert(fillAttendanceFiles);
+            }
+
+            return fillAttendance0;
+
+
+        }else {
+            FillAttendance fillAttendance = new FillAttendance();
+            fillAttendance.setId(UUID.randomUUID().toString());
+            fillAttendance.setPersonId(personId);
+            fillAttendance.setType(type);
+            fillAttendance.setFillDay(workAttendanceDate);
+            fillAttendance.setFillAttendanceTime(workAttendanceTime);
+
+            fillAttendance.setApprovalPersonId(Long.valueOf(approvalPersonId));
+            fillAttendance.setStatus("0");
+            fillAttendance.setBusinessWorkAttendanceId(workAttendanceId);
+            String approvalNo = com.jpsoft.smart.modules.common.utils.StringUtils.getApprovalNo();
+            fillAttendance.setApprovalNo(approvalNo);
+            fillAttendance.setCreateTime(new Date());
+            fillAttendance.setDelFlag(false);
+            fillAttendanceDAO.insert(fillAttendance);
+            if (photoFile != null) {
+                FillAttendanceFiles fillAttendanceFiles = new FillAttendanceFiles();
+                fillAttendanceFiles.setId(UUID.randomUUID().toString());
+                fillAttendanceFiles.setFillAttendanceId(fillAttendance.getId());
+                fillAttendanceFiles.setFileUrl(photoFile);
+                fillAttendanceFiles.setCreateTime(new Date());
+                fillAttendanceFiles.setDelFlag(false);
+                fillAttendanceFilesDAO.insert(fillAttendanceFiles);
+            }
+            return fillAttendance;
+        }
+
+
+
+
+
+
+
     }
 
     @Override
     public void updateAndWorkAtten(PersonInfo personInfo, String content, FillAttendance fillAttendance) {
-        fillAttendance.setType("1");
+        fillAttendance.setStatus("1");
         fillAttendance.setApprovalContent(content);
         fillAttendance.setUpdateTime(new Date());
         fillAttendance.setUpdateBy(personInfo.getName());
@@ -149,5 +186,10 @@ public class FillAttendanceServiceImpl implements FillAttendanceService {
 
     }
 
+    @Override
+    public FillAttendance findByBusinessWorkAttendanceId(String businessWorkAttendanceId) {
+        return fillAttendanceDAO.findByBusinessWorkAttendanceId(businessWorkAttendanceId);
+    }
+
 
 }

+ 6 - 0
common/src/main/resources/mapper/business/FillAttendance.xml

@@ -165,4 +165,10 @@
             a.${sort.name} ${sort.order}
         </foreach>
     </select>
+
+    <select id="findByBusinessWorkAttendanceId" resultMap="FillAttendanceMap">
+        select * from business_fill_attendance
+        where business_work_attendance_id = #{businessWorkAttendanceId}
+        and del_flag = 0
+    </select>
 </mapper>

+ 3 - 0
common/src/main/resources/mapper/business/WorkAttendance.xml

@@ -113,6 +113,9 @@
             <if test="searchParams.maxRecordTime != null">
                 and record_time >= #{searchParams.maxRecordTime}
             </if>
+            <if test="searchParams.result != null">
+                and result_ = #{searchParams.result}
+            </if>
         </where>
         <foreach item="sort" collection="sortList" open="order by" separator=",">
             ${sort.name} ${sort.order}

+ 87 - 33
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/WorkAttendanceApiController.java

@@ -3,10 +3,13 @@ package com.jpsoft.smart.modules.mobile.controller;
 import cn.hutool.core.date.DateField;
 import cn.hutool.core.date.DateUtil;
 import com.github.pagehelper.Page;
+import com.google.gson.internal.$Gson$Types;
 import com.jpsoft.smart.config.OSSConfig;
 import com.jpsoft.smart.config.TemperatureConfig;
 import com.jpsoft.smart.modules.base.dto.WorkAttendanceDTO;
+import com.jpsoft.smart.modules.base.dto.WorkDTO;
 import com.jpsoft.smart.modules.base.entity.AlarmConfig;
+import com.jpsoft.smart.modules.base.entity.CompanyInfo;
 import com.jpsoft.smart.modules.base.entity.PersonInfo;
 import com.jpsoft.smart.modules.base.service.AlarmConfigService;
 import com.jpsoft.smart.modules.base.service.CompanyInfoService;
@@ -67,26 +70,70 @@ public class WorkAttendanceApiController {
     @RequestMapping(value = "pageList", method = RequestMethod.POST)
     @ApiImplicitParams({
             @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
-            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form"),
+            @ApiImplicitParam(name = "result", value = "全部/缺卡(0/1)", required = true, paramType = "form")
     })
+
     public MessageResult<Map> pageList(@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
-                                       @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
+                                       @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,String result,
+
                                        @RequestAttribute String subject, String token) {
         MessageResult<Map> msgResult = new MessageResult<>();
 
         try {
+            Map<String, Object> dataMap = new HashMap<>();
+            PersonInfo personInfo = personInfoService.get(Long.valueOf(subject));
             Map<String, Object> searchParams = new HashMap<>();
-
             List<Sort> sortList = new ArrayList<>();
             sortList.add(new Sort("record_time", "desc"));
-
-            PersonInfo personInfo = personInfoService.get(Long.valueOf(subject));
-
             searchParams.put("personId", personInfo.getId());
 
+            if ("1".equals(result)){
+                searchParams.put("result","0");
+            }
             Page<WorkAttendance> page = workAttendanceService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
+            Page<WorkDTO> workDTOPage = PojoUtils.convertPage(page,WorkDTO.class);
+            if (workDTOPage.getResult().size()>0){
+                for (WorkDTO workDTO : workDTOPage){
+                    FillAttendance fillAttendance = fillAttendanceService.findByBusinessWorkAttendanceId(workDTO.getId());
+                    if (workDTO.getResult().equals("0")){
+                        if (fillAttendance !=null){
+                            workDTO.setStatus(fillAttendance.getStatus());
+                            if (fillAttendance.getStatus().equals("0")){
+                                workDTO.setStatusN("审核中");
+                            }else if (fillAttendance.getStatus().equals("1")){
+                                workDTO.setStatusN("通过");
+                            }else if (fillAttendance.getStatus().equals("2")){
+                                workDTO.setStatusN("拒绝");
+                            }
+                        }
+                        else {
+                            workDTO.setStatusN("未处理");
+                        }
+                    }else if (workDTO.getResult().equals("1")){
+                        if (fillAttendance != null && fillAttendance.getStatus().equals("1")){
+                            workDTO.setStatus("1");
+                            workDTO.setStatusN("审核通过");
+                        }
+
+                    }
+                }
+                dataMap = PojoUtils.pageWrapper(workDTOPage);
+            }
+
+
+
+
+
+
+
+
+
+     //       searchParams.put("personId", personInfo.getId());
 
-            Map<String, Object> dataMap = PojoUtils.pageWrapper(page);
+     //       Page<WorkAttendance> page = workAttendanceService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
+
+     //       Map<String, Object> dataMap = PojoUtils.pageWrapper(page);
 
             msgResult.setData(dataMap);
             msgResult.setResult(true);
@@ -117,10 +164,13 @@ public class WorkAttendanceApiController {
                 throw new Exception("申请人不存在");
             }
 
+            CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
+
             String workAttendanceDate = "";
             String workAttendanceTime = "";
             if (StringUtils.isNotBlank(workAttendanceId)) {
                 WorkAttendance workAttendance = workAttendanceService.get(workAttendanceId);
+                AlarmConfig alarmConfig = alarmConfigService.get(workAttendance.getAlarmConfigId());
                 if (workAttendance == null) {
                     throw new Exception("考勤记录不存在");
                 }
@@ -130,13 +180,29 @@ public class WorkAttendanceApiController {
                 //考勤日期
                 workAttendanceDate = DateUtil.format(workAttendance.getRecordTime(), "yyyy-MM-dd");
                 //考勤时间段
-                workAttendanceTime = DateUtil.format(workAttendance.getRecordTime(), "HH:mm") + "-" + DateUtil.format(workAttendance.getCreateTime(), "HH:mm");
+                workAttendanceTime = alarmConfig.getStartTime()  + "-" + alarmConfig.getEndTime();
             } else {
                 workAttendanceDate = DateUtil.today();
                 //     String newWorkAttendanceTime = "";
                 //获取当天星期,国外和国内一周开始日期不一样,要偏一天
                 Integer weekDay = DateUtil.dayOfWeek(DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, -1));
-                List<AlarmConfig> alarmConfigList = alarmConfigService.findByCompanyIdAndWeekDay(personInfo.getCompanyId(), '%' + weekDay.toString() + '%');
+         //       List<AlarmConfig> alarmConfigList = alarmConfigService.findByCompanyIdAndWeekDay(personInfo.getCompanyId(), '%' + weekDay.toString() + '%');
+
+                String[] arr = companyInfo.getCode().split(",");
+
+                Set<Integer> weekdaySet = new TreeSet<>();
+
+                List<AlarmConfig> alarmConfigList = null;
+
+                for (int i=arr.length-1;i>=0;i--) {
+                    alarmConfigList = alarmConfigService.findByCompanyId(arr[i]);
+
+                    if (alarmConfigList!=null && alarmConfigList.size()>0){
+                        break;
+                    }
+                }
+
+
 
                 if (alarmConfigList.size() <= 0) {
                     throw new Exception("当天无考勤配置");
@@ -280,10 +346,15 @@ public class WorkAttendanceApiController {
                     throw new Exception("只有缺卡才能申请补卡");
                 }
 
+                FillAttendance fillAttendance = fillAttendanceService.findByBusinessWorkAttendanceId(workAttendanceId);
+                if (fillAttendance != null && fillAttendance.getStatus().equals("1")){
+                    throw new Exception("已经审核通过");
+                }
+
                 //考勤日期
-                workAttendanceDate = DateUtil.format(workAttendance.getRecordTime(), "yyyy-MM-dd");
+            //    workAttendanceDate = DateUtil.format(workAttendance.getRecordTime(), "yyyy-MM-dd");
                 //考勤时间段
-                workAttendanceTime = DateUtil.format(workAttendance.getRecordTime(), "HH:mm") + "-" + DateUtil.format(workAttendance.getCreateTime(), "HH:mm");
+          //      workAttendanceTime = DateUtil.format(workAttendance.getRecordTime(), "HH:mm") + "-" + DateUtil.format(workAttendance.getCreateTime(), "HH:mm");
 
 
             }
@@ -374,6 +445,7 @@ public class WorkAttendanceApiController {
             Page<FillAttendance> fillAttendancePage = fillAttendanceService.pageSearch(searchParam, pageIndex, pageSize, sortList);
             if (fillAttendancePage.getResult().size()>0){
                 for (FillAttendance fillAttendance : fillAttendancePage){
+                    fillAttendance.setFaceImageUrl(personInfo.getFaceImageUrl());
                     if (fillAttendance.getType().equals("1")){
                         fillAttendance.setTypeN("外勤打卡");
                     }
@@ -436,6 +508,8 @@ public class WorkAttendanceApiController {
             Page<FillAttendance> fillAttendancePage = fillAttendanceService.pageSearch(searchParam, pageIndex, pageSize, sortList);
             if (fillAttendancePage.getResult().size()>0){
                 for (FillAttendance fillAttendance : fillAttendancePage){
+                    PersonInfo workerPerson = personInfoService.get(fillAttendance.getPersonId());
+                    fillAttendance.setFaceImageUrl(workerPerson.getFaceImageUrl());
                     if (fillAttendance.getType().equals("1")){
                         fillAttendance.setTypeN("外勤打卡");
                     }
@@ -473,7 +547,7 @@ public class WorkAttendanceApiController {
     })
     public MessageResult<Map> approvalList(
             @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
-            @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
+            @RequestParam(value = "pageSize", defaultValue = "100") int pageSize,
             @RequestAttribute String subject, String token) {
         MessageResult<Map> msgResult = new MessageResult<>();
 
@@ -603,29 +677,9 @@ public class WorkAttendanceApiController {
 
 
 
-//            FillAttendanceFiles fillAttendanceFiles = fillAttendanceFilesService.findByFillAttendanceId(fillAttendance.getId());
-//
-//
-//            PersonInfo approvalPerson = personInfoService.get(fillAttendance.getApprovalPersonId());
-//
-//            WorkAttendanceDTO workAttendanceDTO = new WorkAttendanceDTO();
-//            BeanUtils.copyProperties(fillAttendance, workAttendanceDTO);
-//            workAttendanceDTO.setFillAttendanceDayAndTime(fillAttendance.getFillDay() + " " + fillAttendance.getFillAttendanceTime());
-//            workAttendanceDTO.setPersonName(personInfo.getName());
-//            workAttendanceDTO.setFaceImageUrl(personInfo.getFaceImageUrl());
-//            workAttendanceDTO.setApprovalPersonName(approvalPerson.getName());
-//            if (fillAttendance.getType().equals("1")) {
-//                workAttendanceDTO.setTypeN("外勤打卡");
-//            } else if (fillAttendance.getType().equals("2")) {
-//                workAttendanceDTO.setTypeN("补卡");
-//            }
-//            workAttendanceDTO.setCompanyName(personInfo.getCompanyName());
-//            workAttendanceDTO.setFillAttendanceFilesUrl(fillAttendanceFiles.getFileUrl() == null ? "" : fillAttendanceFiles.getFileUrl());
-//
-//            msgResult.setData(workAttendanceDTO);
-
 
             msgResult.setResult(true);
+            msgResult.setMessage("成功");
         } catch (Exception ex) {
             log.error(ex.getMessage(), ex);