Kaynağa Gözat

Merge remote-tracking branch 'origin/V1' into V1

zhengqiang 5 yıl önce
ebeveyn
işleme
8abb022f00

+ 19 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/PunchLocationDAO.java

@@ -0,0 +1,19 @@
+package com.jpsoft.smart.modules.base.dao;
+
+import com.jpsoft.smart.modules.base.entity.PunchLocation;
+import com.jpsoft.smart.modules.common.dto.Sort;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+
+@Repository
+public interface PunchLocationDAO {
+	int insert(PunchLocation entity);
+	int update(PunchLocation entity);
+	int exist(String id);
+	PunchLocation get(String id);
+	int delete(String id);
+	List<PunchLocation> list();
+	List<PunchLocation> search(Map<String, Object> searchParams, List<Sort> sortList);
+}

+ 22 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/PunchRecordDAO.java

@@ -0,0 +1,22 @@
+package com.jpsoft.smart.modules.base.dao;
+
+import com.jpsoft.smart.modules.base.entity.PunchRecord;
+import com.jpsoft.smart.modules.common.dto.Sort;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+
+@Repository
+public interface PunchRecordDAO {
+	int insert(PunchRecord entity);
+	int update(PunchRecord entity);
+	int exist(String id);
+	PunchRecord get(String id);
+	int delete(String id);
+	List<PunchRecord> list();
+	List<PunchRecord> search(Map<String, Object> searchParams, List<Sort> sortList);
+
+    List<PunchRecord> findByPersonAndDate(@Param("personId") Long personId, @Param("startDate") String startDate, @Param("endDate") String endDate);
+}

+ 9 - 0
common/src/main/java/com/jpsoft/smart/modules/base/entity/DeviceInfo.java

@@ -181,4 +181,13 @@ public class DeviceInfo {
 
 	@ApiModelProperty(value = "异常原因")
 	private String isBind;
+
+	@ApiModelProperty(value = "经度")
+	private String longtitude;
+
+	@ApiModelProperty(value = "纬度")
+	private String latitude;
+
+	@ApiModelProperty(value = "设备场景值(数据库 1:为学校大门)")
+	private String deviceAddress;
 }

+ 86 - 0
common/src/main/java/com/jpsoft/smart/modules/base/entity/PunchLocation.java

@@ -0,0 +1,86 @@
+package com.jpsoft.smart.modules.base.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+  描述:base_punch_location的实体类
+ */
+@Data
+@ApiModel(value = "base_punch_location的实体类")
+public class PunchLocation {
+	/**
+	 *
+	 */
+        @ApiModelProperty(value = "")
+	private String id;
+	/**
+	 *学校ID
+	 */
+        @ApiModelProperty(value = "学校ID")
+	private String companyId;
+	/**
+	 *学校ID
+	 */
+	@ApiModelProperty(value = "学校ID")
+	private String companyName;
+	/**
+	 *打卡点名称
+	 */
+        @ApiModelProperty(value = "打卡点名称")
+	private String name;
+	/**
+	 *打卡点经度
+	 */
+        @ApiModelProperty(value = "打卡点经度")
+	private String longtitude;
+	/**
+	 *打卡点维度
+	 */
+        @ApiModelProperty(value = "打卡点维度")
+	private String latitude;
+	/**
+	 *备注描述
+	 */
+        @ApiModelProperty(value = "备注描述")
+	private String remark;
+	/**
+	 *是否启用
+	 */
+        @ApiModelProperty(value = "是否启用")
+	private Boolean isEnable;
+	/**
+	 *是否删除
+	 */
+        @ApiModelProperty(value = "是否删除")
+	private Boolean delFlag;
+	/**
+	 *创建人
+	 */
+        @ApiModelProperty(value = "创建人")
+	private String createBy;
+	/**
+	 *创建时间
+	 */
+    	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	    @ApiModelProperty(value = "创建时间")
+	private Date createTime;
+	/**
+	 *更新人
+	 */
+        @ApiModelProperty(value = "更新人")
+	private String updateBy;
+	/**
+	 *更新时间
+	 */
+    	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	    @ApiModelProperty(value = "更新时间")
+	private Date updateTime;
+}

+ 76 - 0
common/src/main/java/com/jpsoft/smart/modules/base/entity/PunchRecord.java

