PersonnelServiceImpl.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. package com.goafanti.personnel.service.impl;
  2. import java.util.ArrayList;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.stereotype.Service;
  8. import com.alibaba.fastjson.JSON;
  9. import com.alibaba.fastjson.JSONArray;
  10. import com.goafanti.common.dao.PersonnelChooseMapper;
  11. import com.goafanti.common.dao.PersonnelContactMapper;
  12. import com.goafanti.common.dao.PersonnelContractMapper;
  13. import com.goafanti.common.dao.PersonnelDossierMapper;
  14. import com.goafanti.common.dao.PersonnelEntryMapper;
  15. import com.goafanti.common.dao.PersonnelPromotionMapper;
  16. import com.goafanti.common.dao.PersonnelQuitMapper;
  17. import com.goafanti.common.model.PersonnelContact;
  18. import com.goafanti.common.model.PersonnelDossier;
  19. import com.goafanti.common.model.PersonnelEntry;
  20. import com.goafanti.core.mybatis.BaseMybatisDao;
  21. import com.goafanti.core.mybatis.page.Pagination;
  22. import com.goafanti.personnel.bo.InputPersonnelBo;
  23. import com.goafanti.personnel.bo.InputPersonnelChooseBo;
  24. import com.goafanti.personnel.bo.InputPersonnelContactBo;
  25. import com.goafanti.personnel.bo.InputPersonnelContractBo;
  26. import com.goafanti.personnel.bo.InputPersonnelEntryBo;
  27. import com.goafanti.personnel.bo.InputPersonnelListBo;
  28. import com.goafanti.personnel.bo.InputPersonnelPromotionBo;
  29. import com.goafanti.personnel.bo.InputPersonnelQuitBo;
  30. import com.goafanti.personnel.bo.OutPersonnelListBo;
  31. import com.goafanti.personnel.service.PersonnelService;
  32. @Service
  33. public class PersonnelServiceImpl extends BaseMybatisDao<PersonnelDossierMapper> implements PersonnelService {
  34. @Autowired
  35. private PersonnelDossierMapper personnelDossierMapper;
  36. @Autowired
  37. private PersonnelContactMapper personnelContactMapper;
  38. @Autowired
  39. private PersonnelEntryMapper personnelEntryMapper;
  40. @Autowired
  41. private PersonnelPromotionMapper personnelPromotionMapper;
  42. @Autowired
  43. private PersonnelContractMapper personnelContractMapper;
  44. @Autowired
  45. private PersonnelChooseMapper personnelChooseMapper;
  46. @Autowired
  47. private PersonnelQuitMapper personnelQuitMapper;
  48. @Override
  49. public int addPersonnel(InputPersonnelBo i) {
  50. return personnelDossierMapper.insertSelective(i);
  51. }
  52. @Override
  53. public int updatePersonnel(InputPersonnelBo i) {
  54. return personnelDossierMapper.updateByPrimaryKeySelective(i);
  55. }
  56. @Override
  57. public int updateContact(InputPersonnelContactBo i) {
  58. PersonnelDossier p=new PersonnelDossier();
  59. p.setId(i.getId());
  60. p.setMobile(i.getMobile());
  61. p.setFixedTel(i.getFixedTel());
  62. personnelDossierMapper.updateByPrimaryKeySelective(p);
  63. JSONArray ja = (JSONArray) JSON.parse(i.getContactList());
  64. List<PersonnelContact> list = new ArrayList<PersonnelContact>();
  65. if (ja != null && !ja.isEmpty()) {
  66. PersonnelContact pc = null;
  67. for (int idx = 0; idx < ja.size(); idx++) {
  68. pc = ja.getJSONObject(idx).toJavaObject(PersonnelContact.class);
  69. list.add(pc);
  70. }
  71. }
  72. for (PersonnelContact pc : list) {
  73. if (pc.getId()!=null) {
  74. personnelContactMapper.updateByPrimaryKeySelective(pc);
  75. }else {
  76. personnelContactMapper.insertSelective(pc);
  77. }
  78. }
  79. return 1;
  80. }
  81. @Override
  82. public int updateEntry(InputPersonnelEntryBo i) {
  83. PersonnelEntry p=personnelEntryMapper.selectByPrimaryKey(i.getId());
  84. if (p==null||p.getId()==null) {
  85. personnelEntryMapper.insertSelective(i);
  86. }else {
  87. personnelEntryMapper.updateByPrimaryKeySelective(i);
  88. }
  89. return 1;
  90. }
  91. @Override
  92. public int updatePromotion(InputPersonnelPromotionBo i) {
  93. if (i.getId()==null) {
  94. personnelPromotionMapper.insertSelective(i);
  95. }else {
  96. personnelPromotionMapper.updateByPrimaryKeySelective(i);
  97. }
  98. return 1;
  99. }
  100. @Override
  101. public int checkDoorId(Integer doorId) {
  102. int i=personnelDossierMapper.checkDoorId(doorId);
  103. return i;
  104. }
  105. @Override
  106. public int updateContract(InputPersonnelContractBo i) {
  107. if (i.getId()==null) {
  108. personnelContractMapper.insertSelective(i);
  109. } else {
  110. personnelContractMapper.updateByPrimaryKeySelective(i);
  111. }
  112. return 1;
  113. }
  114. @Override
  115. public int updateChoose(InputPersonnelChooseBo i) {
  116. if (i.getId()==null) {
  117. personnelChooseMapper.insertSelective(i);
  118. } else {
  119. personnelChooseMapper.updateByPrimaryKeySelective(i);
  120. }
  121. return 1;
  122. }
  123. @Override
  124. public int updateQuit(InputPersonnelQuitBo i) {
  125. if (i.getId()==null) {
  126. personnelQuitMapper.insertSelective(i);
  127. } else {
  128. personnelQuitMapper.updateByPrimaryKeySelective(i);
  129. }
  130. PersonnelDossier pd=new PersonnelDossier();
  131. pd.setId(i.getPdId());
  132. pd.setQuitTime(i.getEffectTime());
  133. personnelDossierMapper.updateByPrimaryKeySelective(pd);
  134. return 1;
  135. }
  136. @SuppressWarnings("unchecked")
  137. @Override
  138. public Pagination<OutPersonnelListBo> selectList(InputPersonnelListBo i) {
  139. Map<String, Object> params = new HashMap<>();
  140. if (i.getPageNo()==null||i.getPageNo()<1)i.setPageNo(1);
  141. if (i.getPageSize()==null||i.getPageSize()<1) i.setPageSize(10);
  142. params.put("i", i);
  143. return (Pagination<OutPersonnelListBo>) findPage("selectPersonnelByList", "selectPersonnelByCount",
  144. params, i.getPageNo(), i.getPageSize());
  145. }
  146. }