Parcourir la source

考勤补卡外勤打卡

fllmoyu il y a 5 ans
Parent
commit
2a550d596f
17 fichiers modifiés avec 975 ajouts et 185 suppressions
  1. 2 0
      common/src/main/java/com/jpsoft/smart/modules/base/dao/AlarmConfigDAO.java
  2. 2 0
      common/src/main/java/com/jpsoft/smart/modules/base/service/AlarmConfigService.java
  3. 11 6
      common/src/main/java/com/jpsoft/smart/modules/base/service/impl/AlarmConfigServiceImpl.java
  4. 5 0
      common/src/main/java/com/jpsoft/smart/modules/business/dao/FillAttendanceFilesDAO.java
  5. 34 3
      common/src/main/java/com/jpsoft/smart/modules/business/entity/FillAttendance.java
  6. 5 0
      common/src/main/java/com/jpsoft/smart/modules/business/entity/WorkAttendance.java
  7. 2 0
      common/src/main/java/com/jpsoft/smart/modules/business/service/FillAttendanceFilesService.java
  8. 5 0
      common/src/main/java/com/jpsoft/smart/modules/business/service/FillAttendanceService.java
  9. 11 6
      common/src/main/java/com/jpsoft/smart/modules/business/service/impl/FillAttendanceFilesServiceImpl.java
  10. 135 53
      common/src/main/java/com/jpsoft/smart/modules/business/service/impl/FillAttendanceServiceImpl.java
  11. 16 1
      common/src/main/java/com/jpsoft/smart/modules/common/utils/StringUtils.java
  12. 5 0
      common/src/main/resources/mapper/base/AlarmConfig.xml
  13. 4 0
      common/src/main/resources/mapper/base/PersonInfo.xml
  14. 129 99
      common/src/main/resources/mapper/business/FillAttendance.xml
  15. 22 2
      common/src/main/resources/mapper/business/FillAttendanceFiles.xml
  16. 13 1
      common/src/main/resources/mapper/business/WorkAttendance.xml
  17. 574 14
      web/src/main/java/com/jpsoft/smart/modules/mobile/controller/WorkAttendanceApiController.java

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/AlarmConfigDAO.java

@@ -16,4 +16,6 @@ public interface AlarmConfigDAO {
 	List<AlarmConfig> list();
 	List<AlarmConfig> search(Map<String, Object> searchParams, List<Sort> sortList);
     List<AlarmConfig> findByCompanyId(String companyId);
+
+    List<AlarmConfig> findByCompanyIdAndWeekDay(String companyId, String weekDay);
 }

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/AlarmConfigService.java

@@ -20,4 +20,6 @@ public interface AlarmConfigService {
     List<AlarmConfig> findByCompanyId(String companyId);
 
     Set<Integer> getWeekdaySetByCompanyId(String companyId);
+
+	List<AlarmConfig> findByCompanyIdAndWeekDay(String companyId, String weekDay);
 }

+ 11 - 6
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/AlarmConfigServiceImpl.java

@@ -33,14 +33,14 @@ public class AlarmConfigServiceImpl implements AlarmConfigService {
 	public int insert(AlarmConfig model) {
 		// TODO Auto-generated method stub
 		//model.set${PkFieldName}(UUID.randomUUID().toString());
-		
+
 		return alarmConfigDAO.insert(model);
 	}
 
 	@Override
 	public int update(AlarmConfig model) {
 		// TODO Auto-generated method stub
-		return alarmConfigDAO.update(model);		
+		return alarmConfigDAO.update(model);
 	}
 
 	@Override
@@ -53,22 +53,22 @@ public class AlarmConfigServiceImpl implements AlarmConfigService {
 	public boolean exist(String id) {
 		// TODO Auto-generated method stub
 		int count = alarmConfigDAO.exist(id);
-		
+
 		return count > 0 ? true : false;
 	}
-	
+
 	@Override
 	public List<AlarmConfig> list() {
 		// TODO Auto-generated method stub
 		return alarmConfigDAO.list();
 	}
-		
+
 	@Override
 	public Page<AlarmConfig> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
         Page<AlarmConfig> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
             alarmConfigDAO.search(searchParams,sortList);
         });
-        
+
         return page;
 	}
 
@@ -104,4 +104,9 @@ public class AlarmConfigServiceImpl implements AlarmConfigService {
 
 		return weekdaySet;
 	}
+
+	@Override
+	public List<AlarmConfig> findByCompanyIdAndWeekDay(String companyId, String weekDay) {
+		return alarmConfigDAO.findByCompanyIdAndWeekDay(companyId,weekDay);
+	}
 }

+ 5 - 0
common/src/main/java/com/jpsoft/smart/modules/business/dao/FillAttendanceFilesDAO.java

@@ -1,4 +1,5 @@
 package com.jpsoft.smart.modules.business.dao;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -16,4 +17,8 @@ public interface FillAttendanceFilesDAO {
 	int delete(String id);
 	List<FillAttendanceFiles> list();
 	List<FillAttendanceFiles> search(Map<String, Object> searchParams, List<Sort> sortList);
+
+    FillAttendanceFiles  findByFillAttendanceId(@Param("fillAttendanceId")String fillAttendanceId);
+
+
 }

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

