123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461 |
- package com.steerinfo.dil.controller;
- import com.github.pagehelper.PageHelper;
- import com.steerinfo.dil.feign.BmsTruckFeign;
- import com.steerinfo.dil.feign.ColumnDataFeign;
- import com.steerinfo.dil.feign.OmsFeign;
- import com.steerinfo.dil.feign.TmstruckFeign;
- import com.steerinfo.dil.mapper.WmspInboundResultMapper;
- import com.steerinfo.dil.model.*;
- import com.steerinfo.dil.service.impl.RmsMaterialServiceImpl;
- import com.steerinfo.dil.service.impl.RmsMaterialSteelServiceImpl;
- import com.steerinfo.dil.service.impl.WmsInboundResultServiceImpl;
- import com.steerinfo.dil.service.impl.WmsInboundScanResultServiceImpl;
- 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 io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.core.annotation.Order;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.math.BigDecimal;
- import java.text.DateFormat;
- import java.text.ParseException;
- import java.util.*;
- /**
- * @author luobang
- * @create 2021-09-07 15:15
- */
- @RestController
- @RequestMapping("${api.version}/inboundScanResult")
- public class WmsInboundScanResultController extends BaseRESTfulController {
- @Autowired
- WmsInboundResultServiceImpl wmsInboundResultService;
- @Autowired
- WmsInboundScanResultServiceImpl wmsInboundScanResultService;
- @Autowired
- RmsMaterialServiceImpl rmsMaterialService;
- @Autowired
- RmsMaterialSteelServiceImpl rmsMaterialSteelService;
- @Autowired
- WmspInboundResultMapper wmspInboundResultMapper;
- @Autowired
- ColumnDataUtil columnDataUtil;
- @Autowired
- ColumnDataFeign columnDataFeign;
- @Autowired
- OmsFeign omsFeign;
- @Autowired
- BmsTruckFeign bmsTruckFeign;
- @Autowired
- TmstruckFeign tmstruckFeign;
- @Autowired
- WmsInboundResultController inboundResultController;
- /**
- * 1.新增扫描吊牌实绩!!!此时入库实绩未生成
- * @param
- * @return
- */
- @ApiOperation(value = "新增扫描吊牌实绩")
- @PostMapping("/insertResult")
- @Transactional
- public synchronized RESTfulResult insertResult(@RequestBody(required = false)Map<String,Object>map) throws Exception {
- //这里需要的参数包括 扫码人账号 userId、二维码信息 resultMaterial
- //首先判断二维码是否已经被扫过了
- //判断条件是查询扫描实绩判断是否已经存在改唯一标识码并且扫码人是否是自己
- System.out.println(map.get("resultMaterial"));
- //订单类型为倒库,直接扫码所有并返回数据
- Map<String,Object> order=wmsInboundScanResultService.getOrderTypeByNum((String)map.get("resultMaterial"));
- if(order !=null && order.get("orderType")!=null && DataChange.dataToBigDecimal(order.get("orderType")).intValue() == 25){
- Integer orderType=DataChange.dataToBigDecimal(order.get("orderType")).intValue();
- BigDecimal orderId=DataChange.dataToBigDecimal(order.get("orderId"));
- //校验是否有装货实绩,若没有则不允许入库
- Integer count=wmsInboundScanResultService.isExistLoad((String)map.get("resultMaterial"));
- if(count==null|| count<=0){
- return failed(null);
- }
- //根据运输订单号查询出库扫码实绩
- List<Map<String,Object>> inboundOld= wmsInboundScanResultService.findInboundScanResult((String)map.get("resultMaterial"));
- //批量新增扫码实绩
- if(inboundOld!=null || inboundOld.size()>0 || inboundOld.get(0)!=null){
- wmsInboundScanResultService.createInboundScanResultByFind(inboundOld,map);
- }
- else{
- System.out.println("物资暂未出库,请先出库再入库!");
- return failed(null);
- }
- //返回新建的扫码实绩数据
- List<Map<String,Object>> mapList= wmsInboundScanResultService.noIssueScanResultList(map.get("userName").toString());
- //新增卸货实绩
- tmstruckFeign.updateUnloadResult(order);
- //关闭运输订单
- omsFeign.closeInwardOrder(orderId.intValue(),2,null);
- //生成计费详单
- bmsTruckFeign.addInwardDetailsOrder(order);
- return success(mapList);
- }
- int isExist= wmsInboundScanResultService.isExist(map.get("userName").toString(),map.get("resultMaterial").toString().substring(0,map.get("resultMaterial").toString().length()-1));
- //通过用户ID查询、当前扫描没有下发的物质、最终展示的集合
- List<Map<String,Object>>mapList= wmsInboundScanResultService.noIssueScanResultList(map.get("userName").toString());
- if (isExist>0){
- //如果已经被扫过了返回扫码实绩集合
- //返回结果显示
- return failed(mapList);
- }else {
- //如果没有被扫
- //创建一个扫码实绩
- Map<String, Object> wmspInboundScanResult =wmsInboundScanResultService.createInboundScanResultByResultMaterial(mapList.size(),map.get("userName").toString(),map.get("resultMaterial").toString(),""+map.get("hookNo"));
- //判断是否创建成功、成功在添加
- // if (wmspInboundScanResult!=null){
- // mapList.add(wmspInboundScanResult);
- // }
- mapList= wmsInboundScanResultService.noIssueScanResultList(map.get("userName").toString());
- }
- System.out.println(mapList);
- return success(mapList);
- }
- /**
- * 1.新增扫描吊牌实绩!!!此时入库实绩未生成
- * @param
- * @return
- */
- @ApiOperation(value = "新增扫描吊牌实绩")
- @PostMapping("/insertScanResultGroup")
- @Transactional
- public synchronized RESTfulResult insertScanResultGroup(@RequestBody(required = false)Map<String,Object>map) throws ParseException {
- //这里需要的参数包括 扫码人账号 userId、二维码信息 resultMaterial
- //首先判断二维码是否已经被扫过了
- int isExist= wmsInboundScanResultService.isExistInboundScanResult(map.get("resultMaterial").toString().substring(0,map.get("resultMaterial").toString().length()-1));
- //通过用户ID查询、当前扫描没有下发的物质、最终展示的集合
- List<Map<String,Object>>mapList= wmsInboundScanResultService.noIssueScanResultList(map.get("userName").toString());
- if (isExist>0){
- //如果已经被少扫过了返回扫码实绩集合
- //返回结果显示
- return failed(mapList);
- }else {
- //如果没有被扫
- //创建一个扫码实绩
- Map<String, Object> wmspInboundScanResult =wmsInboundScanResultService.createInboundScanResultByResultMaterial(mapList.size(),map.get("userName").toString(),map.get("resultMaterial").toString(),""+map.get("hookNo"));
- //判断是否创建成功、成功在添加
- // if (wmspInboundScanResult!=null){
- // mapList.add(wmspInboundScanResult);
- // }
- mapList= wmsInboundScanResultService.noIssueScanResultList(map.get("userName").toString());
- }
- return success(mapList);
- }
- /**
- * 1.新增扫描吊牌实绩!!!此时入库实绩未生成
- * @param
- * @return
- */
- @ApiOperation(value = "新增扫描吊牌实绩")
- @PostMapping("/insertResult2")
- @Transactional
- public synchronized RESTfulResult insertResult2(@RequestBody(required = false)Map<String,Object>map) throws ParseException {
- int i=0;
- WmspInboundScanResult wmspInboundScanResult = new WmspInboundScanResult();
- //获取工号查找id
- BigDecimal loadId = wmsInboundScanResultService.getLoadId(map);
- map.put("loadId",loadId);
- BigDecimal inboundResultId = new BigDecimal((Integer)map.get("inboundId"));
- //判断是否重复扫码
- //调用判断是否重复扫码的方法
- if(inboundResultId.intValue() == -1){
- if(wmsInboundScanResultService.checkScanTag(map,loadId) == 0){
- List<Map<String,Object>>mapList =wmsInboundScanResultService.getScanResult(loadId);
- return failed(mapList);
- }
- }
- wmspInboundScanResult.setResultId(new BigDecimal(String.valueOf(wmsInboundScanResultService.count())));
- //设置入库物资件数,默认一件
- wmspInboundScanResult.setInboundMaterialNumber(new BigDecimal(1));
- //设置吊钢工已扫物资件数
- wmspInboundScanResult.setResultNumber(new BigDecimal(wmsInboundScanResultService.scanNumber(map)+1));
- map.put("resultNumber",wmspInboundScanResult.getResultNumber());
- //设置常规字段 插入人为吊钢工的名字
- wmspInboundScanResult.setInsertTime(new Date());
- //设置吊钢工扫描吊牌时间
- wmspInboundScanResult.setResultLoadTime(new Date());
- //设置状态为未下发
- wmspInboundScanResult.setResultStatus(new BigDecimal(0));
- //设置吊钢工Id
- wmspInboundScanResult.setLoadId(loadId);
- //设置扫描吊牌实绩
- String str = (String) map.get("resultMaterial");
- wmspInboundScanResult.setResultMaterial(str);
- //设置入库实绩ID
- if (inboundResultId.intValue() != -1){
- BigDecimal hh=wmspInboundScanResult.getInboundResultId() ;
- wmspInboundScanResult.setInboundResultId(inboundResultId);
- wmspInboundScanResult.setResultStatus(new BigDecimal(1));
- }
- //设置逻辑删除字段
- wmspInboundScanResult.setResultDeleted(new BigDecimal(1));
- //新增钢材物资ID
- Integer k = rmsMaterialSteelService.insertRmsMaterialSteel(str,""+map.get("hookNo"));
- wmspInboundScanResult.setMaterialId(new BigDecimal(k));
- //根据班次班组查找同一车间的另一位小伙伴
- //判断物资是否为线材
- BigDecimal count = wmsInboundScanResultService.selectMaterialTypeByMaterialId(new BigDecimal(k));
- wmspInboundScanResult.setInboundAbnormalis(new BigDecimal(0));
- if(count != null){
- BigDecimal otherLoadId = wmsInboundScanResultService.getOtherLoadId(map);
- map.put("otherLoadId",otherLoadId);
- //查找另一位兄弟的相同次数的扫描实绩里面的物资ID
- Integer otherMaterialId = wmsInboundScanResultService.getOtherMaterialSteelId(map);
- if (otherMaterialId==k) {
- wmspInboundScanResult.setInboundAbnormalis(new BigDecimal(1));
- }
- else{
- wmspInboundScanResult.setInboundAbnormalis(new BigDecimal(0));
- }
- }
- //插入扫描吊牌实绩
- Integer integer = wmsInboundScanResultService.insertWmsInboundScanResult(wmspInboundScanResult);
- System.out.println("-----------"+integer);
- if (integer!=1){
- return failed();
- }
- //判断物资是否为线材
- if(count != null){
- //如果不为线材
- //更新异常值
- wmsInboundScanResultService.updateInboundAbnormal(map);
- }
- List<Map<String,Object>>mapList =wmsInboundScanResultService.getScanResult(loadId);
- return success(mapList);
- }
- /**
- * 展示未下发扫描实绩
- * @return
- */
- @ApiOperation(value="展示未下发扫描实绩")
- @PostMapping("/getScanResult")
- public RESTfulResult getScanResult(@RequestBody(required = false) Map<String,Object>map){
- BigDecimal loadId = wmsInboundScanResultService.getLoadId(map);
- map.put("loadId",loadId);
- List<Map<String,Object>>mapList =wmsInboundScanResultService.getScanResult(loadId);
- return success(mapList);
- }
- /**
- *
- * @return
- */
- @ApiOperation(value="展示垛位")
- @PostMapping("/selectStackingInfoByWarehouseId")
- public RESTfulResult selectStackingInfoByWarehouseId(@RequestBody(required = false) Map<String,Object>map){
- List<Map<String,Object>>mapList =wmsInboundScanResultService.selectStacking(map);
- return success(mapList);
- }
- /**
- *
- * @return
- */
- @ApiOperation(value="更新状态")
- @PostMapping("/updateStatus")
- public RESTfulResult updateStatus(@RequestBody(required = false) Map<String,Object>map){
- Integer integer =wmsInboundScanResultService.updateStatus(map);
- return success(integer);
- }
- /**
- * 展示异常入库吊钢工扫描吊牌实绩
- * @return
- */
- @ApiOperation(value="展示异常入库吊钢工扫描吊牌实绩")
- @PostMapping("/getIssuedTagNoResult")
- public RESTfulResult getIssuedTagNoResult(){
- HashMap<String, Object> map = new HashMap<>();
- List<Map<String, Object>> scanIssuedTagResult = wmsInboundScanResultService.getIssuedScanTagNoResult(map);
- return success(scanIssuedTagResult);
- }
- //根据入库实绩id查找扫描实绩
- @PostMapping("/selectScanResultByIboundResultId")
- @ApiOperation(value = "根据入库实绩id获得扫描实绩数据")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "apiId", value = "", required = false, dataType = "BigDecimal"),
- })
- public RESTfulResult selectScanResultByIboundResultId(@RequestBody(required = false) Map<String, Object> mapValue,
- Integer apiId,
- Integer pageNum,
- Integer pageSize,
- Integer inboundId) {
- if (inboundId!=null){
- mapValue.put("inboundId",inboundId);
- }
- List<Map<String, Object>> reboundResultTotal = wmsInboundResultService.selectScanResultByIboundResultId(mapValue);
- List<Map<String, Object>> columnDataList = columnDataFeign.getColumnData(apiId);
- /*分页*/
- PageHelper.startPage(pageNum, pageSize);
- /*返回中英文对照结果,计算表头*/
- List<Map<String, Object>> reboundResult = wmsInboundResultService.selectScanResultByIboundResultId(mapValue);
- for (Map<String, Object> columnData : columnDataList) {
- columnData.put("filters", setListMap(reboundResultTotal, columnData.get("prop").toString()));
- }
- PageListAdd pageList = new PageListAdd(reboundResult);
- pageList.setColumnData(columnDataList);
- return success(pageList);
- }
- Set<Map<String, Object>> setListMap(List<Map<String, Object>> list, String name) {
- Set<Map<String, Object>> setString = new HashSet<>();
- for (Map<String, Object> map : list) {
- Map<String, Object> map1 = new HashMap<>();
- map1.put("text", map.get(name));
- if (map.get(name) != null) {
- //判断是否是运力类型
- if ("capacity_type".equals(name)) {
- switch (map.get(name).toString().trim()) {
- case "自有电车":
- map1.put("value", 0);
- break;
- case "自有汽车":
- map1.put("value", 1);
- break;
- case "社会车辆":
- map1.put("value", 2);
- break;
- }
- } else {
- map1.put("value", map.get(name));
- }
- setString.add(map1);
- }
- }
- return setString;
- }
- // 根据index找到对应的成品并改变其入库状态
- @ApiOperation(value="展示垛位")
- @PostMapping("/changeInboundIscomplete")
- public RESTfulResult changeInboundIscomplete(@RequestBody(required = false) Map<String,Object>map){
- Integer stackResultId1= (Integer) map.get("stackResultId");
- BigDecimal stackResultId=new BigDecimal(stackResultId1);
- int result =wmsInboundScanResultService.changeInboundIscomplete(stackResultId);
- return success(result);
- }
- /**
- * 1.新增退货扫描吊牌实绩!!!此时入库实绩未生成
- * @param
- * @return
- */
- @ApiOperation(value = "新增扫描吊牌实绩")
- @PostMapping("/insertReboundScanResult")
- @Transactional
- public synchronized RESTfulResult insertReboundScanResult(@RequestBody(required = false)Map<String,Object>map) throws ParseException {
- //判断自己是否已经扫过了、并且没有出库过
- int isExist= wmsInboundScanResultService.isExist2(map.get("userName").toString(),map.get("resultMaterial").toString().substring(0,map.get("resultMaterial").toString().length()-1));
- //通过用户ID查询、当前扫描没有下发的物质、最终展示的集合
- List<Map<String,Object>>mapList= wmsInboundScanResultService.noIssueScanResultList2(map.get("userName").toString());
- if (isExist>0){
- //如果已经被少扫过了返回扫码实绩集合
- //返回结果显示
- return failed(mapList);
- }else {
- //如果没有被扫
- //创建一个扫码实绩
- Map<String, Object> wmspInboundScanResult =wmsInboundScanResultService.createInboundScanResultByResultMaterial2(mapList.size(),map.get("userName").toString(),map.get("resultMaterial").toString(),""+map.get("hookNo"));
- //判断是否创建成功、成功在添加
- if (wmspInboundScanResult!=null){
- mapList.add(wmspInboundScanResult);
- }
- }
- return success(mapList);
- }
- @ApiOperation(value = "补录吊牌入库实绩")
- @PostMapping("/recordScanResult")
- @Transactional
- public synchronized RESTfulResult recordScanResult(@RequestBody(required = false)Map<String,Object> map) throws Exception {
- //System.out.println(map);
- if(map.get("materialOnlyCode") != null && DataChange.dataToBigDecimal(map.get("deleteFlag")).intValue() == 1) {
- //走删除接口
- int i = wmsInboundScanResultService.deleteMaterialSteelMes(map);
- if(i == 0) {
- return failed("物资不存在");
- }
- return success();
- }
- if(map.get("number")==null){
- //return failed("请输入数量");
- map.put("number",1);
- }
- if(map.get("materialCode")==null){
- return failed("请输入物资编码");
- }
- if(map.get("furnaceNumber")==null){
- return failed("请输入炉号");
- }
- if(map.get("userName")==null){
- map.put("userName","L1267");
- //return failed("请输入用户名");
- }
- if(map.get("theoreticalWeight")==null){
- return failed("请输入理重");
- }
- if(map.get("warehouseId")==null && map.get("warehouseName") == null){
- return failed("请输入仓库id");
- }
- //根据仓库名称寻找仓库id
- BigDecimal warehouseId = wmspInboundResultMapper.selectWarehouseIdByName(map.get("warehouseName").toString());
- if(warehouseId != null) {
- map.put("warehouseId",warehouseId);
- }
- Integer number=Integer.parseInt(map.get("number").toString());
- String userName=map.get("userName").toString();
- if(number<=0){
- return failed("数量错误,结束");
- }
- //创建扫描实绩
- List<Map<String,Object>> resultMaterials=wmsInboundScanResultService.createResultMaterials(map);//创建吊牌
- wmsInboundScanResultService.createInboundScanResultByFind(resultMaterials,map);//新增扫描实绩
- List<Map<String,Object>> inboundScans=wmsInboundScanResultService.noIssueScanResultList(userName);//查询入库扫描实绩
- //创建入库实绩
- BigDecimal groupId=new BigDecimal(2),personnelWorkshopid=DataChange.dataToBigDecimal(map.get("warehouseId").toString());
- return inboundResultController.addInvoice(userName,groupId,personnelWorkshopid,inboundScans,"物流系统补录");
- }
- }
|