package com.steerinfo.dil.controller; import com.steerinfo.dil.feign.ESFeign; import com.steerinfo.dil.model.TmstruckLoadResult; import com.steerinfo.dil.service.ITmstruckLoadResultService; import com.steerinfo.dil.util.BaseRESTfulController; import com.steerinfo.dil.util.ColumnDataUtil; import com.steerinfo.dil.util.DataChange; import com.steerinfo.dil.util.PageListAdd; import com.steerinfo.framework.controller.RESTfulResult; import com.steerinfo.framework.service.pagehelper.PageHelper; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import io.swagger.models.auth.In; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; import java.util.*; /** * TmstruckLoadResult RESTful接口: * @author generator * @version 1.0-SNAPSHORT 2021-09-02 10:38 * 类描述 * 修订历史: * 日期:2021-09-02 * 作者:generator * 参考: * 描述:TmstruckLoadResult RESTful接口 * @see null * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved. */ @RestController @RequestMapping("/${api.version}/tmstruckloadresults") public class TmstruckLoadResultController extends BaseRESTfulController { @Autowired ITmstruckLoadResultService tmstruckLoadResultService; @Autowired ESFeign esFeign; @Autowired ColumnDataUtil columnDataUtil; @ApiOperation(value="生成装车实绩 :远程调用专用") @ApiImplicitParams({ @ApiImplicitParam(name = "resultId", value = "装车作业实绩ID", required = false, dataType = "Integer"), }) @PostMapping("/addLoadResult") public RESTfulResult addLoadResult(@RequestBody(required=false) Map map){ int i = tmstruckLoadResultService.addLoadResult(map); return success(i); } @ApiOperation(value="查询所有正在排队的销售订单") @ApiImplicitParams({ @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"), @ApiImplicitParam(name = "apiId(227)", value = "动态表头", required = false, dataType = "Integer"), @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"), @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer"), }) @PostMapping("/getSaleOrderOnQueue") public RESTfulResult getSaleOrderOnQueue(@RequestBody(required=false) Map mapValue, Integer apiId, Integer pageNum, Integer pageSize, String con){ PageHelper.startPage(pageNum,pageSize); //分页数据 List> queueSaleOrder = tmstruckLoadResultService.getSaleOrderOnQueue(mapValue); PageListAdd pageList = columnDataUtil.tableColumnData(apiId, null,queueSaleOrder); return success(pageList); } @ApiOperation(value="修改装车点和装车顺序:销售钢材专用 ") @ApiImplicitParams({ @ApiImplicitParam(name = "map", value = "", required = false, dataType = "Map"), }) @PostMapping("/updateLoadingIdAndLoadSq") public RESTfulResult updateLoadingIdAndLoadSq(@RequestBody(required=false) Map map){ int i = tmstruckLoadResultService.updateLoadingIdAndLoadSq(map); return success(i); } @ApiOperation(value="查询所有装车实绩") @ApiImplicitParams({ @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"), @ApiImplicitParam(name = "apiId(91)", value = "动态表头", required = false, dataType = "Integer"), @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"), @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer"), }) @PostMapping("/getAllLoadResult") public RESTfulResult getAllLoadResult(@RequestBody(required=false) Map mapValue, Integer apiId, Integer pageNum, Integer pageSize, Integer status, Integer orderType, String con, String userId, String userIds){ if (status!=null){ mapValue.put("status", status); } if (orderType!=null){ mapValue.put("orderTypee", orderType); } if (userId!=null){ mapValue.put("userId",userId); } if (userIds!=null){ mapValue.put("userIds",userIds); } PageHelper.startPage(pageNum,pageSize); //分页数据 List> loadResult = tmstruckLoadResultService.getAllLoadResult(mapValue); PageListAdd pageList = columnDataUtil.tableColumnData(apiId, null,loadResult); return success(pageList); } @ApiOperation(value="销售新增钢材装车实绩 ") @ApiImplicitParams({ @ApiImplicitParam(name = "map", value = "", required = false, dataType = "Map"), }) @PostMapping("/addSaleLoadResult") public RESTfulResult addSaleLoadResult(@RequestBody(required=false) Map map){ try { int i = tmstruckLoadResultService.addXSLoadResult(map); if(i == 1){ return success("装货成功"); }else if(i == 0){ return failed("委托发送失败"); }else if(i == -1){ return failed("装货失败,该订单无装货实绩"); }else { return failed("装车失败!请联系管理员"); } } catch (Exception e) { return failed("装车失败!请联系管理员"); } } @ApiOperation(value="销售新增钢渣、水渣、危化品装车实绩 ") @ApiImplicitParams({ @ApiImplicitParam(name = "map", value = "", required = false, dataType = "Map"), }) @PostMapping("/addSale2LoadResult") public RESTfulResult addSale2LoadResult(@RequestBody(required=false) Map map){ try { int i = tmstruckLoadResultService.addXS2LoadResult(map); if(i > 0){ return success("装货成功"); }else if(i == -2){ return failed("已装过此物资"); }else if(i == -3) { return failed("该订单没有装货作业"); }else if (i==-5){ return failed("请勿重复装车"); }else { return failed("装货异常,请联系管理员!"); } } catch (Exception e) { System.out.println(e.getMessage()); } return failed("装货异常,请联系管理员!"); } @ApiOperation(value="修改汽车装车实绩") @ApiImplicitParams({ @ApiImplicitParam(name = "tmstruckLoadResult", value = "装车作业实绩对象", required = false, dataType = "TmstruckLoadResult"), }) @PostMapping("/updateLoadResult") public RESTfulResult updateLoadResult(@RequestBody TmstruckLoadResult tmstruckLoadResult){ tmstruckLoadResult.setUpdateUsername("admin"); tmstruckLoadResult.setUpdateTime(new Date()); int i = tmstruckLoadResultService.updateLoadResult(tmstruckLoadResult); return success(i); } @ApiOperation(value="通过ID查询装车实绩 ") @ApiImplicitParams({ @ApiImplicitParam(name = "resultId", value = "装车作业实绩ID", required = false, dataType = "Integer"), }) @PostMapping("/getLoadResultById/{resultId}") public RESTfulResult getLoadResultById(@PathVariable("resultId") Integer resultId){ List> date = tmstruckLoadResultService.getLoadResultById(resultId); return success(date); } @ApiOperation(value="逻辑删除车装车实绩") @ApiImplicitParams({ @ApiImplicitParam(name = "tmstruckLoadResult", value = "装车作业实绩对象", required = false, dataType = "TmstruckLoadResult"), }) @PostMapping("/deleteLoadResult/{resultId}") public RESTfulResult deleteLoadResult(@PathVariable("resultId")Integer resultId){ TmstruckLoadResult tmstruckLoadResult = new TmstruckLoadResult(); tmstruckLoadResult.setDeleteName("admin"); tmstruckLoadResult.setDeleteTime(new Date()); tmstruckLoadResult.setResultId(new BigDecimal(resultId)); tmstruckLoadResult.setStatus(new BigDecimal(1)); int i = tmstruckLoadResultService.updateLoadResult(tmstruckLoadResult); return success(i); } @ApiOperation(value="修改n个装车点 ") @ApiImplicitParams({ @ApiImplicitParam(name = "resultId", value = "装车作业实绩ID", required = false, dataType = "Integer"), }) @PostMapping("/updateLoadResultList") public RESTfulResult updateLoadResultList(@RequestBody(required = false) List> mapList){ int i = tmstruckLoadResultService.updateLoadingIds(mapList); return success(i); } @ApiOperation(value="查询所有装车实绩") @ApiImplicitParams({ @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"), @ApiImplicitParam(name = "173", value = "动态表头", required = false, dataType = "Integer"), @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"), @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer"), }) @PostMapping("/getAllLoadResultForSale") public RESTfulResult getAllLoadResultForSale(@RequestBody(required=false) Map mapValue, Integer apiId, Integer pageNum, Integer pageSize, Integer status ){ if(mapValue == null){ mapValue = new HashMap<>(); } if(status != null){ mapValue.put("status", status); } //不分页筛选数据 List> allLoadResult = tmstruckLoadResultService.selectLoadResultForSale(mapValue); for (int j=0;j map= allLoadResult.get(j); Integer loadDuration = Integer.parseInt(map.get("loadDuration").toString()); String min=loadDuration/60+"分"+loadDuration%60+"秒"; map.put("min",min); } PageHelper.startPage(pageNum,pageSize); //分页数据 List> loadResult = tmstruckLoadResultService.selectLoadResultForSale(mapValue); for (int j=0;j map= loadResult.get(j); Integer loadDuration = Integer.parseInt(map.get("loadDuration").toString()); String min=loadDuration/60+"分"+loadDuration%60+"秒"; map.put("min",min); } //DataChange.changeDateToDayDate(loadResult, "resultLoadStartTime"); PageListAdd pageList = columnDataUtil.tableColumnData(apiId, allLoadResult,loadResult); return success(pageList); } //内转物流新增装车实绩 @ApiOperation(value="内转物流新增装车实绩 ") @ApiImplicitParams({ @ApiImplicitParam(name = "orderNumber", value = "运输订单号", required = false, dataType = "String"), }) @PostMapping("/addLoadResultForconverted") public RESTfulResult addLoadResultForconverted(@RequestBody(required = false) Map map){ String orderNumber=(String)map.get("orderNumber"); Map loadResultIdForOrderNumber = tmstruckLoadResultService.getLoadResultIdForOrderNumber(orderNumber); Integer loadResultId =(Integer) loadResultIdForOrderNumber.get("loadResultId"); //通过运输订单号查找实绩是否存在 int i=0; int i1=0; int i2=0; if (loadResultId==null){ //执行新增 i=tmstruckLoadResultService.addLoadResultForconverted(map); //然后执行更新 i1=tmstruckLoadResultService.updateLoadResultForconverted(map); } else { i2=tmstruckLoadResultService.updateLoadResultForconverted(map); } return success(i+i1+i2); } //***********************************内转物流************************************************* /** * 新增汽车装货实绩 */ @ApiOperation(value="新增汽车装车实绩") @ApiImplicitParams({ @ApiImplicitParam(name = "mapValue", value = "", required = false, dataType = "Map"), }) @PostMapping("/addLoadResultForConverted") public RESTfulResult addLoadResultForConverted(@RequestBody(required=false) Map map){ int i = tmstruckLoadResultService.addLoadResultForConverted(map); return success(i); } @ApiOperation(value="查询所有装车实绩") @ApiImplicitParams({ @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"), @ApiImplicitParam(name = "apiId(206)", value = "动态表头", required = false, dataType = "Integer"), @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"), @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer"), }) @PostMapping("/selectLoadResultForConverted") public RESTfulResult selectLoadResultForConverted(@RequestBody(required=false) Map mapValue, Integer apiId, Integer pageNum, Integer pageSize ){ //不分页筛选数据 List> allLoadResult = tmstruckLoadResultService.selectLoadResultForConverted(mapValue); PageHelper.startPage(pageNum,pageSize); //分页数据 List> loadResult = tmstruckLoadResultService.selectLoadResultForConverted(mapValue); PageListAdd pageList = columnDataUtil.tableColumnData(apiId, allLoadResult,loadResult); return success(pageList); } //根据实绩id渲染数据 @ApiOperation(value="通过ID查询装车实绩 ") @ApiImplicitParams({ @ApiImplicitParam(name = "resultId", value = "装车作业实绩ID", required = false, dataType = "Integer"), }) @PostMapping("/getLoadResultByResultId/{resultId}") public RESTfulResult getLoadResultByResultId(@PathVariable("resultId") Integer resultId){ List> date = tmstruckLoadResultService.selectLoadResultByResultId(resultId); return success(date); } @ApiOperation(value="新增达州站-厂内装车实绩 ") @ApiImplicitParams({ @ApiImplicitParam(name = "resultId", value = "装车作业实绩ID", required = false, dataType = "Integer"), }) @PostMapping("/addDaZhouToDaGangLoadResult") public RESTfulResult addDaZhouToDaGangLoadResult(@RequestBody(required = false)Map map){ int i = tmstruckLoadResultService.addDaZhouToDaGangLoadResult(map); return success(i); } @ApiOperation(value = "采购内转查询待装车物资信息") @PostMapping("/cgNzLoadingResult") public RESTfulResult cgnzLoadResult(@RequestBody(required = false)Mapmapval, Integer apiId, Integer pageNum, Integer pageSize, Integer orderType, Integer orderStatus){ mapval.put("orderType",orderType); mapval.put("orderStatus",orderStatus); //不分页筛选数据 List> LoadingResult = tmstruckLoadResultService.getCgNzLoadingResult(mapval); PageHelper.startPage(pageNum,pageSize); //分页数据 List> loadResult = tmstruckLoadResultService.getCgNzLoadingResult(mapval); PageListAdd pageList = columnDataUtil.tableColumnData(apiId, LoadingResult,loadResult); return success(pageList); } }