MouldController.java 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. package com.hssx.cloudmodel.controller;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.hssx.cloudmodel.entity.InjectionMolding;
  4. import com.hssx.cloudmodel.entity.Mould;
  5. import com.hssx.cloudmodel.entity.User;
  6. import com.hssx.cloudmodel.entity.vo.MouldVO;
  7. import com.hssx.cloudmodel.entity.vo.UserVO;
  8. import com.hssx.cloudmodel.service.MouldService;
  9. import com.hssx.cloudmodel.service.ProjectService;
  10. import com.hssx.cloudmodel.service.UserService;
  11. import com.hssx.cloudmodel.util.HttpRespMsg;
  12. import com.hssx.cloudmodel.util.PageUtil;
  13. import io.swagger.annotations.ApiOperation;
  14. import org.springframework.beans.BeanUtils;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.scheduling.annotation.EnableScheduling;
  17. import org.springframework.scheduling.annotation.Scheduled;
  18. import org.springframework.stereotype.Controller;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RequestParam;
  21. import org.springframework.web.bind.annotation.ResponseBody;
  22. /**
  23. * @author 吴涛涛
  24. * @since 2019-07-30
  25. */
  26. @Controller
  27. @RequestMapping("/mould")
  28. @EnableScheduling
  29. public class MouldController {
  30. @Autowired
  31. private MouldService mouldService;
  32. @Autowired
  33. private UserService userService;
  34. @Autowired
  35. private ProjectService projectService;
  36. /**
  37. * 添加/修改模具设备
  38. * 添加参数:equipmentId 设备id, modelNo 模具编号 ,modelName 模具名称 ,maintainCount 保养设定次数:"1,2,3"
  39. * 修改参数:id 模具id, settingLife 使用年限, initialModulus 初始模次 equipmentId 设备id,
  40. * produceCompanyId 生产方公司id,ocCycle 每模平均周期,rfid rfid码,maintainCount 保养设定次数:"1,2,3"
  41. *
  42. * materialType 材料牌号,color 颜色,size 模具尺寸,machineTonnage 吨位,mallWeight 成品重量(单位:G),headWeight 料头重量(单位:G)
  43. * maxShotWeight 最大射胶量(单位:G),minShotWeight 最小射胶量(单位:G),cycle 成型周期,commonModelTemperature 公模(动模)模温
  44. * motherModelTemperature 母模(定模)模温
  45. * 模具更新时多传的参数 preUpdateId 要被更新的模具的id dynamicId
  46. * @return
  47. */
  48. @ApiOperation("添加/修改模具")
  49. @RequestMapping("/addOrUpdate")
  50. @ResponseBody
  51. public HttpRespMsg addOrUpdate(Mould mould, InjectionMolding injectionMolding, String token, @RequestParam(required = false) Integer dynamicId) {
  52. HttpRespMsg msg = new HttpRespMsg();
  53. QueryWrapper<User> qw = new QueryWrapper<>();
  54. qw.eq("head_imgurl",token);
  55. User user = userService.getOne(qw);
  56. msg = mouldService.addAndUpdateMould(mould,user,dynamicId,injectionMolding);
  57. return msg;
  58. }
  59. /**
  60. * 更换模具云模盒
  61. * mouldId 模具id equipmentId 云模盒设备id token 用户身份凭证
  62. * @return
  63. */
  64. @ApiOperation("更换模具云模盒")
  65. @RequestMapping("/changeMouldEquipment")
  66. @ResponseBody
  67. public HttpRespMsg changeMouldEquipment(Mould mould,Integer mouldId, String token) {
  68. HttpRespMsg msg = new HttpRespMsg();
  69. msg = mouldService.changeMouldEquipment(mould,mouldId,token);
  70. return msg;
  71. }
  72. /**
  73. * 给项目分配模具获取该公司下的模具列表
  74. * parentId 当前人parentId ,id当前人id
  75. * @return
  76. */
  77. @ApiOperation("获取该公司下的模具列表")
  78. @RequestMapping("/modelList")
  79. @ResponseBody
  80. public HttpRespMsg addAndUpdateProject(User user) {
  81. HttpRespMsg msg = new HttpRespMsg();
  82. msg = projectService.getModelListByCompanyId(user);
  83. return msg;
  84. }
  85. /**
  86. * 给编辑项目时返回的项目里的模具和可供选择的模具
  87. * projectId 项目id ,token 人员身份凭证
  88. * @return
  89. */
  90. @ApiOperation("给编辑项目时返回的项目里的模具和可供选择的模具")
  91. @RequestMapping("/chooseModelList")
  92. @ResponseBody
  93. public HttpRespMsg chooseModelList(UserVO userVO) {
  94. HttpRespMsg msg = new HttpRespMsg();
  95. msg = projectService.getModelListByCompanyIdAndProjectId(userVO);
  96. return msg;
  97. }
  98. /**
  99. * 给项目分配模具获取该公司下的模具列表
  100. * token 当前人唯一权限 pageNum 当前页码,pageSize 每页条数 projectId 项目id筛选(默认传-1)
  101. * searchType 搜索类型0-模具编号,1-模具名称(默认传0) keyName 关键字查询
  102. * @return
  103. */
  104. @ApiOperation("模具列表")
  105. @RequestMapping("/list")
  106. @ResponseBody
  107. public HttpRespMsg list(UserVO userVO, PageUtil page,String token) {
  108. System.out.println("keyName"+userVO.getKeyName());
  109. HttpRespMsg msg = new HttpRespMsg();
  110. User user = userService.getOne(new QueryWrapper<User>().eq("head_imgurl", token));
  111. BeanUtils.copyProperties(user,userVO);
  112. msg = projectService.getModelListByUser(userVO,page);
  113. return msg;
  114. }
  115. /**
  116. * 模具详情
  117. * 参数 id 模具id,token 当前用户凭证
  118. * @return
  119. */
  120. @ApiOperation("模具详情")
  121. @RequestMapping("/detail")
  122. @ResponseBody
  123. public HttpRespMsg detail(MouldVO mouldVO){
  124. HttpRespMsg msg = mouldService.getMoildDetail(mouldVO);
  125. return msg;
  126. }
  127. /**
  128. * 模具详情
  129. * 参数 id 模具id
  130. * @return
  131. */
  132. @ApiOperation("删除模具")
  133. @RequestMapping("/delMould")
  134. @ResponseBody
  135. public HttpRespMsg delMould(Mould mould){
  136. HttpRespMsg msg = new HttpRespMsg();
  137. msg = mouldService.delMoule(mould);
  138. return msg;
  139. }
  140. /**
  141. * 模具保养提醒
  142. */
  143. @ApiOperation("模具保养提醒")
  144. @RequestMapping("/maintenanceReminder")
  145. @ResponseBody
  146. @Scheduled(cron = "0 0 12 * * ?")//配置时间点触发(每日中午12点)
  147. public HttpRespMsg maintenanceReminder() throws Exception {
  148. HttpRespMsg msg = mouldService.maintenanceReminder();
  149. return msg;
  150. }
  151. /**
  152. * 丢包数据检测
  153. */
  154. @ApiOperation("丢包数据检测")
  155. @RequestMapping("/packageLoss")
  156. @ResponseBody
  157. @Scheduled(cron = "0 0 23 * * ?")//配置时间点触发(每日中午23点)
  158. public HttpRespMsg packageLoss() throws Exception {
  159. HttpRespMsg msg = mouldService.packageLoss();
  160. return msg;
  161. }
  162. /**
  163. * 是否开启模具保养提醒
  164. * 参数 isMaintain 是否开启保养 0-是 1-否
  165. */
  166. @ApiOperation("模具保养提醒")
  167. @RequestMapping("/isMaintain")
  168. @ResponseBody
  169. public HttpRespMsg isMaintain(Mould mould) throws Exception {
  170. HttpRespMsg msg = mouldService.isMaintain(mould);
  171. return msg;
  172. }
  173. /**
  174. * 需要保养的模具列表
  175. * 参数 token 用户凭证
  176. */
  177. @ApiOperation("需要保养的模具列表")
  178. @RequestMapping("/maintainMouldList")
  179. @ResponseBody
  180. public HttpRespMsg maintainMouldList(UserVO userVO) throws Exception {
  181. HttpRespMsg msg = mouldService.maintainMouldList(userVO);
  182. return msg;
  183. }
  184. /**
  185. * 报废提醒的模具列表
  186. * 参数 token 用户凭证
  187. */
  188. @ApiOperation("报废提醒的模具列表")
  189. @RequestMapping("/scrapMouldList")
  190. @ResponseBody
  191. public HttpRespMsg scrapMouldList(UserVO userVO) throws Exception {
  192. HttpRespMsg msg = mouldService.scrapMouldList(userVO);
  193. return msg;
  194. }
  195. /**
  196. * 模具地图概览
  197. * token 当前人唯一权限
  198. * @return
  199. */
  200. @ApiOperation("模具地图概览")
  201. @RequestMapping("/listMap")
  202. @ResponseBody
  203. public HttpRespMsg listMap(UserVO userVO, String token) {
  204. HttpRespMsg msg = new HttpRespMsg();
  205. User user = userService.getOne(new QueryWrapper<User>().eq("head_imgurl", token));
  206. BeanUtils.copyProperties(user,userVO);
  207. msg = projectService.getModelListMapByUser(userVO);
  208. return msg;
  209. }
  210. // /**
  211. // * 本地E盘文件上传到腾讯云
  212. // * @return
  213. // */
  214. // @ApiOperation("本地E盘文件上传到腾讯云")
  215. // @RequestMapping("/listMap")
  216. // @ResponseBody
  217. // public HttpRespMsg uploadQcloud(UserVO userVO, String token) {
  218. // HttpRespMsg msg = new HttpRespMsg();
  219. // }
  220. /**
  221. * 运行次数更新
  222. */
  223. @ApiOperation("运行次数更新")
  224. @RequestMapping("/updateRuntimesTask")
  225. @ResponseBody
  226. @Scheduled(cron = "0 */5 * * * ?")//定时任务,每5分钟检测一次
  227. public HttpRespMsg updateRuntimesTask() throws Exception {
  228. HttpRespMsg msg = mouldService.updateRuntimesTask();
  229. return msg;
  230. }
  231. /**
  232. * 运行次数更新(23:00-24:00)
  233. */
  234. @ApiOperation("运行次数更新(23:00-24:00)")
  235. @RequestMapping("/updateLastTimeRuntimesTask")
  236. @ResponseBody
  237. @Scheduled(cron = "0 0 1 * * ?")//定时任务,每天1点触发
  238. public HttpRespMsg updateLastTimeRuntimesTask() throws Exception {
  239. HttpRespMsg msg = mouldService.updateLastTimeRuntimesTask();
  240. return msg;
  241. }
  242. }