BaseWashoutPointServiceImpl.java 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. package com.huimv.receive.service.impl;
  2. import cn.hutool.core.util.ObjectUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  5. import com.huimv.receive.common.token.TokenSign;
  6. import com.huimv.receive.common.utils.Result;
  7. import com.huimv.receive.common.utils.ResultCode;
  8. import com.huimv.receive.entity.BaseProcess;
  9. import com.huimv.receive.entity.BaseVisitingMid;
  10. import com.huimv.receive.entity.BaseWashoutPoint;
  11. import com.huimv.receive.entity.dto.GetWashoutPointDto;
  12. import com.huimv.receive.entity.dto.WashListDto;
  13. import com.huimv.receive.entity.vo.DestVo;
  14. import com.huimv.receive.entity.vo.WashOutVo;
  15. import com.huimv.receive.mapper.*;
  16. import com.huimv.receive.service.IBaseWashoutPointService;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.stereotype.Service;
  19. import javax.servlet.http.HttpServletRequest;
  20. import java.util.ArrayList;
  21. import java.util.Date;
  22. import java.util.List;
  23. import java.util.Map;
  24. /**
  25. * <p>
  26. * 服务实现类
  27. * </p>
  28. *
  29. * @author author
  30. * @since 2024-03-06
  31. */
  32. @Service
  33. public class BaseWashoutPointServiceImpl extends ServiceImpl<BaseWashoutPointMapper, BaseWashoutPoint> implements IBaseWashoutPointService {
  34. @Autowired
  35. private BaseWashoutPointMapper washoutPointMapper;
  36. @Autowired
  37. private BaseVisitingMapper visitingMapper;
  38. @Autowired
  39. private SysAccountMultilevelMapper accountMultilevelMapper;
  40. @Autowired
  41. private BaseProcessMapper processMapper;
  42. @Autowired
  43. private BaseVisitingMidMapper midMapper;
  44. @Override
  45. public Result list(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  46. String farmId = paramsMap.get("farmId");
  47. List<BaseVisitingMid> midList = midMapper.selectList(new QueryWrapper<BaseVisitingMid>().eq("farm_id", farmId));
  48. // List<BaseVisiting> visitings = visitingMapper.selectList(new QueryWrapper<>());
  49. List<GetWashoutPointDto> washoutPointDtos = new ArrayList<>();
  50. if (ObjectUtil.isEmpty(midList)) {
  51. return new Result(ResultCode.SUCCESS, washoutPointDtos);
  52. } else {
  53. for (BaseVisitingMid visiting : midList) {
  54. Integer type = visiting.getId();
  55. List<BaseWashoutPoint> list = washoutPointMapper.selectList(new QueryWrapper<BaseWashoutPoint>()
  56. .eq("farm_ids", farmId).eq("mid_id", type));
  57. List<WashListDto> washListDtos = new ArrayList<>();
  58. if (list.size() != 0) {
  59. for (BaseWashoutPoint point : list) {
  60. WashListDto washListDto = new WashListDto();
  61. washListDto.setAddressId(point.getLocationId());
  62. washListDto.setFlowLists(point.getFlowList());
  63. washListDto.setNextName(point.getTailLocationName());
  64. washListDto.setPcrTime(point.getPcrTime());
  65. washListDtos.add(washListDto);
  66. }
  67. GetWashoutPointDto getWashoutPointDto = new GetWashoutPointDto();
  68. getWashoutPointDto.setFarmIds(farmId);
  69. getWashoutPointDto.setNumber(list.size());
  70. getWashoutPointDto.setVisitingType(visiting.getVisitingType());
  71. getWashoutPointDto.setMidId(visiting.getId());
  72. getWashoutPointDto.setMidName(visiting.getVisitingName());
  73. getWashoutPointDto.setWashListDtos(washListDtos);
  74. washoutPointDtos.add(getWashoutPointDto);
  75. }
  76. }
  77. }
  78. return new Result(ResultCode.SUCCESS, washoutPointDtos);
  79. }
  80. @Override
  81. public Result add(HttpServletRequest httpServletRequest, WashOutVo washOutVo) {
  82. List<GetWashoutPointDto> washoutPointDtos = washOutVo.getWashoutPointDtos();
  83. String farmId = washOutVo.getFarmId();
  84. //如果当前存在进行中流程,则初始化流程配置不能修改或删除
  85. QueryWrapper<BaseProcess> processQueryWrapper = new QueryWrapper<>();
  86. processQueryWrapper.eq("farm_id", farmId).eq("process_type",0);
  87. List<BaseProcess> processes = processMapper.selectList(processQueryWrapper);
  88. if (processes.size() > 0) {
  89. return new Result(10001, "当前存在进行中流程,无法修改", true);
  90. }
  91. //访问类型集合
  92. QueryWrapper<BaseWashoutPoint> queryWrapper = new QueryWrapper<>();
  93. queryWrapper.eq("farm_ids",farmId);
  94. washoutPointMapper.delete(queryWrapper);
  95. for (GetWashoutPointDto washoutPointDto : washoutPointDtos) {
  96. //流程集合
  97. List<WashListDto> washListDtos = washoutPointDto.getWashListDtos();
  98. int i = 1;
  99. for (WashListDto washListDto : washListDtos) {
  100. BaseWashoutPoint washoutPoint = new BaseWashoutPoint();
  101. washoutPoint.setCreateTime(new Date());
  102. washoutPoint.setCreateUser(TokenSign.getMemberIdByJwtToken(httpServletRequest));
  103. washoutPoint.setFlowList(washListDto.getFlowLists());
  104. washoutPoint.setLocationId(washListDto.getAddressId());
  105. washoutPoint.setPcrTime(washListDto.getPcrTime());
  106. washoutPoint.setVisitingType(washoutPointDto.getVisitingType());
  107. washoutPoint.setTailLocationName(washListDto.getNextName());
  108. washoutPoint.setFarmIds(farmId);
  109. washoutPoint.setPointLevel(i);
  110. washoutPoint.setMidName(washoutPointDto.getMidName());
  111. washoutPoint.setMidId(washoutPointDto.getMidId());
  112. washoutPointMapper.insert(washoutPoint);
  113. i++;
  114. }
  115. }
  116. return new Result(10000, "添加成功!", true);
  117. }
  118. @Override
  119. public Result delete(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  120. String farmId = paramsMap.get("farmId");
  121. String type = paramsMap.get("type");//访问类型
  122. String level = paramsMap.get("level");//洗消站等级
  123. washoutPointMapper.delete(new QueryWrapper<BaseWashoutPoint>().like("farm_ids", farmId)
  124. .eq("visiting_type", type).eq("point_level", level));
  125. return new Result(10000, "删除成功!", true);
  126. }
  127. @Override
  128. public Result listDest(Map<String, String> paramsMap) {
  129. String farmId = paramsMap.get("farmId");
  130. String vistitType = paramsMap.get("midId");
  131. // if ("0".equals(vistitType)){
  132. // vistitType= "7";
  133. // }
  134. List<BaseWashoutPoint> baseWashoutPointList = washoutPointMapper.listDest(farmId,vistitType);
  135. List<DestVo> destVoList = new ArrayList<>();
  136. for (BaseWashoutPoint baseWashoutPoint : baseWashoutPointList) {
  137. DestVo destVo2 = new DestVo();
  138. destVo2.setId(baseWashoutPoint.getLocationId());
  139. destVo2.setLocationName(baseWashoutPoint.getTailLocationName());
  140. destVoList.add(destVo2);
  141. }
  142. return new Result(ResultCode.SUCCESS,destVoList);
  143. }
  144. @Override
  145. public Result listWash(Map<String, String> paramsMap) {
  146. String farmId = paramsMap.get("farmId");
  147. String vistitType = paramsMap.get("midId");
  148. List<BaseWashoutPoint> points = washoutPointMapper.listWash(farmId, vistitType);
  149. List<DestVo> destVoList = new ArrayList<>();
  150. for (BaseWashoutPoint baseWashoutPoint : points) {
  151. DestVo destVo = new DestVo();
  152. destVo.setId(baseWashoutPoint.getLocationId());
  153. destVo.setLocationName(baseWashoutPoint.getLocationName());
  154. destVoList.add(destVo);
  155. }
  156. return new Result(ResultCode.SUCCESS,destVoList);
  157. }
  158. }