UserServiceServiceImpl.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. package com.goafanti.user.service.impl;
  2. import java.util.Date;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import com.goafanti.admin.service.DepartmentService;
  7. import org.springframework.beans.BeanUtils;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.stereotype.Service;
  10. import com.goafanti.common.constant.AFTConstants;
  11. import com.goafanti.common.dao.UserServiceFollowMapper;
  12. import com.goafanti.common.dao.UserServiceMapper;
  13. import com.goafanti.common.model.UserService;
  14. import com.goafanti.common.utils.DateUtils;
  15. import com.goafanti.common.utils.StringUtils;
  16. import com.goafanti.core.mybatis.BaseMybatisDao;
  17. import com.goafanti.core.mybatis.page.Pagination;
  18. import com.goafanti.core.shiro.token.TokenManager;
  19. import com.goafanti.user.bo.InputListOrderUserService;
  20. import com.goafanti.user.bo.InputUserServiceFollow;
  21. import com.goafanti.user.bo.OrderProject;
  22. import com.goafanti.user.bo.OutOrderUserService;
  23. import com.goafanti.user.bo.OutUserServiceFollow;
  24. import com.goafanti.user.service.UserServiceService;
  25. @Service
  26. public class UserServiceServiceImpl extends BaseMybatisDao<UserServiceMapper> implements UserServiceService {
  27. @Autowired
  28. private UserServiceMapper userServiceMapper;
  29. @Autowired
  30. private UserServiceFollowMapper userServiceFollowMapper;
  31. @Autowired
  32. private DepartmentService departmentService;
  33. @Override
  34. public int addUseService(InputUserServiceFollow us) {
  35. us.setAid(TokenManager.getAdminId());
  36. if (StringUtils.isNotBlank(us.getRenewalTimes())) {
  37. us.setRenewalTime(DateUtils.StringToDate(us.getRenewalTimes(), AFTConstants.YYYYMMDD));
  38. }
  39. Date date=new Date();
  40. us.setCreateTime(date);
  41. userServiceFollowMapper.insertSelective(us);
  42. Integer id=userServiceMapper.selectByUid(us.getUid());
  43. UserService u=new UserService();
  44. BeanUtils.copyProperties(us, u);
  45. u.setNewTime(date);
  46. if (id==null) {
  47. userServiceMapper.insertSelective(u);
  48. }else {
  49. u.setId(id);
  50. u.setCreateTime(null);
  51. userServiceMapper.updateByPrimaryKeySelective(u);
  52. }
  53. return 1;
  54. }
  55. @Override
  56. public List<OutUserServiceFollow> listUseServiceFollow(String uid) {
  57. return userServiceFollowMapper.listUseServiceFollow(uid);
  58. }
  59. @SuppressWarnings("unchecked")
  60. @Override
  61. public Pagination<OutOrderUserService> listOrderUseService(InputListOrderUserService i) {
  62. Map<String, Object> map = setParams(i);
  63. Pagination<OutOrderUserService> p=(Pagination<OutOrderUserService>) findPage("OrderUseServiceList", "OrderUseServiceCount", map, i.getPageNo(), i.getPageSize());
  64. List<OutOrderUserService> list= (List<OutOrderUserService>) p.getList();
  65. setOrderUserService(list);
  66. return p;
  67. }
  68. private Map<String, Object> setParams(InputListOrderUserService i) {
  69. Map<String, Object>map =new HashMap<String, Object>();
  70. if(i.getUserName()!=null)map.put("userName", i.getUserName());
  71. if(i.getDeps()!=null)map.put("deps", departmentService.parseArray(i.getDeps()));
  72. if(i.getStartFollowTimes()!=null)map.put("startFollowTimes", i.getStartFollowTimes());
  73. if(i.getEndFollowTimes()!=null)map.put("endFollowTimes", i.getEndFollowTimes()+" 23:59:59");
  74. if(i.getStartSignTimes()!=null)map.put("startSignTimes", i.getStartSignTimes());
  75. if(i.getEndSignTimes()!=null)map.put("endSignTimes", i.getEndSignTimes()+" 23:59:59");
  76. if(i.getAddWechat()!=null)map.put("addWechat", i.getAddWechat());
  77. if(i.getRenewal()!=null)map.put("renewal", i.getRenewal());
  78. return map;
  79. }
  80. @SuppressWarnings("unchecked")
  81. @Override
  82. public List<OutOrderUserService> listOrderUseServiceGetList(InputListOrderUserService i) {
  83. Map<String, Object> map = setParams(i);
  84. if (i.getPageSize()==null) i.setPageSize(99999);
  85. List<OutOrderUserService> list=(List<OutOrderUserService>) findList("OrderUseServiceList", map,i.getPageNo(), i.getPageSize());
  86. setOrderUserService(list);
  87. return list;
  88. }
  89. private void setOrderUserService(List<OutOrderUserService> list) {
  90. for (OutOrderUserService ou: list) {
  91. StringBuffer projects=new StringBuffer();
  92. StringBuffer consultants=new StringBuffer();
  93. StringBuffer declareBatchs=new StringBuffer();
  94. StringBuffer certificationNos=new StringBuffer();
  95. for (OrderProject o : ou.getList()) {
  96. if (StringUtils.isNotBlank(o.getCommodityName())) {
  97. projects.append(o.getCommodityName());
  98. } else {
  99. projects.append("无");
  100. }
  101. projects.append("/");
  102. if (StringUtils.isNotBlank(o.getReceiverName())) {
  103. consultants.append(o.getReceiverName());
  104. } else {
  105. consultants.append("无");
  106. }
  107. consultants.append("/");
  108. if (o.getDeclarationBatch() != null) {
  109. declareBatchs.append(o.getDeclarationBatch());
  110. } else {
  111. declareBatchs.append("无");
  112. }
  113. declareBatchs.append("/");
  114. if (StringUtils.isNotBlank(o.getCertificateNumber())) {
  115. certificationNos.append(o.getCertificateNumber());
  116. } else {
  117. certificationNos.append("无");
  118. }
  119. certificationNos.append("/");
  120. }
  121. if(projects.length()>1)ou.setProjects(projects.substring(0, projects.length()-1));
  122. if(consultants.length()>1)ou.setConsultants(consultants.substring(0, consultants.length()-1));
  123. if(declareBatchs.length()>1)ou.setDeclareBatchs(declareBatchs.substring(0, declareBatchs.length()-1));
  124. if(certificationNos.length()>1)ou.setCertificationNos(certificationNos.substring(0, certificationNos.length()-1));
  125. }
  126. }
  127. }