QpUsegasApplyManageController.java 13 KB

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