3bc95b0a99c87529d4326bd6a7220ca1350a05d4.svn-base 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. package cn.com.goldenwater.dcproj.controller.general;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.model.*;
  5. import cn.com.goldenwater.dcproj.param.GwComFileParam;
  6. import cn.com.goldenwater.dcproj.service.*;
  7. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  8. import cn.com.goldenwater.id.util.UuidUtil;
  9. import com.github.pagehelper.PageInfo;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiOperation;
  12. import io.swagger.annotations.ApiParam;
  13. import org.apache.commons.lang3.StringUtils;
  14. import org.slf4j.Logger;
  15. import org.slf4j.LoggerFactory;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.beans.factory.annotation.Value;
  18. import org.springframework.util.Assert;
  19. import org.springframework.web.bind.annotation.*;
  20. import org.springframework.web.multipart.MultipartFile;
  21. import javax.servlet.http.HttpServletRequest;
  22. import javax.servlet.http.HttpServletResponse;
  23. import java.io.File;
  24. import java.io.IOException;
  25. import java.util.*;
  26. import java.util.regex.Pattern;
  27. /**
  28. * @author zhaohg
  29. * @date 2019-2-18
  30. */
  31. @Api(value = "文件管理", tags = "01文件管理")
  32. @RestController
  33. @RequestMapping("/file")
  34. public class GwComFileController extends BaseController {
  35. private Logger logger = LoggerFactory.getLogger(getClass());
  36. private Pattern pattern = Pattern.compile("\\d{12}$");
  37. @Autowired
  38. private GwComFileService gwComFileService;
  39. @Autowired
  40. private AttAdBaseService attAdBaseService;
  41. @Autowired
  42. private NewsService newsService;
  43. @Autowired
  44. private BisInspOprdCstrProjRgstrService bisInspOprdCstrProjRgstrService;
  45. @Value("${getFile.prefix}")
  46. public String prefix;
  47. @Autowired
  48. private OlBisInspOrgService olBisInspOrgService;
  49. @ApiOperation(value = "添加文件", notes = "参数字段说明:{\n\r" +
  50. " \"file\":\"上传文件\",\n\r" +
  51. " \"fileTitle\":\"标题\",\n\r" +
  52. " \"keyWord\":\"版号\",\n\r" +
  53. " };\n\r" +
  54. "返回结构说明:{\n\r" +
  55. " \"success\":\"是否成功(true为成功,false为失败)\",\n\r" +
  56. " \"code\":\"错误代码\",\n\r" +
  57. " \"data(数据信息)\":\n\r" +
  58. " {\n\r" +
  59. " \"guid \":\"主键id\",\n\r" +
  60. " \"filePath \":\"文件路径\",\n\r" +
  61. " \"fileType \":\"文件类型\",\n\r" +
  62. " \"fileTitle\":\"标题\",\n\r" +
  63. " \"createDate\":\"时间\",\n\r" +
  64. " \"keyWord\":\"版号\",\n\r" +
  65. " \"fileName\":\"文件名称\",\n\r" +
  66. " \"fileExt\":\"文件扩展名\",\n\r" +
  67. " }\n\r" +
  68. " }")
  69. @RequestMapping(value = "/insert", method = RequestMethod.POST)
  70. public BaseResponse<GwComFile> insert(@RequestParam("file") MultipartFile file, GwComFile gwComFile, HttpServletRequest request) {
  71. String uuid = UuidUtil.uuid(); // 生成uuid
  72. gwComFile.setId(uuid);
  73. //按时间日期存文件
  74. System.out.println("submit file in");
  75. Calendar dat = Calendar.getInstance();
  76. if (null == gwComFile.getCreateDate()) {
  77. gwComFile.setCreateDate(Calendar.getInstance().getTime());
  78. }
  79. if (file != null) {
  80. String originalFilename = file.getOriginalFilename();
  81. gwComFile.setFileName(originalFilename);
  82. gwComFile.setFileTitle(StringUtils.isNotBlank(gwComFile.getFileTitle()) ? gwComFile.getFileTitle() : gwComFile.getFileName());
  83. gwComFile.setFileSize((double) file.getSize());
  84. gwComFile.setFileExt(originalFilename.substring(1 + originalFilename.lastIndexOf(".")));
  85. String filePath = prefix + dat.get(Calendar.YEAR) + File.separator + (dat.get(Calendar.MONTH) + 1) + File.separator + dat.get(Calendar.DAY_OF_MONTH) + File.separator + uuid + "." + gwComFile.getFileExt();
  86. gwComFile.setFilePath(filePath);
  87. if (gwComFile.getFileExt().toLowerCase().equals("html") ||
  88. gwComFile.getFileExt().toLowerCase().equals("htm") ||
  89. gwComFile.getFileExt().toLowerCase().equals("js") ||
  90. gwComFile.getFileExt().toLowerCase().equals("jsp") ||
  91. gwComFile.getFileExt().toLowerCase().equals("aspx") ||
  92. gwComFile.getFileExt().toLowerCase().equals("php") ||
  93. gwComFile.getFileExt().toLowerCase().equals("python") ||
  94. gwComFile.getFileExt().toLowerCase().equals("exe")) {
  95. return buildFailResponse(1001, "文件上传失败");
  96. }
  97. }
  98. //写入文件
  99. String filePath = dat.get(Calendar.YEAR) + File.separator + (dat.get(Calendar.MONTH) + 1) + File.separator + dat.get(Calendar.DAY_OF_MONTH);
  100. boolean success = gwComFileService.writeFile(gwComFile, file, filePath);
  101. System.out.println("submit file " + success);
  102. if (success) {
  103. System.out.println("submit file success");
  104. gwComFileService.insert(gwComFile);
  105. if ("1".equals(gwComFile.getIsNotice())) {
  106. // String currentAdcode = AdLevelUtil.getAddvcd(olBisInspOrgService.getProvince(getCurrentOrgId()));
  107. BisInspOrg bisInspOrg = olBisInspOrgService.getDefaultOrg(getCurrentOrgId());
  108. AttAdBase attAdBase = attAdBaseService.get(bisInspOrg.getAdCode());
  109. News news = new News();
  110. news.setOrgId(bisInspOrg.getOrgId());
  111. news.setAdCode(bisInspOrg.getAdCode());
  112. news.setAdName(attAdBase.getAdName());
  113. news.setAdFullName(attAdBase.getAdFullName());
  114. news.setAdGrad(attAdBase.getAdGrad());
  115. news.setTitle(file.getOriginalFilename().substring(0, file.getOriginalFilename().lastIndexOf(".")));
  116. news.setDes(file.getOriginalFilename().substring(0, file.getOriginalFilename().lastIndexOf(".")));
  117. news.setClcUrl(gwComFile.getFilePath());
  118. news.setIntm(new Date());
  119. news.setDataStat("0");
  120. newsService.insert(news);
  121. }
  122. if (StringUtils.isNotBlank(gwComFile.getBizType()) && gwComFile.getBizType().contains("signature")) {
  123. String orgId = request.getHeader("orgId");
  124. if (gwComFile.getBizId().endsWith(orgId)) {
  125. String registrId = gwComFile.getBizId().replace(orgId, "");
  126. BisInspOprdCstrProjRgstr oprdCstrProjRgstr = bisInspOprdCstrProjRgstrService.get(registrId);
  127. if (oprdCstrProjRgstr != null) {
  128. oprdCstrProjRgstr.setState("1");
  129. bisInspOprdCstrProjRgstrService.update(oprdCstrProjRgstr);
  130. }
  131. }
  132. }
  133. } else {
  134. return buildFailResponse(1001, "文件上传失败");
  135. }
  136. return buildSuccessResponse(gwComFile);
  137. }
  138. @ApiOperation(value = "添加文件", notes = "参数字段说明:{\n\r" +
  139. " \"file\":\"上传文件\",\n\r" +
  140. " \"fileTitle\":\"标题\",\n\r" +
  141. " \"keyWord\":\"版号\",\n\r" +
  142. " };\n\r" +
  143. "返回结构说明:{\n\r" +
  144. " \"success\":\"是否成功(true为成功,false为失败)\",\n\r" +
  145. " \"code\":\"错误代码\",\n\r" +
  146. " \"data(数据信息)\":\n\r" +
  147. " {\n\r" +
  148. " \"guid \":\"主键id\",\n\r" +
  149. " \"filePath \":\"文件路径\",\n\r" +
  150. " \"fileType \":\"文件类型\",\n\r" +
  151. " \"fileTitle\":\"标题\",\n\r" +
  152. " \"createDate\":\"时间\",\n\r" +
  153. " \"keyWord\":\"版号\",\n\r" +
  154. " \"fileName\":\"文件名称\",\n\r" +
  155. " \"fileExt\":\"文件扩展名\",\n\r" +
  156. " }\n\r" +
  157. " }")
  158. @RequestMapping(value = "/insertMulId", method = RequestMethod.POST)
  159. public BaseResponse<GwComFile> insertMulId(@RequestParam("file") MultipartFile file, GwComFile gwComFile, HttpServletRequest request) {
  160. try {
  161. if (gwComFile != null) {
  162. if (StringUtils.isNotBlank(gwComFile.getBizId())) {
  163. String[] arr = gwComFile.getBizId().split(",");
  164. for (String id : arr) {
  165. GwComFile gwComFile1 = new GwComFile();
  166. gwComFile1.setBizId(id);
  167. gwComFile1.setBizType(gwComFile.getBizType());
  168. this.insert(file, gwComFile1, request);
  169. }
  170. }
  171. }
  172. } catch (Exception e) {
  173. return buildFailResponse();
  174. }
  175. return buildSuccessResponse(gwComFile);
  176. }
  177. @RequestMapping(value = "/insertList", method = RequestMethod.POST)
  178. public BaseResponse<List<GwComFile>> insertList(@RequestParam("file") List<MultipartFile> files, GwComFile gwComFile, HttpServletRequest request) {
  179. List<GwComFile> gwComFiles = new ArrayList<>();
  180. for (int i = 0; i < files.size(); i++) {
  181. String uuid = UuidUtil.uuid(); // 生成uuid
  182. GwComFile bizParam = new GwComFile();
  183. bizParam.setBizId(gwComFile.getBizId());
  184. bizParam.setBizType(gwComFile.getBizType());
  185. bizParam.setId(uuid);
  186. //按时间日期存文件
  187. System.out.println("submit file in");
  188. Calendar dat = Calendar.getInstance();
  189. if (null == bizParam.getCreateDate()) {
  190. bizParam.setCreateDate(Calendar.getInstance().getTime());
  191. }
  192. if (files.get(i) != null) {
  193. String originalFilename = files.get(i).getOriginalFilename();
  194. bizParam.setFileName(originalFilename);
  195. bizParam.setFileTitle(StringUtils.isNotBlank(bizParam.getFileTitle()) ? bizParam.getFileTitle() : bizParam.getFileName());
  196. bizParam.setFileSize((double) files.get(i).getSize());
  197. bizParam.setFileExt(originalFilename.substring(1 + originalFilename.lastIndexOf(".")));
  198. String filePath = prefix + dat.get(Calendar.YEAR) + File.separator + (dat.get(Calendar.MONTH) + 1) + File.separator + dat.get(Calendar.DAY_OF_MONTH) + File.separator + uuid + "." + bizParam.getFileExt();
  199. bizParam.setFilePath(filePath);
  200. }
  201. //写入文件
  202. String filePath = dat.get(Calendar.YEAR) + File.separator + (dat.get(Calendar.MONTH) + 1) + File.separator + dat.get(Calendar.DAY_OF_MONTH);
  203. boolean success = gwComFileService.writeFile(bizParam, files.get(i), filePath);
  204. System.out.println("submit file " + success);
  205. if (success) {
  206. System.out.println("submit file success");
  207. gwComFileService.insert(bizParam);
  208. if ("1".equals(bizParam.getIsNotice())) {
  209. // String currentAdcode = AdLevelUtil.getAddvcd(olBisInspOrgService.getProvince(getCurrentOrgId()));
  210. BisInspOrg bisInspOrg = olBisInspOrgService.getDefaultOrg(getCurrentOrgId());
  211. AttAdBase attAdBase = attAdBaseService.get(bisInspOrg.getAdCode());
  212. News news = new News();
  213. news.setOrgId(bisInspOrg.getOrgId());
  214. news.setAdCode(bisInspOrg.getAdCode());
  215. news.setAdName(attAdBase.getAdName());
  216. news.setAdFullName(attAdBase.getAdFullName());
  217. news.setAdGrad(attAdBase.getAdGrad());
  218. news.setTitle(files.get(i).getOriginalFilename().substring(0, files.get(i).getOriginalFilename().lastIndexOf(".")));
  219. news.setDes(files.get(i).getOriginalFilename().substring(0, files.get(i).getOriginalFilename().lastIndexOf(".")));
  220. news.setClcUrl(bizParam.getFilePath());
  221. news.setIntm(new Date());
  222. news.setDataStat("0");
  223. newsService.insert(news);
  224. }
  225. if (StringUtils.isNotBlank(bizParam.getBizType()) && bizParam.getBizType().contains("signature")) {
  226. String orgId = request.getHeader("orgId");
  227. if (bizParam.getBizId().endsWith(orgId)) {
  228. String registrId = bizParam.getBizId().replace(orgId, "");
  229. BisInspOprdCstrProjRgstr oprdCstrProjRgstr = bisInspOprdCstrProjRgstrService.get(registrId);
  230. if (oprdCstrProjRgstr != null) {
  231. oprdCstrProjRgstr.setState("1");
  232. bisInspOprdCstrProjRgstrService.update(oprdCstrProjRgstr);
  233. }
  234. }
  235. }
  236. gwComFiles.add(bizParam);
  237. } else {
  238. return buildFailResponse(1001, "文件上传失败");
  239. }
  240. }
  241. return buildSuccessResponse(gwComFiles);
  242. }
  243. @ApiOperation(value = "根据ID删除xxx")
  244. @RequestMapping(value = "/{id}", method = RequestMethod.POST)
  245. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  246. GwComFile gwComFile = gwComFileService.get(id);
  247. int ret = gwComFileService.delete(id);
  248. gwComFileService.updatePblmVedio(gwComFile.getBizId());
  249. return buildSuccessResponse();
  250. }
  251. @ApiOperation(value = "文件列表")
  252. @RequestMapping(value = "/findImgPage", method = RequestMethod.POST)
  253. public BaseResponse findPage(@ApiParam(name = "gwComFileParam", value = "GwComFileParam", required = true)
  254. @RequestBody GwComFileParam gwComFileParam) {
  255. return buildSuccessResponse(gwComFileService.findImgPage(gwComFileParam));
  256. }
  257. @ApiOperation(value = "更新xxx信息")
  258. @RequestMapping(value = "/update", method = RequestMethod.POST)
  259. public BaseResponse update(@ApiParam(name = "gwComFile", value = "GwComFile", required = true) @RequestBody GwComFile gwComFile) {
  260. Assert.notNull(gwComFile.getId(), "主键id为必填参数");
  261. int ret = gwComFileService.update(gwComFile);
  262. return buildSuccessResponse();
  263. }
  264. @ApiOperation(value = "更新文件信息")
  265. @RequestMapping(value = "/updateFile", method = RequestMethod.POST)
  266. public BaseResponse updateFile(@RequestParam("file") MultipartFile file, GwComFile newGwComFile) {
  267. Assert.notNull(newGwComFile.getId(), "主键id为必填参数");
  268. GwComFile gwComFile = gwComFileService.get(newGwComFile.getId());
  269. File gwFile = new File(gwComFile.getFilePath());
  270. if (gwFile.exists()) {
  271. gwFile.delete();
  272. }
  273. Calendar dat = Calendar.getInstance();
  274. if (null == gwComFile.getCreateDate()) {
  275. gwComFile.setCreateDate(Calendar.getInstance().getTime());
  276. }
  277. if (file != null) {
  278. String originalFilename = file.getOriginalFilename();
  279. gwComFile.setFileName(originalFilename);
  280. gwComFile.setFileTitle(StringUtils.isNotBlank(gwComFile.getFileTitle()) ? gwComFile.getFileTitle() : gwComFile.getFileName());
  281. gwComFile.setFileSize((double) file.getSize());
  282. gwComFile.setFileExt(originalFilename.substring(1 + originalFilename.lastIndexOf(".")));
  283. String filePath = prefix + dat.get(Calendar.YEAR) + File.separator + (dat.get(Calendar.MONTH) + 1) + File.separator + dat.get(Calendar.DAY_OF_MONTH) + File.separator + gwComFile.getId() + "." + gwComFile.getFileExt();
  284. gwComFile.setFilePath(filePath);
  285. }
  286. //写入文件
  287. String filePath = dat.get(Calendar.YEAR) + File.separator + (dat.get(Calendar.MONTH) + 1) + File.separator + dat.get(Calendar.DAY_OF_MONTH);
  288. boolean success = gwComFileService.writeFile(gwComFile, file, filePath);
  289. if (success) {
  290. int ret = gwComFileService.update(gwComFile);
  291. } else {
  292. return buildFailResponse(1001, "文件上传失败");
  293. }
  294. return buildSuccessResponse(gwComFile);
  295. }
  296. @ApiOperation(value = "根据ID获取xxx(单表)")
  297. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  298. public BaseResponse<GwComFile> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  299. GwComFile gwComFile = gwComFileService.get(id);
  300. return buildSuccessResponse(gwComFile);
  301. }
  302. @ApiOperation(value = "根据业务ID获取文件")
  303. @RequestMapping(value = "/findFileByBiz", method = RequestMethod.POST)
  304. public BaseResponse<List<GwComFile>> findFileByBiz(@ApiParam(name = "bizId", value = "bizId", required = true) @RequestParam String bizId) {
  305. List<GwComFile> gwComFileList = gwComFileService.findFileByBiz(bizId);
  306. return buildSuccessResponse(gwComFileList);
  307. }
  308. @ApiOperation(value = "把所有图片制作一份缩略图(按月份的文件夹修改)")
  309. @RequestMapping(value = "/changeSmallImg", method = RequestMethod.GET)
  310. public BaseResponse<String> changeSmallImg(@ApiParam(name = "year", value = "year", required = true) @RequestParam String year, @ApiParam(name = "mnth", value = "mnth", required = true) @RequestParam String mnth) {
  311. gwComFileService.changeSmallImg(year, mnth);
  312. return buildSuccessResponse("执行完成");
  313. }
  314. @ApiOperation(value = "根据查询条件获取文件列表")
  315. @RequestMapping(value = "/findPageInfo", method = RequestMethod.POST)
  316. public BaseResponse<PageInfo<GwComFile>> findPageInfo(@RequestBody GwComFileParam gwComFileParam) {
  317. PageInfo<GwComFile> gwComFileList = gwComFileService.findFilePageByBiz(gwComFileParam);
  318. return buildSuccessResponse(gwComFileList);
  319. }
  320. @ApiOperation(value = "根据查询条件获取所有文件列表")
  321. @RequestMapping(value = "/findAllFile", method = RequestMethod.POST)
  322. public BaseResponse<List<GwComFile>> findAllFile(@RequestBody GwComFileParam gwComFileParam) {
  323. List<GwComFile> gwComFileList = gwComFileService.findAllFile(gwComFileParam);
  324. return buildSuccessResponse(gwComFileList);
  325. }
  326. @ApiOperation(value = "根据id下载文件")
  327. @RequestMapping(value = "/downFile/{id}", method = RequestMethod.GET)
  328. public BaseResponse downFile(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id, HttpServletResponse response) {
  329. GwComFile gwComFile = gwComFileService.get(id);
  330. if (gwComFile == null) {
  331. return buildFailResponse("文件不存在");
  332. }
  333. gwComFile.setFilePath(gwComFile.getFilePath().substring(gwComFile.getFilePath().indexOf(prefix) + 7));
  334. int result = gwComFileService.downFile(gwComFile, response);
  335. if (result == 0) {
  336. return buildFailResponse("文件不存在");
  337. }
  338. return buildSuccessResponse();
  339. }
  340. @ApiOperation(value = "根据文件ID置顶")
  341. @GetMapping(value = "/top/{id}")
  342. public BaseResponse<String> getTop(@PathVariable String id) {
  343. gwComFileService.updateTopById(id);
  344. return buildSuccessResponse(id);
  345. }
  346. @ApiOperation(value = "根据文件ID取消置顶")
  347. @GetMapping(value = "/cancelTop/{id}")
  348. @Deprecated
  349. public BaseResponse<String> cancelTop(@PathVariable String id) {
  350. gwComFileService.updateTopById(id);
  351. return buildSuccessResponse(id);
  352. }
  353. @ApiOperation(value = "获取前N条近期面貌督查")
  354. @RequestMapping(value = "/getTopNFace", method = RequestMethod.GET)
  355. public BaseResponse<List<GwComFile>> getTopNFace(
  356. @ApiParam(name = "n", value = "前n调记录", required = false) @RequestParam(defaultValue = "5", required = false) String n,
  357. @ApiParam(name = "adCode", value = "行政区代码", required = false) @RequestParam(required = false) String adCode,
  358. @ApiParam(name = "ptype", value = "督查类别", required = false) @RequestParam(required = false) String pType) {
  359. String currentAdcode = AdLevelUtil.getAddvcd(olBisInspOrgService.getProvince(getCurrentOrgId()));
  360. if (StringUtils.isNotBlank(pType)) {
  361. pType = String.valueOf(Integer.parseInt(pType));
  362. }
  363. if (StringUtils.isNotBlank(adCode)) {
  364. if (validateAdCode(adCode)) {
  365. adCode = AdLevelUtil.getAddvcd(adCode);
  366. } else {
  367. adCode = currentAdcode;
  368. }
  369. } else {
  370. adCode = currentAdcode;
  371. }
  372. List<GwComFile> gwComFiles = gwComFileService.getTopNFace(n, adCode, pType, currentAdcode);
  373. return buildSuccessResponse(gwComFiles);
  374. }
  375. @ApiOperation(value = "获取前N条问题")
  376. @RequestMapping(value = "/getTopNPblm", method = RequestMethod.GET)
  377. public BaseResponse<List<GwComFile>> getTopNPblm(
  378. @ApiParam(name = "n", value = "前n调记录", required = false) @RequestParam(defaultValue = "8", required = false) String n,
  379. @ApiParam(name = "adCode", value = "行政区代码", required = false) @RequestParam(required = false) String adCode,
  380. @ApiParam(name = "ptype", value = "督查类别", required = false) @RequestParam(required = false) String pType) {
  381. String currentAdcode = AdLevelUtil.getAddvcd(olBisInspOrgService.getProvince(getCurrentOrgId()));
  382. if (StringUtils.isNotBlank(pType)) {
  383. pType = String.valueOf(Integer.parseInt(pType));
  384. }
  385. if (StringUtils.isNotBlank(adCode)) {
  386. adCode = AdLevelUtil.getAddvcd(adCode);
  387. } else {
  388. adCode = currentAdcode;
  389. }
  390. List<GwComFile> gwComFiles = gwComFileService.getTopNPblm(n, adCode, pType, currentAdcode);
  391. return buildSuccessResponse(gwComFiles);
  392. }
  393. @ApiOperation(value = "获取前N条问题视频")
  394. @RequestMapping(value = "/getTopNPblmVido", method = RequestMethod.GET)
  395. public BaseResponse<List<GwComFile>> getTopNPblmVido(
  396. @ApiParam(name = "n", value = "前n调记录", required = false) @RequestParam(defaultValue = "5", required = false) String n,
  397. @ApiParam(name = "adCode", value = "行政区代码", required = false) @RequestParam(required = false) String adCode,
  398. @ApiParam(name = "ptype", value = "督查类别", required = false) @RequestParam(required = false) String pType) {
  399. String currentAdcode = AdLevelUtil.getAddvcd(olBisInspOrgService.getProvince(getCurrentOrgId()));
  400. if (StringUtils.isNotBlank(pType)) {
  401. pType = String.valueOf(Integer.parseInt(pType));
  402. }
  403. if (StringUtils.isNotBlank(adCode)) {
  404. if (validateAdCode(adCode)) {
  405. adCode = AdLevelUtil.getAddvcd(adCode);
  406. } else {
  407. adCode = currentAdcode;
  408. }
  409. } else {
  410. adCode = currentAdcode;
  411. }
  412. List<GwComFile> gwComFiles = gwComFileService.getTopNPblmVido(n, adCode, pType, currentAdcode);
  413. return buildSuccessResponse(gwComFiles);
  414. }
  415. /**
  416. * 正则:行政区划编码 12位数字即可
  417. *
  418. * @param in
  419. * @return
  420. */
  421. private boolean validateAdCode(String in) {
  422. return this.pattern.matcher(in).matches();
  423. }
  424. @ApiOperation(value = "获取前N条稽察问题资源")
  425. @RequestMapping(value = "/getTopTacPblm", method = RequestMethod.GET)
  426. public BaseResponse<List<GwComFile>> getTopTacPlam(
  427. @ApiParam(name = "n", value = "前n调记录", required = false) @RequestParam(defaultValue = "5", required = false) String n,
  428. @ApiParam(name = "adCode", value = "行政区代码", required = false) @RequestParam(required = false) String adCode) {
  429. String province = "";
  430. if (StringUtils.isBlank(adCode)) {
  431. province = olBisInspOrgService.getProvince(getCurrentOrgId());
  432. } else {
  433. province = adCode;
  434. }
  435. List<GwComFile> gwComFiles = gwComFileService.getTopTacPblm(n, province);
  436. return buildSuccessResponse(gwComFiles);
  437. }
  438. @ApiOperation(value = "获取前N条稽察问题视频资源")
  439. @RequestMapping(value = "/getTopTacPblmvideo", method = RequestMethod.GET)
  440. public BaseResponse<List<GwComFile>> getTopTacPblmvideo(
  441. @ApiParam(name = "n", value = "前n调记录", required = false) @RequestParam(defaultValue = "5", required = false) String n,
  442. @ApiParam(name = "adCode", value = "行政区代码", required = false) @RequestParam(required = false) String adCode) {
  443. String province = "";
  444. if (StringUtils.isBlank(adCode)) {
  445. province = olBisInspOrgService.getProvince(getCurrentOrgId());
  446. } else {
  447. province = adCode;
  448. }
  449. List<GwComFile> gwComFiles = gwComFileService.getTopTacPblmVideo(n, province);
  450. return buildSuccessResponse(gwComFiles);
  451. }
  452. //按照项目导出工地标准化的图片数据
  453. @ApiOperation(value = "按照项目导出工地标准化的图片数据")
  454. @RequestMapping(value = "/getpicInfo", method = RequestMethod.GET)
  455. public BaseResponse getpicInfo() throws IOException {
  456. gwComFileService.getpicInfo();
  457. return buildSuccessResponse();
  458. }
  459. @ApiOperation(value = "调用wsdl接口推送数据")
  460. @RequestMapping(value = "/wsdl/push/data", method = RequestMethod.POST)
  461. public BaseResponse sendToWsdlData(@ApiParam(name = "gwComFileParam", value = "GwComFileParam", required = true)
  462. @RequestBody GwComFileParam gwComFileParam) {
  463. BaseResponse response = buildSuccessResponse();
  464. String result = gwComFileService.toWsdlPushData(gwComFileParam);
  465. response.setData(result);
  466. return response;
  467. }
  468. }