@@ -35,9 +35,9 @@ public class FillAttendance {
 	@ApiModelProperty(value = "编号")
 	private String companyName;
 	/**
-	 *申请类型:外勤打卡、补卡
+	 *申请类型:外勤打卡:1、补卡:2
 	 */
-	@ApiModelProperty(value = "申请类型:外勤打卡、补卡")
+	@ApiModelProperty(value = "申请类型:外勤打卡:1、补卡:2")
 	private String type;
 	/**
 	 *申请类型翻译
@@ -70,10 +70,14 @@ public class FillAttendance {
 	@ApiModelProperty(value = "审核人姓名")
 	private String approvalPersonName;
 	/**
-	 *状态
+	 *状态0:审核中,1:同意,2:拒绝
 	 */
 	@ApiModelProperty(value = "状态")
 	private String status;
+
+	@ApiModelProperty(value = "状态翻译")
+	private String statusN;
+
 	/**
 	 *创建人
 	 */
@@ -103,4 +107,31 @@ public class FillAttendance {
 	 */
 	@ApiModelProperty(value = "删除状态")
 	private Boolean delFlag;
+
+	/**
+	 * 考勤表对应id
+	 */
+	@ApiModelProperty(value = "考勤表对应id")
+	private String businessWorkAttendanceId;
+
+	/**
+	 * 审核编号
+	 */
+	@ApiModelProperty(value = "审核编号")
+	private String approvalNo;
+
+
+	/**
+	 * 审核时间
+	 */
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+	@ApiModelProperty(value = "审核时间")
+	private Date approvalTime;
+
+	/**
+	 * 审核意见
+	 */
+	private String approvalContent;
+
 }

+ 5 - 0
common/src/main/java/com/jpsoft/smart/modules/business/entity/WorkAttendance.java

@@ -105,4 +105,9 @@ public class WorkAttendance implements Serializable {
 
     @ApiModelProperty(value = "上班-1,下班-2")
     private Integer classifier;
+
+    /**
+     * 考勤类型(1:机器记录,2:人工填报)
+     */
+    private String sources;
 }

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

@@ -14,4 +14,6 @@ public interface FillAttendanceFilesService {
 	int delete(String id);
 	List<FillAttendanceFiles> list();
 	Page<FillAttendanceFiles> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize,boolean count, List<Sort> sortList);
+
+    FillAttendanceFiles findByFillAttendanceId(String id);
 }

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

@@ -3,6 +3,7 @@ package com.jpsoft.smart.modules.business.service;
 import java.util.List;
 import java.util.Map;
 import com.github.pagehelper.Page;
+import com.jpsoft.smart.modules.base.entity.PersonInfo;
 import com.jpsoft.smart.modules.business.entity.FillAttendance;
 import com.jpsoft.smart.modules.common.dto.Sort;
 
@@ -14,4 +15,8 @@ public interface FillAttendanceService {
 	int delete(String id);
 	List<FillAttendance> list();
 	Page<FillAttendance> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, List<Sort> sortList);
+    FillAttendance insertAndfile(String workAttendanceId, String workAttendanceDate, String workAttendanceTime, String content, String type, String photoFile, String approvalPersonId,Long personId,String alarmConfigId) throws Exception;
+
+
+	void updateAndWorkAtten(PersonInfo personInfo, String content, FillAttendance fillAttendance);
 }

+ 11 - 6
common/src/main/java/com/jpsoft/smart/modules/business/service/impl/FillAttendanceFilesServiceImpl.java

@@ -30,14 +30,14 @@ public class FillAttendanceFilesServiceImpl implements FillAttendanceFilesServic
 	public int insert(FillAttendanceFiles model) {
 		// TODO Auto-generated method stub
 		//model.setId(UUID.randomUUID().toString());
-		
+
 		return fillAttendanceFilesDAO.insert(model);
 	}
 
 	@Override
 	public int update(FillAttendanceFiles model) {
 		// TODO Auto-generated method stub
-		return fillAttendanceFilesDAO.update(model);		
+		return fillAttendanceFilesDAO.update(model);
 	}
 
 	@Override
@@ -50,22 +50,27 @@ public class FillAttendanceFilesServiceImpl implements FillAttendanceFilesServic
 	public boolean exist(String id) {
 		// TODO Auto-generated method stub
 		int count = fillAttendanceFilesDAO.exist(id);
-		
+
 		return count > 0 ? true : false;
 	}
-	
+
 	@Override
 	public List<FillAttendanceFiles> list() {
 		// TODO Auto-generated method stub
 		return fillAttendanceFilesDAO.list();
 	}
-		
+
 	@Override
 	public Page<FillAttendanceFiles> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
         Page<FillAttendanceFiles> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
             fillAttendanceFilesDAO.search(searchParams,sortList);
         });
-        
+
         return page;
 	}
+
+	@Override
+	public FillAttendanceFiles findByFillAttendanceId(String fillAttendanceId) {
+		return fillAttendanceFilesDAO.findByFillAttendanceId(fillAttendanceId);
+	}
 }

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

@@ -1,13 +1,18 @@
 package com.jpsoft.smart.modules.business.service.impl;
 
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
+import java.math.BigDecimal;
+import java.util.*;
 import javax.annotation.Resource;
 
+import com.jpsoft.smart.modules.base.entity.PersonInfo;
 import com.jpsoft.smart.modules.business.dao.FillAttendanceDAO;
+import com.jpsoft.smart.modules.business.dao.FillAttendanceFilesDAO;
+import com.jpsoft.smart.modules.business.dao.WorkAttendanceDAO;
 import com.jpsoft.smart.modules.business.entity.FillAttendance;
+import com.jpsoft.smart.modules.business.entity.FillAttendanceFiles;
+import com.jpsoft.smart.modules.business.entity.WorkAttendance;
 import com.jpsoft.smart.modules.business.service.FillAttendanceService;
+import com.jpsoft.smart.modules.common.utils.StringUtils;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 import com.github.pagehelper.Page;
@@ -15,57 +20,134 @@ import com.jpsoft.smart.modules.common.dto.Sort;
 import com.github.pagehelper.PageHelper;
 
 @Transactional
