d3dc741a5e01434f2f8c3671d8cc749604248337.svn-base 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. package cn.com.goldenwater.dcproj.controller.pblm;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.dao.ObjInspPblmsDao;
  5. import cn.com.goldenwater.dcproj.dto.ObjInspPblmsDto;
  6. import cn.com.goldenwater.dcproj.model.ObjInspPblms;
  7. import cn.com.goldenwater.dcproj.model.ObjTypeCheck;
  8. import cn.com.goldenwater.dcproj.model.OlBisInspOrg;
  9. import cn.com.goldenwater.dcproj.param.ObjInspPblmsParam;
  10. import cn.com.goldenwater.dcproj.param.ObjInspPblmsParams;
  11. import cn.com.goldenwater.dcproj.param.WagaPblm;
  12. import cn.com.goldenwater.dcproj.service.ObjInspPblmsService;
  13. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  14. import cn.com.goldenwater.id.util.UuidUtil;
  15. import cn.com.goldenwater.target.CheckException;
  16. import io.swagger.annotations.Api;
  17. import io.swagger.annotations.ApiOperation;
  18. import io.swagger.annotations.ApiParam;
  19. import org.apache.commons.lang3.StringUtils;
  20. import org.slf4j.Logger;
  21. import org.slf4j.LoggerFactory;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.data.redis.core.RedisTemplate;
  24. import org.springframework.util.Assert;
  25. import org.springframework.web.bind.annotation.*;
  26. import javax.servlet.http.HttpServletRequest;
  27. import java.util.*;
  28. import static cn.com.goldenwater.dcproj.util.CheckUtil.check;
  29. /**
  30. * @author lune
  31. * @date 2019-2-18
  32. */
  33. @Api(value = "小水库督查问题分类标准库", tags = "小水库督查问题分类标准库")
  34. @RestController
  35. @RequestMapping("/dc/insp/pblms")
  36. public class ObjInspPblmsController extends BaseController {
  37. private Logger logger = LoggerFactory.getLogger(getClass());
  38. @Autowired
  39. private ObjInspPblmsService objInspPblmsService;
  40. @Autowired
  41. private OlBisInspOrgService olBisInspOrgService;
  42. @ApiOperation(value = "添加问题分类标准库")
  43. @RequestMapping(value = "", method = RequestMethod.POST)
  44. public BaseResponse<String> insert(@ApiParam(name = "objInspPblms", value = "ObjInspPblms", required = true) @RequestBody ObjInspPblms objInspPblms) {
  45. String uuid = UuidUtil.uuid();
  46. objInspPblms.setGuid(uuid);
  47. int ret = objInspPblmsService.insert(objInspPblms);
  48. return buildSuccessResponse(uuid);
  49. }
  50. @ApiOperation(value = "获取问题类别")
  51. @RequestMapping(value = "/getPblmType", method = {RequestMethod.GET, RequestMethod.POST})
  52. public BaseResponse<List<ObjInspPblms>> getPblmType(ObjInspPblmsParam objInspPblmsParam) {
  53. if (StringUtils.isBlank(objInspPblmsParam.getType()) &&
  54. StringUtils.isBlank(objInspPblmsParam.getPguid())) {
  55. return buildSuccessResponse(objInspPblmsService.findList(null));
  56. }
  57. String orgId = getCurrentOrgId();
  58. OlBisInspOrg olBisInspOrg = olBisInspOrgService.get(orgId);
  59. Optional.ofNullable(olBisInspOrg).orElseThrow(() -> new CheckException("当前机构不存在!!"));
  60. if ("1".equals(olBisInspOrg.getPblmLogo()) && "1".equals(objInspPblmsParam.getType())) {
  61. objInspPblmsParam.setOrgId(olBisInspOrg.getQuoteOrgId());
  62. } else if ("22".equals(objInspPblmsParam.getType())) {
  63. objInspPblmsParam.setPguid(null);
  64. objInspPblmsParam.setOrgId(null);
  65. // if ("063".equals(orgId)) {
  66. // objInspPblmsParam.setOrgId(orgId);
  67. // }
  68. } else {
  69. objInspPblmsParam.setOrgId(null);
  70. }
  71. List<ObjInspPblms> objInspPblms;
  72. objInspPblms = objInspPblmsService.findList(objInspPblmsParam);
  73. //如果没找到问题清单,则设置通用问题清单
  74. if (objInspPblms.size() == 0) {
  75. ObjInspPblmsParam objInspPblmsParam1 = new ObjInspPblmsParam();
  76. objInspPblmsParam1.setType("111");
  77. objInspPblms = objInspPblmsService.findList(objInspPblmsParam1);
  78. for (ObjInspPblms item : objInspPblms) {
  79. item.setType(objInspPblmsParam.getType());
  80. }
  81. }
  82. return buildSuccessResponse(objInspPblms);
  83. }
  84. @ApiOperation(value = "获取根据附件表问题类别")
  85. @RequestMapping(value = "/getPblmTypeInAttach", method = {RequestMethod.POST})
  86. public BaseResponse<List<ObjInspPblms>> getPblmTypeInAttach(@RequestBody ObjInspPblmsParams objInspPblms) {
  87. List<ObjInspPblms> obj = new ArrayList<>();
  88. try {
  89. obj = objInspPblmsService.getPblmTypeInAttach(objInspPblms);
  90. } catch (Exception e) {
  91. e.printStackTrace();
  92. logger.error(e.getMessage());
  93. return buildFailResponse(e.getMessage());
  94. }
  95. return buildSuccessResponse(obj);
  96. }
  97. @ApiOperation(value = "根据ID删除问题分类标准库")
  98. @RequestMapping(value = "/{id}", method = RequestMethod.POST)
  99. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  100. int ret = objInspPblmsService.delete(id);
  101. return buildSuccessResponse();
  102. }
  103. @ApiOperation(value = "更新问题分类标准库信息")
  104. @RequestMapping(value = "/update", method = RequestMethod.POST)
  105. public BaseResponse update(@ApiParam(name = "objInspPblms", value = "ObjInspPblms", required = true) @RequestBody ObjInspPblms objInspPblms) {
  106. Assert.notNull(objInspPblms.getGuid(), "主键id为必填参数");
  107. int ret = objInspPblmsService.update(objInspPblms);
  108. return buildSuccessResponse();
  109. }
  110. @ApiOperation(value = "根据ID获取问题分类标准库(单表)")
  111. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  112. public BaseResponse<ObjInspPblms> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  113. ObjInspPblms objInspPblms = objInspPblmsService.get(id);
  114. return buildSuccessResponse(objInspPblms);
  115. }
  116. @ApiOperation(value = "获取整个标准库数据")
  117. @RequestMapping(value = "/findAll", method = RequestMethod.GET)
  118. public BaseResponse<List<ObjInspPblms>> findAll() {
  119. List<ObjInspPblms> pblmsList = objInspPblmsService.findList(null);
  120. return buildSuccessResponse(pblmsList);
  121. }
  122. @ApiOperation(value = "获取所有数据类型")
  123. @RequestMapping(value = "/getPblmsType", method = {RequestMethod.GET})
  124. public BaseResponse<List<String>> getPblmsType() {
  125. List<String> pblmsType = objInspPblmsService.findPblmsName(getCurrentOrgId());
  126. return buildSuccessResponse(pblmsType);
  127. }
  128. @ApiOperation(value = "获取所有的问题名称,去重")
  129. @RequestMapping(value = "/getPblmNames", method = RequestMethod.GET)
  130. public BaseResponse<List<String>> getPblmNames(ObjInspPblmsParam objInspPblmsParam) {
  131. OlBisInspOrg olBisInspOrg = olBisInspOrgService.get(getCurrentOrgId());
  132. if (olBisInspOrg == null) {
  133. throw new CheckException("当前机构不存在!!");
  134. }
  135. if ("1".equals(olBisInspOrg.getPblmLogo()) && "1".equals(objInspPblmsParam.getType())) {
  136. objInspPblmsParam.setOrgId(olBisInspOrg.getQuoteOrgId());
  137. } else {
  138. objInspPblmsParam.setOrgId("");
  139. }
  140. List<String> pblmNames = objInspPblmsService.getPblmNames(objInspPblmsParam);
  141. return buildSuccessResponse(pblmNames);
  142. }
  143. @ApiOperation(value = "获取所有数据检查项")
  144. @RequestMapping(value = "/getCheckPoints", method = {RequestMethod.POST})
  145. public BaseResponse<List<String>> getPblmsType(@RequestBody ObjInspPblmsParam objInspPblmsParam) {
  146. if (StringUtils.isBlank(objInspPblmsParam.getType())) {
  147. objInspPblmsParam.setType("1");
  148. }
  149. List<String> pblmsType = objInspPblmsService.findPblmsCheckPoints(objInspPblmsParam, getCurrentOrgId());
  150. return buildSuccessResponse(pblmsType);
  151. }
  152. @ApiOperation(value = "获取所有问题描述信息")
  153. @RequestMapping(value = "/getPblmsDesc", method = {RequestMethod.POST})
  154. public BaseResponse<List<String>> getPblmsDesc(@RequestBody ObjInspPblmsParam objInspPblmsParam) {
  155. if (StringUtils.isBlank(objInspPblmsParam.getType())) {
  156. objInspPblmsParam.setType("1");
  157. }
  158. OlBisInspOrg olBisInspOrg = olBisInspOrgService.get(getCurrentOrgId());
  159. if (olBisInspOrg == null) {
  160. throw new CheckException("当前机构不存在!!");
  161. }
  162. Map<String, String> params = new HashMap<>();
  163. params.put("type", objInspPblmsParam.getType());
  164. params.put("inspPblmsName", objInspPblmsParam.getInspPblmsName());
  165. params.put("checkPoint", objInspPblmsParam.getCheckPoint());
  166. if ("1".equals(olBisInspOrg.getPblmLogo()) && "1".equals(objInspPblmsParam.getType())) {
  167. params.put("orgId", olBisInspOrg.getQuoteOrgId());
  168. }
  169. List<String> pblmsType = objInspPblmsService.findPblmsDesc(params);
  170. return buildSuccessResponse(pblmsType);
  171. }
  172. @ApiOperation(value = "获取标准表单个信息")
  173. @RequestMapping(value = "/getByPblms", method = {RequestMethod.POST})
  174. public BaseResponse<ObjInspPblms> getByPblms(@RequestBody ObjInspPblmsParam objInspPblmsParam) {
  175. check(StringUtils.isNotBlank(objInspPblmsParam.getType()), "type.no");
  176. Map<String, String> params = new HashMap<>(6);
  177. params.put("inspPblmsName", objInspPblmsParam.getInspPblmsName());
  178. params.put("checkPoint", objInspPblmsParam.getCheckPoint());
  179. params.put("pblmDesc", objInspPblmsParam.getPblmDesc());
  180. params.put("type", objInspPblmsParam.getType());
  181. params.put("guid", objInspPblmsParam.getGuid());
  182. String orgId = getCurrentOrgId();
  183. OlBisInspOrg olBisInspOrg = olBisInspOrgService.get(orgId);
  184. if ("1".equals(olBisInspOrg.getPblmLogo()) && "1".equals(objInspPblmsParam.getType())) {
  185. params.put("orgId", olBisInspOrg.getQuoteOrgId());
  186. } else {
  187. params.put("orgId", "");
  188. }
  189. ObjInspPblms pblmsType = objInspPblmsService.getByPblms(params);
  190. return buildSuccessResponse(pblmsType);
  191. }
  192. @ApiOperation(value = "获取标准表单个信息")
  193. @RequestMapping(value = "/getPblmsByType", method = {RequestMethod.POST})
  194. public BaseResponse<ObjInspPblms> getPblmsByType(@RequestBody ObjInspPblmsParam objInspPblmsParam) {
  195. String orgId = getCurrentOrgId();
  196. OlBisInspOrg olBisInspOrg = olBisInspOrgService.get(orgId);
  197. if (olBisInspOrg == null) {
  198. throw new CheckException("当前机构不存在!!");
  199. }
  200. if ("1".equals(olBisInspOrg.getPblmLogo()) && "1".equals(objInspPblmsParam.getType())) {
  201. objInspPblmsParam.setOrgId(olBisInspOrg.getQuoteOrgId());
  202. } else {
  203. objInspPblmsParam.setOrgId(null);
  204. }
  205. ObjInspPblms pblmsType = objInspPblmsService.getPblmsByType(objInspPblmsParam);
  206. return buildSuccessResponse(pblmsType);
  207. }
  208. @Autowired
  209. private ObjInspPblmsDao objInspPblmsDao;
  210. @ApiOperation(value = "获取标准表单个信息(未启用)")
  211. @RequestMapping(value = "/getByWagaPblm", method = {RequestMethod.POST})
  212. public BaseResponse<Map<String, Object>> getByPblms(@RequestBody WagaPblm wagaPblm) {
  213. String sn = wagaPblm.getSn();
  214. if (StringUtils.isNotBlank(sn)) {
  215. sn = sn.replace("至", "-");
  216. sn = sn.replace("到", "-");
  217. StringBuffer buffer = new StringBuffer();
  218. if (sn.contains(",")) {
  219. String[] arrays = sn.split(",");
  220. for (String array : arrays) {
  221. if (array.contains("-")) {
  222. String[] startAndEnd = array.split("-");
  223. if (startAndEnd.length == 2) {
  224. int start = Integer.parseInt(startAndEnd[0]);
  225. int end = Integer.parseInt(startAndEnd[1]);
  226. for (int i = start; i <= end; i++) {
  227. buffer.append(i + ",");
  228. }
  229. } else {
  230. buffer.append(startAndEnd[0] + ",");
  231. }
  232. } else {
  233. buffer.append(array + ",");
  234. }
  235. }
  236. } else if (sn.contains("-")) {
  237. String[] startAndEnd = sn.split("-");
  238. if (startAndEnd.length == 2) {
  239. int start = Integer.parseInt(startAndEnd[0]);
  240. int end = Integer.parseInt(startAndEnd[1]);
  241. for (int i = start; i <= end; i++) {
  242. buffer.append(i + ",");
  243. }
  244. } else {
  245. buffer.append(startAndEnd[0] + ",");
  246. }
  247. } else {
  248. buffer.append(sn);
  249. }
  250. String snStr = buffer.toString();
  251. if (snStr.endsWith(",")) {
  252. snStr = snStr.substring(0, snStr.length() - 1);
  253. }
  254. wagaPblm.setSn(snStr);
  255. List<ObjInspPblms> inspPblms = objInspPblmsDao.findWagaPblm(wagaPblm.getSn(), wagaPblm.getAttach(), getCurrentOrgId());
  256. Map<String, Object> retMap = new HashMap<>();
  257. List<String> pblmNames = new ArrayList<>();
  258. for (ObjInspPblms pblms : inspPblms) {
  259. if (!pblmNames.contains(pblms.getInspPblmsName())) {
  260. pblmNames.add(pblms.getInspPblmsName());
  261. }
  262. }
  263. retMap.put("pblms", pblmNames);
  264. retMap.put("datas", inspPblms);
  265. return buildSuccessResponse(retMap);
  266. }
  267. return buildSuccessResponse(null);
  268. }
  269. @ApiOperation(value = "根据规则id和类型获取对应的描述信息")
  270. @RequestMapping(value = "/getPblmsByQuesNum/{id}/{type}", method = {RequestMethod.GET})
  271. public BaseResponse<List<ObjTypeCheck>> getPblmsByQuesNum(@ApiParam(name = "id", value = "规则id", required = true) @PathVariable String id,
  272. @ApiParam(name = "type", value = "类型", required = true) @PathVariable String type) {
  273. // 1. 跟id取出对应的 规则(问题标准 0:全国标准,1:自定义标准)
  274. OlBisInspOrg olBisInspOrg = olBisInspOrgService.get(getCurrentOrgId());
  275. if (olBisInspOrg == null) {
  276. throw new CheckException("当前机构不存在!!");
  277. }
  278. List<ObjTypeCheck> bisInspItemQuesNumDtoList = objInspPblmsService.getPblmsByQuesNum(id, type, olBisInspOrg);
  279. return buildSuccessResponse(bisInspItemQuesNumDtoList);
  280. }
  281. @ApiOperation(value = "根据督查类型获取所有的问题标准的分类、检查项和描述信息")
  282. @RequestMapping(value = "/getAllPblmsByType/{type}", method = {RequestMethod.GET})
  283. public BaseResponse getAllPblmsByType(@ApiParam(name = "type", value = "类型", required = true)
  284. @PathVariable String type) {
  285. return buildSuccessResponse(objInspPblmsService.getAllPblmsByType(type, getCurrentOrgId()));
  286. }
  287. @Autowired
  288. private RedisTemplate redisTemplate;
  289. @ApiOperation(value = "获取小水库(水闸)标准数据tree类型:type=1水库,type=6水闸")
  290. @RequestMapping(value = "/getPblmsRverTree/{type}", method = {RequestMethod.GET})
  291. public BaseResponse<List<ObjInspPblmsDto>> getPblmsRverTree(@PathVariable(required = true) String type, HttpServletRequest request) {
  292. //第一节点
  293. OlBisInspOrg olBisInspOrg = olBisInspOrgService.get(getCurrentOrgId());
  294. String orgId = "";
  295. if ("1".equals(olBisInspOrg.getPblmLogo()) && "1".equals(type)) {
  296. orgId = olBisInspOrg.getQuoteOrgId();
  297. }
  298. String pblmsName = request.getParameter("pblmsName");
  299. String sort1 = request.getParameter("sort1");
  300. List<ObjInspPblmsDto> pblmsType = new ArrayList<>();
  301. List<ObjInspPblmsDto> pblmsList = new ArrayList<>();
  302. pblmsType = objInspPblmsService.findPblmsDtoName(type, pblmsName, orgId, sort1);
  303. pblmsList = objInspPblmsService.findPblmsDTO(type, pblmsName, orgId, sort1);
  304. Set<ObjInspPblmsDto> secondList = new HashSet<>();
  305. if (pblmsList == null) {
  306. throw new CheckException("未查到任何数据!!");
  307. }
  308. for (ObjInspPblmsDto pblm : pblmsList) {
  309. ObjInspPblmsDto secChild = new ObjInspPblmsDto();
  310. secChild.setCheckPoint(pblm.getCheckPoint());
  311. secChild.setInspPblmsName(pblm.getInspPblmsName());
  312. secondList.add(secChild);
  313. }
  314. for (ObjInspPblmsDto pblm : pblmsType) {
  315. List<ObjInspPblmsDto> chlist = new ArrayList<>();
  316. for (ObjInspPblmsDto sec : secondList) {
  317. if (pblm.getInspPblmsName().equals(sec.getInspPblmsName())) {
  318. chlist.add(sec);
  319. }
  320. }
  321. pblm.setChildren(chlist);
  322. }
  323. for (ObjInspPblmsDto sec : secondList) {
  324. List<ObjInspPblmsDto> chlist = new ArrayList<>();
  325. for (ObjInspPblmsDto pblm : pblmsList) {
  326. if (sec.getInspPblmsName().equals(pblm.getInspPblmsName()) && sec.getCheckPoint().equals(pblm.getCheckPoint())) {
  327. chlist.add(pblm);
  328. }
  329. }
  330. sec.setChildren(chlist);
  331. }
  332. return buildSuccessResponse(pblmsType);
  333. }
  334. }