FumigationAlterController.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. package com.chinaitop.depot.fumigation.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.chinaitop.depot.fumigation.model.*;
  4. import com.chinaitop.depot.fumigation.service.*;
  5. import com.chinaitop.depot.utils.HttpUtil;
  6. import com.chinaitop.depot.utils.JsonToObjectUtils;
  7. import com.chinaitop.depot.utils.ParameterUtil;
  8. import com.fasterxml.jackson.databind.ObjectMapper;
  9. import com.github.pagehelper.PageHelper;
  10. import com.github.pagehelper.PageInfo;
  11. import io.swagger.annotations.Api;
  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.Value;
  16. import org.springframework.http.MediaType;
  17. import org.springframework.util.CollectionUtils;
  18. import org.springframework.web.bind.annotation.RequestMapping;
  19. import org.springframework.web.bind.annotation.RequestMethod;
  20. import org.springframework.web.bind.annotation.RestController;
  21. import javax.annotation.Resource;
  22. import java.io.IOException;
  23. import java.text.ParseException;
  24. import java.text.SimpleDateFormat;
  25. import java.util.Date;
  26. import java.util.HashMap;
  27. import java.util.List;
  28. import java.util.Map;
  29. /**
  30. * @author lvzhikai
  31. * @description: 熏蒸作业善后
  32. * @create 2019-1-21 10:57
  33. */
  34. @RestController
  35. @RequestMapping(value = "/storage/fumigationAfter")
  36. @Api(value = "FumigationAfterController", description = "熏蒸作业善后类")
  37. @SuppressWarnings("all")
  38. public class FumigationAlterController {
  39. @Resource
  40. FumigationAfterService fumigationAfterService;
  41. @Resource
  42. private FumigationPlanService fumigationPlanService;
  43. @Resource
  44. private FumigationProcessService fumigationProcessService;
  45. @Resource
  46. private PesticidePlanService pesticidePlanService;
  47. @Resource
  48. private FumigationForRecordService fumigationForRecordService;
  49. // 获取ip地址
  50. @Value("${reportUrl}")
  51. private String reportPath;
  52. /**
  53. * 列表
  54. * @param pageNum
  55. * @param pageSize
  56. * @param houseId
  57. * @param orgId
  58. * @return
  59. */
  60. @RequestMapping(value = "/getFumigationAfterList", method = RequestMethod.GET)
  61. @ApiOperation(value = "熏蒸作业善后列表", notes = "熏蒸作业善后列表,支持分页")
  62. @ApiImplicitParams({
  63. @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
  64. @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
  65. @ApiImplicitParam(name = "houseId", value = "仓房Id", paramType = "query"),
  66. @ApiImplicitParam(name = "orgId", value = "组织机构编号", paramType = "query")
  67. })
  68. public PageInfo<Map<String,Object>> getFumigationAfterList(Integer pageNum, Integer pageSize, Integer houseId, String createTime, Integer orgId) {
  69. Map<String,Object> map = new HashMap<>();
  70. List<Map<String,Object>> list = null;
  71. if (ParameterUtil.isnotnull(orgId))//粮库查询
  72. map.put("orgId",orgId);
  73. if (ParameterUtil.isnotnull(houseId))//粮库查询
  74. map.put("houseId",houseId);
  75. if (ParameterUtil.isnotnull(createTime)) {//归档用
  76. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  77. Date date = null;
  78. try {
  79. date = dateFormat.parse(createTime);
  80. } catch (ParseException e) {
  81. e.printStackTrace();
  82. }
  83. map.put("createTime", date);
  84. }
  85. if (pageNum!=null && pageSize!=null) {
  86. PageHelper.startPage(pageNum, pageSize);
  87. }
  88. list = fumigationAfterService.getFumigationAfterList(map);
  89. PageInfo<Map<String,Object>> pageInfo = new PageInfo<Map<String,Object>>(list);
  90. return pageInfo;
  91. }
  92. /**
  93. * 保存熏蒸善后信息
  94. * @param fumigation
  95. * @return
  96. */
  97. @RequestMapping(value="/saveFumigationAfterDate", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
  98. @ApiOperation(value="保存熏蒸善后信息", notes = "保存熏蒸善后信息")
  99. @ApiImplicitParams({
  100. @ApiImplicitParam(name = "fumigationAfter", value = "熏蒸善后数据", paramType = "form")
  101. })
  102. public Map<String, Object> saveFumigationAfterDate(String fumigationAfter) throws Exception {
  103. Map<String, Object> modelMap = new HashMap<String, Object>();
  104. // JSON字符串转对象
  105. ObjectMapper mapper = new ObjectMapper();
  106. TFumigationAfter tFumigationAfter = (TFumigationAfter) JsonToObjectUtils.jsonToObject(fumigationAfter,"com.chinaitop.depot.fumigation.model.TFumigationAfter");
  107. tFumigationAfter.setDeleteState("1");//默认设置删除标志
  108. if (tFumigationAfter.getId() == null) {
  109. tFumigationAfter.setCreateTime(new Date());//创建时间
  110. tFumigationAfter.setId(ParameterUtil.getCode());
  111. fumigationAfterService.add(tFumigationAfter);
  112. //修改熏蒸状态
  113. TFumigationForrecordExample example = new TFumigationForrecordExample();
  114. TFumigationForrecordExample.Criteria criteria = example.createCriteria();
  115. criteria.andIdEqualTo(tFumigationAfter.getRecordId());
  116. TFumigationForrecord tFumigationForrecord = new TFumigationForrecord();
  117. tFumigationForrecord.setState(10);
  118. fumigationForRecordService.updateByExample(tFumigationForrecord, example);
  119. /*try {
  120. //向市级提交数据--熏蒸计划
  121. TFumigationPlan planData = fumigationPlanService.findById(tFumigationAfter.getFumigationId());
  122. Map<String, Object> planMap = ParameterUtil.convertBean(planData);
  123. //熏蒸善后
  124. List<TFumigationAfter> afterData = fumigationAfterService.findByFumigationId(tFumigationAfter.getFumigationId());
  125. Map<String, Object> afterMap = ParameterUtil.convertBean(afterData.get(0));
  126. planMap.put("fumigationAfter",afterMap);
  127. //熏蒸施药
  128. TFumigationPesticideExample pesticideexample = new TFumigationPesticideExample();
  129. TFumigationPesticideExample.Criteria pesticidecriteria = pesticideexample.createCriteria();
  130. pesticidecriteria.andFumigationIdEqualTo(tFumigationAfter.getFumigationId());
  131. List<TFumigationPesticide> pesticideData = pesticidePlanService.getFumigationPesticideList(pesticideexample);
  132. Map<String, Object> pesticideMap = ParameterUtil.convertBean(pesticideData.get(0));
  133. planMap.put("fumigationPesticide",pesticideMap);
  134. //熏蒸过程
  135. TFumigationProcessExample processExample = new TFumigationProcessExample();
  136. TFumigationProcessExample.Criteria processcriteria = processExample.createCriteria();
  137. processcriteria.andFumigationIdEqualTo(tFumigationAfter.getFumigationId());
  138. List<TFumigationProcess> processData = fumigationProcessService.getDataByFumId(processExample);
  139. Map<String, Object> processMap = ParameterUtil.convertBean(pesticideData.get(0));
  140. planMap.put("fumigationProcess",processMap);
  141. String url = reportPath+"/api/cbl-app/cbl/fumigation/insertFumigationPlan";//市级接口
  142. String strResult = HttpUtil.doPost(url, JSON.toJSONString(planMap));
  143. }catch (IOException e) {
  144. e.printStackTrace();
  145. } finally {
  146. modelMap.put("status", "success");
  147. }*/
  148. } else {
  149. tFumigationAfter.setUpdateTime(new Date());//修改时间
  150. fumigationAfterService.update(tFumigationAfter);
  151. }
  152. modelMap.put("status", "success");
  153. return modelMap;
  154. }
  155. /**
  156. * 根据id查询熏蒸过程
  157. * @param id 主键id
  158. * @return
  159. */
  160. @RequestMapping(value="/getAfterDeatil", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
  161. @ApiOperation(value="根据id查询熏蒸过程数据", notes = "根据id查询熏蒸过程数据")
  162. @ApiImplicitParams({
  163. @ApiImplicitParam(name = "afterId", value = "主键id", paramType = "query")
  164. })
  165. public Map<String, Object> getAfterDeatil(String afterId) {
  166. Map<String, Object> modelMap = new HashMap<String, Object>();
  167. if (afterId != null) {
  168. TFumigationAfter tFumigationAfter = fumigationAfterService.findById(afterId);
  169. modelMap.put("afterEdit",tFumigationAfter);//熏蒸善后数据
  170. TFumigationProcessExample example = new TFumigationProcessExample();
  171. TFumigationProcessExample.Criteria criteria = example.createCriteria();
  172. criteria.andRecordIdEqualTo(tFumigationAfter.getRecordId());
  173. criteria.andDeleteStateEqualTo("1");
  174. List<TFumigationProcess> tFumigationProcess = fumigationProcessService.getDataByFumId(example);
  175. if(!CollectionUtils.isEmpty(tFumigationProcess)){
  176. modelMap.put("processEdit",tFumigationProcess.get(0));//熏蒸作业过程数据
  177. }
  178. TFumigationForrecord fumigationForrecord = fumigationForRecordService.getById(tFumigationAfter.getRecordId());
  179. /* TFumigationPlan tFumigationPlan = fumigationPlanService.findById(tFumigationProcess.getFumigationId());*/
  180. modelMap.put("fumigationEdit",fumigationForrecord);//熏蒸方案数据
  181. /*TFumigationPlan tFumigationPlan = fumigationPlanService.findById(tFumigationAfter.getFumigationId());
  182. modelMap.put("fumigationEdit",tFumigationPlan);//熏蒸方案数据*/
  183. }
  184. return modelMap;
  185. }
  186. /**
  187. * 删除熏蒸善后信息
  188. * @param fumigationId 主键id
  189. * @return
  190. * @throws Exception
  191. */
  192. @RequestMapping(value="/removeAfterPlan", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
  193. @ApiOperation(value="删除熏蒸善后信息", notes = "删除熏蒸善后信息")
  194. @ApiImplicitParams({
  195. @ApiImplicitParam(name = "afterId", value = "主键id", paramType = "form"),
  196. @ApiImplicitParam(name = "recordId", value = "熏蒸备案表ID", paramType = "form")
  197. })
  198. public Map<String, Object> removeAfterPlan(String afterId,String recordId) throws Exception {
  199. Map<String, Object> modelMap = new HashMap<>();
  200. if (afterId != null) {
  201. TFumigationAfterExample example = new TFumigationAfterExample();
  202. TFumigationAfterExample.Criteria criteria = example.createCriteria();
  203. criteria.andIdEqualTo(afterId);
  204. TFumigationAfter tFumigationAfter = new TFumigationAfter();
  205. tFumigationAfter.setDeleteState("0");
  206. fumigationAfterService.updateByExample(tFumigationAfter, example);
  207. //修改熏蒸状态
  208. /* TFumigationPlanExample fumExample = new TFumigationPlanExample();
  209. TFumigationPlanExample.Criteria fumCriteria = fumExample.createCriteria();
  210. fumCriteria.andIdEqualTo(fumigationId);
  211. TFumigationPlan tFumigationPlan = new TFumigationPlan();
  212. tFumigationPlan.setState(10);
  213. fumigationPlanService.updateByExample(tFumigationPlan, fumExample);*/
  214. TFumigationForrecordExample forrecordExample = new TFumigationForrecordExample();
  215. TFumigationForrecordExample.Criteria exampleCriteria = forrecordExample.createCriteria();
  216. exampleCriteria.andIdEqualTo(recordId);
  217. TFumigationForrecord tFumigationForrecord = new TFumigationForrecord();
  218. tFumigationForrecord.setState(10);
  219. fumigationForRecordService.updateByExample(tFumigationForrecord, forrecordExample);
  220. modelMap.put("status", "success");
  221. }
  222. return modelMap;
  223. }
  224. /**
  225. * 查询作业列表数据
  226. * @param id 主键id
  227. * @return
  228. */
  229. @RequestMapping(value="/getHomeWorkQueryList", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
  230. @ApiOperation(value="查询作业列表数据", notes = "查询作业列表数据")
  231. @ApiImplicitParams({
  232. @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
  233. @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
  234. @ApiImplicitParam(name = "houseId", value = "仓房Id", paramType = "query"),
  235. @ApiImplicitParam(name = "orgId", value = "组织机构编号", paramType = "query")
  236. })
  237. public PageInfo<Map<String,Object>> getHomeWorkQueryList(Integer pageNum, Integer pageSize, Integer houseId, String orgId) {
  238. Map<String,Object> map = new HashMap<>();
  239. List<Map<String,Object>> list = null;
  240. map.put("houseId",houseId);
  241. map.put("orgId",orgId);
  242. if (pageNum!=null && pageSize!=null) {
  243. PageHelper.startPage(pageNum, pageSize);
  244. }
  245. list = fumigationAfterService.selectHomeWorkQueryList(map);
  246. PageInfo<Map<String,Object>> pageInfo = new PageInfo<Map<String,Object>>(list);
  247. return pageInfo;
  248. }
  249. }