-@Component(value="fillAttendanceService")
+@Component(value = "fillAttendanceService")
 public class FillAttendanceServiceImpl implements FillAttendanceService {
-	@Resource(name="fillAttendanceDAO")
-	private FillAttendanceDAO fillAttendanceDAO;
-
-	@Override
-	public FillAttendance get(String id) {
-		// TODO Auto-generated method stub
-		return fillAttendanceDAO.get(id);
-	}
-
-	@Override
-	public int insert(FillAttendance model) {
-		// TODO Auto-generated method stub
-		//model.setId(UUID.randomUUID().toString());
-		
-		return fillAttendanceDAO.insert(model);
-	}
-
-	@Override
-	public int update(FillAttendance model) {
-		// TODO Auto-generated method stub
-		return fillAttendanceDAO.update(model);		
-	}
-
-	@Override
-	public int delete(String id) {
-		// TODO Auto-generated method stub
-		return fillAttendanceDAO.delete(id);
-	}
-
-	@Override
-	public boolean exist(String id) {
-		// TODO Auto-generated method stub
-		int count = fillAttendanceDAO.exist(id);
-		
-		return count > 0 ? true : false;
-	}
-	
-	@Override
-	public List<FillAttendance> list() {
-		// TODO Auto-generated method stub
-		return fillAttendanceDAO.list();
-	}
-		
-	@Override
-	public Page<FillAttendance> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
-        Page<FillAttendance> page = PageHelper.startPage(pageNumber,pageSize).doSelectPage(()->{
-            fillAttendanceDAO.search(searchParams,sortList);
+    @Resource(name = "fillAttendanceDAO")
+    private FillAttendanceDAO fillAttendanceDAO;
+
+	@Resource(name = "workAttendanceDAO")
+	private WorkAttendanceDAO workAttendanceDAO;
+
+	@Resource(name = "fillAttendanceFilesDAO")
+	private FillAttendanceFilesDAO fillAttendanceFilesDAO;
+
+    @Override
+    public FillAttendance get(String id) {
+        // TODO Auto-generated method stub
+        return fillAttendanceDAO.get(id);
+    }
+
+    @Override
+    public int insert(FillAttendance model) {
+        // TODO Auto-generated method stub
+        //model.setId(UUID.randomUUID().toString());
+
+        return fillAttendanceDAO.insert(model);
+    }
+
+    @Override
+    public int update(FillAttendance model) {
+        // TODO Auto-generated method stub
+        return fillAttendanceDAO.update(model);
+    }
+
+    @Override
+    public int delete(String id) {
+        // TODO Auto-generated method stub
+        return fillAttendanceDAO.delete(id);
+    }
+
+    @Override
+    public boolean exist(String id) {
+        // TODO Auto-generated method stub
+        int count = fillAttendanceDAO.exist(id);
+
+        return count > 0 ? true : false;
+    }
+
+    @Override
+    public List<FillAttendance> list() {
+        // TODO Auto-generated method stub
+        return fillAttendanceDAO.list();
+    }
+
+    @Override
+    public Page<FillAttendance> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, List<Sort> sortList) {
+        Page<FillAttendance> page = PageHelper.startPage(pageNumber, pageSize).doSelectPage(() -> {
+            fillAttendanceDAO.search(searchParams, sortList);
         });
-        
+
         return page;
-	}
+    }
+
+    @Override
+    public FillAttendance insertAndfile(String workAttendanceId, String workAttendanceDate, String workAttendanceTime, String content, String type, String photoFile, String approvalPersonId,Long personId,String alarmConfigId) throws Exception{
+        if (StringUtils.isBlank(workAttendanceId)) {
+            //无考勤记录则为外勤打卡
+			WorkAttendance workAttendance = new WorkAttendance();
+			workAttendance.setId(UUID.randomUUID().toString());
+			workAttendance.setAlarmConfigId(alarmConfigId);
+			workAttendance.setPersonId(personId);
+			workAttendance.setResult("0");
+			workAttendance.setTemperature(BigDecimal.ZERO);
+			workAttendance.setRecordTime(new Date());
+			workAttendance.setCreateTime(new Date());
+			workAttendance.setDelFlag(false);
+			workAttendance.setSources("2");
+			workAttendanceDAO.insert(workAttendance);
+			workAttendanceId = workAttendance.getId();
+
+
+
+        }
+        //新增外勤打卡、补卡申请记录
+        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;
+    }
+
+    @Override
+    public void updateAndWorkAtten(PersonInfo personInfo, String content, FillAttendance fillAttendance) {
+        fillAttendance.setType("1");
+        fillAttendance.setApprovalContent(content);
+        fillAttendance.setUpdateTime(new Date());
+        fillAttendance.setUpdateBy(personInfo.getName());
+        fillAttendance.setApprovalTime(new Date());
+        fillAttendanceDAO.update(fillAttendance);
+
+        WorkAttendance workAttendance = workAttendanceDAO.get(fillAttendance.getBusinessWorkAttendanceId());
+        if (workAttendance.getResult().equals("0")){
+            workAttendance.setResult("1");
+            workAttendanceDAO.update(workAttendance);
+
+        }
+
+    }
+
+
 }

+ 16 - 1
common/src/main/java/com/jpsoft/smart/modules/common/utils/StringUtils.java

@@ -49,6 +49,21 @@ public final class StringUtils extends org.apache.commons.lang3.StringUtils {
 		return key;
 	}
 
