SmartUserServiceImpl.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. package com.template.services.impl;
  2. import com.baomidou.mybatisplus.core.conditions.Wrapper;
  3. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  5. import com.baomidou.mybatisplus.core.metadata.IPage;
  6. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  7. import com.template.mapper.SmartUserMapper;
  8. import com.template.model.dto.WarningUserDto;
  9. import com.template.model.enumModel.eIdentityStatu;
  10. import com.template.model.pojo.SmartUser;
  11. import com.template.model.pojo.SmartWarning;
  12. import com.template.model.result.PageUtils;
  13. import com.template.model.vo.*;
  14. import com.template.services.SmartUserService;
  15. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  16. import org.apache.ibatis.annotations.Param;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.stereotype.Service;
  19. import org.springframework.util.StringUtils;
  20. import java.util.List;
  21. /**
  22. * <p>
  23. * 服务实现类
  24. * </p>
  25. *
  26. * @author ceshi
  27. * @since 2023-12-04
  28. */
  29. @Service
  30. public class SmartUserServiceImpl extends ServiceImpl<SmartUserMapper, SmartUser> implements SmartUserService {
  31. @Autowired
  32. private SmartUserMapper smartUserMapper;
  33. @Override
  34. public int insertSmartUser(SmartUser sa) {
  35. int result = smartUserMapper.insert(sa);
  36. return sa.getId();
  37. }
  38. @Override
  39. public int updateSmartUser(SmartUser sa) {
  40. int result = smartUserMapper.updateById(sa);
  41. return result;
  42. }
  43. @Override
  44. public PageUtils<SmartUser> queryPageSmartUsers(int currentPage, int pageCount, List<Integer> departmentIds) {
  45. Page<SmartUser> page = new Page<>(currentPage, pageCount);
  46. // QueryWrapper<SmartUser> queryWrapper = new QueryWrapper<>();
  47. // queryWrapper.eq(departmentId > 0, "department_id", departmentId);
  48. IPage<SmartUser> result = smartUserMapper.selectPage(page, null);
  49. return new PageUtils<>(result);
  50. }
  51. @Override
  52. public PageUtils<UserVo> querySmartUserPages(int currentPage, int pageCount, List<Integer> departmentIds, String name) {
  53. Page<UserVo> page = new Page<>();
  54. page.setCurrent(currentPage);
  55. page.setSize(pageCount);
  56. IPage<UserVo> result = smartUserMapper.querySmartUserPages(page, departmentIds, name);
  57. return new PageUtils(result);
  58. }
  59. @Override
  60. public PageUtils<GradeVo> querySmartSecordPage(int currentPage, int pageCount, String name, Integer userId) {
  61. Page<GradeVo> page = new Page<>();
  62. page.setCurrent(currentPage);
  63. page.setSize(pageCount);
  64. IPage<GradeVo> result = smartUserMapper.querySmartSecordPage(page, name, userId);
  65. return new PageUtils(result);
  66. }
  67. @Override
  68. public List<SmartUser> querySmartUsers(List<Integer> departmentIds, String name) {
  69. List<SmartUser> result = smartUserMapper.querySmartUsers(departmentIds, name);
  70. return result;
  71. }
  72. @Override
  73. public List<SmartUser> getSmartUserByIds(List<Integer> ids) {
  74. QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
  75. queryWrapper.in("id", ids);
  76. queryWrapper.eq("is_cancel", 0);
  77. List<SmartUser> result = smartUserMapper.selectList(queryWrapper);
  78. return result;
  79. }
  80. @Override
  81. public List<SmartUser> getSmartUserIds(List<String> ids) {
  82. QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
  83. queryWrapper.in("id", ids);
  84. queryWrapper.eq("is_cancel", 0);
  85. List<SmartUser> result = smartUserMapper.selectList(queryWrapper);
  86. return result;
  87. }
  88. @Override
  89. public int getSmartUserCountByIds(List<Integer> ids) {
  90. QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
  91. queryWrapper.in("id", ids);
  92. queryWrapper.eq("is_cancel", 0);
  93. int result = smartUserMapper.selectCount(queryWrapper);
  94. return result;
  95. }
  96. @Override
  97. public boolean updateUserBatchById(List<SmartUser> users) {
  98. boolean result = this.updateBatchById(users);
  99. return result;
  100. }
  101. @Override
  102. public Integer querySmartUserByCardNo(String cardNo) {
  103. QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
  104. queryWrapper.eq("card_no", cardNo);
  105. queryWrapper.eq("is_cancel", 0);
  106. int existCount = smartUserMapper.selectCount(queryWrapper);
  107. return existCount;
  108. }
  109. @Override
  110. public List<SmartUser> queryStudentBySchoolClass(Integer schoolClass) {
  111. QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
  112. queryWrapper.eq("school_class", schoolClass);
  113. queryWrapper.eq("identity_id", eIdentityStatu.Student.getValue());
  114. queryWrapper.eq("is_cancel", 0);
  115. List<SmartUser> result = smartUserMapper.selectList(queryWrapper);
  116. return result;
  117. }
  118. @Override
  119. public int deleteSmartUserById(int id) {
  120. int result = smartUserMapper.deleteById(id);
  121. return result;
  122. }
  123. @Override
  124. public int deleteSmartUserByIds(List<Integer> ids) {
  125. int result = smartUserMapper.deleteBatchIds(ids);
  126. return result;
  127. }
  128. @Override
  129. public SmartUser getSmartById(Integer id) {
  130. QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
  131. queryWrapper.eq("is_cancel", 0);
  132. queryWrapper.eq("id", id);
  133. SmartUser result = smartUserMapper.selectOne(queryWrapper);
  134. return result;
  135. }
  136. @Override
  137. public List<SmartUser> getSmartUserByxwuids(List<String> xwuids) {
  138. QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
  139. queryWrapper.in("xw_student_uid", xwuids);
  140. queryWrapper.eq("is_cancel", 0);
  141. List<SmartUser> result = smartUserMapper.selectList(queryWrapper);
  142. return result;
  143. }
  144. @Override
  145. public List<SmartUser> getListPush() {
  146. LambdaQueryWrapper<SmartUser> wrapper = new LambdaQueryWrapper<>();
  147. wrapper.eq(SmartUser::getIsCancel, 0)
  148. .eq(SmartUser::getIsPush, 1);
  149. List<SmartUser> smartUserList = this.list(wrapper);
  150. return smartUserList;
  151. }
  152. @Override
  153. public List<SmartUser> getAffiliateList(Integer id) {
  154. return smartUserMapper.getAffiliateList(id);
  155. }
  156. @Override
  157. public List<AffiliateUserVo> queryAffiliateUserById(Integer id) {
  158. List<AffiliateUserVo> result = smartUserMapper.queryAffiliateUserById(id);
  159. return result;
  160. }
  161. @Override
  162. public List<SmartUser> queryStudentDatas() {
  163. QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
  164. queryWrapper.eq("is_cancel", 0);
  165. queryWrapper.eq("identity_id", eIdentityStatu.Student.getValue());
  166. List<SmartUser> result = smartUserMapper.selectList(queryWrapper);
  167. return result;
  168. }
  169. @Override
  170. public PageUtils<WarningUserDto> warningUserList(int currentPage, int pageCount, String name) {
  171. Page<UserVo> page = new Page<>();
  172. page.setCurrent(currentPage);
  173. page.setSize(pageCount);
  174. IPage<WarningUserDto> result = smartUserMapper.warningUserList(page, name);
  175. return new PageUtils(result);
  176. }
  177. @Override
  178. public List<WarningUserDto> warningPushList() {
  179. return smartUserMapper.warningPushList();
  180. }
  181. @Override
  182. public List<AffiliateParentVo> queryAffiliateParents(Integer userId) {
  183. return smartUserMapper.queryAffiliateParents(userId);
  184. }
  185. @Override
  186. public SmartUser queryUserInfo(String name, String cardNo, String idCard) {
  187. QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
  188. queryWrapper.eq(StringUtils.hasText(name), "name", name);
  189. queryWrapper.eq(StringUtils.hasText(cardNo), "card_no", cardNo);
  190. queryWrapper.eq(StringUtils.hasText(idCard), "id_card", idCard);
  191. queryWrapper.eq("is_cancel", 0);
  192. SmartUser result = smartUserMapper.selectOne(queryWrapper);
  193. return result;
  194. }
  195. @Override
  196. public List<SmartUser> getSmartUserList(List<Integer> ids) {
  197. QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
  198. queryWrapper.eq("is_cancel", 0);
  199. queryWrapper.in("id", ids);
  200. List<SmartUser> result = smartUserMapper.selectList(queryWrapper);
  201. return result;
  202. }
  203. @Override
  204. public List<SmartUser> querySmartUserByCardNos(List<String> cardNos) {
  205. QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
  206. queryWrapper.eq("is_cancel", 0);
  207. queryWrapper.in("card_no", cardNos);
  208. List<SmartUser> result = smartUserMapper.selectList(queryWrapper);
  209. return result;
  210. }
  211. @Override
  212. public SmartUserVo querySmartUserById(Integer id) {
  213. SmartUserVo result = smartUserMapper.querySmartUserById(id);
  214. return result;
  215. }
  216. @Override
  217. public int deleteUserBatch(List<deleteUserVo> list) {
  218. int result = smartUserMapper.deleteUserBatch(list);
  219. return result;
  220. }
  221. @Override
  222. public PageUtils<UserDeleteVo> queryUserDeletePage(int currentPage, int pageCount) {
  223. Page<UserDeleteVo> page = new Page<>();
  224. page.setCurrent(currentPage);
  225. page.setSize(pageCount);
  226. IPage<UserDeleteVo> result = smartUserMapper.queryUserDeletePage(page);
  227. return new PageUtils(result);
  228. }
  229. @Override
  230. public SmartStudentVo querySmartStudentById(Integer userId) {
  231. SmartStudentVo result = smartUserMapper.querySmartStudentById(userId);
  232. return result;
  233. }
  234. @Override
  235. public List<SmartUser> queryStudentsByGrade(List<String> gradeIds) {
  236. QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
  237. queryWrapper.eq("identity_id", eIdentityStatu.Student.getValue());
  238. queryWrapper.in(gradeIds != null && gradeIds.size() > 0, "grade", gradeIds);
  239. List<SmartUser> result = smartUserMapper.selectList(queryWrapper);
  240. return result;
  241. }
  242. @Override
  243. public List<SmartUser> queryUsersByClass(Integer schoolClass) {
  244. QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
  245. queryWrapper.eq(schoolClass != null, "school_class", schoolClass);
  246. queryWrapper.eq("identity_id", eIdentityStatu.Student.getValue());
  247. List<SmartUser> users = smartUserMapper.selectList(queryWrapper);
  248. return users;
  249. }
  250. @Override
  251. public List<SmartUser> getListUser() {
  252. LambdaQueryWrapper<SmartUser> wrapper = new LambdaQueryWrapper<>();
  253. wrapper.eq(SmartUser::getIsCancel, 0);
  254. List<SmartUser> smartUserList = this.list(wrapper);
  255. return smartUserList;
  256. }
  257. @Override
  258. public SmartUser getPhoneUser(String phone) {
  259. LambdaQueryWrapper<SmartUser> wrapper=new LambdaQueryWrapper<>();
  260. wrapper.eq(SmartUser::getPhone,phone);
  261. SmartUser smartUser = this.getOne(wrapper);
  262. return smartUser;
  263. }
  264. @Override
  265. public List<SmartUser> getPhoneUsers(String phone) {
  266. QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
  267. queryWrapper.eq("phone", phone);
  268. List<SmartUser> result = smartUserMapper.selectList(queryWrapper);
  269. return result;
  270. }
  271. @Override
  272. public List<SmartUser> getAffiliateUser(String affiliate) {
  273. return smartUserMapper.getAffiliateUser(affiliate);
  274. }
  275. @Override
  276. public SmartUser getCard(String certificateNumber) {
  277. LambdaQueryWrapper<SmartUser> wrapper=new LambdaQueryWrapper<>();
  278. wrapper/*.eq(SmartUser::getIdCard,certificateNumber)
  279. .or()*/
  280. .eq(SmartUser::getCardNo,certificateNumber);
  281. SmartUser one = this.getOne(wrapper);
  282. return one;
  283. }
  284. @Override
  285. public SmartUser getBsStudentNo(String idNum) {
  286. LambdaQueryWrapper<SmartUser> wrapper=new LambdaQueryWrapper<>();
  287. wrapper.eq(SmartUser::getBsStudentNo,idNum)
  288. .or()
  289. .eq(SmartUser::getBsStaffCode,idNum)
  290. .or()
  291. .eq(SmartUser::getIdCard,idNum);
  292. SmartUser one = this.getOne(wrapper);
  293. return one;
  294. }
  295. @Override
  296. public List<SmartUser> getChargeTeacher(Integer schoolClass) {
  297. LambdaQueryWrapper<SmartUser> wrapper=new LambdaQueryWrapper<>();
  298. wrapper.eq(SmartUser::getSchoolClass,schoolClass)
  299. .eq(SmartUser::getDepartmentId,137);
  300. List<SmartUser> list = this.list(wrapper);
  301. return list;
  302. }
  303. }