定时任务同步员工打卡数据,设备模块增加websocket和前端通讯

master
Yangwl 2 weeks ago
parent 271ff4005b
commit b24f6eca27

@ -69,4 +69,8 @@ public interface RemoteUserService {
/**部门基础数据数据**/
@PostMapping("/dept/sysDeptInfoTask")
public R sysDeptInfoTask();
/**员工打卡数据**/
@PostMapping("/user/clockInRecord")
public R sysClockInRecord();
}

@ -61,6 +61,11 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
public R sysDeptInfoTask() {
return R.fail("hr人力资源基础数据-部门信息同步失败:"+throwable.getMessage());
}
@Override
public R sysClockInRecord() {
return R.fail("hr人力资源基础数据-员工考勤打卡信息同步失败:"+throwable.getMessage());
}
};
}
}

@ -83,6 +83,13 @@
<artifactId>op-common-swagger</artifactId>
</dependency>
<!-- pom.xml -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
</dependencies>
<build>

@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.op.common.security.annotation.EnableCustomConfig;
import com.op.common.security.annotation.EnableRyFeignClients;
import com.op.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
*
@ -14,6 +15,7 @@ import com.op.common.swagger.annotation.EnableCustomSwagger2;
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@EnableScheduling
@SpringBootApplication
public class DeviceApplication {
public static void main(String[] args) {

@ -182,6 +182,7 @@ public class EquRepairOrder extends BaseEntity {
@Excel(name = "审核意见")
private String auditOpinion;
/**
*
*/
@ -268,6 +269,16 @@ public class EquRepairOrder extends BaseEntity {
private String orderTimeStart;
private String orderTimeEnd;
private Equipment equipment;
public Equipment getEquipment() {
return equipment;
}
public void setEquipment(Equipment equipment) {
this.equipment = equipment;
}
//图片文件
public String getFileList() {
return fileList;

@ -4,10 +4,7 @@ import java.util.List;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.domain.BaseFileData;
import com.op.device.domain.EquEquipment;
import com.op.device.domain.EquFile;
import com.op.device.domain.EquRepairOrder;
import com.op.device.domain.EquTeamUser;
import com.op.device.domain.*;
import com.op.system.api.domain.SysNoticeGroup;
import org.apache.ibatis.annotations.Param;
@ -113,4 +110,6 @@ public interface EquRepairOrderMapper {
//查询公告绑定的班组
List<SysNoticeGroup> getNoticesGroup(SysNoticeGroup noticeQo);
Equipment selectEquInfoByequCode(Equipment equipment);
}

@ -0,0 +1,48 @@
package com.op.device.schedul;
import com.alibaba.fastjson2.JSON;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.device.domain.EquRepairOrder;
import com.op.device.domain.Equipment;
import com.op.device.mapper.EquRepairOrderMapper;
import com.op.device.service.IEquRepairOrderService;
import com.op.device.websocket.WebSocketUsers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.handler.TextWebSocketHandler;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
@EnableScheduling
public class MyWebSocketHandler extends TextWebSocketHandler {
@Autowired
private EquRepairOrderMapper equRepairOrderMapper;
@Scheduled(fixedRate = 10000) // 每60秒执行一次
@DS("ds_1000")
public void sendPeriodicMessages() {
EquRepairOrder equRepairOrder=new EquRepairOrder();
equRepairOrder.setOrderStatus("2");
List<EquRepairOrder> equRepairOrderList=equRepairOrderMapper.selectEquRepairOrderList(equRepairOrder);
Equipment equipment=new Equipment();
List<EquRepairOrder> equRepairOrders=new ArrayList<>();
for (EquRepairOrder repairOrder : equRepairOrderList) {
equipment.setEquipmentCode(repairOrder.getEquipmentCode());
equipment=equRepairOrderMapper.selectEquInfoByequCode(equipment);
repairOrder.setEquipment(equipment);
equRepairOrders.add(repairOrder);
}
String jsonResult = JSON.toJSONString(equRepairOrders);
WebSocketUsers.sendMessageToUsersByText(jsonResult);
}
}

@ -603,4 +603,5 @@ public class EquRepairOrderServiceImpl implements IEquRepairOrderService {
public List<EquEquipment> selectGroupLineList() {
return equEquipmentMapper.selectEquipmentGroupLine();
}
}

@ -0,0 +1,58 @@
package com.op.device.websocket;
import java.util.concurrent.Semaphore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
*
* @author ruoyi
*/
public class SemaphoreUtils
{
/**
* SemaphoreUtils
*/
private static final Logger LOGGER = LoggerFactory.getLogger(SemaphoreUtils.class);
/**
*
*
* @param semaphore
* @return
*/
public static boolean tryAcquire(Semaphore semaphore)
{
boolean flag = false;
try
{
flag = semaphore.tryAcquire();
}
catch (Exception e)
{
LOGGER.error("获取信号量异常", e);
}
return flag;
}
/**
*
*
* @param semaphore
*/
public static void release(Semaphore semaphore)
{
try
{
semaphore.release();
}
catch (Exception e)
{
LOGGER.error("释放信号量异常", e);
}
}
}

@ -0,0 +1,20 @@
package com.op.device.websocket;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* websocket
*
* @author ruoyi
*/
@Configuration
public class WebSocketConfig
{
@Bean
public ServerEndpointExporter serverEndpointExporter()
{
return new ServerEndpointExporter();
}
}

@ -0,0 +1,106 @@
package com.op.device.websocket;
import java.util.concurrent.Semaphore;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
* websocket
*
* @author ruoyi
*/
@Component
@ServerEndpoint("/websocket/message")
public class WebSocketServer
{
/**
* WebSocketServer
*/
private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketServer.class);
/**
* 线100
*/
public static int socketMaxOnlineCount = 100;
private static Semaphore socketSemaphore = new Semaphore(socketMaxOnlineCount);
/**
*
*/
@OnOpen
public void onOpen(Session session) throws Exception
{
boolean semaphoreFlag = false;
// 尝试获取信号量
semaphoreFlag = SemaphoreUtils.tryAcquire(socketSemaphore);
if (!semaphoreFlag)
{
// 未获取到信号量
LOGGER.error("\n 当前在线人数超过限制数- {}", socketMaxOnlineCount);
WebSocketUsers.sendMessageToUserByText(session, "当前在线人数超过限制数:" + socketMaxOnlineCount);
session.close();
}
else
{
// 添加用户
WebSocketUsers.put(session.getId(), session);
LOGGER.info("\n 建立连接 - {}", session);
LOGGER.info("\n 当前人数 - {}", WebSocketUsers.getUsers().size());
WebSocketUsers.sendMessageToUserByText(session, "连接成功");
}
}
/**
*
*/
@OnClose
public void onClose(Session session)
{
LOGGER.info("\n 关闭连接 - {}", session);
// 移除用户
boolean removeFlag = WebSocketUsers.remove(session.getId());
if (!removeFlag)
{
// 获取到信号量则需释放
SemaphoreUtils.release(socketSemaphore);
}
}
/**
*
*/
@OnError
public void onError(Session session, Throwable exception) throws Exception
{
if (session.isOpen())
{
// 关闭连接
session.close();
}
String sessionId = session.getId();
LOGGER.info("\n 连接异常 - {}", sessionId);
LOGGER.info("\n 异常信息 - {}", exception);
// 移出用户
WebSocketUsers.remove(sessionId);
// 获取到信号量则需释放
SemaphoreUtils.release(socketSemaphore);
}
/**
*
*/
@OnMessage
public void onMessage(String message, Session session)
{
String msg = message.replace("你", "我").replace("吗", "");
WebSocketUsers.sendMessageToUserByText(session, msg);
}
}

@ -0,0 +1,140 @@
package com.op.device.websocket;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.websocket.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* websocket
*
* @author ruoyi
*/
public class WebSocketUsers
{
/**
* WebSocketUsers
*/
private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketUsers.class);
/**
*
*/
private static Map<String, Session> USERS = new ConcurrentHashMap<String, Session>();
/**
*
*
* @param key
* @param session
*/
public static void put(String key, Session session)
{
USERS.put(key, session);
}
/**
*
*
* @param session
*
* @return
*/
public static boolean remove(Session session)
{
String key = null;
boolean flag = USERS.containsValue(session);
if (flag)
{
Set<Map.Entry<String, Session>> entries = USERS.entrySet();
for (Map.Entry<String, Session> entry : entries)
{
Session value = entry.getValue();
if (value.equals(session))
{
key = entry.getKey();
break;
}
}
}
else
{
return true;
}
return remove(key);
}
/**
*
*
* @param key
*/
public static boolean remove(String key)
{
LOGGER.info("\n 正在移出用户 - {}", key);
Session remove = USERS.remove(key);
if (remove != null)
{
boolean containsValue = USERS.containsValue(remove);
LOGGER.info("\n 移出结果 - {}", containsValue ? "失败" : "成功");
return containsValue;
}
else
{
return true;
}
}
/**
* 线
*
* @return
*/
public static Map<String, Session> getUsers()
{
return USERS;
}
/**
*
*
* @param message
*/
public static void sendMessageToUsersByText(String message)
{
Collection<Session> values = USERS.values();
for (Session value : values)
{
sendMessageToUserByText(value, message);
}
}
/**
*
*
* @param userName
* @param message
*/
public static void sendMessageToUserByText(Session session, String message)
{
if (session != null)
{
try
{
session.getBasicRemote().sendText(message);
}
catch (IOException e)
{
LOGGER.error("\n[发送消息异常]", e);
}
}
else
{
LOGGER.info("\n[你已离线]");
}
}
}

@ -345,5 +345,15 @@
left join base_team_user btu on sng.group_code = btu.team_code
where sng.notice_id = #{noticeId} and sng.del_flag = '0'
</select>
<select id="selectEquInfoByequCode" resultType="com.op.device.domain.Equipment" >
SELECT
equipment_code,
equipment_name,
sap_code
FROM
[dbo].[base_equipment]
WHERE
equipment_code = #{equipmentCode}
</select>
</mapper>

@ -221,6 +221,11 @@ public class RyTask {
logger.info("++hr部门基础数据同步+开始++sysPostInfoTask+++++");
remoteUserService.sysDeptInfoTask();
}
//同步每天的员工打卡信息
public void sysClockInRecord(){
logger.info("++hr部门员工打卡信息数据同步+开始++sysClockInRecord+++++");
remoteUserService.sysClockInRecord();
}
/************部门基础数据定时任务开始*****************/
/************装运单同步定时任务*********************/
public void SynchronizationOfShippingDocuments(){

@ -82,6 +82,14 @@
<groupId>com.op</groupId>
<artifactId>op-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
</dependencies>

@ -382,5 +382,9 @@ public class SysUserController extends BaseController {
public R syncUserInfoTask() {
return R.ok(userService.syncUserInfoTask());
}
/**人员考勤打卡信息**/
@PostMapping("/clockInRecord")
public R syncClockInRecord() {
return R.ok(userService.syncClockInRecord());
}
}

@ -0,0 +1,94 @@
package com.op.system.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* mes_clock_record
*
* @author yangwl
* @date 2025-03-21
*/
public class MesClockRecord extends BaseEntity
{
private static final long serialVersionUID = 1L;
private String day;
private String time;
/** 打卡时间 */
@Excel(name = "打卡时间", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date clockTime;
/** 工号 */
@Excel(name = "工号")
private String workNo;
/** 姓名 */
@Excel(name = "姓名")
private String name;
public void setClockTime(Date clockTime)
{
this.clockTime = clockTime;
}
public Date getClockTime()
{
return clockTime;
}
public String getDay() {
return day;
}
public void setDay(String day) {
this.day = day;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getWorkNo() {
return workNo;
}
public void setWorkNo(String workNo) {
this.workNo = workNo;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
@Override
public String toString() {
return "MesClockRecord{" +
"day='" + day + '\'' +
", time='" + time + '\'' +
", clockTime=" + clockTime +
", workNo='" + workNo + '\'' +
", name='" + name + '\'' +
'}';
}
}

@ -0,0 +1,66 @@
package com.op.system.mapper;
import java.util.Date;
import java.util.List;
import com.op.system.domain.MesClockRecord;
import feign.Param;
/**
* Mapper
*
* @author yangwl
* @date 2025-03-21
*/
public interface MesClockRecordMapper
{
/**
*
*
* @param clockTime ID
* @return
*/
public MesClockRecord selectMesClockRecordById(Date clockTime);
/**
*
*
* @param mesClockRecord
* @return
*/
public List<MesClockRecord> selectMesClockRecordList(MesClockRecord mesClockRecord);
/**
*
*
* @param mesClockRecord
* @return
*/
public int insertMesClockRecord(MesClockRecord mesClockRecord);
/**
*
*
* @param mesClockRecord
* @return
*/
public int updateMesClockRecord(MesClockRecord mesClockRecord);
/**
*
*
* @param clockTime ID
* @return
*/
public int deleteMesClockRecordById(Date clockTime);
/**
*
*
* @param clockTimes ID
* @return
*/
public int deleteMesClockRecordByIds(String[] clockTimes);
void insertMesClockRecordList(List<MesClockRecord> list);
}

@ -0,0 +1,62 @@
package com.op.system.service;
import java.util.Date;
import java.util.List;
import com.op.system.domain.MesClockRecord;
/**
* Service
*
* @author yangwl
* @date 2025-03-21
*/
public interface IMesClockRecordService
{
/**
*
*
* @param clockTime ID
* @return
*/
public MesClockRecord selectMesClockRecordById(Date clockTime);
/**
*
*
* @param mesClockRecord
* @return
*/
public List<MesClockRecord> selectMesClockRecordList(MesClockRecord mesClockRecord);
/**
*
*
* @param mesClockRecord
* @return
*/
public int insertMesClockRecord(MesClockRecord mesClockRecord);
/**
*
*
* @param mesClockRecord
* @return
*/
public int updateMesClockRecord(MesClockRecord mesClockRecord);
/**
*
*
* @param ids ID
* @return
*/
public int deleteMesClockRecordByIds(String ids);
/**
*
*
* @param clockTime ID
* @return
*/
public int deleteMesClockRecordById(Date clockTime);
}

@ -210,4 +210,6 @@ public interface ISysUserService {
public List<Map<String, String>> getPoolNameList(SysUser user);
public R syncUserInfoTask();
public R syncClockInRecord();
}

@ -0,0 +1,101 @@
package com.op.system.service.impl;
import java.util.Date;
import java.util.List;
import com.op.common.core.text.Convert;
import com.op.common.core.utils.DateUtils;
import com.op.system.mapper.MesClockRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.system.domain.MesClockRecord;
import com.op.system.service.IMesClockRecordService;
/**
* Service
*
* @author yangwl
* @date 2025-03-21
*/
@Service
public class MesClockRecordServiceImpl implements IMesClockRecordService
{
@Autowired
private MesClockRecordMapper mesClockRecordMapper;
/**
*
*
* @param clockTime ID
* @return
*/
@Override
public MesClockRecord selectMesClockRecordById(Date clockTime)
{
return mesClockRecordMapper.selectMesClockRecordById(clockTime);
}
/**
*
*
* @param mesClockRecord
* @return
*/
@Override
public List<MesClockRecord> selectMesClockRecordList(MesClockRecord mesClockRecord)
{
return mesClockRecordMapper.selectMesClockRecordList(mesClockRecord);
}
/**
*
*
* @param mesClockRecord
* @return
*/
@Override
public int insertMesClockRecord(MesClockRecord mesClockRecord)
{
mesClockRecord.setCreateTime(DateUtils.getNowDate());
return mesClockRecordMapper.insertMesClockRecord(mesClockRecord);
}
/**
*
*
* @param mesClockRecord
* @return
*/
@Override
public int updateMesClockRecord(MesClockRecord mesClockRecord)
{
mesClockRecord.setUpdateTime(DateUtils.getNowDate());
return mesClockRecordMapper.updateMesClockRecord(mesClockRecord);
}
/**
*
*
* @param ids ID
* @return
*/
@Override
public int deleteMesClockRecordByIds(String ids)
{
return mesClockRecordMapper.deleteMesClockRecordByIds(Convert.toStrArray(ids));
}
/**
*
*
* @param clockTime ID
* @return
*/
@Override
public int deleteMesClockRecordById(Date clockTime)
{
return mesClockRecordMapper.deleteMesClockRecordById(clockTime);
}
}

@ -1,5 +1,6 @@
package com.op.system.service.impl;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -8,17 +9,22 @@ import javax.validation.Validator;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.http.HttpUtils;
import com.op.common.core.web.domain.AjaxResult;
import com.op.system.api.RemoteOpenService;
import com.op.system.api.domain.quality.HRInfo;
import com.op.system.api.domain.quality.OAInfo;
import com.op.system.api.domain.sap.SapWorkCenter;
import com.op.system.domain.SysDatasource;
import com.op.system.domain.*;
import com.op.system.mapper.*;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -34,9 +40,6 @@ import com.op.common.datascope.annotation.DataScope;
import com.op.common.security.utils.SecurityUtils;
import com.op.system.api.domain.SysRole;
import com.op.system.api.domain.SysUser;
import com.op.system.domain.SysPost;
import com.op.system.domain.SysUserPost;
import com.op.system.domain.SysUserRole;
import com.op.system.service.ISysConfigService;
import com.op.system.service.ISysUserService;
import org.springframework.web.context.request.RequestContextHolder;
@ -74,6 +77,9 @@ public class SysUserServiceImpl implements ISysUserService {
@Autowired
private SysDatasourceMapper sysDatasourceMapper;
@Autowired
private MesClockRecordMapper mesClockRecordMapper;
@Autowired
private RemoteOpenService remoteOpenService;
@ -569,7 +575,9 @@ public class SysUserServiceImpl implements ISysUserService {
return R.ok();
}
protected int syncUserInfoFunc(List<HRInfo> dtos){
protected int syncUserInfoFunc(List<HRInfo> dtos){
log.info("人力信息同步:"+ JSONObject.toJSONString(dtos));
Date nowDate = DateUtils.getNowDate();
String createBy = "job";
@ -651,6 +659,75 @@ public class SysUserServiceImpl implements ISysUserService {
return 1;
}
@Override
public R syncClockInRecord() {
DynamicDataSourceContextHolder.push("ds_1000");// 这是数据源的key
try {
/*从接口获取人员打卡信息*/
// 获取当前日期
Calendar calendar = Calendar.getInstance();
// 定义日期格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// 格式化日期
String formattedDate = sdf.format(calendar.getTime());
JSONObject jsonObject = new JSONObject();
jsonObject.put("day", formattedDate);
// 将 JSON 对象转换为字符串
String jsonString = jsonObject.toString();
// 调用 sendPost 方法(确保此方法内部使用 POST 方法发送数据)
String url = "http://lj.lanju.cn:8801/outside/api/mes/attendanceRecord/today/list.do";
String result = HttpUtils.sendPostWechart(url, jsonString);
List<MesClockRecord> mesClockRecordList =JSONArray.parseArray(result,MesClockRecord.class);
SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<MesClockRecord> clockRecordList = mesClockRecordList.stream().map(mesClockRecord -> {
String ClockTime=mesClockRecord.getDay()+ " " +mesClockRecord.getTime();
try {
Date clockTime = sdfs.parse(ClockTime);
mesClockRecord.setClockTime(clockTime);
} catch (ParseException e) {
e.printStackTrace();
}
return mesClockRecord;
}).collect(Collectors.toList());
// 处理响应结果
batchInsert(clockRecordList);
System.out.println("服务器响应: " + clockRecordList);
return R.ok(result);
}catch (Exception e) {
e.printStackTrace();
return R.fail(e.getMessage());
}
}
@Autowired // 关键:注入 SqlSessionFactory
private SqlSessionFactory sqlSessionFactory;
public void batchInsert(List<MesClockRecord> records) {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
try {
MesClockRecordMapper mapper = sqlSession.getMapper(MesClockRecordMapper.class);
int batchSize = 500;
for (int i = 0; i < records.size(); i += batchSize) {
int end = Math.min(i + batchSize, records.size());
List<MesClockRecord> subList = records.subList(i, end);
mapper.insertMesClockRecordList(subList);
sqlSession.flushStatements(); // 批处理执行
}
sqlSession.commit(); // 提交事务
} catch (Exception e) {
sqlSession.rollback();
throw new RuntimeException("批量插入失败", e);
} finally {
sqlSession.close();
}
}
}

@ -0,0 +1,87 @@
<?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">
<mapper namespace="com.op.system.mapper.MesClockRecordMapper">
<resultMap type="MesClockRecord" id="MesClockRecordResult">
<result property="clockTime" column="clock_time" />
<result property="workno" column="workno" />
<result property="name" column="name" />
<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>
<sql id="selectMesClockRecordVo">
select clock_time, workno, name, create_by, create_time, update_by, update_time from mes_clock_record
</sql>
<select id="selectMesClockRecordList" parameterType="MesClockRecord" resultMap="MesClockRecordResult">
<include refid="selectMesClockRecordVo"/>
<where>
<if test="clockTime != null "> and clock_time = #{clockTime}</if>
<if test="workno != null and workno != ''"> and workno = #{workno}</if>
<if test="name != null and name != ''"> and name like ('%' + #{name} + '%')</if>
</where>
</select>
<select id="selectMesClockRecordById" parameterType="Date" resultMap="MesClockRecordResult">
<include refid="selectMesClockRecordVo"/>
where clock_time = #{clockTime}
</select>
<insert id="insertMesClockRecord" parameterType="MesClockRecord">
insert into mes_clock_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="clockTime != null">clock_time,</if>
<if test="workNo != null">workno,</if>
<if test="name != null">name,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clockTime != null">#{clockTime},</if>
<if test="workNo != null">#{workNo},</if>
<if test="name != null">#{name},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<insert id="insertMesClockRecordList">
INSERT INTO mes_clock_record (clock_time,workno, name) VALUES
<foreach collection="list" item="item" separator=",">
(#{item.clockTime}, #{item.workNo}, #{item.name})
</foreach>
</insert>
<update id="updateMesClockRecord" parameterType="MesClockRecord">
update mes_clock_record
<trim prefix="SET" suffixOverrides=",">
<if test="workno != null">workno = #{workno},</if>
<if test="name != null">name = #{name},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where clock_time = #{clockTime}
</update>
<delete id="deleteMesClockRecordById" parameterType="Date">
delete from mes_clock_record where clock_time = #{clockTime}
</delete>
<delete id="deleteMesClockRecordByIds" parameterType="String">
delete from mes_clock_record where clock_time in
<foreach item="clockTime" collection="array" open="(" separator="," close=")">
#{clockTime}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save