EmsGmPcJhController.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. package com.steerinfo.ems.emsgmpcjh.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.steerinfo.auth.utils.JwtUtil;
  4. import com.steerinfo.ems.Utils.DateUtils;
  5. import com.steerinfo.ems.Utils.ExcelToolUtils;
  6. import com.steerinfo.ems.Utils.WebSocket;
  7. import com.steerinfo.ems.emsgmpcjh.mapper.EmsGmPcJhMapper;
  8. import com.steerinfo.ems.emsgmpcjh.model.EmsGmPcJh;
  9. import com.steerinfo.ems.emsgmpcjh.service.IEmsGmPcJhService;
  10. import com.steerinfo.ems.emsprodplanweightadjustment.mapper.EmsProdplanWeightAdjustmentMapper;
  11. import com.steerinfo.ems.emsprodplanweightadjustment.model.EmsProdplanWeightAdjustment;
  12. import com.steerinfo.framework.controller.BaseRESTfulController;
  13. import com.steerinfo.framework.controller.RESTfulResult;
  14. import com.steerinfo.framework.service.pagehelper.PageList;
  15. import io.swagger.annotations.ApiImplicitParam;
  16. import io.swagger.annotations.ApiImplicitParams;
  17. import io.swagger.annotations.ApiOperation;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.web.bind.annotation.*;
  20. import org.springframework.web.multipart.MultipartFile;
  21. import java.io.File;
  22. import java.math.BigDecimal;
  23. import java.util.Date;
  24. import java.util.HashMap;
  25. import java.util.Map;
  26. /**
  27. * EmsGmPcJh RESTful接口:
  28. * @author generator
  29. * @version 1.0-SNAPSHORT 2021-09-10 07:00
  30. * 类描述
  31. * 修订历史:
  32. * 日期:2021-09-10
  33. * 作者:generator
  34. * 参考:
  35. * 描述:EmsGmPcJh RESTful接口
  36. * @see null
  37. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  38. */
  39. @RestController
  40. @RequestMapping("/${api.version}/emsgmpcjhs")
  41. public class EmsGmPcJhController extends BaseRESTfulController {
  42. private static final String AT2005 = "G-G1-";
  43. private static final String AT2006 = "G-G2-";
  44. private static final String AT2004 = "G-L1-";
  45. private static final String AT2007 = "G-X1-";
  46. @Autowired
  47. IEmsGmPcJhService emsGmPcJhService;
  48. @Autowired
  49. EmsGmPcJhMapper emsGmPcJhMapper;
  50. @Autowired
  51. private WebSocket webSocket;
  52. @Autowired
  53. EmsProdplanWeightAdjustmentMapper emsProdplanWeightAdjustmentMapper;
  54. @ApiOperation(value="获取列表", notes="分页查询")
  55. @ApiImplicitParams({
  56. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  57. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
  58. })
  59. //@RequiresPermissions("emsgmpcjh:view")
  60. @GetMapping(value = "/")
  61. public RESTfulResult list(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
  62. if(parmas.get("grades") != null && !parmas.get("grades").toString().isEmpty()){
  63. String grades = parmas.get("grades").toString();
  64. if(!grades.startsWith("'")){
  65. grades = "'" + grades.replaceAll(",", "','").replaceAll(",", "','") + "'";
  66. }
  67. parmas.put("grades", grades);
  68. }
  69. if(parmas.get("specifications") != null && !parmas.get("specifications").toString().isEmpty()){
  70. String grades = parmas.get("specifications").toString();
  71. if(!grades.startsWith("'")){
  72. grades = "'" + grades.replaceAll(",", "','").replaceAll(",", "','") + "'";
  73. }
  74. parmas.put("specifications", grades);
  75. }
  76. if(parmas.get("lengthTimesWidth") != null && !parmas.get("lengthTimesWidth").toString().isEmpty()){
  77. String grades = parmas.get("lengthTimesWidth").toString();
  78. if(!grades.startsWith("'")){
  79. grades = "'" + grades.replaceAll(",", "','").replaceAll(",", "','") + "'";
  80. }
  81. parmas.put("lengthTimesWidth", grades);
  82. }
  83. PageList<EmsGmPcJh> list = emsGmPcJhService.queryForPage(parmas, pageNum, pageSize);
  84. return success(list);
  85. }
  86. @ApiOperation(value="获取列表", notes="分页模糊查询")
  87. @ApiImplicitParams({
  88. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  89. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
  90. })
  91. //@RequiresPermissions("emsgmpcjh:view")
  92. @GetMapping(value = "/like/")
  93. public RESTfulResult listLike(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
  94. PageList<EmsGmPcJh> list = emsGmPcJhService.queryLikeForPage(parmas, pageNum, pageSize);
  95. return success(list);
  96. }
  97. @ApiOperation(value="创建", notes="根据EmsGmPcJh对象创建GM计划")
  98. @ApiImplicitParam(name = "emsGmPcJh", value = "详细实体emsGmPcJh", required = true, dataType = "EmsGmPcJh")
  99. //@RequiresPermissions("emsgmpcjh:create")
  100. @PostMapping(value = "/")
  101. public RESTfulResult add(@RequestBody EmsGmPcJh model){
  102. String userId = JwtUtil.getUseridByToken();
  103. String yyyymmdd = DateUtils.dateStr(model.getJhTime(), "yyyyMMdd");
  104. model.setStartTime(yyyymmdd);
  105. model.setType(this.getType(model));
  106. String maxid = emsGmPcJhService.getMaxid(model);
  107. model.setId(maxid);
  108. model.setKxfWeight(model.getPlanWeight());
  109. model.setYxfWeight(new BigDecimal("0"));
  110. model.setCreateTime(new Date());
  111. model.setCreateMan(userId);
  112. EmsGmPcJh emsGmPcJh = emsGmPcJhService.add(model);
  113. EmsProdplanWeightAdjustment emsProdplanWeightAdjustment = new EmsProdplanWeightAdjustment();
  114. emsProdplanWeightAdjustment.setId(model.getId());
  115. emsProdplanWeightAdjustment.setAuditStatus("0");
  116. emsProdplanWeightAdjustment.setPlanWeight(model.getPlanWeight());
  117. emsProdplanWeightAdjustment.setPlanWeightOld(model.getPlanWeight());
  118. emsProdplanWeightAdjustmentMapper.insert(emsProdplanWeightAdjustment);
  119. return success(emsGmPcJh);
  120. }
  121. @ApiOperation(value="创建", notes="根据EmsGmPcJh对象创建GM计划")
  122. @ApiImplicitParam(name = "emsGmPcJh", value = "详细实体emsGmPcJh", required = true, dataType = "EmsGmPcJh")
  123. //@RequiresPermissions("emsgmpcjh:create")
  124. @PostMapping(value = "/addNbJH")
  125. public RESTfulResult addNbJH(@RequestBody EmsGmPcJh model){
  126. String userId = JwtUtil.getUseridByToken();
  127. String yyyymmdd = DateUtils.dateStr(model.getJhTime(), "yyyyMMdd");
  128. model.setStartTime(yyyymmdd);
  129. model.setType(this.getNbJH(model));
  130. String maxid = emsGmPcJhService.getMaxid(model);
  131. model.setId(maxid);
  132. model.setPlanWeight(model.getPlanWeight() == null ? new BigDecimal("0"): model.getPlanWeight());
  133. model.setKxfWeight(model.getPlanWeight() == null ? new BigDecimal("0"): model.getPlanWeight());
  134. model.setYxfWeight(new BigDecimal("0"));
  135. model.setCreateTime(new Date());
  136. model.setState("2");
  137. model.setCreateMan(userId);
  138. EmsGmPcJh emsGmPcJh = emsGmPcJhService.add(model);
  139. return success(emsGmPcJh);
  140. }
  141. @ApiOperation(value="获取详细信息", notes="根据url的id来获取详细信息")
  142. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String")
  143. //@RequiresPermissions("emsgmpcjh:view")
  144. @GetMapping(value = "/{id}")
  145. public RESTfulResult get(@PathVariable String id){
  146. EmsGmPcJh emsGmPcJh = emsGmPcJhService.getById(id);
  147. return success(emsGmPcJh);
  148. }
  149. @ApiOperation(value="更新详细信息", notes="根据url的id来指定更新对象,并根据传过来的emsGmPcJh信息来更新详细信息")
  150. @ApiImplicitParams({
  151. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String"),
  152. @ApiImplicitParam(name = "emsGmPcJh", value = "详细实体emsGmPcJh", required = true, dataType = "EmsGmPcJh")
  153. })
  154. //@RequiresPermissions("emsgmpcjh:update")
  155. @PutMapping(value = "/batchupdate", produces = "application/json;charset=UTF-8")
  156. public RESTfulResult update(@RequestBody EmsGmPcJh[] models){
  157. String userId = JwtUtil.getUseridByToken();
  158. for (EmsGmPcJh model : models) {
  159. EmsGmPcJh emsGmPcJh = this.emsGmPcJhMapper.selectByPrimaryKey(model.getId());
  160. if(emsGmPcJh.getState().equals("2")) {
  161. return failed(null,"操作失败,编号为"+emsGmPcJh.getId()+"已经下发");
  162. }
  163. if (emsGmPcJh.getState().equals("1")) {
  164. return failed(model, "操作失败,计划号为:" + model.getId() + "正在审核");
  165. }
  166. if (emsGmPcJh.getState().equals("3")) {
  167. return failed(model, "操作失败,计划号为:" + model.getId() + "已接收");
  168. }
  169. model.setYxfWeight(new BigDecimal("0"));
  170. model.setKxfWeight(model.getPlanWeight());
  171. model.setUpdateMan(userId);
  172. model.setUpdateTime(new Date());
  173. EmsProdplanWeightAdjustment emsProdplanWeightAdjustment = emsProdplanWeightAdjustmentMapper.selectByPrimaryKey(model.getId());
  174. emsProdplanWeightAdjustment.setPlanWeight(model.getPlanWeight());
  175. emsProdplanWeightAdjustment.setPlanWeightOld(model.getPlanWeight());
  176. emsGmPcJhMapper.updateByPrimaryKey(model);
  177. emsProdplanWeightAdjustmentMapper.updateByPrimaryKey(emsProdplanWeightAdjustment);
  178. }
  179. return success();
  180. }
  181. @ApiOperation(value="删除", notes="根据url的id来指定删除对象")
  182. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String")
  183. //@RequiresPermissions("emsgmpcjh:delete")
  184. @DeleteMapping(value = "/delete",produces = "application/json;charset=UTF-8")//String
  185. public RESTfulResult delete(@RequestBody EmsGmPcJh[] models){
  186. for (EmsGmPcJh model : models) {
  187. EmsGmPcJh emsGmPcJh = this.emsGmPcJhMapper.selectByPrimaryKey(model.getId());
  188. if(emsGmPcJh.getState().equals("2")) {
  189. return failed(null,"操作失败,编号为"+emsGmPcJh.getId()+"已经下发");
  190. }
  191. if (model.getState().equals("1")) {
  192. return failed(null,"计划号为:"+model.getId()+"正在审核");
  193. }
  194. if (model.getState().equals("3")) {
  195. return failed(null,"计划号为:"+model.getId()+"已经接收");
  196. }
  197. emsGmPcJhMapper.deleteByPrimaryKey(model.getId());
  198. }
  199. return success();
  200. }
  201. @ApiOperation(value="更新详细信息", notes="根据url的id来指定更新对象,并根据传过来的emsGmPcJh信息来更新详细信息")
  202. @ApiImplicitParams({
  203. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String"),
  204. @ApiImplicitParam(name = "emsGmPcJh", value = "详细实体emsGmPcJh", required = true, dataType = "EmsGmPcJh")
  205. })
  206. //@RequiresPermissions("emsgmpcjh:update")
  207. @PutMapping(value = "/updatestate", produces = "application/json;charset=UTF-8")
  208. public RESTfulResult updatestate(@RequestBody EmsGmPcJh[] models){
  209. String userId = JwtUtil.getUseridByToken();
  210. String soketMessage="国贸订单编号";
  211. boolean result = false;
  212. for (EmsGmPcJh model : models) {
  213. EmsGmPcJh emsGmPcJh = this.emsGmPcJhMapper.selectByPrimaryKey(model.getId());
  214. if(emsGmPcJh.getState().equals("2")) {
  215. return failed(null,"操作失败,编号为"+emsGmPcJh.getId()+"已经下发");
  216. }
  217. if (emsGmPcJh.getState().equals("3")) {
  218. return failed(null,"操作失败,编号为"+emsGmPcJh.getId()+"已经接收");
  219. }
  220. if (emsGmPcJh.getState().equals("1")) {
  221. return failed(null,"操作失败,编号为"+emsGmPcJh.getId()+"正在审核");
  222. }
  223. if(emsGmPcJh.getState().equals("0")) {
  224. result = true;
  225. soketMessage+=emsGmPcJh.getId()+",";
  226. }
  227. model.setYxfWeight(new BigDecimal("0"));
  228. model.setKxfWeight(model.getPlanWeight());
  229. model.setUpdateTime(new Date());
  230. model.setUpdateMan(userId);
  231. emsGmPcJhService.updateState(model);
  232. }
  233. if(result){
  234. soketMessage += "已下发,请注意接收";
  235. String[] roles = {"生产部-生产处"};
  236. Map <String, Object> map = new HashMap<String,Object>();
  237. map.put("role",roles);
  238. map.put("title","国贸订单下发");
  239. map.put("message",soketMessage);
  240. map.put("tips","您好,有新的国贸计划已下发,请注意接收。");
  241. soketMessage= JSON.toJSONString(map);
  242. webSocket.sendAllMessage(soketMessage);
  243. }
  244. return success();
  245. }
  246. @ApiOperation(value="更新详细信息", notes="根据url的id来指定更新对象,并根据传过来的emsGmPcJh信息来更新详细信息")
  247. @ApiImplicitParams({
  248. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String"),
  249. @ApiImplicitParam(name = "emsGmPcJh", value = "详细实体emsGmPcJh", required = true, dataType = "EmsGmPcJh")
  250. })
  251. //@RequiresPermissions("emsgmpcjh:update")
  252. @PutMapping(value = "/submitaudit", produces = "application/json;charset=UTF-8")
  253. public RESTfulResult submitaudit(@RequestBody EmsGmPcJh[] models){
  254. String soketMessage="国贸订单编号";
  255. boolean result = false;
  256. String userId = JwtUtil.getUseridByToken();
  257. for (EmsGmPcJh model : models) {
  258. EmsGmPcJh emsGmPcJh = this.emsGmPcJhMapper.selectByPrimaryKey(model.getId());
  259. if(emsGmPcJh.getState().equals("2")) {
  260. return failed(null,"操作失败,编号为"+emsGmPcJh.getId()+"已经下发");
  261. }
  262. if (emsGmPcJh.getState().equals("3")) {
  263. return failed(null,"操作失败,编号为"+emsGmPcJh.getId()+"已经接收");
  264. }
  265. if (emsGmPcJh.getState().equals("1")) {
  266. return failed(null, "操作失败,编号为" + emsGmPcJh.getId() + "正在审核");
  267. }
  268. model.setYxfWeight(new BigDecimal("0"));
  269. model.setKxfWeight(model.getPlanWeight());
  270. model.setUpdateTime(new Date());
  271. model.setUpdateMan(userId);
  272. emsGmPcJhService.updateState(model);
  273. result = true;
  274. soketMessage+=emsGmPcJh.getId()+",";
  275. }
  276. if(result){
  277. soketMessage += "已提交审核,请注意接收";
  278. String[] roles = {"国贸-部门领导"};
  279. Map <String, Object> map = new HashMap<String,Object>();
  280. map.put("role",roles);
  281. map.put("title","国贸订单审核");
  282. map.put("message",soketMessage);
  283. map.put("tips","您好,有新的国贸计划已提交审核,请注意接收。");
  284. soketMessage= JSON.toJSONString(map);
  285. webSocket.sendAllMessage(soketMessage);
  286. }
  287. return success();
  288. }
  289. //@RequiresPermissions("emsgmpcjh:update")
  290. @PutMapping(value = "/passaudits", produces = "application/json;charset=UTF-8")
  291. public RESTfulResult passaudits(@RequestBody EmsGmPcJh[] models){
  292. String soketMessage="国贸订单编号";
  293. boolean result = false;
  294. String userId = JwtUtil.getUseridByToken();
  295. for (EmsGmPcJh model : models) {
  296. EmsGmPcJh emsGmPcJh = this.emsGmPcJhMapper.selectByPrimaryKey(model.getId());
  297. if(emsGmPcJh.getState().equals("2")) {
  298. return failed(null,"操作失败,编号为"+emsGmPcJh.getId()+"已经下发");
  299. }
  300. if (emsGmPcJh.getState().equals("3")) {
  301. return failed(null,"操作失败,编号为"+emsGmPcJh.getId()+"已经接收");
  302. }
  303. model.setUpdateMan(userId);
  304. emsGmPcJhService.updateState(model);
  305. result = true;
  306. soketMessage+=emsGmPcJh.getId()+",";
  307. if(result){
  308. soketMessage += "下发,请注意接收";
  309. String[] roles = {"生产部-生产处"};
  310. Map <String, Object> map = new HashMap<String,Object>();
  311. map.put("role",roles);
  312. map.put("title","国贸订单下发");
  313. map.put("message",soketMessage);
  314. map.put("tips","您好,有新的国贸计划已经下发,请注意接收。");
  315. soketMessage= JSON.toJSONString(map);
  316. webSocket.sendAllMessage(soketMessage);
  317. }
  318. }
  319. return success();
  320. }
  321. //@RequiresPermissions("emsgmpcjh:update")
  322. @PutMapping(value = "/turndown", produces = "application/json;charset=UTF-8")
  323. public RESTfulResult turndown(@RequestBody EmsGmPcJh[] models){
  324. String userId = JwtUtil.getUseridByToken();
  325. String soketMessage="国贸订单编号";
  326. boolean result = false;
  327. for (EmsGmPcJh model : models) {
  328. EmsGmPcJh emsGmPcJh = this.emsGmPcJhMapper.selectByPrimaryKey(model.getId());
  329. if (emsGmPcJh.getState().equals("3")) {
  330. return failed(null,"操作失败,编号为"+emsGmPcJh.getId()+"已经接收");
  331. }
  332. emsGmPcJhService.updateState(model);
  333. result = true;
  334. soketMessage+=emsGmPcJh.getId()+",";
  335. if(result){
  336. soketMessage += "已被撤回,请注意查看";
  337. String[] roles = {"国贸-业务人员"};
  338. Map <String, Object> map = new HashMap<String,Object>();
  339. map.put("role",roles);
  340. map.put("title","国贸订单审核");
  341. map.put("message",soketMessage);
  342. map.put("tips","您好,您提交的订单已被撤回,请注意查看。");
  343. soketMessage= JSON.toJSONString(map);
  344. webSocket.sendAllMessage(soketMessage);
  345. }
  346. }
  347. return success();
  348. }
  349. @ApiOperation(value="获取列表", notes="分页模糊查询")
  350. @ApiImplicitParams({
  351. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  352. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
  353. })
  354. @GetMapping("/getGmDates")
  355. public RESTfulResult getGmDates(@RequestParam HashMap<String,Object> parmas,Integer pageNum,Integer pageSize){
  356. if(parmas.get("workprocType") != null && !parmas.get("workprocType").toString().isEmpty()){
  357. String workprocType = parmas.get("workprocType").toString();
  358. if(!workprocType.startsWith("'")){
  359. workprocType = "'" + workprocType.replaceAll(",", "','").replaceAll(",", "','") + "'";
  360. }
  361. parmas.put("workprocType", workprocType);
  362. }
  363. PageList<Map<String, Object>> gmPcJhDataForPage = emsGmPcJhService.getGmPcJhDataForPage(parmas, pageNum, pageSize);
  364. return success(gmPcJhDataForPage);
  365. }
  366. @ApiOperation(value="获取列表", notes="分页模糊查询")
  367. @ApiImplicitParams({
  368. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  369. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
  370. })
  371. @GetMapping("/getXsDdDate")
  372. public RESTfulResult getXsDdDate(@RequestParam HashMap<String,Object> parmas,Integer pageNum,Integer pageSize){
  373. if(parmas.get("workprocType") != null && !parmas.get("workprocType").toString().isEmpty()){
  374. String workprocType = parmas.get("workprocType").toString();
  375. if(!workprocType.startsWith("'")){
  376. workprocType = "'" + workprocType.replaceAll(",", "','").replaceAll(",", "','") + "'";
  377. }
  378. parmas.put("workprocType", workprocType);
  379. }
  380. if(parmas.get("auditStatus") != null && !parmas.get("auditStatus").toString().isEmpty()){
  381. String auditStatus = parmas.get("auditStatus").toString();
  382. if(!auditStatus.startsWith("'")){
  383. auditStatus = "'" + auditStatus.replaceAll(",", "','").replaceAll(",", "','") + "'";
  384. }
  385. parmas.put("auditStatus", auditStatus);
  386. }
  387. PageList<Map<String, Object>> getXsDdDateForPage= emsGmPcJhService.getXsDdDate(parmas, pageNum, pageSize);
  388. return success(getXsDdDateForPage);
  389. }
  390. @ApiOperation(value="获取列表", notes="分页模糊查询")
  391. @ApiImplicitParams({
  392. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  393. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
  394. })
  395. @GetMapping("/getShData")
  396. public RESTfulResult getShData(@RequestParam HashMap<String,Object> parmas,Integer pageNum,Integer pageSize){
  397. if(parmas.get("workprocType") != null && !parmas.get("workprocType").toString().isEmpty()){
  398. String workprocType = parmas.get("workprocType").toString();
  399. if(!workprocType.startsWith("'")){
  400. workprocType = "'" + workprocType.replaceAll(",", "','").replaceAll(",", "','") + "'";
  401. }
  402. parmas.put("workprocType", workprocType);
  403. }
  404. PageList<Map<String, Object>> xsShData = emsGmPcJhService.getXsShData(parmas, pageNum, pageSize);
  405. return success(xsShData);
  406. }
  407. @ApiOperation(value="更新详细信息", notes="根据url的id来指定更新对象,并根据传过来的emsGmPcJh信息来更新详细信息")
  408. @ApiImplicitParams({
  409. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String"),
  410. @ApiImplicitParam(name = "emsGmPcJh", value = "详细实体emsGmPcJh", required = true, dataType = "EmsGmPcJh")
  411. })
  412. //@RequiresPermissions("emsgmpcjh:update")
  413. @PutMapping(value = "/batchcopy", produces = "application/json;charset=UTF-8")
  414. public RESTfulResult batchcopy(@RequestBody EmsGmPcJh[] models){
  415. String userId = JwtUtil.getUseridByToken();
  416. for (EmsGmPcJh model : models) {
  417. String yyyymmdd = DateUtils.dateStr(model.getJhTime(), "yyyyMMdd");
  418. model.setStartTime(yyyymmdd);
  419. model.setType(this.getType(model));
  420. String maxid = emsGmPcJhService.getMaxid(model);
  421. model.setId(maxid);
  422. model.setState("0");
  423. model.setKxfWeight(model.getPlanWeight());
  424. model.setYxfWeight(new BigDecimal("0"));
  425. model.setUpdateTime(null);
  426. model.setUpdateMan(null);
  427. model.setCreateTime(new Date());
  428. model.setCreateMan(userId);
  429. emsGmPcJhService.add(model);
  430. }
  431. return success();
  432. }
  433. /**
  434. * @MethodName excelimport
  435. * @Author TZH
  436. * @Description 导入文件
  437. * @Date 2021/01/12 15:20
  438. **/
  439. @PostMapping(value = "excelimport")
  440. public RESTfulResult excelimport(@RequestParam("file") MultipartFile file) throws Exception {
  441. RESTfulResult rs= null;
  442. try {
  443. if(file.isEmpty()){
  444. return failed(null,"上传失败,请选择文件");
  445. }
  446. String fileNmae = file.getOriginalFilename();
  447. File files = ExcelToolUtils.multipartFileToFile(file);
  448. rs = emsGmPcJhService.insertexcel(files);
  449. ExcelToolUtils.delteTempFile(files);
  450. } catch (Exception e){
  451. e.printStackTrace();
  452. rs.setCode("500");
  453. rs.setMessage("服务端异常!");
  454. }finally {
  455. }
  456. return rs;
  457. }
  458. public String getType (EmsGmPcJh emsGmPcJh){
  459. if (emsGmPcJh.getWorkprocType().equals("AT2004")){
  460. return AT2004;
  461. }
  462. if(emsGmPcJh.getWorkprocType().equals("AT2005")){
  463. return AT2005;
  464. }
  465. if (emsGmPcJh.getWorkprocType().equals("AT2006")){
  466. return AT2006;
  467. }
  468. if (emsGmPcJh.getWorkprocType().equals("AT2007")) {
  469. return AT2007;
  470. }
  471. return null;
  472. }
  473. public String getNbJH (EmsGmPcJh emsGmPcJh){
  474. if (emsGmPcJh.getWorkprocType().equals("AT2004")){
  475. return "N-L1-";
  476. }
  477. if(emsGmPcJh.getWorkprocType().equals("AT2005")){
  478. return "N-G1-";
  479. }
  480. if (emsGmPcJh.getWorkprocType().equals("AT2006")){
  481. return "N-G2-";
  482. }
  483. if (emsGmPcJh.getWorkprocType().equals("AT2007")) {
  484. return "N-X1-";
  485. }
  486. return null;
  487. }
  488. }