Compare commits

...

2 Commits

5 changed files with 41 additions and 11 deletions

View File

@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 维修工人 Mapper
*
@ -26,4 +28,11 @@ public interface RepairWorkerMapper extends BaseMapper<RepairWorker> {
**/
IPage<RepairWorkerRespVO> queryListPage(@Param("entity") RepairWorkerPageReqVO entity, Page<RepairWorkerRespVO> page);
}
/**
* 获取所有维修工人的id
* @return List<Long> 维修工人id列表
* @author lzt
* @date 2024年10月10日
**/
List<Long> getAllWorkerIds();
}

View File

@ -57,4 +57,6 @@ public interface RepairRecordsService extends IService<RepairRecords> {
*/
List<RepairRecordsRespVO> queryAllRepairRecords(RepairRecordsPageReqVO pageReqVO);
}

View File

@ -62,7 +62,7 @@ public class RepairRecordsServiceImpl extends ServiceImpl<RepairRecordsMapper, R
* @apiNote lzt
* @param pageReqVO 查询条件
* @return queryAllRepairRecords 所有维修记录
* @date
* @date 2024年10月9日
*/
@Override
public List<RepairRecordsRespVO> queryAllRepairRecords(RepairRecordsPageReqVO pageReqVO) {

View File

@ -36,20 +36,28 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
* 批量创建维修工人
*
* @param userList 选中用户集合
* @author PQZ
* @date 18:33 2024/10/9
* @author lzt
* @date 2024年10月10日
**/
@Override
public void saveWorkers(List<UserDTO> userList) {
if (CollectionUtil.isNotEmpty(userList)){
//获取已有的维修工人ID列表
List<Long> existingWorkerIds = workerMapper.getAllWorkerIds();
List<RepairWorker> saveList = new ArrayList<>();
userList.forEach(item -> {
RepairWorker worker = new RepairWorker();
worker.setUserId(item.getId());
worker.setUserName(item.getNickname());
saveList.add(worker);
if (!existingWorkerIds.contains(item.getId())) {
RepairWorker worker = new RepairWorker();
worker.setUserId(item.getId());
worker.setUserName(item.getNickname());
saveList.add(worker);
}
});
saveBatch(saveList);
if (!saveList.isEmpty()) {
saveBatch(saveList);
}
}
}
@ -84,4 +92,4 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
return workerMapper.queryListPage(pageReqVO,page);
}
}
}

View File

@ -28,4 +28,15 @@
order by main.create_time desc
</select>
</mapper>
<select id="getAllWorkerIds" resultType="java.lang.Long">
SELECT
main.user_id
FROM
dl_repair_worker main
WHERE
main.deleted = 0
</select>
</mapper>