QpUsegasApplyController.java 12 KB

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