+
+	/**
+	 * 审批编号生成。
+	 * @return {String}
+	 */
+	public synchronized static String getApprovalNo() {
+		SimpleDateFormat format = new SimpleDateFormat("MMddHHmmss", Locale.getDefault());
+		Date date = new Date();
+		String key = format.format(date);
+		Integer ran = (int)((Math.random()*9+1)*100000);
+		key = ran.toString() + key;
+		//	key = key.substring(0, 24);
+		return key;
+	}
+
 	/**
 	 * 字符串格式化
 	 *
@@ -141,6 +156,6 @@ public final class StringUtils extends org.apache.commons.lang3.StringUtils {
 	}
 
 	public static void main(String[] args) {
-		System.out.println(random(32, RandomType.ALL));
+		System.out.println(random(32, RandomType.INT));
 	}
 }

+ 5 - 0
common/src/main/resources/mapper/base/AlarmConfig.xml

@@ -134,4 +134,9 @@
         order by start_time asc
     ]]>
     </select>
+    <select id="findByCompanyIdAndWeekDay" resultMap="AlarmConfigMap">
+        select * from base_alarm_config
+        where company_id=#{companyId} and del_flag=0
+        and weekdays_ like #{weekDay}
+    </select>
 </mapper>

+ 4 - 0
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -188,6 +188,10 @@
             <if test="searchParams.name != null">
                 and a.name_ like #{searchParams.name}
             </if>
+            <if test="searchParams.popedom != null">
+                and a.popedom_ like #{searchParams.popedom}
+            </if>
+
             <if test="searchParams.nameList != null">
                 <foreach item="name" collection="searchParams.nameList" open="and (" separator="or" close=")">
                     a.name_ like #{name}

+ 129 - 99
common/src/main/resources/mapper/business/FillAttendance.xml

@@ -1,35 +1,40 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- namespace必须指向DAO接口 -->
 <mapper namespace="com.jpsoft.smart.modules.business.dao.FillAttendanceDAO">
-	<resultMap id="FillAttendanceMap" type="com.jpsoft.smart.modules.business.entity.FillAttendance">
-		<id property="id" column="id_" />
-			<result property="personId" column="person_id" />
-			<result property="personName" column="person_name" />
-			<result property="companyName" column="company_name" />
-			<result property="type" column="type_" />
-			<result property="fillDay" column="fill_day" />
-			<result property="fillAttendanceTime" column="fill_attendance_time" />
-			<result property="content" column="content_" />
-			<result property="approvalPersonId" column="approval_person_id" />
-			<result property="approvalPersonName" column="approval_person_name" />
-			<result property="status" column="status_" />
-			<result property="createBy" column="create_by" />
-			<result property="createTime" column="create_time" />
-			<result property="updateBy" column="update_by" />
-			<result property="updateTime" column="update_time" />
-			<result property="delFlag" column="del_flag" />
-			</resultMap>
-	<insert id="insert" parameterType="com.jpsoft.smart.modules.business.entity.FillAttendance">
-	<!--
-	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
-		select sys_guid() from dual
-	</selectKey>
-	-->
-	<![CDATA[
+    <resultMap id="FillAttendanceMap" type="com.jpsoft.smart.modules.business.entity.FillAttendance">
+        <id property="id" column="id_"/>
+        <result property="personId" column="person_id"/>
+        <result property="personName" column="person_name"/>
+        <result property="companyName" column="company_name"/>
+        <result property="type" column="type_"/>
+        <result property="fillDay" column="fill_day"/>
+        <result property="fillAttendanceTime" column="fill_attendance_time"/>
+        <result property="content" column="content_"/>
+        <result property="approvalPersonId" column="approval_person_id"/>
+        <result property="approvalPersonName" column="approval_person_name"/>
+        <result property="status" column="status_"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="businessWorkAttendanceId" column="business_work_attendance_id"/>
+        <result property="approvalNo" column="approval_no"/>
+        <result property="approvalTime" column="approval_time"/>
+        <result property="approvalContent" column="approval_content"/>
+
+    </resultMap>
+    <insert id="insert" parameterType="com.jpsoft.smart.modules.business.entity.FillAttendance">
+        <!--
+        <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+            select sys_guid() from dual
+        </selectKey>
+        -->
+        <![CDATA[
 		insert into business_fill_attendance
-	    (id_,person_id,type_,fill_day,fill_attendance_time,content_,approval_person_id,status_,create_by,create_time,update_by,update_time,del_flag)
+	    (id_,person_id,type_,fill_day,fill_attendance_time,content_,approval_person_id,status_,create_by,create_time,update_by,update_time,del_flag,business_work_attendance_id,approval_no,approval_time,approval_content)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -45,65 +50,81 @@
 ,#{updateBy,jdbcType=VARCHAR}
 ,#{updateTime,jdbcType= TIMESTAMP }
 ,#{delFlag,jdbcType= NUMERIC }
+,#{businessWorkAttendanceId,jdbcType=VARCHAR}
+,#{approvalNo,jdbcType=VARCHAR}
+,#{approvalTime,jdbcType=TIMESTAMP}
+,#{approvalContent,jdbcType=VARCHAR}
 		)
 	]]>
-	</insert>
-	<delete id="delete" parameterType="string">
+    </insert>
+    <delete id="delete" parameterType="string">
 		delete from business_fill_attendance where id_=#{id,jdbcType=VARCHAR}
 	</delete>
-	<update id="update" parameterType="com.jpsoft.smart.modules.business.entity.FillAttendance">
-		update business_fill_attendance
-		<set>
-				<if test="personId!=null">
-		person_id=#{personId,jdbcType= NUMERIC },
-		</if>
-				<if test="type!=null">
-		type_=#{type,jdbcType=VARCHAR},
-		</if>
-				<if test="fillDay!=null">
-		fill_day=#{fillDay,jdbcType=VARCHAR},
-		</if>
-				<if test="fillAttendanceTime!=null">
-		fill_attendance_time=#{fillAttendanceTime,jdbcType=VARCHAR},
-		</if>
-				<if test="content!=null">
-		content_=#{content,jdbcType=VARCHAR},
-		</if>
-				<if test="approvalPersonId!=null">
-		approval_person_id=#{approvalPersonId,jdbcType= NUMERIC },
-		</if>
-				<if test="status!=null">
-		status_=#{status,jdbcType=VARCHAR},
-		</if>
-				<if test="createBy!=null">
-		create_by=#{createBy,jdbcType=VARCHAR},
-		</if>
-				<if test="createTime!=null">
-		create_time=#{createTime,jdbcType= TIMESTAMP },
-		</if>
-				<if test="updateBy!=null">
-		update_by=#{updateBy,jdbcType=VARCHAR},
-		</if>
-				<if test="updateTime!=null">
-		update_time=#{updateTime,jdbcType= TIMESTAMP },
-		</if>
-				<if test="delFlag!=null">
-		del_flag=#{delFlag,jdbcType= NUMERIC },
-		</if>
-		</set>
-	where id_=#{id}
-	</update>
-	<select id="get" parameterType="string" resultMap="FillAttendanceMap">
+    <update id="update" parameterType="com.jpsoft.smart.modules.business.entity.FillAttendance">
+        update business_fill_attendance
+        <set>
+            <if test="personId!=null">
+                person_id=#{personId,jdbcType= NUMERIC },
+            </if>
+            <if test="type!=null">
+                type_=#{type,jdbcType=VARCHAR},
+            </if>
+            <if test="fillDay!=null">
+                fill_day=#{fillDay,jdbcType=VARCHAR},
+            </if>
+            <if test="fillAttendanceTime!=null">
+                fill_attendance_time=#{fillAttendanceTime,jdbcType=VARCHAR},
+            </if>
+            <if test="content!=null">
+                content_=#{content,jdbcType=VARCHAR},
+            </if>
+            <if test="approvalPersonId!=null">
+                approval_person_id=#{approvalPersonId,jdbcType= NUMERIC },
+            </if>
+            <if test="status!=null">
+                status_=#{status,jdbcType=VARCHAR},
+            </if>
+            <if test="createBy!=null">
+                create_by=#{createBy,jdbcType=VARCHAR},
+            </if>
+            <if test="createTime!=null">
+                create_time=#{createTime,jdbcType= TIMESTAMP },
+            </if>
+            <if test="updateBy!=null">
+                update_by=#{updateBy,jdbcType=VARCHAR},
+            </if>
+            <if test="updateTime!=null">
+                update_time=#{updateTime,jdbcType= TIMESTAMP },
+            </if>
+            <if test="delFlag!=null">
+                del_flag=#{delFlag,jdbcType= NUMERIC },
+            </if>
+            <if test="businessWorkAttendanceId!=null">
+                business_work_attendance_id=#{businessWorkAttendanceId,jdbcType= VARCHAR },
+            </if>
+            <if test="approvalNo!=null">
+                approval_no=#{approvalNo,jdbcType= VARCHAR },
+            </if>
+            <if test="approvalTime!=null">
+                approval_time=#{approvalTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="approvalContent!=null">
+                approval_content=#{approvalContent,jdbcType=VARCHAR},
+            </if>
+        </set>
+        where id_=#{id}
+    </update>
+    <select id="get" parameterType="string" resultMap="FillAttendanceMap">
 		select * from business_fill_attendance where id_=#{0} and del_flag = 0
 	</select>
-	<select id="exist" parameterType="string" resultType="int">
+    <select id="exist" parameterType="string" resultType="int">
 		select count(*) from business_fill_attendance where id_=#{0} and del_flag = 0
 	</select>
-	<select id="list" resultMap="FillAttendanceMap">
+    <select id="list" resultMap="FillAttendanceMap">
 		select * from business_fill_attendance and del_flag = 0
 	</select>
-	<select id="search" parameterType="hashmap" resultMap="FillAttendanceMap">
-		<![CDATA[
+    <select id="search" parameterType="hashmap" resultMap="FillAttendanceMap">
+        <![CDATA[
 			select a.*,
 			b.name_ as person_name,
 			c.name_ as approval_person_name,
@@ -113,26 +134,35 @@
 			left join base_person_info c on a.approval_person_id = c.id_
 			left join base_company_info d on b.company_id = d.id_
 		]]>
-		<where>
-			a.del_flag = 0
-			and b.del_flag = 0
-			and c.del_flag = 0
-			and d.del_flag = 0
-			<if test="searchParams.id != null">
-				and a.ID_ like #{searchParams.id}
-			</if>
-			<if test="searchParams.personName != null">
-				and b.name_ like #{searchParams.personName}
-			</if>
-			<if test="searchParams.type != null">
-				and a.type_ = #{searchParams.type}
-			</if>
-			<if test="searchParams.status != null">
-				and a.status_ like #{searchParams.status}
-			</if>
-		</where>
-		<foreach item="sort" collection="sortList"  open="order by" separator=",">
-			a.${sort.name} ${sort.order}
-	 	</foreach>
-	</select>
+        <where>
+            a.del_flag = 0
+            and b.del_flag = 0
+            and c.del_flag = 0
+            and d.del_flag = 0
+            <if test="searchParams.id != null">
+                and a.ID_ like #{searchParams.id}
+            </if>
+            <if test="searchParams.personName != null">
+                and b.name_ like #{searchParams.personName}
+            </if>
+            <if test="searchParams.type != null">
+                and a.type_ = #{searchParams.type}
+            </if>
+            <if test="searchParams.status != null">
+                and a.status_ like #{searchParams.status}
+            </if>
+            <if test="searchParams.personId != null">
+                and a.person_id like #{searchParams.personId}
+            </if>
+            <if test="searchParams.approvalPersonId != null">
+                and a.approval_person_id = #{searchParams.approvalPersonId}
+            </if>
+            <if test="searchParams.notStatus != null">
+                and a.status_ != #{searchParams.notStatus}
+            </if>
+        </where>
+        <foreach item="sort" collection="sortList" open="order by" separator=",">
+            a.${sort.name} ${sort.order}
+        </foreach>
+    </select>
 </mapper>

+ 22 - 2
common/src/main/resources/mapper/business/FillAttendanceFiles.xml

@@ -1,9 +1,20 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- namespace必须指向DAO接口 -->
 <mapper namespace="com.jpsoft.smart.modules.business.dao.FillAttendanceFilesDAO">
-	<resultMap id="FillAttendanceFilesMap" type="com.jpsoft.smart.modules.business.entity.FillAttendanceFiles">
+    <sql id="Base_Column_List">
+    id_,
+    fill_attendance_id,
+    file_name,
+    file_url,
+    create_by,
+    create_time,
+    update_by,
+    update_time,
+    del_flag
+</sql>
+    <resultMap id="FillAttendanceFilesMap" type="com.jpsoft.smart.modules.business.entity.FillAttendanceFiles">
 		<id property="id" column="id_" />
 			<result property="fillAttendanceId" column="fill_attendance_id" />
 			<result property="fileName" column="file_name" />
@@ -96,4 +107,13 @@
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+
+<!--auto generated by MybatisCodeHelper on 2020-04-27-->
+    <select id="findByFillAttendanceId" resultMap="FillAttendanceFilesMap">
+        select
+        <include refid="Base_Column_List"/>
+        from business_fill_attendance_files
+        where fill_attendance_id=#{fillAttendanceId}
+		and del_flag = 0
+    </select>
 </mapper>

+ 13 - 1
common/src/main/resources/mapper/business/WorkAttendance.xml

@@ -15,6 +15,7 @@
         <result property="updateBy" column="update_by"/>
         <result property="updateTime" column="update_time"/>
         <result property="delFlag" column="del_flag"/>
+        <result property="sources" column="sources_"/>
     </resultMap>
     <resultMap id="WorkAttendanceMap2" type="com.jpsoft.smart.modules.business.entity.WorkAttendance" extends="WorkAttendanceMap">
         <result property="classifier" column="classifier_"/>
@@ -27,7 +28,7 @@
         -->
         <![CDATA[
 		insert into business_work_attendance
-	    (id_,alarm_config_id,person_id,result_,create_by,create_time,update_by,update_time,del_flag,record_time,temperature_)
+	    (id_,alarm_config_id,person_id,result_,create_by,create_time,update_by,update_time,del_flag,record_time,temperature_,sources_)
 		values
 		(
 			#{id,jdbcType=VARCHAR}
@@ -41,6 +42,8 @@
 			,#{delFlag,jdbcType= NUMERIC }
 			,#{recordTime,jdbcType= TIMESTAMP }
 			,#{temperature,jdbcType= NUMERIC }
+            ,#{sources,jdbcType=VARCHAR}
+
 		)
 	]]>
     </insert>
@@ -80,6 +83,9 @@
             <if test="temperature!=null">
                 temperature_=#{temperature,jdbcType= NUMERIC },
             </if>
+            <if test="sources!=null">
+                sources_=#{sources,jdbcType=VARCHAR},
+            </if>
         </set>
         where id_=#{id}
     </update>
@@ -101,6 +107,12 @@
             <if test="searchParams.personId != null">
                 and person_id like #{searchParams.personId}
             </if>
+            <if test="searchParams.alarmConfigId != null">
+                and alarm_config_id = #{searchParams.alarmConfigId}
+            </if>
+            <if test="searchParams.maxRecordTime != null">
+                and record_time >= #{searchParams.maxRecordTime}
+            </if>
         </where>
         <foreach item="sort" collection="sortList" open="order by" separator=",">
             ${sort.name} ${sort.order}

+ 574 - 14
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/WorkAttendanceApiController.java

@@ -1,27 +1,38 @@
 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.jpsoft.smart.config.OSSConfig;
 import com.jpsoft.smart.config.TemperatureConfig;
+import com.jpsoft.smart.modules.base.dto.WorkAttendanceDTO;
+import com.jpsoft.smart.modules.base.entity.AlarmConfig;
 import com.jpsoft.smart.modules.base.entity.PersonInfo;
 import com.jpsoft.smart.modules.base.service.AlarmConfigService;
 import com.jpsoft.smart.modules.base.service.CompanyInfoService;
 import com.jpsoft.smart.modules.base.service.PersonInfoService;
+import com.jpsoft.smart.modules.business.entity.FillAttendance;
+import com.jpsoft.smart.modules.business.entity.FillAttendanceFiles;
 import com.jpsoft.smart.modules.business.entity.WorkAttendance;
+import com.jpsoft.smart.modules.business.service.FillAttendanceFilesService;
+import com.jpsoft.smart.modules.business.service.FillAttendanceService;
 import com.jpsoft.smart.modules.business.service.WorkAttendanceService;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
 import com.jpsoft.smart.modules.common.dto.Sort;
+import com.jpsoft.smart.modules.common.utils.OSSUtil;
 import com.jpsoft.smart.modules.common.utils.PojoUtils;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.math3.random.HaltonSequenceGenerator;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @RestController
 @RequestMapping("/mobile/workAttendance")
@@ -42,15 +53,25 @@ public class WorkAttendanceApiController {
     @Autowired
     private WorkAttendanceService workAttendanceService;
 
-    @ApiOperation(value="考勤记录")
-    @RequestMapping(value = "pageList",method = RequestMethod.POST)
+    @Autowired
+    private FillAttendanceService fillAttendanceService;
+
+    @Autowired
+    private FillAttendanceFilesService fillAttendanceFilesService;
+
+
+    @Autowired
+    private OSSConfig ossConfig;
+
+    @ApiOperation(value = "考勤记录")
+    @RequestMapping(value = "pageList", method = RequestMethod.POST)
     @ApiImplicitParams({
-            @ApiImplicitParam(name="token",value = "令牌",required = true,paramType = "form"),
-            @ApiImplicitParam(name="subject",value = "目标(不传)",paramType = "form")
+            @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
     })
-    public MessageResult<Map> pageList(@RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
-                                       @RequestParam(value="pageSize",defaultValue="20") int pageSize,
-                                       @RequestAttribute String subject, String token){
+    public MessageResult<Map> pageList(@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
+                                       @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
+                                       @RequestAttribute String subject, String token) {
         MessageResult<Map> msgResult = new MessageResult<>();
 
         try {
@@ -65,13 +86,416 @@ public class WorkAttendanceApiController {
 
             Page<WorkAttendance> page = workAttendanceService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
 
-            Map<String,Object> dataMap = PojoUtils.pageWrapper(page);
+            Map<String, Object> dataMap = PojoUtils.pageWrapper(page);
+
+            msgResult.setData(dataMap);
+            msgResult.setResult(true);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "补卡申请获取时间段")
+    @RequestMapping(value = "patchCard", method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form"),
+            @ApiImplicitParam(name = "workAttendanceId", value = "考勤id", required = false, paramType = "form")
+    })
+    public MessageResult<Map> patchCard(String workAttendanceId, @RequestAttribute String subject, String token) {
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        try {
+
+            PersonInfo personInfo = personInfoService.get(Long.valueOf(subject));
+            if (personInfo == null) {
+                throw new Exception("申请人不存在");
+            }
+
+            String workAttendanceDate = "";
+            String workAttendanceTime = "";
+            if (StringUtils.isNotBlank(workAttendanceId)) {
+                WorkAttendance workAttendance = workAttendanceService.get(workAttendanceId);
+                if (workAttendance == null) {
+                    throw new Exception("考勤记录不存在");
+                }
+                if (!"0".equals(workAttendance.getResult())) {
+                    throw new Exception("只有缺卡才能申请补卡");
+                }
+                //考勤日期
+                workAttendanceDate = DateUtil.format(workAttendance.getRecordTime(), "yyyy-MM-dd");
+                //考勤时间段
+                workAttendanceTime = DateUtil.format(workAttendance.getRecordTime(), "HH:mm") + "-" + DateUtil.format(workAttendance.getCreateTime(), "HH:mm");
+            } 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() + '%');
+
+                if (alarmConfigList.size() <= 0) {
+                    throw new Exception("当天无考勤配置");
+                }
+                for (AlarmConfig alarmConfig : alarmConfigList) {
+                    Long nowTime = new Date().getTime();
+                    //    Date startTime = DateUtil.parseTime(alarmConfig.getStartTime());
+                    Long startTime = DateUtil.parse(alarmConfig.getStartTime()).getTime();
+                    Long endTime = DateUtil.parse(alarmConfig.getEndTime()).getTime();
+                    if (nowTime <= endTime && nowTime >= startTime) {
+                        workAttendanceTime = alarmConfig.getStartTime() + "-" + alarmConfig.getEndTime();
+                        break;
+
+                    } else {
+                        continue;
+                    }
+                }
+                if (StringUtils.isBlank(workAttendanceTime)) {
+                    throw new Exception("不在考勤时间段");
+                }
 
+
+            }
+
+
+            HashMap<String, Object> dataMap = new HashMap<>();
+            dataMap.put("workAttendanceId", workAttendanceId);
+            dataMap.put("workAttendanceDate", workAttendanceDate);
+            dataMap.put("workAttendanceTime", workAttendanceTime);
             msgResult.setData(dataMap);
             msgResult.setResult(true);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value = "补卡申请数据提交")
+    @RequestMapping(value = "postPatchCard", method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form"),
+            @ApiImplicitParam(name = "workAttendanceId", value = "考勤id", required = false, paramType = "form"),
+            @ApiImplicitParam(name = "workAttendanceDate", value = "考勤日期", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "workAttendanceTime", value = "考勤时间段", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "type", value = "外勤打卡/补卡(1/2)", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "content", value = "申请理由", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "photoFile", value = "图片", required = false, paramType = "form"),
+            @ApiImplicitParam(name = "approvalPersonId", value = "审核人", required = true, paramType = "form")
+    })
+    public MessageResult<WorkAttendanceDTO> postPatchCard(
+            String workAttendanceId,
+            @RequestParam("workAttendanceDate") String workAttendanceDate,
+            @RequestParam("workAttendanceTime") String workAttendanceTime,
+            @RequestParam("type") String type,
+            @RequestParam("content") String content,
+            String photoFile,
+            @RequestParam("approvalPersonId") String approvalPersonId,
+            @RequestAttribute String subject, String token) {
+        MessageResult<WorkAttendanceDTO> msgResult = new MessageResult<>();
+
+        try {
+            //查询操作人
+            PersonInfo personInfo = personInfoService.get(Long.valueOf(subject));
+            if (personInfo == null) {
+                throw new Exception("申请人不存在");
+            }
+
+            //审核人
+            PersonInfo approvalPerson = personInfoService.get(Long.valueOf(approvalPersonId));
+            if (approvalPerson == null) {
+                throw new Exception("审核人不存在");
+            }
+
+            String alarmConfigId = "";
+
+            //外勤打卡
+            if ("1".equals(type)) {
+                String newWorkAttendanceDate = DateUtil.today();
+                String newWorkAttendanceTime = "";
+                //      workAttendanceDate = DateUtil.today();
+                //获取当天星期,国外和国内一周开始日期不一样,要偏一天
+                Integer weekDay = DateUtil.dayOfWeek(DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, -1));
+                List<AlarmConfig> alarmConfigList = alarmConfigService.findByCompanyIdAndWeekDay(personInfo.getCompanyId(), '%' + weekDay.toString() + '%');
+
+                if (alarmConfigList.size() <= 0) {
+                    throw new Exception("当天无考勤配置");
+                }
+                for (AlarmConfig alarmConfig : alarmConfigList) {
+                    Long nowTime = new Date().getTime();
+                    //    Date startTime = DateUtil.parseTime(alarmConfig.getStartTime());
+                    Long startTime = DateUtil.parse(alarmConfig.getStartTime()).getTime();
+                    Long endTime = DateUtil.parse(alarmConfig.getEndTime()).getTime();
+                    if (nowTime <= endTime && nowTime >= startTime) {
+                        newWorkAttendanceTime = alarmConfig.getStartTime() + "-" + alarmConfig.getEndTime();
+                        alarmConfigId = alarmConfig.getId();
+                        break;
+
+                    } else {
+                        continue;
+                    }
+                }
+                if (StringUtils.isBlank(newWorkAttendanceTime)) {
+                    throw new Exception("不在考勤时间段");
+                }
+
+                if (!workAttendanceDate.equals(newWorkAttendanceDate) || !workAttendanceTime.equals(newWorkAttendanceTime)) {
+                    throw new Exception("考勤数据错误,请确认");
+                }
+
+
+                Map<String, Object> searchParam = new HashMap<>();
+                searchParam.put("alarmConfigId", alarmConfigId);
+                searchParam.put("personId", personInfo.getId());
+                searchParam.put("maxRecordTime", DateUtil.beginOfDay(new Date()));
+                List<Sort> sortList = new ArrayList<>();
+                sortList.add(new Sort("record_time", "desc"));
+                Page<WorkAttendance> workAttendancePage = workAttendanceService.pageSearch(searchParam, 1, 20, true, sortList);
+                if (workAttendancePage.getResult().size() > 0) {
+                    throw new Exception("此时间段已有打卡记录");
+                }
+
+
+            }
+            //补卡
+            else if ("2".equals(type)) {
+                if (StringUtils.isBlank(workAttendanceId)) {
+                    throw new Exception("考勤记录id不存在");
+                }
+
+                WorkAttendance workAttendance = workAttendanceService.get(workAttendanceId);
+                if (workAttendance == null) {
+                    throw new Exception("考勤记录不存在");
+                }
+                if (!"0".equals(workAttendance.getResult())) {
+                    throw new Exception("只有缺卡才能申请补卡");
+                }
+
+                //考勤日期
+                workAttendanceDate = DateUtil.format(workAttendance.getRecordTime(), "yyyy-MM-dd");
+                //考勤时间段
+                workAttendanceTime = DateUtil.format(workAttendance.getRecordTime(), "HH:mm") + "-" + DateUtil.format(workAttendance.getCreateTime(), "HH:mm");
+
+
+            }
+
+            FillAttendance fillAttendance = fillAttendanceService.insertAndfile(workAttendanceId, workAttendanceDate, workAttendanceTime, content, type, photoFile, approvalPersonId, personInfo.getId(), alarmConfigId);
+
+
+//            //新增外勤打卡、补卡申请记录
+//            FillAttendance fillAttendance = new FillAttendance();
+//            fillAttendance.setId(UUID.randomUUID().toString());
+//            fillAttendance.setPersonId(personInfo.getId());
+//            fillAttendance.setType(type);
+//            fillAttendance.setFillDay(workAttendanceDate);
+//            fillAttendance.setFillAttendanceTime(workAttendanceTime);
+//            fillAttendance.setContent(content);
+//            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);
+//            fillAttendanceService.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);
+//                fillAttendanceFilesService.insert(fillAttendanceFiles);
+//            }
+
+            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(photoFile == null ? "" : photoFile);
+
+            msgResult.setData(workAttendanceDTO);
+            msgResult.setMessage("提交成功");
+            msgResult.setResult(true);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value = "个人考勤申请记录列表")
+    @RequestMapping(value = "ownListPatchCard", method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
+    })
+    public MessageResult<Map> ownListPatchCard(
+            @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
+            @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
+            @RequestAttribute String subject, String token) {
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        try {
+
+            PersonInfo personInfo = personInfoService.get(Long.valueOf(subject));
+            if (personInfo == null) {
+                throw new Exception("人员不存在");
+            }
+
+            Map<String, Object> searchParam = new HashMap<>();
+            searchParam.put("personId", personInfo.getId());
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("create_time", "desc"));
+            Page<FillAttendance> fillAttendancePage = fillAttendanceService.pageSearch(searchParam, pageIndex, pageSize, sortList);
+            if (fillAttendancePage.getResult().size()>0){
+                for (FillAttendance fillAttendance : fillAttendancePage){
+                    if (fillAttendance.getType().equals("1")){
+                        fillAttendance.setTypeN("外勤打卡");
+                    }
+                    else {
+                        fillAttendance.setTypeN("补卡");
+                    }
+                    if (fillAttendance.getStatus().equals("0")){
+                        fillAttendance.setStatusN("审核中");
+                    }if (fillAttendance.getStatus().equals("1")){
+                        fillAttendance.setStatusN("通过");
+                    }if (fillAttendance.getStatus().equals("2")){
+                        fillAttendance.setStatusN("拒绝");
+                    }
+                }
+            }
+
+
+            msgResult.setData(PojoUtils.pageWrapper(fillAttendancePage));
+            msgResult.setResult(true);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "审核人考勤申请记录列表")
+    @RequestMapping(value = "adminListPatchCard", method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form"),
+            @ApiImplicitParam(name = "status", value = "状态(0:未处理,3:已处理)", required = true, paramType = "form")
+    })
+    public MessageResult<Map> adminListPatchCard(
+            @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
+            @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
+            @RequestAttribute String subject, String token,String status) {
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        try {
+
+            PersonInfo personInfo = personInfoService.get(Long.valueOf(subject));
+            if (personInfo == null) {
+                throw new Exception("人员不存在");
+            }
+
+            Map<String, Object> searchParam = new HashMap<>();
+            searchParam.put("approvalPersonId", personInfo.getId());
+            if (status.equals("0")){
+                searchParam.put("status",status);
+            }else {
+                //已处理
+                searchParam.put("notStatus","0");
+            }
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("create_time", "desc"));
+            Page<FillAttendance> fillAttendancePage = fillAttendanceService.pageSearch(searchParam, pageIndex, pageSize, sortList);
+            if (fillAttendancePage.getResult().size()>0){
+                for (FillAttendance fillAttendance : fillAttendancePage){
+                    if (fillAttendance.getType().equals("1")){
+                        fillAttendance.setTypeN("外勤打卡");
+                    }
+                    else {
+                        fillAttendance.setTypeN("补卡");
+                    }
+                    if (fillAttendance.getStatus().equals("0")){
+                        fillAttendance.setStatusN("审核中");
+                    }if (fillAttendance.getStatus().equals("1")){
+                        fillAttendance.setStatusN("通过");
+                    }if (fillAttendance.getStatus().equals("2")){
+                        fillAttendance.setStatusN("拒绝");
+                    }
+                }
+            }
+
+
+            msgResult.setData(PojoUtils.pageWrapper(fillAttendancePage));
+            msgResult.setResult(true);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
         }
-        catch (Exception ex){
-            log.error(ex.getMessage(),ex);
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "审核人列表")
+    @RequestMapping(value = "approvalList", method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
+    })
+    public MessageResult<Map> approvalList(
+            @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
+            @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
+            @RequestAttribute String subject, String token) {
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        try {
+
+            PersonInfo personInfo = personInfoService.get(Long.valueOf(subject));
+            if (personInfo == null) {
+                throw new Exception("人员不存在");
+            }
+            Map<String,Object> searchParam = new HashMap<>();
+            searchParam.put("companyId",personInfo.getCompanyId());
+            searchParam.put("popedom","%2%");
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("create_time","asc"));
+            Page<PersonInfo> page = personInfoService.pageSearch(searchParam,pageIndex,pageSize,true,sortList);
+
+
+
+            msgResult.setData(PojoUtils.pageWrapper(page));
+            msgResult.setResult(true);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());
@@ -79,4 +503,140 @@ public class WorkAttendanceApiController {
 
         return msgResult;
     }
+
+
+
+
+    @ApiOperation(value = "考勤申请记录详情")
+    @RequestMapping(value = "detailPatchCard", method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form"),
+            @ApiImplicitParam(name = "id", value = "考勤申请id", required = true, paramType = "form"),
+    })
+    public MessageResult<WorkAttendanceDTO> detailPatchCard(@RequestParam("id") String id,
+            @RequestAttribute String subject, String token) {
+        MessageResult<WorkAttendanceDTO> msgResult = new MessageResult<>();
+
+        try {
+
+            PersonInfo personInfo = personInfoService.get(Long.valueOf(subject));
+            if (personInfo == null) {
+                throw new Exception("人员不存在");
+            }
+            FillAttendance fillAttendance = fillAttendanceService.get(id);
+            if (fillAttendance == null){
+                throw new Exception("记录不存在");
+            }
+            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);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "考勤申请记录审核")
+    @RequestMapping(value = "approvalPatchCard", method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form"),
+            @ApiImplicitParam(name = "ids", value = "考勤申请ids", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "content", value = "审核意见", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "status", value = "通过/拒绝(1/2)", required = true, paramType = "form")
+    })
+    public MessageResult<WorkAttendanceDTO> approvalPatchCard(@RequestParam("ids") String ids,String content,@RequestParam("status") String status,
+                                                            @RequestAttribute String subject, String token) {
+        MessageResult<WorkAttendanceDTO> msgResult = new MessageResult<>();
+
+        try {
+
+            PersonInfo personInfo = personInfoService.get(Long.valueOf(subject));
+            if (personInfo == null) {
+                throw new Exception("人员不存在");
+            }
+            if (StringUtils.isBlank(ids)){
+                throw new Exception("请选择要处理的几率");
+            }
+            List<String> idList = Arrays.asList(ids.split(","));
+            for (String id : idList){
+                FillAttendance fillAttendance = fillAttendanceService.get(id);
+                if (fillAttendance != null){
+                    if ("2".equals(status)) {
+                        fillAttendance.setStatus(status);
+                        fillAttendance.setUpdateTime(new Date());
+                        fillAttendance.setUpdateBy(personInfo.getName());
+                        fillAttendance.setApprovalTime(new Date());
+                        fillAttendance.setApprovalContent(content);
+                        fillAttendanceService.update(fillAttendance);
+                    }else {
+                        fillAttendanceService.updateAndWorkAtten(personInfo,content,fillAttendance);
+                    }
+
+                }
+            }
+
+
+
+//            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);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+
+
 }