EmsProdplanYearController.java 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. package com.steerinfo.ems.emsprodplanyear.controller;
  2. import com.steerinfo.auth.utils.JwtUtil;
  3. import com.steerinfo.ems.emsprodplanmonth.mapper.EmsProdplanMonthMapper;
  4. import com.steerinfo.ems.emsprodplanmonth.model.EmsProdplanMonth;
  5. import com.steerinfo.ems.emsprodplanmonth.service.IEmsProdplanMonthService;
  6. import com.steerinfo.ems.emsprodplanyear.mapper.EmsProdplanYearMapper;
  7. import com.steerinfo.ems.emsprodplanyear.model.EmsProdplanYear;
  8. import com.steerinfo.ems.emsprodplanyear.service.IEmsProdplanYearService;
  9. import com.steerinfo.framework.controller.BaseRESTfulController;
  10. import com.steerinfo.framework.controller.RESTfulResult;
  11. import com.steerinfo.framework.service.pagehelper.PageList;
  12. import io.swagger.annotations.ApiImplicitParam;
  13. import io.swagger.annotations.ApiImplicitParams;
  14. import io.swagger.annotations.ApiOperation;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.web.bind.annotation.*;
  17. import java.math.BigDecimal;
  18. import java.text.ParseException;
  19. import java.text.SimpleDateFormat;
  20. import java.util.*;
  21. import java.util.stream.Collectors;
  22. /**
  23. * EmsProdplanYear RESTful接口:
  24. * @author generator
  25. * @version 1.0-SNAPSHORT 2021-06-26 08:40
  26. * 类描述
  27. * 修订历史:
  28. * 日期:2021-06-26
  29. * 作者:generator
  30. * 参考:
  31. * 描述:EmsProdplanYear RESTful接口
  32. * @see null
  33. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  34. */
  35. @RestController
  36. @RequestMapping("/${api.version}/emsprodplanyears")
  37. public class EmsProdplanYearController extends BaseRESTfulController {
  38. @Autowired
  39. IEmsProdplanYearService emsProdplanYearService;
  40. @Autowired
  41. private EmsProdplanYearMapper emsProdplanYearMapper;
  42. @Autowired
  43. private EmsProdplanMonthMapper emsProdplanMonthMapper;
  44. @Autowired
  45. private IEmsProdplanMonthService emsProdplanMonthService;
  46. @ApiOperation(value="获取列表", notes="分页查询")
  47. @ApiImplicitParams({
  48. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  49. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
  50. })
  51. @GetMapping(value = "/")
  52. public RESTfulResult list(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
  53. PageList<EmsProdplanYear> list = emsProdplanYearService.queryForPage(parmas, pageNum, pageSize);
  54. return success(list);
  55. }
  56. /**
  57. * 根据前端传参,获取页面数据
  58. * @RequiresPermissions("emsprodplanyear:view")
  59. * @param parmas 参数列表
  60. * @param pageNum 开始页码
  61. * @param pageSize 一页多少
  62. * @return 返回一个带有分页信息的集合
  63. */
  64. @GetMapping(value = "/getList")
  65. public RESTfulResult getlist(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
  66. // 因为页面产品/工序数量不同,所以获取;
  67. Integer parentNum = parmas.get("parentNum") == null ? 4: Integer.valueOf(parmas.get("parentNum").toString().trim());
  68. pageSize = pageSize * parentNum;
  69. PageList<EmsProdplanYear> list = emsProdplanYearService.queryForPage(parmas, pageNum, pageSize);
  70. // 根据月份汇总数据
  71. Map<String,List<EmsProdplanYear>> stringListMap =
  72. (HashMap<String, List<EmsProdplanYear>>) list.getList().stream().collect(
  73. Collectors.groupingBy(EmsProdplanYear::getYearmonth)
  74. );
  75. // HashMap无序,所以这里要转LinkedHashMap,并返回有序列表
  76. Map<String,List<EmsProdplanYear>> sortListMap = new LinkedHashMap<>();
  77. stringListMap.entrySet().stream().sorted(
  78. Map.Entry.comparingByKey()).forEachOrdered(x-> sortListMap.put(x.getKey(),x.getValue())
  79. );
  80. // 返回实际行数
  81. list.setTotal((long) Math.ceil(list.getTotal()/(double)parentNum));
  82. List mapList = new ArrayList<>();
  83. //数据,进行组装
  84. mapList.add(sortListMap);
  85. list.setList(mapList);
  86. return success(list);
  87. }
  88. @ApiOperation(value="获取列表", notes="分页模糊查询")
  89. @ApiImplicitParams({
  90. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  91. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
  92. })
  93. @GetMapping(value = "/like/")
  94. public RESTfulResult listLike(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
  95. PageList<EmsProdplanYear> list = emsProdplanYearService.queryLikeForPage(parmas, pageNum, pageSize);
  96. return success(list);
  97. }
  98. @ApiOperation(value="创建", notes="根据EmsProdplanYear对象创建")
  99. @ApiImplicitParam(name = "emsProdplanYear", value = "详细实体emsProdplanYear", required = true, dataType = "EmsProdplanYear")
  100. @PostMapping(value = "/", produces = "application/json;charset=UTF-8")
  101. public RESTfulResult add(@RequestBody EmsProdplanYear[] models) throws ParseException {
  102. String userId = JwtUtil.getUseridByToken();
  103. Calendar c = Calendar.getInstance();
  104. for (int i = 0; i < models.length; i++) {
  105. EmsProdplanYear model = models[i];
  106. Boolean lineBool = (model.getLine() == null || model.getLine().equals(""))
  107. && (model.getProductid() == null || model.getProductid().equals(""));
  108. if(lineBool){
  109. return failed(null,"工序为空");
  110. }
  111. if(model.getYearmonth() == null){
  112. return failed(null,"请选择时间");
  113. }
  114. if (model.getUnit() == null || model.getUnit().equals("")) {
  115. model.setUnit("吨");
  116. }
  117. Map map = new HashMap(16);
  118. map.put("line",model.getLine());
  119. map.put("yearmonth",new SimpleDateFormat("yyyy-MM").format(model.getYearmonth()));
  120. map.put("productid",model.getProductid());
  121. List list = emsProdplanYearService.getDateForProduct((HashMap<String, Object>) map);
  122. if (list.size()>0){
  123. return failed(null,"该月时间段数据已生成,无法再次生成");
  124. }
  125. model.setCjr(userId);
  126. model.setCjsj(new Date());
  127. emsProdplanYearService.add(model);
  128. int dayMax = emsProdplanYearService.getDaysOfMonth(model.getYearmonth());
  129. Integer sumWeight = 0;
  130. EmsProdplanMonth maxSqno = emsProdplanMonthService.getMaxSqno();
  131. String unit = "008";
  132. String productid = "";
  133. String workProcid = "";
  134. switch (model.getParentid()) {
  135. case "LG":
  136. sumWeight = model.getWeight().intValue();
  137. productid="方坯";
  138. if (model.getLine().equals("AT2007")){
  139. productid="异型坯";
  140. }
  141. unit="008";
  142. workProcid = "AT2004";
  143. break;
  144. case "LT":
  145. sumWeight = model.getWeight().intValue();
  146. productid="生铁";
  147. unit="008";
  148. break;
  149. case "SJ":
  150. sumWeight = model.getWeight().intValue();
  151. productid="烧结矿";
  152. unit="008";
  153. break;
  154. case "ZG" :
  155. sumWeight = model.getWeight().intValue();
  156. productid="线材";
  157. if(model.getLine().equals("AT2007")) {
  158. productid="H型钢";
  159. }
  160. unit="008";
  161. break;
  162. case "FDC" :
  163. sumWeight = model.getWeight().intValue();
  164. productid="发电量";
  165. unit="006";
  166. break;
  167. case "JCS" :
  168. sumWeight = model.getWeight().intValue();
  169. productid="白灰粉";
  170. unit="008";
  171. break;
  172. case "JCW" :
  173. sumWeight = model.getWeight().intValue();
  174. productid="矿渣粉";
  175. unit="008";
  176. workProcid = model.getProductid();
  177. break;
  178. case "JJZ" :
  179. sumWeight = model.getWeight1().intValue() + model.getWeight2().intValue();
  180. productid="焦炭";
  181. unit="008";
  182. workProcid = "AT1007";
  183. break;
  184. case "JJF" :
  185. sumWeight = model.getWeight().intValue();
  186. if(model.getLine().equals("AT3009")) {
  187. productid = "粗苯";
  188. workProcid = "AT2011";
  189. }
  190. if (model.getLine().equals("AT3024")){
  191. productid="焦油";
  192. workProcid = "AT2011";//model.setLine("AT2011");
  193. }
  194. if(model.getLine().equals("AT3010")){
  195. productid="硫铵";
  196. workProcid = "AT3010";
  197. }
  198. unit="008";
  199. //workProcid = "AT1007";
  200. break;
  201. default: break;
  202. }
  203. int[] avgWeight = emsProdplanYearService.avgWeight(sumWeight,dayMax);
  204. for (int k = 0;k < dayMax;k++) {
  205. EmsProdplanMonth monModel = new EmsProdplanMonth();
  206. c.setTime(model.getYearmonth());
  207. c.add(Calendar.DATE, k);
  208. monModel.setMay(c.getTime());
  209. monModel.setUnit(unit);
  210. monModel.setProductid(productid);
  211. monModel.setWeightMonth(model.getWeight());
  212. if (workProcid.equals("")) {
  213. monModel.setWorkprocid(model.getLine());
  214. } else {
  215. monModel.setWorkprocid(workProcid);
  216. monModel.setWeightMonth(BigDecimal.valueOf(sumWeight));
  217. }
  218. monModel.setWeightDay(BigDecimal.valueOf(avgWeight[k]));
  219. monModel.setKxf_weight(BigDecimal.valueOf(avgWeight[k]));
  220. monModel.setYxf_weight(BigDecimal.valueOf(0));
  221. monModel.setJxdays("0");
  222. monModel.setMemo("根据年计划,系统自动生成。");
  223. monModel.setCreateman("系统");
  224. monModel.setCreatetime(new Date());
  225. monModel.setSqno(maxSqno.getSqno()+k);
  226. Map monMap = new HashMap();
  227. monMap.put("may",new SimpleDateFormat("yyyy-MM-dd").format(monModel.getMay()));
  228. monMap.put("workprocid","'"+monModel.getWorkprocid()+"'");
  229. monMap.put("productid",monModel.getProductid());
  230. monMap.put("startTime",new SimpleDateFormat("yyyy-MM-dd").format(monModel.getMay()));
  231. monMap.put("endTime",new SimpleDateFormat("yyyy-MM-dd").format(monModel.getMay()));
  232. List<EmsProdplanMonth> monList = emsProdplanMonthMapper.selectByParameters(monMap);
  233. if(monList.size()<=0){
  234. EmsProdplanMonth emsProdplanMonth = emsProdplanMonthService.add(monModel);
  235. } else {
  236. if(model.getParentid().equals("LG") || model.getParentid().equals("JJZ")) {
  237. monModel.setKxf_weight(monList.get(0).getKxf_weight().add(monModel.getKxf_weight()));
  238. monModel.setWeightMonth(monList.get(0).getWeightMonth().add(monModel.getWeightMonth()));
  239. monModel.setWeightDay(monList.get(0).getWeightDay().add(monModel.getWeightDay()));
  240. monModel.setId(monList.get(0).getId());
  241. emsProdplanMonthService.modify(monModel);
  242. }
  243. }
  244. }
  245. }
  246. return success();
  247. }
  248. @ApiOperation(value="获取详细信息", notes="根据url的id来获取详细信息")
  249. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String")
  250. @GetMapping(value = "/{id}")
  251. public RESTfulResult get(@PathVariable String id){
  252. EmsProdplanYear emsProdplanYear = emsProdplanYearService.getById(id);
  253. return success(emsProdplanYear);
  254. }
  255. @ApiOperation(value="更新详细信息", notes="根据url的id来指定更新对象,并根据传过来的emsProdplanYear信息来更新详细信息")
  256. @ApiImplicitParams({
  257. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String"),
  258. @ApiImplicitParam(name = "emsProdplanYear", value = "详细实体emsProdplanYear", required = true, dataType = "EmsProdplanYear")
  259. })
  260. @PutMapping(value = "/{id}", produces = "application/json;charset=UTF-8")
  261. public RESTfulResult update(@PathVariable String id, @RequestBody EmsProdplanYear model){
  262. model.setId(id);
  263. EmsProdplanYear emsProdplanYear = emsProdplanYearService.modify(model);
  264. return success(emsProdplanYear);
  265. }
  266. @ApiOperation(value="删除", notes="根据url的id来指定删除对象")
  267. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String")
  268. @DeleteMapping(value = "/delete", produces = "application/json;charset=UTF-8")
  269. public RESTfulResult delete(@RequestBody EmsProdplanYear[] models){
  270. if(models.length >= 1) {
  271. for (int i = 0; i < models.length; i++) {
  272. EmsProdplanYear m = models[i];
  273. if(m==null || m.getNo() ==null || m.getNo().isEmpty()){
  274. return failed(null, "请传入数据ID");
  275. }
  276. EmsProdplanYear tv = emsProdplanYearService.getById(m.getNo());
  277. if (tv == null){
  278. return failed(null, "数据已经删除,请重新查询数据");
  279. }
  280. }
  281. } else {
  282. return failed(null, "请输入要删除的数据");
  283. }
  284. for (int i = 0; i< models.length; i++) {
  285. emsProdplanYearService.delete(models[i].getId());
  286. }
  287. return success();
  288. }
  289. // //年计划 炼钢厂获取编辑页面
  290. // @ApiOperation(value = "查询",notes = "根据时间来生成数据")
  291. // @ApiImplicitParams({
  292. // @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  293. // @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
  294. // })
  295. // @GetMapping(value = "/getDateEditForPage")
  296. // public RESTfulResult getDateEditForPage(@RequestParam HashMap<String, Object> parmas,Integer pageNum, Integer pageSize){
  297. // if(parmas.get("parentid") == null){
  298. // return failed(null, "请选择工序站所");
  299. // }
  300. // if(parmas.get("yearmonth")==null || parmas.get("yearmonth")==null){
  301. // return failed(null, "请选择生成时间");
  302. // }
  303. // try {
  304. // Date end = new SimpleDateFormat("yyyy-MM-dd").parse(parmas.get("jzsj").toString());
  305. // Date start = new SimpleDateFormat("yyyy-MM-dd").parse(parmas.get("cjsj").toString());
  306. // if ((end.getTime()-start.getTime()) / (24 * 60 * 60 * 1000) > 366){
  307. // return failed(null, "生成时间跨度不得超过1年");
  308. // }
  309. // } catch (ParseException e) {
  310. // return failed(null, "时间格式错误");
  311. // }
  312. // PageList<Map<String, Object>> list = emsProdplanYearService.getDateEditForPage(parmas, pageNum, pageSize);
  313. // if(list == null) {
  314. // return failed(null, "日期格式有误");
  315. // }
  316. // return success(list);
  317. // }
  318. @PutMapping(value = "/batchupdateList", produces = "application/json;charset=UTF-8")
  319. public RESTfulResult updateList(@RequestBody EmsProdplanYear[] models) {
  320. String userId = JwtUtil.getUseridByToken();
  321. for (int i = 0; i < models.length; i++) {
  322. EmsProdplanYear model = models[i];
  323. if (model.getNo() == null || model.getNo().equals("")) {
  324. return failed(null, "id为空");
  325. }
  326. if (model.getParentid() == null || model.getNo().equals("")) {
  327. return failed(null, "parentid为空");
  328. }
  329. // 因为一行数据由多条数据组成,所以这里为了确保数据准确性,应该再根据编号查询一次新的数据
  330. EmsProdplanYear emsProdplanYear = emsProdplanYearService.getById(model.getNo());
  331. Calendar c = Calendar.getInstance();
  332. int dayMax = 0;
  333. try {
  334. dayMax = emsProdplanYearService.getDaysOfMonth(emsProdplanYear.getYearmonth());
  335. } catch (ParseException e) {
  336. e.printStackTrace();
  337. }
  338. Integer sumWeight = 0;
  339. EmsProdplanMonth maxSqno = emsProdplanMonthService.getMaxSqno();
  340. String unit = "008";
  341. String productid = "";
  342. String workProcid = "";
  343. switch (model.getParentid()) {
  344. case "LG":
  345. sumWeight = model.getWeight().intValue();
  346. productid="方坯";
  347. if (model.getLine().equals("AT2007-1")){
  348. productid="异型坯";
  349. }
  350. unit="008";
  351. workProcid = "AT2004";
  352. break;
  353. case "LT":
  354. sumWeight = model.getWeight().intValue();
  355. productid="生铁";
  356. unit="008";
  357. break;
  358. case "SJ":
  359. sumWeight = model.getWeight().intValue();
  360. productid="烧结矿";
  361. unit="008";
  362. break;
  363. case "ZG" :
  364. sumWeight = model.getWeight().intValue();
  365. productid="线材";
  366. if(model.getLine().equals("AT2007")) {
  367. productid="H型钢";
  368. }
  369. unit="008";
  370. break;
  371. case "FDC" :
  372. sumWeight = model.getWeight().intValue();
  373. productid="发电量";
  374. unit="006";
  375. break;
  376. case "JCS" :
  377. sumWeight = model.getWeight().intValue();
  378. productid="白灰粉";
  379. unit="008";
  380. break;
  381. case "JCW" :
  382. sumWeight = model.getWeight().intValue();
  383. productid="矿渣粉";
  384. unit="008";
  385. workProcid = model.getProductid();
  386. break;
  387. case "JJZ" :
  388. sumWeight = model.getWeight1().intValue() + model.getWeight2().intValue();
  389. productid="焦炭";
  390. unit="008";
  391. workProcid = "AT1007";
  392. break;
  393. case "JJF" :
  394. // sumWeight = model.getWeight().intValue();
  395. // productid="焦油";
  396. // if(model.getLine().equals("AT3009")){
  397. // productid="粗苯";
  398. // }
  399. // if(model.getLine().equals("AT3010")){
  400. // productid="硫铵";
  401. // }
  402. // unit="008";
  403. // //workProcid = "AT1007";
  404. // break;
  405. sumWeight = model.getWeight().intValue();
  406. if(model.getLine().equals("AT3009")) {
  407. productid = "粗苯";
  408. workProcid = "AT2011";
  409. }
  410. if (model.getLine().equals("AT3024")){
  411. productid="焦油";
  412. workProcid = "AT2011";
  413. }
  414. if(model.getLine().equals("AT3010")){
  415. productid="硫铵";
  416. workProcid = "AT3010";
  417. }
  418. unit="008";
  419. break;
  420. default: break;
  421. }
  422. int[] avgWeight = emsProdplanYearService.avgWeight(sumWeight,dayMax);
  423. for (int k = 0;k < dayMax;k++) {
  424. EmsProdplanMonth monModel = new EmsProdplanMonth();
  425. c.setTime(model.getYearmonth());
  426. c.add(Calendar.DATE, k);
  427. monModel.setMay(c.getTime());
  428. monModel.setUnit(unit);
  429. monModel.setProductid(productid);
  430. monModel.setWeightMonth(model.getWeight());
  431. if (workProcid.equals("")) {
  432. monModel.setWorkprocid(model.getLine());
  433. } else {
  434. monModel.setWorkprocid(workProcid);
  435. monModel.setWeightMonth(BigDecimal.valueOf(sumWeight));
  436. }
  437. monModel.setWeightDay(BigDecimal.valueOf(avgWeight[k]));
  438. monModel.setKxf_weight(BigDecimal.valueOf(avgWeight[k]));
  439. monModel.setYxf_weight(BigDecimal.valueOf(0));
  440. monModel.setJxdays("0");
  441. monModel.setMemo("根据年计划,系统自动生成。");
  442. monModel.setCreateman("系统");
  443. monModel.setCreatetime(new Date());
  444. monModel.setSqno(maxSqno.getSqno()+k);
  445. Map monMap = new HashMap();
  446. monMap.put("may",new SimpleDateFormat("yyyy-MM-dd").format(monModel.getMay()));
  447. monMap.put("workprocid","'"+monModel.getWorkprocid()+"'");
  448. monMap.put("productid",monModel.getProductid());
  449. monMap.put("startTime",new SimpleDateFormat("yyyy-MM-dd").format(monModel.getMay()));
  450. monMap.put("endTime",new SimpleDateFormat("yyyy-MM-dd").format(monModel.getMay()));
  451. List<EmsProdplanMonth> monList = emsProdplanMonthMapper.selectByParameters(monMap);
  452. if(monList.size()<=0){
  453. emsProdplanMonthService.add(monModel);
  454. } else {
  455. if((model.getParentid().equals("LG")&&monModel.getProductid().equals("方坯")) || model.getParentid().equals("JJZ")) {
  456. if (k == 0){
  457. monList.get(0).setWeightMonth(BigDecimal.valueOf(0));
  458. monList.get(0).setWeightDay(BigDecimal.valueOf(0));
  459. }
  460. //monModel.setKxf_weight(monList.get(0).getKxf_weight().add(monModel.getKxf_weight()));
  461. monModel.setWeightMonth(monList.get(0).getWeightMonth().add(monModel.getWeightMonth()));
  462. monModel.setWeightDay(monList.get(0).getWeightDay().add(monModel.getWeightDay()));
  463. monModel.setId(monList.get(0).getId());
  464. emsProdplanMonthService.modify(monModel);
  465. } else {
  466. monModel.setId(monList.get(0).getId());
  467. emsProdplanMonthService.modify(monModel);
  468. }
  469. }
  470. }
  471. emsProdplanYear.setWeight(model.getWeight());
  472. emsProdplanYear.setWeight1(model.getWeight1());
  473. emsProdplanYear.setWeight2(model.getWeight2());
  474. emsProdplanYear.setMemo(model.getMemo());
  475. emsProdplanYear.setXgr(userId);
  476. emsProdplanYear.setXgsj(new Date());
  477. emsProdplanYearMapper.updateByPrimaryKey(emsProdplanYear);
  478. }
  479. return success();
  480. }
  481. @PutMapping(value = "/batchupdate", produces = "application/json;charset=UTF-8")
  482. public RESTfulResult update(@RequestBody EmsProdplanYear[] models){
  483. String userId = JwtUtil.getUseridByToken();
  484. for (int i = 0; i< models.length; i++) {
  485. EmsProdplanYear model = models[i];
  486. if(model.getNo() == null || model.getNo().equals("")) {
  487. return failed(null,"id为空");
  488. }
  489. if(model.getParentid() == null || model.getNo().equals("")){
  490. return failed(null,"parentid为空");
  491. }
  492. model.setXgr(userId);
  493. model.setXgsj(new Date());
  494. emsProdplanYearMapper.updateByPrimaryKey(model);
  495. }
  496. // if(!failmsg.isEmpty()){
  497. // return failed(null, "序号 [" + failmsg.substring(0, failmsg.length()-1) + "] 已审核,不允许修改");
  498. // }
  499. // for (int i = 0; i< models.length; i++) {
  500. // EmsProdplanYear model = models[i];
  501. // if(model.getCjsj() == null || model.getJzsj() == null){
  502. // return failed(null, "数据请传入时间");
  503. // }
  504. // if(model.getLine() == null || model.getLine().isEmpty()){
  505. // return failed(null, "数据请传入位置");
  506. // }
  507. // if(model.getWeight() == null || model.getWeight() == null){
  508. // return failed(null, "请填写完整数据");
  509. // }
  510. // String strDateFormat = "yyyy-MM-dd";
  511. // SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
  512. // Map map = new HashMap();
  513. // map.put("line",model.getLine());
  514. // map.put("cjsj",sdf.format(model.getCjsj()));
  515. // map.put("jzsj",sdf.format(model.getJzsj()));
  516. // EmsProdplanYear byId = emsProdplanYearService.getByParams(map);
  517. // if(model.getNo() != null && !model.getNo().equals("")){
  518. // model.setXgr(userId);
  519. // model.setXgsj(new Date());
  520. // emsProdplanYearMapper.updateByPrimaryKey(model);
  521. // }
  522. // else if(byId != null && byId.getZt().equals("1")){
  523. // return failed(null, ""+byId.getLine()+"在该期间数据已经生成,无法再次生成");
  524. // }
  525. // else {
  526. // model.setCjr(userId);
  527. // model.setCjsj(new Date());
  528. // model.setZt("1");
  529. // model.setCjr(userId);
  530. // emsProdplanYearService.add(model);
  531. // }
  532. // }
  533. return success();
  534. }
  535. }