CenterdataTHousingconstructionSteelcylinderLogController.java 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package com.sooka.sponest.data.housingconstruction.controller;
  2. import com.ruoyi.common.core.web.controller.BaseController;
  3. import com.ruoyi.common.core.web.domain.AjaxResult;
  4. import com.ruoyi.common.core.web.page.TableDataInfo;
  5. import com.ruoyi.common.log.annotation.Log;
  6. import com.ruoyi.common.log.enums.BusinessType;
  7. import com.ruoyi.common.security.annotation.RequiresPermissions;
  8. import com.sooka.sponest.data.housingconstruction.domain.CenterdataTHousingconstructionSteelcylinder;
  9. import com.sooka.sponest.data.housingconstruction.domain.CenterdataTHousingconstructionSteelcylinderLog;
  10. import com.sooka.sponest.data.housingconstruction.service.ICenterdataTHousingconstructionSteelcylinderLogService;
  11. import com.sooka.sponest.data.housingconstruction.service.ICenterdataTHousingconstructionSteelcylinderService;
  12. import com.sooka.sponest.data.utils.ExcelUtil;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.web.bind.annotation.*;
  15. import javax.servlet.http.HttpServletResponse;
  16. import java.util.List;
  17. /**
  18. * 钢瓶日志Controller
  19. *
  20. * @author ruoyi
  21. * @date 2024-07-30
  22. */
  23. @RestController
  24. @RequestMapping("/steelcylinderLog")
  25. public class CenterdataTHousingconstructionSteelcylinderLogController extends BaseController {
  26. @Autowired
  27. private ICenterdataTHousingconstructionSteelcylinderLogService centerdataTHousingconstructionSteelcylinderLogService;
  28. @Autowired
  29. private ICenterdataTHousingconstructionSteelcylinderService centerdataTHousingconstructionSteelcylinderService;
  30. /**
  31. * 查询钢瓶日志列表
  32. */
  33. @RequiresPermissions("data:steelcylinderLog:list")
  34. @GetMapping("/list")
  35. public TableDataInfo list(CenterdataTHousingconstructionSteelcylinderLog centerdataTHousingconstructionSteelcylinderLog) {
  36. startPage();
  37. List<CenterdataTHousingconstructionSteelcylinderLog> list = centerdataTHousingconstructionSteelcylinderLogService.selectCenterdataTHousingconstructionSteelcylinderLogList(centerdataTHousingconstructionSteelcylinderLog);
  38. return getDataTable(list);
  39. }
  40. /**
  41. * 导出钢瓶日志列表
  42. */
  43. @RequiresPermissions("data:steelcylinderLog:export")
  44. @Log(title = "钢瓶日志", businessType = BusinessType.EXPORT)
  45. @PostMapping("/export")
  46. public void export(HttpServletResponse response, CenterdataTHousingconstructionSteelcylinderLog centerdataTHousingconstructionSteelcylinderLog) {
  47. List<CenterdataTHousingconstructionSteelcylinderLog> list = centerdataTHousingconstructionSteelcylinderLogService.selectCenterdataTHousingconstructionSteelcylinderLogList(centerdataTHousingconstructionSteelcylinderLog);
  48. ExcelUtil<CenterdataTHousingconstructionSteelcylinderLog> util = new ExcelUtil<CenterdataTHousingconstructionSteelcylinderLog>(CenterdataTHousingconstructionSteelcylinderLog.class);
  49. util.exportExcel(response, list, "钢瓶日志数据");
  50. }
  51. /**
  52. * 获取钢瓶日志详细信息
  53. */
  54. @RequiresPermissions("data:steelcylinderLog:query")
  55. @GetMapping(value = "/{id}")
  56. public AjaxResult getInfo(@PathVariable("id") String id) {
  57. return AjaxResult.success(centerdataTHousingconstructionSteelcylinderLogService.selectCenterdataTHousingconstructionSteelcylinderLogById(id));
  58. }
  59. /*
  60. * 按钢瓶id查询最新日志
  61. *
  62. * @author 韩福成
  63. * @date 2024/8/1 上午11:10
  64. */
  65. @GetMapping(value = "getSteelcylinderLog/{steelcylinderId}")
  66. public AjaxResult getSteelcylinderLog(@PathVariable("steelcylinderId") String steelcylinderId) {
  67. return AjaxResult.success(centerdataTHousingconstructionSteelcylinderLogService.selectBySteelcylinderId(steelcylinderId));
  68. }
  69. /*
  70. * 添加钢瓶流转信息
  71. *
  72. * @author 韩福成
  73. * @date 2024/7/31 下午5:21
  74. */
  75. @PostMapping(value = "/addLog")
  76. public AjaxResult addLog(@RequestBody CenterdataTHousingconstructionSteelcylinderLog centerdataTHousingconstructionSteelcylinderLog) {
  77. CenterdataTHousingconstructionSteelcylinder steelcylinder = centerdataTHousingconstructionSteelcylinderService.selectCenterdataTHousingconstructionSteelcylinderById(centerdataTHousingconstructionSteelcylinderLog.getSteelcylinderId());
  78. //修改钢瓶状态
  79. CenterdataTHousingconstructionSteelcylinder centerdataTHousingconstructionSteelcylinder = new CenterdataTHousingconstructionSteelcylinder();
  80. centerdataTHousingconstructionSteelcylinder.setId(centerdataTHousingconstructionSteelcylinderLog.getSteelcylinderId());
  81. centerdataTHousingconstructionSteelcylinder.setState(centerdataTHousingconstructionSteelcylinderLog.getState());
  82. centerdataTHousingconstructionSteelcylinderService.updateCenterdataTHousingconstructionSteelcylinder(centerdataTHousingconstructionSteelcylinder);
  83. //按钢瓶id查询最新日志
  84. CenterdataTHousingconstructionSteelcylinderLog log = centerdataTHousingconstructionSteelcylinderLogService.selectBySteelcylinderId(centerdataTHousingconstructionSteelcylinderLog.getSteelcylinderId());
  85. if (log ==null){
  86. return toAjax(centerdataTHousingconstructionSteelcylinderLogService.insertCenterdataTHousingconstructionSteelcylinderLog(centerdataTHousingconstructionSteelcylinderLog));
  87. }else {
  88. if (steelcylinder.getState().equals("state_5")&&centerdataTHousingconstructionSteelcylinderLog.getState().equals("state_2")){
  89. centerdataTHousingconstructionSteelcylinderLog.setJoinWarehouseTime(log.getJoinWarehouseTime());
  90. return toAjax(centerdataTHousingconstructionSteelcylinderLogService.insertCenterdataTHousingconstructionSteelcylinderLog(centerdataTHousingconstructionSteelcylinderLog));
  91. }else {
  92. centerdataTHousingconstructionSteelcylinderLog.setId(log.getId());
  93. return toAjax(centerdataTHousingconstructionSteelcylinderLogService.updateCenterdataTHousingconstructionSteelcylinderLog(centerdataTHousingconstructionSteelcylinderLog));
  94. }
  95. }
  96. }
  97. }