考勤配置增加默认选项
parent
70de0ffc14
commit
fdc8f217d9
|
|
@ -0,0 +1,16 @@
|
|||
### 1.给attendance_cfg表中增加is_default int 1-默认,0-非默认
|
||||
|
||||
更新历史数据
|
||||
|
||||
UPDATE attendance_cfg set is_default=1
|
||||
|
||||
更新历史数据
|
||||
|
||||
UPDATE pro_mobile_attendance_data pmad
|
||||
INNER JOIN (
|
||||
SELECT ac.project_id, ac.id AS cfg_id
|
||||
FROM attendance_cfg ac
|
||||
WHERE ac.is_default = 1 AND ac.enabled = 1
|
||||
) ac ON pmad.project_id = ac.project_id
|
||||
SET pmad.cfg_id = ac.cfg_id
|
||||
WHERE pmad.att_device = 'device' AND pmad.cfg_id = 0;
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
-- 更新pro_mobile_attendance_data表的cfg_id,根据project_id从attendance_cfg中找到默认配置ID
|
||||
UPDATE pro_mobile_attendance_data pmad
|
||||
INNER JOIN (
|
||||
SELECT ac.project_id, ac.id AS cfg_id
|
||||
FROM attendance_cfg ac
|
||||
WHERE ac.is_default = 1 AND ac.enabled = 1
|
||||
) ac ON pmad.project_id = ac.project_id
|
||||
SET pmad.cfg_id = ac.cfg_id
|
||||
WHERE pmad.att_device = 'device' AND pmad.cfg_id = 0;
|
||||
|
||||
-- 测试查询:查看更新效果
|
||||
SELECT pmad.id, pmad.project_id, pmad.cfg_id, ac.id AS new_cfg_id
|
||||
FROM pro_mobile_attendance_data pmad
|
||||
LEFT JOIN (
|
||||
SELECT ac.project_id, ac.id
|
||||
FROM attendance_cfg ac
|
||||
WHERE ac.is_default = 1 AND ac.enabled = 1
|
||||
) ac ON pmad.project_id = ac.project_id
|
||||
WHERE pmad.att_device = 'device' AND pmad.cfg_id = 0;
|
||||
|
||||
-- 分批更新(可选,适用于大数据量)
|
||||
UPDATE pro_mobile_attendance_data pmad
|
||||
INNER JOIN (
|
||||
SELECT ac.project_id, ac.id AS cfg_id
|
||||
FROM attendance_cfg ac
|
||||
WHERE ac.is_default = 1 AND ac.enabled = 1
|
||||
) ac ON pmad.project_id = ac.project_id
|
||||
SET pmad.cfg_id = ac.cfg_id
|
||||
WHERE pmad.att_device = 'device' AND pmad.cfg_id = 0
|
||||
LIMIT 1000;
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -37,6 +37,10 @@ public class AttendanceCfg extends BaseEntity
|
|||
@Excel(name = "1-启用,0-停用")
|
||||
private Long enabled;
|
||||
|
||||
/** 1-默认,0-非默认 */
|
||||
@Excel(name = "1-默认,0-非默认")
|
||||
private Long isDefault;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态")
|
||||
private Long state;
|
||||
|
|
@ -118,6 +122,15 @@ public class AttendanceCfg extends BaseEntity
|
|||
{
|
||||
return enabled;
|
||||
}
|
||||
public void setIsDefault(Long isDefault)
|
||||
{
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
public Long getIsDefault()
|
||||
{
|
||||
return isDefault;
|
||||
}
|
||||
public void setState(Long state)
|
||||
{
|
||||
this.state = state;
|
||||
|
|
@ -174,6 +187,7 @@ public class AttendanceCfg extends BaseEntity
|
|||
.append("vendorsCode", getVendorsCode())
|
||||
.append("vendorsParameter", getVendorsParameter())
|
||||
.append("enabled", getEnabled())
|
||||
.append("isDefault", getIsDefault())
|
||||
.append("state", getState())
|
||||
.append("remark", getRemark())
|
||||
.append("isDel", getIsDel())
|
||||
|
|
|
|||
|
|
@ -64,4 +64,14 @@ public interface AttendanceCfgMapper
|
|||
* 获取物机管理配置
|
||||
*/
|
||||
String getMachMaterCfg(@Param("projectId") Long projectId,@Param("cfgType") String cfgType);
|
||||
|
||||
/**
|
||||
* 根据项目ID和公司ID查询默认配置
|
||||
*/
|
||||
AttendanceCfg selectDefaultCfgByProjectAndCom(@Param("projectId") Long projectId, @Param("comId") Long comId);
|
||||
|
||||
/**
|
||||
* 根据设备编号查询默认配置
|
||||
*/
|
||||
AttendanceCfg selectDefaultCfgByDeviceNo(@Param("deviceNo") String deviceNo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="vendorsCode" column="vendors_code" />
|
||||
<result property="vendorsParameter" column="vendors_parameter" />
|
||||
<result property="enabled" column="enabled" />
|
||||
<result property="isDefault" column="is_default" />
|
||||
<result property="state" column="state" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="isDel" column="is_del" />
|
||||
|
|
@ -26,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectAttendanceCfgVo">
|
||||
SELECT ac.id, ac.com_id, ac.project_id, ac.vendors_code, ac.vendors_parameter, ac.enabled, ac.state, ac.remark, ac.is_del, ac.create_by, ac.create_time, ac.update_by
|
||||
SELECT ac.id, ac.com_id, ac.project_id, ac.vendors_code, ac.vendors_parameter, ac.enabled, ac.is_default, ac.state, ac.remark, ac.is_del, ac.create_by, ac.create_time, ac.update_by
|
||||
, ac.update_time,dp.`dept_name` comp_name,pp.`project_name`,dic.`dict_label` vendors_name,sd.sub_dept_name dept_name,ac.dept_id
|
||||
FROM attendance_cfg ac
|
||||
LEFT JOIN sys_dept dp ON ac.`com_id`=dp.`dept_id`
|
||||
|
|
@ -62,6 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="vendorsCode != null">vendors_code,</if>
|
||||
<if test="vendorsParameter != null">vendors_parameter,</if>
|
||||
<if test="enabled != null">enabled,</if>
|
||||
<if test="isDefault != null">is_default,</if>
|
||||
<if test="state != null">state,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="isDel != null">is_del,</if>
|
||||
|
|
@ -77,6 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="vendorsCode != null">#{vendorsCode},</if>
|
||||
<if test="vendorsParameter != null">#{vendorsParameter},</if>
|
||||
<if test="enabled != null">#{enabled},</if>
|
||||
<if test="isDefault != null">#{isDefault},</if>
|
||||
<if test="state != null">#{state},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="isDel != null">#{isDel},</if>
|
||||
|
|
@ -96,6 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="vendorsCode != null">vendors_code = #{vendorsCode},</if>
|
||||
<if test="vendorsParameter != null">vendors_parameter = #{vendorsParameter},</if>
|
||||
<if test="enabled != null">enabled = #{enabled},</if>
|
||||
<if test="isDefault != null">is_default = #{isDefault},</if>
|
||||
<if test="state != null">state = #{state},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="isDel != null">is_del = #{isDel},</if>
|
||||
|
|
@ -120,4 +124,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="getMachMaterCfg" resultType="String">
|
||||
select param_data from pro_machmater_config where project_id=#{projectId} and cfg_type=#{cfgType} LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectDefaultCfgByProjectAndCom" resultMap="AttendanceCfgResult">
|
||||
<include refid="selectAttendanceCfgVo"/>
|
||||
where ac.project_id = #{projectId} and ac.com_id = #{comId} and ac.is_default = 1 and ac.enabled = 1
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectDefaultCfgByDeviceNo" resultMap="AttendanceCfgResult">
|
||||
<include refid="selectAttendanceCfgVo"/>
|
||||
where exists (
|
||||
select 1 from attendance_ubi_device ad
|
||||
where ad.device_no = #{deviceNo}
|
||||
and ad.project_id = ac.project_id
|
||||
and ad.com_id = ac.com_id
|
||||
)
|
||||
and ac.is_default = 1 and ac.enabled = 1
|
||||
limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
|
|||
import com.yanzhu.common.core.utils.DateUtils;
|
||||
import com.yanzhu.common.core.utils.StringUtils;
|
||||
import com.yanzhu.common.core.web.domain.AjaxResult;
|
||||
import com.yanzhu.manage.domain.AttendanceCfg;
|
||||
import com.yanzhu.manage.domain.AttendanceUbiData;
|
||||
import com.yanzhu.manage.domain.AttendanceUbiDevice;
|
||||
import com.yanzhu.manage.domain.ProMobileAttendanceData;
|
||||
|
|
@ -36,6 +37,9 @@ public class UniCallBackController {
|
|||
@Autowired
|
||||
private IProMobileAttendanceDataService proMobileAttendanceDataService;
|
||||
|
||||
@Autowired
|
||||
private IAttendanceCfgService attendanceCfgService;
|
||||
|
||||
/**
|
||||
* 识别回调
|
||||
* @return
|
||||
|
|
@ -123,7 +127,11 @@ public class UniCallBackController {
|
|||
if(device==null){
|
||||
return AjaxResult.error("没有查询到设备No");
|
||||
}
|
||||
|
||||
AttendanceCfg cfg = attendanceCfgService.selectDefaultCfgByDeviceNo(deviceNo);
|
||||
Long cfgId = (cfg != null && cfg.getId() != null) ? cfg.getId() : 0L;
|
||||
ProMobileAttendanceData attendanceData=new ProMobileAttendanceData();
|
||||
attendanceData.setCfgId(cfgId);
|
||||
if(list.size()==0){
|
||||
//增加操作
|
||||
ProProjectInfoSubdeptsUsers userWhere=new ProProjectInfoSubdeptsUsers();
|
||||
|
|
@ -153,6 +161,7 @@ public class UniCallBackController {
|
|||
attendanceData.setAttDate(showTime);
|
||||
attendanceData.setAttImg(filePath);
|
||||
attendanceData.setWorkAreaId(device.getWorkAreaId());
|
||||
attendanceData.setCfgId(cfgId);
|
||||
if(device.getDirection()==0) {
|
||||
addData.setInTime(showTime);
|
||||
addData.setInData(data);
|
||||
|
|
@ -184,6 +193,7 @@ public class UniCallBackController {
|
|||
attendanceData.setProjectId(projectId);
|
||||
attendanceData.setAttDate(showTime);
|
||||
attendanceData.setAttImg(filePath);
|
||||
attendanceData.setCfgId(cfgId);
|
||||
if(device.getDirection()==0){
|
||||
attendanceData.setInOut("in");
|
||||
proMobileAttendanceDataService.addAttendanceData(attendanceData);
|
||||
|
|
|
|||
|
|
@ -63,4 +63,14 @@ public interface IAttendanceCfgService
|
|||
* 获取物机管理配置
|
||||
*/
|
||||
String getMachMaterCfg(Long projectId, String cfgType);
|
||||
|
||||
/**
|
||||
* 根据项目ID和公司ID查询默认配置
|
||||
*/
|
||||
AttendanceCfg selectDefaultCfgByProjectAndCom(Long projectId, Long comId);
|
||||
|
||||
/**
|
||||
* 根据设备编号查询默认配置
|
||||
*/
|
||||
AttendanceCfg selectDefaultCfgByDeviceNo(String deviceNo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,9 +59,17 @@ public class AttendanceCfgServiceImpl implements IAttendanceCfgService
|
|||
AttendanceCfg query = new AttendanceCfg();
|
||||
query.setProjectId(attendanceCfg.getProjectId());
|
||||
List<AttendanceCfg> cfgs = attendanceCfgMapper.selectAttendanceCfgList(query);
|
||||
|
||||
if(cfgs.size()>0){
|
||||
throw new ServiceException("当前项目已配置考勤信息...");
|
||||
}
|
||||
|
||||
if(attendanceCfg.getEnabled() != null || attendanceCfg.getEnabled() == 0L){
|
||||
attendanceCfg.setIsDefault(0L);
|
||||
} else if(attendanceCfg.getIsDefault() == null){
|
||||
attendanceCfg.setIsDefault(1L);
|
||||
}
|
||||
|
||||
attendanceCfg.setCreateBy(SecurityContextHolder.getUserName());
|
||||
attendanceCfg.setCreateTime(DateUtils.getNowDate());
|
||||
return attendanceCfgMapper.insertAttendanceCfg(attendanceCfg);
|
||||
|
|
@ -76,6 +84,26 @@ public class AttendanceCfgServiceImpl implements IAttendanceCfgService
|
|||
@Override
|
||||
public int updateAttendanceCfg(AttendanceCfg attendanceCfg)
|
||||
{
|
||||
if(attendanceCfg.getIsDefault() != null && attendanceCfg.getIsDefault() == 1L){
|
||||
AttendanceCfg currentCfg = attendanceCfgMapper.selectAttendanceCfgById(attendanceCfg.getId());
|
||||
if(currentCfg != null && currentCfg.getProjectId() != null){
|
||||
AttendanceCfg query = new AttendanceCfg();
|
||||
query.setProjectId(currentCfg.getProjectId());
|
||||
List<AttendanceCfg> cfgs = attendanceCfgMapper.selectAttendanceCfgList(query);
|
||||
for(AttendanceCfg cfg : cfgs){
|
||||
if(!cfg.getId().equals(attendanceCfg.getId()) && cfg.getIsDefault() != null && cfg.getIsDefault() == 1L){
|
||||
cfg.setIsDefault(0L);
|
||||
attendanceCfgMapper.updateAttendanceCfg(cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AttendanceCfg currentCfg = attendanceCfgMapper.selectAttendanceCfgById(attendanceCfg.getId());
|
||||
if(currentCfg != null && currentCfg.getIsDefault() != null && currentCfg.getIsDefault() == 1L && attendanceCfg.getIsDefault() != null){
|
||||
throw new ServiceException("不能修改唯一默认配置为非默认");
|
||||
}
|
||||
|
||||
attendanceCfg.setUpdateBy(SecurityContextHolder.getUserName());
|
||||
attendanceCfg.setUpdateTime(DateUtils.getNowDate());
|
||||
return attendanceCfgMapper.updateAttendanceCfg(attendanceCfg);
|
||||
|
|
@ -90,6 +118,21 @@ public class AttendanceCfgServiceImpl implements IAttendanceCfgService
|
|||
@Override
|
||||
public int deleteAttendanceCfgByIds(Long[] ids)
|
||||
{
|
||||
for(Long id : ids){
|
||||
AttendanceCfg cfg = attendanceCfgMapper.selectAttendanceCfgById(id);
|
||||
if(cfg != null && cfg.getIsDefault() != null && cfg.getIsDefault() == 1L && cfg.getProjectId() != null){
|
||||
AttendanceCfg query = new AttendanceCfg();
|
||||
query.setProjectId(cfg.getProjectId());
|
||||
List<AttendanceCfg> cfgs = attendanceCfgMapper.selectAttendanceCfgList(query);
|
||||
for(AttendanceCfg c : cfgs){
|
||||
if(!c.getId().equals(id) && c.getIsDefault() != null && c.getIsDefault() == 0L){
|
||||
c.setIsDefault(1L);
|
||||
attendanceCfgMapper.updateAttendanceCfg(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return attendanceCfgMapper.deleteAttendanceCfgByIds(ids);
|
||||
}
|
||||
|
||||
|
|
@ -102,6 +145,19 @@ public class AttendanceCfgServiceImpl implements IAttendanceCfgService
|
|||
@Override
|
||||
public int deleteAttendanceCfgById(Long id)
|
||||
{
|
||||
AttendanceCfg cfg = attendanceCfgMapper.selectAttendanceCfgById(id);
|
||||
if(cfg != null && cfg.getIsDefault() != null && cfg.getIsDefault() == 1L && cfg.getProjectId() != null){
|
||||
AttendanceCfg query = new AttendanceCfg();
|
||||
query.setProjectId(cfg.getProjectId());
|
||||
List<AttendanceCfg> cfgs = attendanceCfgMapper.selectAttendanceCfgList(query);
|
||||
for(AttendanceCfg c : cfgs){
|
||||
if(!c.getId().equals(id) && c.getIsDefault() != null && c.getIsDefault() == 0L){
|
||||
c.setIsDefault(1L);
|
||||
attendanceCfgMapper.updateAttendanceCfg(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return attendanceCfgMapper.deleteAttendanceCfgById(id);
|
||||
}
|
||||
|
||||
|
|
@ -112,4 +168,20 @@ public class AttendanceCfgServiceImpl implements IAttendanceCfgService
|
|||
public String getMachMaterCfg(Long projectId, String cfgType) {
|
||||
return attendanceCfgMapper.getMachMaterCfg(projectId,cfgType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据项目ID和公司ID查询默认配置
|
||||
*/
|
||||
@Override
|
||||
public AttendanceCfg selectDefaultCfgByProjectAndCom(Long projectId, Long comId) {
|
||||
return attendanceCfgMapper.selectDefaultCfgByProjectAndCom(projectId, comId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据设备编号查询默认配置
|
||||
*/
|
||||
@Override
|
||||
public AttendanceCfg selectDefaultCfgByDeviceNo(String deviceNo) {
|
||||
return attendanceCfgMapper.selectDefaultCfgByDeviceNo(deviceNo);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,9 @@ public class ProMobileAttendanceDataServiceImpl implements IProMobileAttendanceD
|
|||
public int addAttendanceData(ProMobileAttendanceData attendanceData) {
|
||||
attendanceData.setIsDel(0L);
|
||||
attendanceData.setRemark("");
|
||||
attendanceData.setCfgId(0L);
|
||||
if(attendanceData.getCfgId() == null){
|
||||
attendanceData.setCfgId(0L);
|
||||
}
|
||||
attendanceData.setState(0L);
|
||||
attendanceData.setAttDevice("device");
|
||||
return insertProMobileAttendanceData(attendanceData);
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ function getCookie() {
|
|||
getCode()
|
||||
getCookie()
|
||||
setTimeout(() => {
|
||||
if (translate && translate.execute) {
|
||||
if (typeof translate !== 'undefined' && translate && translate.execute) {
|
||||
translate.execute();
|
||||
}
|
||||
}, 1000);
|
||||
|
|
|
|||
|
|
@ -70,6 +70,13 @@
|
|||
<el-switch v-model="scope.row.enabled" :active-value="1" @change="doUpdateRow(scope.row)" :inactive-value="0"></el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否默认" align="center" prop="isDefault">
|
||||
<template #default="scope">
|
||||
<el-tag :type="scope.row.isDefault === 1 ? 'success' : 'info'">
|
||||
{{ scope.row.isDefault === 1 ? '是' : '否' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
|
|
@ -139,6 +146,12 @@
|
|||
<el-form-item label="已启用" prop="enabled">
|
||||
<el-switch v-model="form.enabled" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
<el-form-item label="是否默认" prop="isDefault">
|
||||
<el-tag :type="form.isDefault === 1 ? 'success' : 'info'" v-if="form.id">
|
||||
{{ form.isDefault === 1 ? '是' : '否' }}
|
||||
</el-tag>
|
||||
<el-switch v-model="form.isDefault" :active-value="1" :inactive-value="0" v-if="!form.id" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
|
|
@ -188,6 +201,7 @@ const data = reactive({
|
|||
vendorsCode: null,
|
||||
vendorsParameter: null,
|
||||
enabled: null,
|
||||
isDefault: null,
|
||||
state: null,
|
||||
isDel: null,
|
||||
},
|
||||
|
|
@ -306,6 +320,7 @@ function reset() {
|
|||
projectGuid: '',
|
||||
vendorsParameter: null,
|
||||
enabled: 1,
|
||||
isDefault: 0,
|
||||
state: null,
|
||||
remark: null,
|
||||
isDel: null,
|
||||
|
|
|
|||
Loading…
Reference in New Issue