package com.steerinfo.dil.controller; import com.steerinfo.dil.feign.ESFeign; import com.steerinfo.dil.mapper.CommonSeq; import com.steerinfo.dil.mapper.WmspInboundScanResultMapper; import com.steerinfo.dil.model.WmspOutboundResult; import com.steerinfo.dil.model.WmspOutboundScanResult; import com.steerinfo.dil.service.IWmspOutboundResultService; import com.steerinfo.dil.service.impl.WmspOutboundResultServiceImpl; 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; /** * WmspOutboundResult RESTful接口: * @author generator * @version 1.0-SNAPSHORT 2021-09-08 10:35 * 类描述 * 修订历史: * 日期:2021-09-08 * 作者:generator * 参考: * 描述:WmspOutboundResult RESTful接口 * @see null * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved. */ @RestController @RequestMapping("/${api.version}/wmspoutboundresults") public class WmspOutboundResultController extends BaseRESTfulController { @Autowired WmspOutboundResultServiceImpl wmspOutboundResultService; @Autowired WmspInboundScanResultMapper wmspInboundScanResultMapper; @Autowired CommonSeq commonSeq; @Autowired ESFeign esFeign; /** * 编写人:hukui * PC端查看钢材出库实绩 * 参数: * apiId:表头id * pageSize:每页记录数 * pageNum:查询页数 * 返回值: * data:所有出库单实绩 * */ @Autowired ColumnDataUtil columnDataUtil; @ApiImplicitParams({ @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"), @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer"), @ApiImplicitParam(name = "apiId", value = "96", required = false, dataType = "BigDecimal"), }) @PostMapping(value = "/getWmspOutboundResult") public RESTfulResult getWmspOutboundResult(@RequestBody(required = false) Map mapval, Integer pageNum, Integer pageSize, Integer apiId, String con ){ if (con != null) { if (!"undefined".equals(con)) { String index = "get_wms_outResult";//设置要查询的索引名称 return success(esFeign.getConResult(mapval, index, apiId, pageNum, pageSize, con));//获取查询结果 } } List> libaryOutBoundList = null; if (mapval.size() == 0) { //将查询结果存入索引中 libaryOutBoundList = wmspOutboundResultService.selectResultNumber(mapval); Map map1 = new HashMap<>(); //添加索引 map1.put("index", "get_wms_outresult"); //添加id map1.put("indexId", "outBoundResultId"); libaryOutBoundList.add(map1); //新建索引 esFeign.insertIndex(libaryOutBoundList); //删除 libaryOutBoundList.remove(libaryOutBoundList.size() - 1); } if (libaryOutBoundList == null) { libaryOutBoundList = wmspOutboundResultService.selectResultNumber(mapval); } PageHelper.startPage(pageNum, pageSize); List> columnList =wmspOutboundResultService.selectResultNumber(mapval); PageListAdd pageList = columnDataUtil.tableColumnData(apiId, libaryOutBoundList, columnList); return success(pageList); } /** * 编写人:hukui * 通过前端扫描司机运单二维码,新增出单实绩并返回新增的出库单实绩 * 参数: * mapval(运输订单号,订单类别) * 返回值: * list:出库单实绩 * */ @Transactional @PostMapping(value = "/insertWmspOutBoundResult") public Map insertWmspOutBoundResult(@RequestBody(required = false) Map mapval){ /**拿到前端传递的运输订单号*/ String orderNumber = mapval.get("orderNumber").toString(); /**根据运输订单号,查询运输订单信息,*/ Map order = wmspOutboundResultService.getOrder(orderNumber); /**拿运输订单信息中的运输订单Id*/ BigDecimal orderId = (BigDecimal) order.get("orderId"); // 根据该运输订单Id判断当前订单是否已经完成出厂,若完成直接返回null if (wmspOutboundResultService.getOutboundStatus(orderId)==0){ /**根据运输订单号,查询出该订单还没有装货的物资*/ List> orderList = wmspOutboundResultService.getMaterial(orderId.intValue()); //拿到还没装货的物资的物资编码 String materialCode = (String) orderList.get(0).get("materialCode"); //拿到还没装货的物资的物资名称 String materialName = (String) orderList.get(0).get("materialName"); //拿到还没装货的物资的规格 String materialSpecification = (String) orderList.get(0).get("materialSpecification"); //拿到还没装货的物资的型号 String materialModel = (String) orderList.get(0).get("materialModel"); //拿到还没装货的物资的物资理重 BigDecimal materialTheoreticalWeight = (BigDecimal) orderList.get(0).get("materialTheoreticalWeight"); //获取装卸工工号 //String personnelJobNumber = mapval.get("personnelJobNumber").toString(); //通过装卸工工号查询装卸工名称 //String personnelName = wmspOutboundResultService.getPersonnelNameByJobnumber(personnelJobNumber); //拿到还没装货的物资id的第一条 BigDecimal materialId = (BigDecimal) orderList.get(0).get("materialId"); /**根据运输订单ID和物资id查询出库单(没有逻辑删除) * 若orderNum大于0,则不是第一次扫描,已经新增出库单,返回详情信息 * 若orderNum等于0,则是第一次扫描,需要增加出库单,再返回详情信息 * */ Map map = new HashMap<>(); map.put("orderId",orderId); map.put("materialId",materialId); //初始化出库单详情信息 Map outBoundDetailedInfo=null; int orderNum = wmspOutboundResultService.ExistWmspOutboundResult(map); if(orderNum == 0){ /**创建出库单实体*/ WmspOutboundResult wmspOutboundResult = new WmspOutboundResult(); /**使用序列号增加生成主键id*/ int seq_wmspoutboundresult = commonSeq.getSeqNumber("seq__WMSP_OUTBOUND_RESULT"); /**获取到当前时间*/ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); /**生成出库单编号*/ String resultNumber = "XSCK" + sdf.format(new Date()); if(seq_wmspoutboundresult < 10){ resultNumber += "0000000" + seq_wmspoutboundresult; }else if(seq_wmspoutboundresult < 100){ resultNumber += "000000" + seq_wmspoutboundresult; }else if(seq_wmspoutboundresult < 1000){ resultNumber += "00000" + seq_wmspoutboundresult; }else if(seq_wmspoutboundresult < 10000){ resultNumber += "0000" + seq_wmspoutboundresult; }else if(seq_wmspoutboundresult < 100000){ resultNumber += "000" + seq_wmspoutboundresult; }else if(seq_wmspoutboundresult < 1000000){ resultNumber += "00" + seq_wmspoutboundresult; }else if(seq_wmspoutboundresult < 10000000){ resultNumber += "0" + seq_wmspoutboundresult; }else{ resultNumber += seq_wmspoutboundresult; } /**拿到运输订单类型*/ BigDecimal orderType = (BigDecimal) order.get("orderType"); /**运输订单类型判断 * orderType : 1 为普通出库 * orderType : 4 为调拨出库 * */ String resultOutboundType = "普通出库"; if(orderType.intValue() == 4){ resultOutboundType = "调拨出库"; } /**把出库单主键id添加到出库单实体中*/ wmspOutboundResult.setResultId(new BigDecimal(seq_wmspoutboundresult)); /**把出库单编号添加到出库单实体中*/ wmspOutboundResult.setResultNumber(resultNumber); /**把运输订单主键添加到出库单实体中*/ wmspOutboundResult.setBillLadingId(orderId); /**把出库类型添加到出库单实体中*/ wmspOutboundResult.setResultOutboundType(resultOutboundType); /**第一次添加为待出库*/ wmspOutboundResult.setResultStatus(new BigDecimal(0)); //常规字段 wmspOutboundResult.setInsertUsername("admin"); wmspOutboundResult.setInsertTime(new Date()); wmspOutboundResult.setUpdateUsername("admin"); wmspOutboundResult.setUpdateTime(new Date()); wmspOutboundResult.setInsertUpdateRemark("无"); wmspOutboundResult.setDeleted(new BigDecimal(0)); //还没装货的物资id的第一条添加到出库单实体中 wmspOutboundResult.setMaterialId(materialId); Integer res = wmspOutboundResultService.insertSelective(wmspOutboundResult); if(res == 1){ //返回出库单详情信息 outBoundDetailedInfo = wmspOutboundResultService.getOutBoundDetailedInfo(orderId); outBoundDetailedInfo.put("orderNumber",orderNumber); // outBoundDetailedInfo.put("personnelName",personnelName); outBoundDetailedInfo.put("materialCode",materialCode); outBoundDetailedInfo.put("materialName",materialName); outBoundDetailedInfo.put("materialSpecification",materialSpecification); outBoundDetailedInfo.put("materialModel",materialModel); outBoundDetailedInfo.put("materialTheoreticalWeight",materialTheoreticalWeight); } }else{ //返回出库单详情信息 outBoundDetailedInfo = wmspOutboundResultService.getOutBoundDetailedInfo(orderId); outBoundDetailedInfo.put("orderNumber",orderNumber); // outBoundDetailedInfo.put("personnelName",personnelName); outBoundDetailedInfo.put("materialCode",materialCode); outBoundDetailedInfo.put("materialName",materialName); outBoundDetailedInfo.put("materialSpecification",materialSpecification); outBoundDetailedInfo.put("materialModel",materialModel); outBoundDetailedInfo.put("materialTheoreticalWeight",materialTheoreticalWeight); } return outBoundDetailedInfo; } return null; } /** * 编写人:zouzhendon * PDA前端装卸工拒绝扫描出的运输订单,并逻辑删除出库单 * 参数: * resultId(出库单Id) * 返回值: * int:是否逻辑删除出库单 * */ @PostMapping(value = "/deletewmspOutboundResult") public RESTfulResult deleteWmspOutboundResult(@RequestParam Integer resultId){ //通过出库单Id逻辑删除出库单 int i = wmspOutboundResultService.deleteWmspOutboundResult(new BigDecimal(resultId)); return success(i); } /** * 编写人:zouzhendon * 装卸工PDA前端扫描钢材吊牌二维码,新增出库单扫描实绩并返回已扫描并稽核成功的物资信息 * 参数: * map(resultNumber 出库单号,personnelJobNumber 装卸工工号 resultMaterial 装卸工扫描吊牌结果) * 返回值: * list:出库单实绩 * */ @Transactional @PostMapping(value = "/insertwmspOutboundScanResult") public synchronized RESTfulResult insertwmspOutboundScanResult(@RequestBody(required = false) Map map){ ///获得前台传来得信息 //获取装卸工扫描吊牌结果 HRB400-14-21706854-9-3049-280-20211001015115-7a63cd87a4095e7f-08010103010100003-4 String resultMaterial = (String) map.get("resultMaterial"); String subResultMaterial = resultMaterial.substring(0,resultMaterial.length() - 1); //获取出库单号 Integer resultId1 = (Integer) map.get("resultId"); //通过出库单号查询出库实绩ID BigDecimal resultId = new BigDecimal(resultId1); /**根据扫描结果查询扫描实绩、判断是否一件出库 * 若scanCount大于0,则不是第一次扫描,已经新增出库扫描实绩,返回已扫描过 * 若scanCount等于0,则是第一次扫描,需要增加出库扫描实绩,再返回已扫描并稽核成功的物资信息 * */ ///判断物质是否已经被扫描 int scanCount = wmspOutboundResultService.ExistScanResult(subResultMaterial); ///如果没有被扫描 if(scanCount==0){ //wmspOutboundResultService.getOutBoundId(resultNumber); //获取装卸工工号 String personnelJobNumber = (String) map.get("personnelJobNumber"); //通过装卸工工号查询装卸工Id BigDecimal personnelId = wmspOutboundResultService.getPersonnelIdByJobnumber(personnelJobNumber); //通过出库实绩Id判断出库单已扫描的件数是否等于运输订单物资表的物资件数 ///解析物质二维码信息 //截取扫描结果,得到物资唯一编码 String[] split = resultMaterial.split("-"); //唯一编码 String MaterialOnlyCode=split[7]; //通过物资物资唯一编码查询钢材物资表的物资Id BigDecimal SteelMaterialId = wmspOutboundResultService.getSteelMaterialIdByMaterialOnlyCode(MaterialOnlyCode); //通过出库实绩Id查询物资Id BigDecimal OutboundMaterialId = wmspOutboundResultService.getOutboundMaterialByResultId(resultId); //初始化出库扫描实绩 WmspOutboundScanResult wmspOutboundScanResult = new WmspOutboundScanResult(); //使用序列号增加生成主键id int seq_wmspOutboundScanResult = commonSeq.getSeqNumber("seq__WMSP_OUTBOUND_SCAN_RESULT"); //插入主键id wmspOutboundScanResult.setResultId(new BigDecimal(seq_wmspOutboundScanResult)); //根据物资id查询相对应的入库实绩ID,并将其赋值给相对应的入库扫描实绩表 List> list= wmspInboundScanResultMapper.getInboundResultIdByMaterial(subResultMaterial); // 默认以获取到的第一个值作为入库实绩Id Map map1 = list.get(0); wmspOutboundScanResult.setInboundResultId((BigDecimal) map1.get("inboundResultId")); //插入出库实绩ID wmspOutboundScanResult.setOutboundResultId(resultId); //插入装卸工Id wmspOutboundScanResult.setLoadId(personnelId); //插入装卸工扫描吊牌结果 wmspOutboundScanResult.setResultMaterial(resultMaterial); //插入装卸工扫描吊牌时间 wmspOutboundScanResult.setResultLoadTime(new Date()); //插入出库物资数量 wmspOutboundScanResult.setOutboundMaterialNumber(new BigDecimal(1)); //常规字段 wmspOutboundScanResult.setInsertUsername("admin"); wmspOutboundScanResult.setInsertTime(new Date()); wmspOutboundScanResult.setUpdateUsername("admin"); wmspOutboundScanResult.setUpdateTime(new Date()); wmspOutboundScanResult.setInsertUpdateRemark("无"); if(SteelMaterialId.intValue()==OutboundMaterialId.intValue()){ int EqualMaterialsNumber = wmspOutboundResultService.EqualMaterialsNumber(resultId); if(EqualMaterialsNumber==1){ //相等返回装货数量已够 wmspOutboundScanResult.setResultCheck(new BigDecimal(1)); }else { //稽核成功,设定扫描实绩稽核结果为成功 wmspOutboundScanResult.setResultCheck(new BigDecimal(0)); } //插入扫描实绩 wmspOutboundResultService.scanResultInsert(wmspOutboundScanResult); }else { //稽核失败,设定扫描实绩稽核结果为失败 wmspOutboundScanResult.setResultCheck(new BigDecimal(1)); //插入扫描实绩 wmspOutboundResultService.scanResultInsert(wmspOutboundScanResult); } //返回已扫描并并稽核成功的物资信息 //1、获取出库单统一信息 //获取月台Id //BigDecimal platformId = wmspOutboundResultService.getPlatformIdByResultId(resultId); //通过月台Id获取仓库名 //String warehouseName = wmspOutboundResultService.getWarehouseNameByPlatformId(platformId); //获取出库单统一部分信息 Map theSameOutboundInfo = wmspOutboundResultService.theSameOutboundInfo(resultId); //theSameOutboundInfo.put("warehouseName",warehouseName); //2、获取出库扫描实绩数据 List> scanAuditSuccessInfo = wmspOutboundResultService.scanAuditSuccessInfo(resultId); //补全出库扫描实绩数据的信息,对扫描实绩进行去重 for (Map stringObjectMap : scanAuditSuccessInfo) { String resultMaterial1 = (String) stringObjectMap.get("resultMaterial"); //截取扫描结果,得到一件物资的详细信息 String[] split1 = resultMaterial1.split("-"); //规格 String Specification="Φ"+split1[1]; stringObjectMap.put("Specification",Specification); //型号 String Model=split1[0]; stringObjectMap.put("Model",Model); //炉号 String FurnaceNumber=split1[2]; stringObjectMap.put("FurnaceNumber",FurnaceNumber); //理重 String TheoreticalWeight=split1[4]; stringObjectMap.put("TheoreticalWeight",TheoreticalWeight); //唯一编码 String MaterialOnlyCode1=split1[7]; stringObjectMap.put("MaterialOnlyCode",MaterialOnlyCode1); //通过唯一编码获取物资名称、计量单位、垛位 Map otherMap = wmspOutboundResultService.getOtherInfoByMaterialOnlyCode(MaterialOnlyCode1); //取出再放入物资名称 String materialName = otherMap.get("materialName").toString(); stringObjectMap.put("materialName",materialName); //取出再放入计量单位 String unitOfMeasureName = otherMap.get("unitOfMeasureName").toString(); stringObjectMap.put("unitOfMeasureName",unitOfMeasureName); //取出再放入垛位 String stackingNo = otherMap.get("stackingNo").toString(); stringObjectMap.put("stackingNo",stackingNo); //合并出库单统一信息map stringObjectMap.putAll(theSameOutboundInfo); } return success(scanAuditSuccessInfo); }else{ //返回已扫描并并稽核成功的物资信息 //1、获取出库单统一信息 //获取月台Id //BigDecimal platformId = wmspOutboundResultService.getPlatformIdByResultId(resultId); //通过月台Id获取仓库名 //String warehouseName = wmspOutboundResultService.getWarehouseNameByPlatformId(platformId); //获取出库单统一部分信息 Map theSameOutboundInfo = wmspOutboundResultService.theSameOutboundInfo(resultId); //theSameOutboundInfo.put("warehouseName",warehouseName); //2、获取出库扫描实绩数据 List> scanAuditSuccessInfo = wmspOutboundResultService.scanAuditSuccessInfo(resultId); //补全出库扫描实绩数据的信息 for (Map stringObjectMap : scanAuditSuccessInfo) { String resultMaterial1 = (String) stringObjectMap.get("resultMaterial"); //截取扫描结果,得到一件物资的详细信息 String[] split1 = resultMaterial1.split("-"); //规格 String Specification = "Φ" + split1[1]; stringObjectMap.put("Specification", Specification); //型号 String Model = split1[0]; stringObjectMap.put("Model", Model); //炉号 String FurnaceNumber = split1[2]; stringObjectMap.put("FurnaceNumber", FurnaceNumber); //理重 String TheoreticalWeight = split1[4]; stringObjectMap.put("TheoreticalWeight", TheoreticalWeight); //唯一编码 String MaterialOnlyCode1 = split1[7]; stringObjectMap.put("MaterialOnlyCode", MaterialOnlyCode1); //通过唯一编码获取物资名称、计量单位、垛位 Map otherMap = wmspOutboundResultService.getOtherInfoByMaterialOnlyCode(MaterialOnlyCode1); //取出再放入物资名称 String materialName = otherMap.get("materialName").toString(); stringObjectMap.put("materialName", materialName); //取出再放入计量单位 String unitOfMeasureName = otherMap.get("unitOfMeasureName").toString(); stringObjectMap.put("unitOfMeasureName", unitOfMeasureName); //取出再放入垛位 String stackingNo = otherMap.get("stackingNo").toString(); stringObjectMap.put("stackingNo", stackingNo); //合并出库单统一信息map stringObjectMap.putAll(theSameOutboundInfo); } return success(scanAuditSuccessInfo); } } /** * 编写人:hujianguo * 装卸工PDA前端点击出库 * 参数: * resultId * 返回值: * result:出库成功标志 * */ @ApiOperation(value = "出库(非0:成功,0:失败)") @PostMapping("/outbountResultToSuccess") public RESTfulResult outbountResultToSuccess(@RequestParam Integer resultId) { int result = wmspOutboundResultService.outbountResultToSuccess(resultId); if (result == 0) { return failed("还未扫描完,请继续!"); } else { return success(result); } } /** * 编写人:hukui * 通过前端扫描司机运单二维码,新增出单实绩并返回新增的出库单实绩 * 参数: * mapval(运输订单号,订单类别) * 返回值: * list:出库单实绩 * */ @PostMapping(value = "/updataResultStatus") public RESTfulResult updataResultStatus(@RequestBody(required = false) Integer resultId){ // 创建一个出库单实体 WmspOutboundResult wmspOutboundResult = new WmspOutboundResult(); // 把前端传递的出库单主键id赋值给实体 wmspOutboundResult.setResultId(new BigDecimal(resultId)); // 把出库单状态改为已出库 wmspOutboundResult.setResultStatus(new BigDecimal(1)); int i = wmspOutboundResultService.updateByPrimaryKeySelective(wmspOutboundResult); return success(i); } /** * 司机扫描订单二维码进行倒库,首先根据运输订单号查找运输订单, * */ @PostMapping("/insertOutBoundResult") public RESTfulResult insertOutBoundResult(@RequestBody(required = false) Map map){ return success(); } }