| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- package com.chinaitop.depot.fumigation.controller;
- import com.alibaba.fastjson.JSON;
- import com.chinaitop.depot.fumigation.model.*;
- import com.chinaitop.depot.fumigation.service.*;
- import com.chinaitop.depot.utils.HttpUtil;
- import com.chinaitop.depot.utils.JsonToObjectUtils;
- import com.chinaitop.depot.utils.ParameterUtil;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.http.MediaType;
- import org.springframework.util.CollectionUtils;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import javax.annotation.Resource;
- import java.io.IOException;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * @author lvzhikai
- * @description: 熏蒸作业善后
- * @create 2019-1-21 10:57
- */
- @RestController
- @RequestMapping(value = "/storage/fumigationAfter")
- @Api(value = "FumigationAfterController", description = "熏蒸作业善后类")
- @SuppressWarnings("all")
- public class FumigationAlterController {
- @Resource
- FumigationAfterService fumigationAfterService;
- @Resource
- private FumigationPlanService fumigationPlanService;
- @Resource
- private FumigationProcessService fumigationProcessService;
- @Resource
- private PesticidePlanService pesticidePlanService;
- @Resource
- private FumigationForRecordService fumigationForRecordService;
- // 获取ip地址
- @Value("${reportUrl}")
- private String reportPath;
- /**
- * 列表
- * @param pageNum
- * @param pageSize
- * @param houseId
- * @param orgId
- * @return
- */
- @RequestMapping(value = "/getFumigationAfterList", method = RequestMethod.GET)
- @ApiOperation(value = "熏蒸作业善后列表", notes = "熏蒸作业善后列表,支持分页")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
- @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
- @ApiImplicitParam(name = "houseId", value = "仓房Id", paramType = "query"),
- @ApiImplicitParam(name = "orgId", value = "组织机构编号", paramType = "query")
- })
- public PageInfo<Map<String,Object>> getFumigationAfterList(Integer pageNum, Integer pageSize, Integer houseId, String createTime, Integer orgId) {
- Map<String,Object> map = new HashMap<>();
- List<Map<String,Object>> list = null;
- if (ParameterUtil.isnotnull(orgId))//粮库查询
- map.put("orgId",orgId);
- if (ParameterUtil.isnotnull(houseId))//粮库查询
- map.put("houseId",houseId);
- if (ParameterUtil.isnotnull(createTime)) {//归档用
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date = null;
- try {
- date = dateFormat.parse(createTime);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- map.put("createTime", date);
- }
- if (pageNum!=null && pageSize!=null) {
- PageHelper.startPage(pageNum, pageSize);
- }
- list = fumigationAfterService.getFumigationAfterList(map);
- PageInfo<Map<String,Object>> pageInfo = new PageInfo<Map<String,Object>>(list);
- return pageInfo;
- }
- /**
- * 保存熏蒸善后信息
- * @param fumigation
- * @return
- */
- @RequestMapping(value="/saveFumigationAfterDate", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
- @ApiOperation(value="保存熏蒸善后信息", notes = "保存熏蒸善后信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "fumigationAfter", value = "熏蒸善后数据", paramType = "form")
- })
- public Map<String, Object> saveFumigationAfterDate(String fumigationAfter) throws Exception {
- Map<String, Object> modelMap = new HashMap<String, Object>();
- // JSON字符串转对象
- ObjectMapper mapper = new ObjectMapper();
- TFumigationAfter tFumigationAfter = (TFumigationAfter) JsonToObjectUtils.jsonToObject(fumigationAfter,"com.chinaitop.depot.fumigation.model.TFumigationAfter");
- tFumigationAfter.setDeleteState("1");//默认设置删除标志
- if (tFumigationAfter.getId() == null) {
- tFumigationAfter.setCreateTime(new Date());//创建时间
- tFumigationAfter.setId(ParameterUtil.getCode());
- fumigationAfterService.add(tFumigationAfter);
- //修改熏蒸状态
- TFumigationForrecordExample example = new TFumigationForrecordExample();
- TFumigationForrecordExample.Criteria criteria = example.createCriteria();
- criteria.andIdEqualTo(tFumigationAfter.getRecordId());
- TFumigationForrecord tFumigationForrecord = new TFumigationForrecord();
- tFumigationForrecord.setState(10);
- fumigationForRecordService.updateByExample(tFumigationForrecord, example);
- /*try {
- //向市级提交数据--熏蒸计划
- TFumigationPlan planData = fumigationPlanService.findById(tFumigationAfter.getFumigationId());
- Map<String, Object> planMap = ParameterUtil.convertBean(planData);
- //熏蒸善后
- List<TFumigationAfter> afterData = fumigationAfterService.findByFumigationId(tFumigationAfter.getFumigationId());
- Map<String, Object> afterMap = ParameterUtil.convertBean(afterData.get(0));
- planMap.put("fumigationAfter",afterMap);
- //熏蒸施药
- TFumigationPesticideExample pesticideexample = new TFumigationPesticideExample();
- TFumigationPesticideExample.Criteria pesticidecriteria = pesticideexample.createCriteria();
- pesticidecriteria.andFumigationIdEqualTo(tFumigationAfter.getFumigationId());
- List<TFumigationPesticide> pesticideData = pesticidePlanService.getFumigationPesticideList(pesticideexample);
- Map<String, Object> pesticideMap = ParameterUtil.convertBean(pesticideData.get(0));
- planMap.put("fumigationPesticide",pesticideMap);
- //熏蒸过程
- TFumigationProcessExample processExample = new TFumigationProcessExample();
- TFumigationProcessExample.Criteria processcriteria = processExample.createCriteria();
- processcriteria.andFumigationIdEqualTo(tFumigationAfter.getFumigationId());
- List<TFumigationProcess> processData = fumigationProcessService.getDataByFumId(processExample);
- Map<String, Object> processMap = ParameterUtil.convertBean(pesticideData.get(0));
- planMap.put("fumigationProcess",processMap);
- String url = reportPath+"/api/cbl-app/cbl/fumigation/insertFumigationPlan";//市级接口
- String strResult = HttpUtil.doPost(url, JSON.toJSONString(planMap));
- }catch (IOException e) {
- e.printStackTrace();
- } finally {
- modelMap.put("status", "success");
- }*/
- } else {
- tFumigationAfter.setUpdateTime(new Date());//修改时间
- fumigationAfterService.update(tFumigationAfter);
- }
- modelMap.put("status", "success");
- return modelMap;
- }
- /**
- * 根据id查询熏蒸过程
- * @param id 主键id
- * @return
- */
- @RequestMapping(value="/getAfterDeatil", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value="根据id查询熏蒸过程数据", notes = "根据id查询熏蒸过程数据")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "afterId", value = "主键id", paramType = "query")
- })
- public Map<String, Object> getAfterDeatil(String afterId) {
- Map<String, Object> modelMap = new HashMap<String, Object>();
- if (afterId != null) {
- TFumigationAfter tFumigationAfter = fumigationAfterService.findById(afterId);
- modelMap.put("afterEdit",tFumigationAfter);//熏蒸善后数据
- TFumigationProcessExample example = new TFumigationProcessExample();
- TFumigationProcessExample.Criteria criteria = example.createCriteria();
- criteria.andRecordIdEqualTo(tFumigationAfter.getRecordId());
- criteria.andDeleteStateEqualTo("1");
- List<TFumigationProcess> tFumigationProcess = fumigationProcessService.getDataByFumId(example);
- if(!CollectionUtils.isEmpty(tFumigationProcess)){
- modelMap.put("processEdit",tFumigationProcess.get(0));//熏蒸作业过程数据
- }
- TFumigationForrecord fumigationForrecord = fumigationForRecordService.getById(tFumigationAfter.getRecordId());
- /* TFumigationPlan tFumigationPlan = fumigationPlanService.findById(tFumigationProcess.getFumigationId());*/
- modelMap.put("fumigationEdit",fumigationForrecord);//熏蒸方案数据
- /*TFumigationPlan tFumigationPlan = fumigationPlanService.findById(tFumigationAfter.getFumigationId());
- modelMap.put("fumigationEdit",tFumigationPlan);//熏蒸方案数据*/
- }
- return modelMap;
- }
- /**
- * 删除熏蒸善后信息
- * @param fumigationId 主键id
- * @return
- * @throws Exception
- */
- @RequestMapping(value="/removeAfterPlan", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
- @ApiOperation(value="删除熏蒸善后信息", notes = "删除熏蒸善后信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "afterId", value = "主键id", paramType = "form"),
- @ApiImplicitParam(name = "recordId", value = "熏蒸备案表ID", paramType = "form")
- })
- public Map<String, Object> removeAfterPlan(String afterId,String recordId) throws Exception {
- Map<String, Object> modelMap = new HashMap<>();
- if (afterId != null) {
- TFumigationAfterExample example = new TFumigationAfterExample();
- TFumigationAfterExample.Criteria criteria = example.createCriteria();
- criteria.andIdEqualTo(afterId);
- TFumigationAfter tFumigationAfter = new TFumigationAfter();
- tFumigationAfter.setDeleteState("0");
- fumigationAfterService.updateByExample(tFumigationAfter, example);
- //修改熏蒸状态
- /* TFumigationPlanExample fumExample = new TFumigationPlanExample();
- TFumigationPlanExample.Criteria fumCriteria = fumExample.createCriteria();
- fumCriteria.andIdEqualTo(fumigationId);
- TFumigationPlan tFumigationPlan = new TFumigationPlan();
- tFumigationPlan.setState(10);
- fumigationPlanService.updateByExample(tFumigationPlan, fumExample);*/
- TFumigationForrecordExample forrecordExample = new TFumigationForrecordExample();
- TFumigationForrecordExample.Criteria exampleCriteria = forrecordExample.createCriteria();
- exampleCriteria.andIdEqualTo(recordId);
- TFumigationForrecord tFumigationForrecord = new TFumigationForrecord();
- tFumigationForrecord.setState(10);
- fumigationForRecordService.updateByExample(tFumigationForrecord, forrecordExample);
- modelMap.put("status", "success");
- }
- return modelMap;
- }
- /**
- * 查询作业列表数据
- * @param id 主键id
- * @return
- */
- @RequestMapping(value="/getHomeWorkQueryList", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value="查询作业列表数据", notes = "查询作业列表数据")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
- @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
- @ApiImplicitParam(name = "houseId", value = "仓房Id", paramType = "query"),
- @ApiImplicitParam(name = "orgId", value = "组织机构编号", paramType = "query")
- })
- public PageInfo<Map<String,Object>> getHomeWorkQueryList(Integer pageNum, Integer pageSize, Integer houseId, String orgId) {
- Map<String,Object> map = new HashMap<>();
- List<Map<String,Object>> list = null;
- map.put("houseId",houseId);
- map.put("orgId",orgId);
- if (pageNum!=null && pageSize!=null) {
- PageHelper.startPage(pageNum, pageSize);
- }
- list = fumigationAfterService.selectHomeWorkQueryList(map);
- PageInfo<Map<String,Object>> pageInfo = new PageInfo<Map<String,Object>>(list);
- return pageInfo;
- }
- }
|