@@ -0,0 +1,76 @@
+package com.jpsoft.smart.modules.base.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 描述:base_punch_record的实体类
+ */
+@Data
+@ApiModel(value = "base_punch_record的实体类")
+public class PunchRecord {
+    /**
+     *
+     */
+    @ApiModelProperty(value = "")
+    private String id;
+    /**
+     * 打卡人ID
+     */
+    @ApiModelProperty(value = "打卡人ID")
+    private Long personId;
+    /**
+     * 打卡点ID
+     */
+    @ApiModelProperty(value = "打卡点ID")
+    private String punchId;
+    /**
+     * 备注
+     */
+    @ApiModelProperty(value = "备注")
+    private String remark;
+    /**
+     * 当前经度
+     */
+    @ApiModelProperty(value = "当前经度")
+    private String longtitude;
+    /**
+     * 当前维度
+     */
+    @ApiModelProperty(value = "当前维度")
+    private String latitude;
+    /**
+     * 是否删除
+     */
+    @ApiModelProperty(value = "是否删除")
+    private Boolean delFlag;
+    /**
+     * 创建人
+     */
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+    /**
+     * 创建时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 更新人
+     */
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+    /**
+     * 更新时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
+    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
+}

+ 18 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/PunchLocationService.java

@@ -0,0 +1,18 @@
+package com.jpsoft.smart.modules.base.service;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.smart.modules.base.entity.PunchLocation;
+import com.jpsoft.smart.modules.common.dto.Sort;
+
+import java.util.List;
+import java.util.Map;
+
+public interface PunchLocationService {
+	PunchLocation get(String id);
+	boolean exist(String id);
+	int insert(PunchLocation model);
+	int update(PunchLocation model);
+	int delete(String id);
+	List<PunchLocation> list();
+	Page<PunchLocation> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
+}

+ 19 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/PunchRecordService.java

@@ -0,0 +1,19 @@
+package com.jpsoft.smart.modules.base.service;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.smart.modules.base.entity.PunchRecord;
+import com.jpsoft.smart.modules.common.dto.Sort;
+
+import java.util.List;
+import java.util.Map;
+
+public interface PunchRecordService {
+	PunchRecord get(String id);
+	boolean exist(String id);
+	int insert(PunchRecord model);
+	int update(PunchRecord model);
+	int delete(String id);
+	List<PunchRecord> list();
+	Page<PunchRecord> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
+    List<PunchRecord> findByPersonAndDate(Long personId, String startDate, String endDate);
+}

+ 70 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PunchLocationServiceImpl.java

@@ -0,0 +1,70 @@
+package com.jpsoft.smart.modules.base.service.impl;
+
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+import com.jpsoft.smart.modules.base.dao.PunchLocationDAO;
+import com.jpsoft.smart.modules.base.entity.PunchLocation;
+import com.jpsoft.smart.modules.base.service.PunchLocationService;
+import com.jpsoft.smart.modules.common.dto.Sort;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+@Transactional
+@Component(value="punchLocationService")
+public class PunchLocationServiceImpl implements PunchLocationService {
+	@Resource(name="punchLocationDAO")
+	private PunchLocationDAO punchLocationDAO;
+
+	@Override
+	public PunchLocation get(String id) {
+		// TODO Auto-generated method stub
+		return punchLocationDAO.get(id);
+	}
+
+	@Override
+	public int insert(PunchLocation model) {
+		// TODO Auto-generated method stub
+		//model.setId(UUID.randomUUID().toString());
+		
+		return punchLocationDAO.insert(model);
+	}
+
+	@Override
+	public int update(PunchLocation model) {
+		// TODO Auto-generated method stub
+		return punchLocationDAO.update(model);		
+	}
+
+	@Override
+	public int delete(String id) {
+		// TODO Auto-generated method stub
+		return punchLocationDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(String id) {
+		// TODO Auto-generated method stub
+		int count = punchLocationDAO.exist(id);
+		
+		return count > 0 ? true : false;
+	}
+	
+	@Override
+	public List<PunchLocation> list() {
+		// TODO Auto-generated method stub
+		return punchLocationDAO.list();
+	}
+		
+	@Override
+	public Page<PunchLocation> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList) {
+        Page<PunchLocation> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
+            punchLocationDAO.search(searchParams,sortList);
+        });
+        
+        return page;
+	}
+}

+ 75 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PunchRecordServiceImpl.java

@@ -0,0 +1,75 @@
+package com.jpsoft.smart.modules.base.service.impl;
+
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+import com.jpsoft.smart.modules.base.dao.PunchRecordDAO;
+import com.jpsoft.smart.modules.base.entity.PunchRecord;
+import com.jpsoft.smart.modules.base.service.PunchRecordService;
+import com.jpsoft.smart.modules.common.dto.Sort;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+@Transactional
+@Component(value="punchRecordService")
+public class PunchRecordServiceImpl implements PunchRecordService {
+	@Resource(name="punchRecordDAO")
+	private PunchRecordDAO punchRecordDAO;
+
+	@Override
+	public PunchRecord get(String id) {
+		// TODO Auto-generated method stub
+		return punchRecordDAO.get(id);
+	}
+
+	@Override
+	public int insert(PunchRecord model) {
+		// TODO Auto-generated method stub
+		//model.setId(UUID.randomUUID().toString());
+
+		return punchRecordDAO.insert(model);
+	}
+
+	@Override
+	public int update(PunchRecord model) {
+		// TODO Auto-generated method stub
+		return punchRecordDAO.update(model);
+	}
+
+	@Override
+	public int delete(String id) {
+		// TODO Auto-generated method stub
+		return punchRecordDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(String id) {
+		// TODO Auto-generated method stub
+		int count = punchRecordDAO.exist(id);
+
+		return count > 0 ? true : false;
+	}
+
+	@Override
+	public List<PunchRecord> list() {
+		// TODO Auto-generated method stub
+		return punchRecordDAO.list();
+	}
+
+	@Override
+	public Page<PunchRecord> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList) {
+        Page<PunchRecord> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
+            punchRecordDAO.search(searchParams,sortList);
+        });
+
+        return page;
+	}
+
+	@Override
+	public List<PunchRecord> findByPersonAndDate(Long personId, String startDate, String endDate) {
+		return punchRecordDAO.findByPersonAndDate(personId,startDate,endDate);
+	}
+}

+ 19 - 5
common/src/main/resources/mapper/base/DeviceInfo.xml

@@ -27,6 +27,9 @@
 		    <result property="heartbeatUpdateTime" column="heartbeat_update_time" />
 		    <result property="abnormalReason" column="abnormal_reason" />
 			<result property="isBind" column="is_bind" />
+			<result property="longtitude" column="longtitude_" />
+			<result property="latitude" column="latitude_" />
+			<result property="deviceAddress" column="device_address" />
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.smart.modules.base.entity.DeviceInfo">
 	<!--
@@ -39,7 +42,8 @@
 	    (id_,header_,device_no,alias_name,address_,is_online,company_id,
 	    unlock_password,code_address,ip_address,port_,type_,is_auto_update,
 	    del_flag,create_by,create_time,update_by,update_time,
-	    default_face_library_id,heartbeat_update_time,abnormal_reason)
+	    default_face_library_id,heartbeat_update_time,abnormal_reason,
+	    longtitude_,latitude_,device_address)
 		values
 		(
 			#{id,jdbcType=VARCHAR}
@@ -63,6 +67,9 @@
 			,#{defaultFaceLibraryId,jdbcType=VARCHAR}
             ,#{heartbeatUpdateTime,jdbcType=TIMESTAMP}
             ,#{abnormalReason,jdbcType=VARCHAR}
+            ,#{longtitude,jdbcType=VARCHAR}
+            ,#{latitude,jdbcType=VARCHAR}
+            ,#{deviceAddress,jdbcType=VARCHAR}
 		)
 	]]>
 	</insert>
@@ -132,16 +139,23 @@
 			<if test="abnormalReason!=null">
 				abnormal_reason=#{abnormalReason,jdbcType= VARCHAR },
 			</if>
+			<if test="longtitude!=null">
+				longtitude_=#{longtitude,jdbcType= VARCHAR },
+			</if>
+			<if test="latitude!=null">
+				latitude_=#{latitude,jdbcType= VARCHAR },
+			</if>
+			<if test="deviceAddress!=null">
+				device_address=#{deviceAddress,jdbcType= VARCHAR },
+			</if>
 		</set>
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="DeviceInfoMap">
-		select
-id_, header_,device_no,alias_name,address_,is_online,company_id,unlock_password,code_address,ip_address,port_,type_,is_auto_update,del_flag,create_by,create_time,update_by,update_time,default_face_library_id		from base_device_info where id_=#{0}
+		select * from base_device_info where id_=#{0}
 	</select>
 	<select id="getByDeviceNo" parameterType="string" resultMap="DeviceInfoMap">
-		select
-id_, header_,device_no,alias_name,address_,is_online,company_id,unlock_password,code_address,ip_address,port_,type_,is_auto_update,del_flag,create_by,create_time,update_by,update_time,default_face_library_id,heartbeat_update_time,abnormal_reason		from base_device_info where device_no=#{0} and del_flag=false
+		select * from base_device_info where device_no=#{0} and del_flag=false
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
 		select count(*) from base_device_info where id_=#{0} and  del_flag=false

+ 128 - 0
common/src/main/resources/mapper/base/PunchLocation.xml

@@ -0,0 +1,128 @@
+<?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">
+<!-- namespace必须指向DAO接口 -->
+<mapper namespace="com.jpsoft.smart.modules.base.dao.PunchLocationDAO">
+	<resultMap id="PunchLocationMap" type="com.jpsoft.smart.modules.base.entity.PunchLocation">
+		<id property="id" column="id_" />
+			<result property="companyId" column="company_id" />
+			<result property="companyName" column="company_name" />
+			<result property="name" column="name_" />
+			<result property="longtitude" column="longtitude_" />
+			<result property="latitude" column="latitude_" />
+			<result property="remark" column="remark_" />
+			<result property="isEnable" column="is_enable" />
+			<result property="delFlag" column="del_flag" />
+			<result property="createBy" column="create_by" />
+			<result property="createTime" column="create_time" />
+			<result property="updateBy" column="update_by" />
+			<result property="updateTime" column="update_time" />
+			</resultMap>
+	<insert id="insert" parameterType="com.jpsoft.smart.modules.base.entity.PunchLocation">
+	<!--
+	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+		select sys_guid() from dual
+	</selectKey>
+	-->
+	<![CDATA[
+		insert into base_punch_location
+	    (id_,company_id,name_,longtitude_,latitude_,remark_,is_enable,del_flag,create_by,create_time,update_by,update_time)
+		values
+		(
+#{id,jdbcType=VARCHAR}
+,#{companyId,jdbcType=VARCHAR}
+,#{name,jdbcType=VARCHAR}
+,#{longtitude,jdbcType=VARCHAR}
+,#{latitude,jdbcType=VARCHAR}
+,#{remark,jdbcType=VARCHAR}
+,#{isEnable,jdbcType= NUMERIC }
+,#{delFlag,jdbcType= NUMERIC }
+,#{createBy,jdbcType=VARCHAR}
+,#{createTime,jdbcType= TIMESTAMP }
+,#{updateBy,jdbcType=VARCHAR}
+,#{updateTime,jdbcType= TIMESTAMP }
+		)
+	]]>
+	</insert>
+	<delete id="delete" parameterType="string">
+		delete from base_punch_location where id_=#{id,jdbcType=VARCHAR}
+	</delete>
+	<update id="update" parameterType="com.jpsoft.smart.modules.base.entity.PunchLocation">
+		update base_punch_location
+		<set>
+				<if test="companyId!=null">
+		company_id=#{companyId,jdbcType=VARCHAR},
+		</if>
+				<if test="name!=null">
+		name_=#{name,jdbcType=VARCHAR},
+		</if>
+				<if test="longtitude!=null">
+		longtitude_=#{longtitude,jdbcType=VARCHAR},
+		</if>
+				<if test="latitude!=null">
+		latitude_=#{latitude,jdbcType=VARCHAR},
+		</if>
+				<if test="remark!=null">
+		remark_=#{remark,jdbcType=VARCHAR},
+		</if>
+				<if test="isEnable!=null">
+		is_enable=#{isEnable,jdbcType= NUMERIC },
+		</if>
+				<if test="delFlag!=null">
+		del_flag=#{delFlag,jdbcType= NUMERIC },
+		</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>
+		</set>
+	where id_=#{id}
+	</update>
+	<select id="get" parameterType="string" resultMap="PunchLocationMap">
+		select * from base_punch_location where id_=#{0} and del_flag = 0
+	</select>
+	<select id="exist" parameterType="string" resultType="int">
+		select count(*) from base_punch_location where id_=#{0} and del_flag = 0
+	</select>
+	<select id="list" resultMap="PunchLocationMap">
+		select * from base_punch_location where del_flag = 0
+	</select>
+	<select id="search" parameterType="hashmap" resultMap="PunchLocationMap">
+		<![CDATA[
+			select a.*,b.name_ as company_name
+			from base_punch_location a left join base_company_info b on a.company_id = b.id_ and b.del_flag = 0
+		]]>
+		<where>
+			a.del_flag = 0
+			<if test="searchParams.id != null">
+				and a.ID_ like #{searchParams.id}
+			</if>
+			<if test="searchParams.companyId != null">
+				and a.company_id = #{searchParams.companyId}
+			</if>
+			<if test="searchParams.companyIds != null">
+				and a.company_id in
+				<foreach collection="searchParams.companyIds" item="companyId" open="( "  close=" ) " separator=",">
+					#{companyId}
+				</foreach>
+			</if>
+			<if test="searchParams.name != null">
+				and a.name_ like #{searchParams.name}
+			</if>
+			<if test="searchParams.isEnable != null">
+				and a.is_enable = #{searchParams.isEnable}
+			</if>
+		</where>
+		<foreach item="sort" collection="sortList"  open="order by" separator=",">
+	        ${sort.name} ${sort.order}
+	 	</foreach>
+	</select>
+</mapper>

+ 124 - 0
common/src/main/resources/mapper/base/PunchRecord.xml

@@ -0,0 +1,124 @@
+<?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">
+<!-- namespace必须指向DAO接口 -->
+<mapper namespace="com.jpsoft.smart.modules.base.dao.PunchRecordDAO">
+	<resultMap id="PunchRecordMap" type="com.jpsoft.smart.modules.base.entity.PunchRecord">
+		<id property="id" column="id_" />
+			<result property="personId" column="person_id" />
+			<result property="punchId" column="punch_id" />
+			<result property="remark" column="remark_" />
+			<result property="longtitude" column="longtitude_" />
+			<result property="latitude" column="latitude_" />
+			<result property="delFlag" column="del_flag" />
+			<result property="createBy" column="create_by" />
+			<result property="createTime" column="create_time" />
+			<result property="updateBy" column="update_by" />
+			<result property="updateTime" column="update_time" />
+			</resultMap>
+	<insert id="insert" parameterType="com.jpsoft.smart.modules.base.entity.PunchRecord">
+	<!--
+	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+		select sys_guid() from dual
+	</selectKey>
+	-->
+	<![CDATA[
+		insert into base_punch_record
+	    (id_,person_id,punch_id,remark_,longtitude_,latitude_,del_flag,create_by,create_time,update_by,update_time)
+		values
+		(
+#{id,jdbcType=VARCHAR}
+,#{personId,jdbcType= NUMERIC }
+,#{punchId,jdbcType=VARCHAR}
+,#{remark,jdbcType=VARCHAR}
+,#{longtitude,jdbcType=VARCHAR}
+,#{latitude,jdbcType=VARCHAR}
+,#{delFlag,jdbcType= NUMERIC }
+,#{createBy,jdbcType=VARCHAR}
+,#{createTime,jdbcType= TIMESTAMP }
+,#{updateBy,jdbcType=VARCHAR}
+,#{updateTime,jdbcType= TIMESTAMP }
+		)
+	]]>
+	</insert>
+	<delete id="delete" parameterType="string">
+		delete from base_punch_record where id_=#{id,jdbcType=VARCHAR}
+	</delete>
+	<update id="update" parameterType="com.jpsoft.smart.modules.base.entity.PunchRecord">
+		update base_punch_record
+		<set>
+				<if test="personId!=null">
+		person_id=#{personId,jdbcType= NUMERIC },
+		</if>
+				<if test="punchId!=null">
+		punch_id=#{punchId,jdbcType=VARCHAR},
+		</if>
+				<if test="remark!=null">
+		remark_=#{remark,jdbcType=VARCHAR},
+		</if>
+				<if test="longtitude!=null">
+		longtitude_=#{longtitude,jdbcType=VARCHAR},
+		</if>
+				<if test="latitude!=null">
+		latitude_=#{latitude,jdbcType=VARCHAR},
+		</if>
+				<if test="delFlag!=null">
+		del_flag=#{delFlag,jdbcType= NUMERIC },
+		</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>
+		</set>
+	where id_=#{id}
+	</update>
+	<select id="get" parameterType="string" resultMap="PunchRecordMap">
+		select * from base_punch_record where id_=#{0} and del_flag = 0
+	</select>
+	<select id="exist" parameterType="string" resultType="int">
+		select count(*) from base_punch_record where id_=#{0} and del_flag = 0
+	</select>
+	<select id="list" resultMap="PunchRecordMap">
+		select * from base_punch_record where del_flag = 0
+	</select>
+	<select id="search" parameterType="hashmap" resultMap="PunchRecordMap">
+		<![CDATA[
+			select * from base_punch_record
+		]]>
+		<where>
+			del_flag = 0
+			<if test="searchParams.id != null">
+				and ID_ like #{searchParams.id}
+			</if>
+			<if test="searchParams.personId != null">
+				and person_id = #{searchParams.personId}
+			</if>
+			<if test="searchParams.punchId != null">
+				and punch_id = #{searchParams.punchId}
+			</if>
+			<if test="searchParams.qtCreateTime != null">
+				and create_time > #{searchParams.qtCreateTime}
+			</if>
+		</where>
+		<foreach item="sort" collection="sortList"  open="order by" separator=",">
+	        ${sort.name} ${sort.order}
+	 	</foreach>
+	</select>
+
+	<select id="findByPersonAndDate" resultMap="PunchRecordMap">
+		select * from base_punch_record where person_id = #{personId}
+		and del_flag=false
+		<![CDATA[
+           and create_time >= #{startDate} and create_time <= #{endDate}
+        ]]>
+		order by create_time desc
+	</select>
+</mapper>

+ 3 - 0
common/src/main/resources/mapper/sys/SysLog.xml

@@ -100,6 +100,9 @@
                     and elapse_ <= #{searchParams.elapseMax}
                 ]]>
             </if>
+            <if test="searchParams.remark != null">
+                and remark_ like #{searchParams.remark}
+            </if>
         </where>
         <foreach item="sort" collection="sortList" open="order by" separator=",">
             ${sort.name} ${sort.order}

+ 96 - 3
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java

@@ -26,6 +26,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
+import org.joda.time.DateTime;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -61,17 +62,20 @@ public class PersonInfoController {
     private PersonDeviceRelationService personDeviceRelationService;
     @Autowired
     private DeviceInfoService deviceInfoService;
-
     @Autowired
     private CompanyInfoService companyInfoService;
-
     @Autowired
     private PersonCompanyService personCompanyService;
     @Autowired
     private CompanyPositionService companyPositionService;
-
     @Autowired
     private DataDictionaryService dataDictionaryService;
+    @Autowired
+    private PersonDeviceFilterLogService personDeviceFilterLogService;
+    @Autowired
+    private PunchLocationService punchLocationService;
+    @Autowired
+    private PunchRecordService punchRecordService;
 
     @ApiOperation(value="创建空记录")
     @GetMapping("create")
@@ -1325,5 +1329,94 @@ public class PersonInfoController {
         return bl;
     }
 
+    @PostMapping("lifeRecordList")
+    @ResponseBody
+    @ApiOperation(value = "生活记录列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "queryDate", value = "选择日期,格式:yyyy-MM-dd", required = true, paramType = "query"),
+            @ApiImplicitParam(name = "personId", value = "人员ID", required = true, paramType = "query")
+    })
+    public MessageResult<List<Map<String, Object>> > lifeRecordList(String queryDate, String personId, @RequestAttribute String subject) {
+        MessageResult<List<Map<String, Object>> > messageResult = new MessageResult<>();
+
+        Map<String, Object> mapData = new HashMap<>();
+
+        try {
+            List<Map<String, Object>> list = new ArrayList<>();
+
+            PersonInfo personInfo = personInfoService.get(Long.valueOf(personId));
+
+            if (personInfo == null) {
+                throw new Exception("当前用户不存在!");
+            }
+
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            Date query = sdf.parse(queryDate);
+
+            Date endDate = new DateTime(query).plusDays(1).toDate();
+
+            String start = queryDate;
+            String end = sdf.format(endDate);
+
+            List<PersonDeviceFilterLog> personDeviceFilterLogList = personDeviceFilterLogService.findByPersonAndDate(personInfo.getId(), start, end);
+
+            for (PersonDeviceFilterLog item : personDeviceFilterLogList) {
+                Map<String, Object> map = new HashMap<>();
+
+                if (item.getRecordTime() != null) {
+                    String recordTime = sdf1.format(item.getRecordTime());
+                    map.put("recordTime", recordTime);
+
+                    DeviceInfo device = deviceInfoService.getByDeviceNo(item.getDeviceNo());
+                    String deviceName = "";
+                    String longtitude = "";
+                    String latitude = "";
+                    if (device != null) {
+                        deviceName = device.getAliasName() + "打卡";
+                        longtitude = device.getLongtitude();
+                        latitude = device.getLatitude();
+                    }
+
+                    map.put("deviceName", deviceName);
+                    map.put("longtitude", longtitude);
+                    map.put("latitude", latitude);
+                }
+
+                list.add(map);
+            }
+
+            List<PunchRecord> punchRecordList = punchRecordService.findByPersonAndDate(personInfo.getId(), start, end);
+            if (punchRecordList.size()>0){
+                for (PunchRecord punchRecord : punchRecordList){
+                    PunchLocation punchLocation = punchLocationService.get(punchRecord.getPunchId());
+                    if (punchLocation != null){
+                        Map<String, Object> map = new HashMap<>();
+                        map.put("recordTime",sdf1.format(punchRecord.getCreateTime()));
+                        map.put("deviceName", punchLocation.getName());
+                        map.put("longtitude", punchLocation.getLongtitude());
+                        map.put("latitude", punchLocation.getLatitude());
+                        list.add(map);
+                    }
+                }
+            }
+
+            List<Map<String, Object>> sortedList = list.stream().sorted(((l,r)->{
+                String time1 = (String)l.get("recordTime");
+                String time2 = (String)r.get("recordTime");
+
+                return time2.compareTo(time1);
+            })).collect(Collectors.toList());
+
+            messageResult.setData(sortedList);
+            messageResult.setResult(true);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+            messageResult.setMessage(ex.getMessage());
+            messageResult.setResult(false);
+        }
+        return messageResult;
+    }
+
 
 }

+ 303 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/PunchLocationController.java

@@ -0,0 +1,303 @@
+package com.jpsoft.smart.modules.base.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.smart.modules.base.entity.CompanyInfo;
+import com.jpsoft.smart.modules.base.entity.PunchLocation;
+import com.jpsoft.smart.modules.base.service.CompanyInfoService;
+import com.jpsoft.smart.modules.base.service.PunchLocationService;
+import com.jpsoft.smart.modules.common.dto.MessageResult;
+import com.jpsoft.smart.modules.common.dto.Sort;
+import com.jpsoft.smart.modules.common.utils.PojoUtils;
+import com.jpsoft.smart.modules.sys.entity.User;
+import com.jpsoft.smart.modules.sys.service.UserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+
+@RestController
+@RequestMapping("/base/punchLocation")
+@Api(description = "punchLocation")
+public class PunchLocationController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private PunchLocationService punchLocationService;
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private CompanyInfoService companyInfoService;
+
+    @ApiOperation(value="创建空记录")
+    @GetMapping("create")
+    public MessageResult<PunchLocation> create(){
+        MessageResult<PunchLocation> msgResult = new MessageResult<>();
+
+        PunchLocation punchLocation = new PunchLocation();
+
+        msgResult.setData(punchLocation);
+        msgResult.setResult(true);
+
+        return msgResult;
+    }
+    
+    @ApiOperation(value="添加信息")
+    @PostMapping("add")
+    public MessageResult<PunchLocation> add(@RequestBody PunchLocation punchLocation, @RequestAttribute String subject){
+        MessageResult<PunchLocation> msgResult = new MessageResult<>();
+
+        try {
+            punchLocation.setId(UUID.randomUUID().toString());
+            punchLocation.setDelFlag(false);
+            punchLocation.setIsEnable(false);
+            punchLocation.setCreateBy(subject);
+            punchLocation.setCreateTime(new Date());
+            
+            int affectCount = punchLocationService.insert(punchLocation);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(punchLocation);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库添加失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="获取信息")
+    @GetMapping("edit/{id}")
+    public MessageResult<PunchLocation> edit(@PathVariable("id") String id){
+        MessageResult<PunchLocation> msgResult = new MessageResult<>();
+
+        try {
+            PunchLocation punchLocation = punchLocationService.get(id);
+
+            if (punchLocation != null) {
+                msgResult.setResult(true);
+                msgResult.setData(punchLocation);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="更新用户")
+    @PostMapping("update")
+    public MessageResult<PunchLocation> update(@RequestBody PunchLocation punchLocation, @RequestAttribute String subject){
+        MessageResult<PunchLocation> msgResult = new MessageResult<>();
+
+        try {
+            punchLocation.setUpdateBy(subject);
+            punchLocation.setUpdateTime(new Date());
+            
+            int affectCount = punchLocationService.update(punchLocation);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(punchLocation);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库更新失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+	@ApiOperation(value="删除")
+    @PostMapping("delete/{id}")
+    public MessageResult<Integer> delete(@PathVariable("id") String id, @RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            PunchLocation punchLocation = punchLocationService.get(id);
+            punchLocation.setDelFlag(true);
+            punchLocation.setUpdateBy(subject);
+            punchLocation.setUpdateTime(new Date());
+
+            int affectCount = punchLocationService.update(punchLocation);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value="批量删除")
+    @PostMapping("batchDelete")
+    public MessageResult<Integer> batchDelete(@RequestBody List<String> idList, @RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            int affectCount = 0;
+
+            for (String id : idList) {
+                PunchLocation punchLocation = punchLocationService.get(id);
+                punchLocation.setDelFlag(true);
+                punchLocation.setUpdateBy(subject);
+                punchLocation.setUpdateTime(new Date());
+
+                affectCount += punchLocationService.update(punchLocation);
+            }
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="列表")
+    @RequestMapping(value = "pageList",method = RequestMethod.POST)
+    public MessageResult<Map> pageList(
+            String id,
+            @RequestParam(value="companyId",defaultValue="") String companyId,
+            @RequestParam(value="name",defaultValue="") String name,
+            @RequestParam(value="isEnable",defaultValue="") String isEnable,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
+            @RequestAttribute String subject){
+
+        //当前用户ID
+        System.out.println(subject);
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("b.sort_no","asc"));
+        sortList.add(new Sort("a.create_time","asc"));
+
+        //当前用户ID
+        User user = userService.get(subject);
+        CompanyInfo companyInfo = companyInfoService.get(user.getCompanyId());
+
+        if (!userService.hasRole(subject,"SYSADMIN")) {
+            String[] arr = companyInfo.getCode().split(",");
+            searchParams.put("companyIds",  Arrays.asList(arr));
+        }
+
+        if (StringUtils.isNotEmpty(id)) {
+            searchParams.put("id","%" + id + "%");
+        }
+
+        if (StringUtils.isNotEmpty(companyId)) {
+            searchParams.put("companyId" ,companyId);
+        }
+
+        if (StringUtils.isNotEmpty(name)) {
+            searchParams.put("name","%" + name + "%");
+        }
+        if (StringUtils.isNotEmpty(isEnable)) {
+            searchParams.put("isEnable",isEnable);
+        }
+
+        Page<PunchLocation> page = punchLocationService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "修改启用状态")
+    @PostMapping("changeEnable")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "编号", required = false, paramType = "form", dataType = "String")
+    })
+    public MessageResult<Boolean> changeEnable(@RequestParam(value = "id", defaultValue = "") String id, @RequestAttribute String subject) {
+        HSSFWorkbook workbook = new HSSFWorkbook();
+        HSSFSheet sheet = workbook.createSheet();
+        MessageResult<Boolean> msgResult = new MessageResult<>();
+        msgResult.setData(true);
+
+        try {
+            PunchLocation punchLocation = punchLocationService.get(id);
+
+            if (punchLocation.getIsEnable()) {
+                punchLocation.setIsEnable(false);
+            } else {
+                if(StringUtils.isNotEmpty(punchLocation.getLatitude())) {
+                    punchLocation.setIsEnable(true);
+                }else{
+                    throw new Exception("请先完成定位!");
+                }
+            }
+            punchLocation.setUpdateBy(subject);
+            punchLocation.setUpdateTime(new Date());
+
+            int affectCount = punchLocationService.update(punchLocation);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("保存失败");
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+}

+ 128 - 0
web/src/main/java/com/jpsoft/smart/modules/sys/controller/LogController.java

@@ -0,0 +1,128 @@
+package com.jpsoft.smart.modules.sys.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.smart.modules.common.dto.MessageResult;
+import com.jpsoft.smart.modules.common.dto.Sort;
+import com.jpsoft.smart.modules.common.utils.PojoUtils;
+import com.jpsoft.smart.modules.sys.entity.SysLog;
+import com.jpsoft.smart.modules.sys.service.SysLogService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+
+@RestController
+@RequestMapping("/sys/log")
+@Api(description = "系统日志")
+public class LogController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private SysLogService sysLogService;
+
+    @GetMapping("add")
+    @Transactional(rollbackFor = Exception.class)
+    public MessageResult<SysLog> add() throws Exception{
+        MessageResult<SysLog> messageResult = new MessageResult<>();
+
+        SysLog sysLog = new SysLog();
+        sysLog.setUserId("test");
+        messageResult.setData(sysLog);
+
+        int affectCount = sysLogService.insert(sysLog);
+
+        logger.warn("affectCount=" + affectCount);
+
+        if (affectCount>0){
+            throw new Exception("回滚测试");
+        }
+
+        return messageResult;
+    }
+
+    @ApiOperation(value="列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "userId",value = "用户编号", paramType = "form"),
+            @ApiImplicitParam(name = "url",value = "url",  paramType = "form"),
+            @ApiImplicitParam(name = "remoteIP",value = "远程IP", paramType="form"),
+            @ApiImplicitParam(name = "startTime",value = "开始时间", paramType="form"),
+            @ApiImplicitParam(name = "endTime",value = "结束时间", paramType="form"),
+            @ApiImplicitParam(name = "elapseMin",value = "耗时大于(毫秒)", paramType="form"),
+            @ApiImplicitParam(name = "elapseMax",value = "耗时小于(毫秒)", paramType="form"),
+            @ApiImplicitParam(name = "pointcut",value = "切入口", paramType="form"),
+            @ApiImplicitParam(name = "remoteIP",value = "远程IP", paramType="form"),
+            @ApiImplicitParam(name = "remark",value = "备注", paramType="form")
+    })
+    @RequestMapping(value = "pageList",method = RequestMethod.POST)
+    public MessageResult<Map> pageList(
+            String userId,
+            String url,
+            String remoteIP,
+            Long elapseMin,
+            Long elapseMax,
+            String pointcut,
+            String remark,
+            @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") Date startTime,
+            @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") Date endTime,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize){
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("create_time","desc"));
+
+        if (StringUtils.isNotEmpty(userId)) {
+            searchParams.put("userId",userId);
+        }
+
+        if (StringUtils.isNotEmpty(url)) {
+            searchParams.put("url",url + "%");
+        }
+
+        if (StringUtils.isNotEmpty(remoteIP)) {
+            searchParams.put("remoteIP",remoteIP + "%");
+        }
+
+        if (StringUtils.isNotEmpty(pointcut)) {
+            searchParams.put("pointcut",pointcut + "%");
+        }
+
+        if (startTime!=null) {
+            searchParams.put("startTime",startTime);
+        }
+
+        if (endTime!=null) {
+            searchParams.put("endTime",endTime);
+        }
+
+        if (elapseMin!=null){
+            searchParams.put("elapseMin",elapseMin);
+        }
+
+        if (elapseMax!=null){
+            searchParams.put("elapseMax",elapseMax);
+        }
+
+        if (StringUtils.isNotEmpty(remark)) {
+            searchParams.put("remark","%" + remark + "%");
+        }
+
+        Page<SysLog> page = sysLogService.pageSearch(searchParams,pageIndex,pageSize,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+}