QpUsegasApplyController.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. package com.zd.airbottle.controller;
  2. import java.time.LocalDate;
  3. import java.util.*;
  4. import java.io.IOException;
  5. import javax.servlet.http.HttpServletResponse;
  6. import com.github.xiaoymin.knife4j.annotations.ApiSupport;
  7. import com.zd.airbottle.domain.*;
  8. import com.zd.airbottle.domain.vo.*;
  9. import com.zd.airbottle.service.IQpFlowDetailService;
  10. import com.zd.airbottle.service.IQpUsegasAuditRecordService;
  11. import com.zd.common.core.domain.per.PerFun;
  12. import com.zd.common.core.domain.per.PerPrefix;
  13. import com.zd.common.core.exception.ServiceException;
  14. import com.zd.common.security.service.TokenService;
  15. import com.zd.system.api.domain.SysUser;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.web.bind.annotation.GetMapping;
  18. import org.springframework.web.bind.annotation.PostMapping;
  19. import org.springframework.web.bind.annotation.PutMapping;
  20. import org.springframework.web.bind.annotation.DeleteMapping;
  21. import org.springframework.web.bind.annotation.PathVariable;
  22. import org.springframework.web.bind.annotation.RequestBody;
  23. import org.springframework.web.bind.annotation.RequestMapping;
  24. import org.springframework.web.bind.annotation.RestController;
  25. import com.zd.common.response.ResultData;
  26. import com.zd.common.log.annotation.Log;
  27. import com.zd.common.log.enums.BusinessType;
  28. import com.zd.common.security.annotation.PreAuthorize;
  29. import com.zd.airbottle.service.IQpUsegasApplyService;
  30. import com.zd.common.core.web.controller.BaseController;
  31. import com.zd.common.core.web.domain.AjaxResult;
  32. import com.zd.common.core.utils.poi.ExcelUtil;
  33. import io.swagger.annotations.Api;
  34. import io.swagger.annotations.ApiOperation;
  35. import com.zd.common.swagger.config.Knife4jConfiguration;
  36. import com.zd.common.core.web.page.TableDataInfo;
  37. /**
  38. * 用气申请Controller
  39. *
  40. * @author zd
  41. * @date 2022-05-10
  42. */
  43. @RestController
  44. @Api(tags = "【用气申请】")
  45. //作者手动加入 ,在接口上加作者@ApiOperationSupport(author = "XXX")
  46. @ApiSupport(author = Knife4jConfiguration.Author.CYL)
  47. @RequestMapping("/useAgsApply")
  48. public class QpUsegasApplyController extends BaseController
  49. {
  50. @Autowired
  51. private IQpUsegasApplyService qpUsegasApplyService;
  52. @Autowired
  53. private TokenService tokenService;
  54. @Autowired
  55. private IQpUsegasAuditRecordService qpUsegasAuditRecordService;
  56. @Autowired
  57. private IQpFlowDetailService qpFlowDetailService;
  58. /**
  59. * 查询用气申请列表
  60. */
  61. // @PreAuthorize(hasPermi = "airbottle:useAgsApply:list")
  62. // @PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_USEAGSAPPLY+ PerFun.LIST)
  63. @GetMapping("/list")
  64. @ApiOperation(value = "查询用气申请列表")
  65. public TableDataInfo<QpUsegasApplyVO> list(QpUsegasApplyVO qpUsegasApply)
  66. {
  67. //获取当前登录用户信息
  68. SysUser sysUser = tokenService.getLoginUser().getSysUser();
  69. qpUsegasApply.setUserId(sysUser.getUserId());//当前登陆人申请数据
  70. startPage();
  71. List<QpUsegasApplyVO> list = qpUsegasApplyService.selectQpUsegasApplyList(qpUsegasApply);
  72. return getDataTable(list);
  73. }
  74. /**
  75. * 导出用气申请列表
  76. */
  77. @ApiOperation(value = "导出用气申请列表")
  78. // @PreAuthorize(hasPermi = "airbottle:useAgsApply:export")
  79. // @PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_USEAGSAPPLY+ PerFun.EXPORT)
  80. @Log(title = "用气申请", businessType = BusinessType.EXPORT)
  81. @PostMapping("/export")
  82. public void export(HttpServletResponse response, QpUsegasApply qpUsegasApply) throws IOException
  83. {
  84. List<QpUsegasApplyExcelVo> list = qpUsegasApplyService.qpUsegasApplyExportExcel(qpUsegasApply);
  85. ExcelUtil<QpUsegasApplyExcelVo> util = new ExcelUtil<QpUsegasApplyExcelVo>(QpUsegasApplyExcelVo.class);
  86. /*util.exportExcel(response, list, "用气申请数据");*/
  87. //本地日期,不包括时分秒
  88. LocalDate nowDate = LocalDate.now();
  89. util.exportExcel(response, list, "用气申请数据", null, "用气申请信息导出表"+nowDate);
  90. }
  91. /**
  92. * 获取用气申请详细信息
  93. */
  94. @ApiOperation(value = "获取用气申请详细信息")
  95. // @PreAuthorize(hasPermi = "airbottle:useAgsApply:query")
  96. // @PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_USEAGSAPPLY+ PerFun.QUERY)
  97. @GetMapping(value = "/{id}")
  98. public ResultData<QpUsegasApply> getInfo(@PathVariable("id") Long id)
  99. {
  100. return ResultData.success(qpUsegasApplyService.selectQpUsegasApplyById(id));
  101. }
  102. /**
  103. * 获取资格申请详细信息
  104. */
  105. @ApiOperation(value = "获取资格申请详细信息")
  106. // @PreAuthorize(hasPermi = "airbottle:apply:query")
  107. // @PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_USEAGSAPPLY+ PerFun.QUERY)
  108. @GetMapping("/getById")
  109. public AjaxResult getById( Long id)
  110. {
  111. Map<String,Object> map = new HashMap<String,Object>();
  112. //申请详情
  113. QpUsegasApply qpUsegasApply =qpUsegasApplyService.selectQpUsegasApplyById(id);
  114. map.put("apply",qpUsegasApply);
  115. //审核记录
  116. QpUsegasAuditRecord record = new QpUsegasAuditRecord();
  117. record.setUsegasApplyId(id);
  118. List<QpUsegasAuditRecord> auditlist = qpUsegasAuditRecordService.selectQpUsegasAuditRecordList(record);
  119. map.put("auditlist",auditlist);
  120. return AjaxResult.success(map);
  121. }
  122. /**
  123. * 获取用气申请详细信息-根据id查询
  124. */
  125. @ApiOperation(value = "获取资格申请详细信息-根据id查询")
  126. //@PreAuthorize(hasPermi = "airbottle:apply:query")
  127. //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_QUALIFICATIONAPPLY+ PerFun.QUERY)
  128. @GetMapping("/getDetails")
  129. public AjaxResult getDetails( Long id)
  130. {
  131. //获取当前登录用户信息
  132. SysUser sysUser = tokenService.getLoginUser().getSysUser();
  133. Map<String,Object> map = new HashMap<>();
  134. //申请单详情
  135. QpUsegasApplyVO usegasApplyVO =qpUsegasApplyService.selectQpUsegasApplyById(id);
  136. map.put("apply",usegasApplyVO);
  137. boolean isAdmin =false;//是否实验室负责人
  138. boolean audit = false;//是否有审核资格
  139. //判断当前的登录用户是否该实验室负责人
  140. if(sysUser.getUserId().equals(usegasApplyVO.getAdminId()) ) {
  141. isAdmin=true;
  142. }
  143. //待审核或者驳回
  144. if(0 == usegasApplyVO.getLeadAuditStaus() || 2 == usegasApplyVO.getLeadAuditStaus()){
  145. //查询是否有审核资格
  146. /*QpFlowDetailVO qpFlowDetail = new QpFlowDetailVO();
  147. qpFlowDetail.setUserType(1L);//1实验室 2实验中心
  148. qpFlowDetail.setUserIds(sysUser.getUserId());//登录人id
  149. qpFlowDetail.setFlowType(2);//用气申请
  150. List<QpFlowDetailVO> flowDetailList = qpFlowDetailService.selectQpFlowDetailList(qpFlowDetail);
  151. if(flowDetailList.size()>0){
  152. audit=true;
  153. }*/
  154. if(sysUser.getUserId().equals(usegasApplyVO.getAdminId()) ) {
  155. audit=true;
  156. }
  157. }else if(1 == usegasApplyVO.getLeadAuditStaus()){
  158. //查询登录用户是否有实验中心审核资格
  159. QpFlowDetailVO qpFlowDetail = new QpFlowDetailVO();
  160. qpFlowDetail.setUserType(2L);//1实验室 2实验中心
  161. qpFlowDetail.setUserId(sysUser.getUserId());//登录人id
  162. List<QpFlowDetailVO> flowDetailList = qpFlowDetailService.selectQpFlowDetailList(qpFlowDetail);
  163. if(flowDetailList.size()>0){
  164. audit=true;
  165. }
  166. }
  167. map.put("isAdmin",isAdmin);
  168. map.put("audit",audit);
  169. /*List<QpAirGoodsConfigRelationVo> airBottlelist = qpQualificationApplyDetailService.selectQpQualificationApplyDetailListRelation(qpQualificationApply.getId());
  170. map.put("airBottlelist",airBottlelist);*/
  171. //审核记录
  172. QpUsegasAuditRecord auditRecord = new QpUsegasAuditRecord();
  173. auditRecord.setUsegasApplyId(id);
  174. List<QpUsegasAuditRecord> auditlist= qpUsegasAuditRecordService.selectQpUsegasAuditRecordList(auditRecord);
  175. map.put("auditlist",auditlist);
  176. return AjaxResult.success(map);
  177. }
  178. /**
  179. * 新增用气申请
  180. */
  181. @ApiOperation(value = "新增用气申请")
  182. //@PreAuthorize(hasPermi = "airbottle:useAgsApply:add")
  183. // @PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_USEAGSAPPLY+ PerFun.ADD)
  184. @Log(title = "用气申请", businessType = BusinessType.INSERT)
  185. @PostMapping
  186. public ResultData add(@RequestBody QpUsegasApply qpUsegasApply)
  187. {
  188. return ResultData.result(qpUsegasApplyService.insertQpUsegasApply(qpUsegasApply));
  189. }
  190. /**
  191. * 修改用气申请
  192. */
  193. @ApiOperation(value = "修改用气申请")
  194. //@PreAuthorize(hasPermi = "airbottle:useAgsApply:edit")
  195. // @PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_USEAGSAPPLY+ PerFun.EDIT)
  196. @Log(title = "用气申请", businessType = BusinessType.UPDATE)
  197. @PutMapping
  198. public ResultData edit(@RequestBody QpUsegasApply qpUsegasApply)
  199. {
  200. return ResultData.result(qpUsegasApplyService.updateQpUsegasApply(qpUsegasApply));
  201. }
  202. @ApiOperation(value = "用气重新申请")
  203. //@PreAuthorize(hasPermi = "airbottle:useAgsApply:add")
  204. //@PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_USEAGSAPPLY+ PerFun.ADD)
  205. @Log(title = "用气重新申请", businessType = BusinessType.INSERT)
  206. @PostMapping("/reapply")
  207. public ResultData<Boolean> reapply(@RequestBody QpUsegasApply qpUsegasApply)
  208. {
  209. if(qpUsegasApply.getId()==null){
  210. throw new ServiceException("参数为空!");
  211. }
  212. return ResultData.result(qpUsegasApplyService.updateQpUsegasApplyRepeat(qpUsegasApply));
  213. /*//删除数据
  214. qpUsegasApplyService.deleteQpUsegasApplyById(qpUsegasApply.getId());
  215. //qpUsegasApplyService.selectQpUsegasApplyById(qpUsegasApply.getId());
  216. //重新录入
  217. return ResultData.result(qpUsegasApplyService.insertQpUsegasApply(qpUsegasApply));*/
  218. }
  219. /**
  220. * 实验中心审核
  221. */
  222. @ApiOperation(value = "实验中心审核")
  223. //@PreAuthorize(hasPermi = "airbottle:apply:centerexamine")
  224. // @PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_USEAGSAPPLY+ "centerexamine")
  225. @Log(title = "实验中心审核", businessType = BusinessType.UPDATE)
  226. @PostMapping("/centerExamine")
  227. public ResultData centerExamine(@RequestBody QpUsegasApply qpUsegasApply)
  228. {
  229. //获取当前登录用户信息
  230. SysUser sysUser = tokenService.getLoginUser().getSysUser();
  231. //审核表数据录入
  232. QpUsegasAuditRecord record = new QpUsegasAuditRecord();
  233. record.setAuditUser(sysUser.getNickName());
  234. record.setAuditUserid(sysUser.getUserId());
  235. record.setAuditTime(new Date());
  236. record.setAuditStatus(qpUsegasApply.getCenterAuditStatus());
  237. record.setRemark(qpUsegasApply.getCenterAuditCause());
  238. record.setUsegasApplyId(qpUsegasApply.getId());
  239. record.setAuditType(2L);
  240. qpUsegasAuditRecordService.insertQpUsegasAuditRecord(record);
  241. //审核操作
  242. qpUsegasApply.setCenterAuditUserid(sysUser.getUserId());
  243. qpUsegasApply.setCenterAuditUsername(sysUser.getNickName());
  244. qpUsegasApply.setCenterAuditTime(new Date());
  245. return ResultData.result(qpUsegasApplyService.updateQpUsegasApply(qpUsegasApply));
  246. }
  247. /**
  248. * 实验室负责人审核
  249. */
  250. @ApiOperation(value = "实验室负责人审核")
  251. // @PreAuthorize(hasPermi = "airbottle:apply:leadexamine")
  252. // @PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_USEAGSAPPLY+ "leadexamine")
  253. @Log(title = "实验室负责人审核", businessType = BusinessType.UPDATE)
  254. @PostMapping("/leadExamine")
  255. public ResultData leadExamine(@RequestBody QpUsegasApply qpUsegasApply)
  256. {
  257. //获取当前登录用户信息
  258. SysUser sysUser = tokenService.getLoginUser().getSysUser();
  259. //审核表数据录入
  260. QpUsegasAuditRecord record = new QpUsegasAuditRecord();
  261. record.setAuditUser(sysUser.getNickName());
  262. record.setAuditUserid(sysUser.getUserId());
  263. record.setAuditTime(new Date());
  264. record.setAuditStatus(qpUsegasApply.getLeadAuditStaus());
  265. record.setRemark(qpUsegasApply.getLeadAuditCause());
  266. record.setUsegasApplyId(qpUsegasApply.getId());
  267. record.setAuditType(1L);
  268. qpUsegasAuditRecordService.insertQpUsegasAuditRecord(record);
  269. //审核操作
  270. qpUsegasApply.setLeadAuditUserid(sysUser.getUserId());
  271. qpUsegasApply.setLeadAuditUsername(sysUser.getNickName());
  272. qpUsegasApply.setLeadAuditTime(new Date());
  273. return ResultData.result(qpUsegasApplyService.updateQpUsegasApply(qpUsegasApply));
  274. }
  275. /**
  276. * 删除用气申请
  277. */
  278. @ApiOperation(value = "删除用气申请")
  279. // @PreAuthorize(hasPermi = "airbottle:useAgsApply:remove")
  280. // @PreAuthorize(hasPermi = PerPrefix.AIRBOTTLE_USEAGSAPPLY+ PerFun.REMOVE)
  281. @Log(title = "用气申请", businessType = BusinessType.DELETE)
  282. @DeleteMapping("/{ids}")
  283. public ResultData remove(@PathVariable Long[] ids)
  284. {
  285. return ResultData.result(qpUsegasApplyService.deleteQpUsegasApplyByIds(ids));
  286. }
  287. }