New file |
| | |
| | | package com.zy.common.web; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.entity.WaitPakin; |
| | | import com.zy.asrs.service.OutStockService; |
| | | import com.zy.asrs.service.WaitPakinService; |
| | | import com.zy.common.entity.InterData; |
| | | import com.zy.common.service.erp.entity.OutStockBillEntry; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/10/30 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | |
| | | public class WcsController { |
| | | @Autowired |
| | | private WaitPakinService waitPakinService; |
| | | @Autowired |
| | | private OutStockService outStockService; |
| | | |
| | | @PostMapping("/inout/cancel/auth/v1") |
| | | @ResponseBody |
| | | public JSON getLocNo(@RequestBody String param) throws Exception { |
| | | log.info("ERP取消任务:"+ param); |
| | | JSONObject jsonObject = JSONObject.parseObject(param);//将参数转化为JSON格式 |
| | | String inter = jsonObject.getString("data"); |
| | | List<InterData> list = JSONArray.parseArray(inter, InterData.class);//获取参数集合 |
| | | JSONObject jsonObject1 = new JSONObject(); |
| | | JSONArray jsonArray = new JSONArray(); |
| | | for (InterData interData : list) { |
| | | //查询对应入库通知档信息 |
| | | Wrapper wrapper = new EntityWrapper<WaitPakin>().eq("supplier", interData.getFBillNo()).eq("matnr", interData.getFnumber()); |
| | | WaitPakin waitPakin = waitPakinService.selectOne(wrapper); |
| | | |
| | | if ((interData.getIoType() == 1 && interData.getMatType() == 1) || (interData.getIoType() == 2 && interData.getMatType() == 2)) { |
| | | if (Cools.isEmpty(waitPakin)) { |
| | | JSONObject object = new JSONObject(); |
| | | object.put("FInterID", interData.getFInterID()); |
| | | object.put("Fnumber", interData.getFnumber()); |
| | | object.put("code", 500); |
| | | object.put("msg", "单据不存在或单据已被删除"); |
| | | jsonArray.add(object); |
| | | continue; |
| | | } |
| | | //判断是否有出库动作 "N"没有 “Y”有 |
| | | if (waitPakin.getIoStatus().equals("N")) { |
| | | //判断传入的数量是否为0来执行删除或者修改 |
| | | if (interData.getFQty().compareTo(BigDecimal.ZERO) == 0) { |
| | | waitPakinService.delete(wrapper); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("Fnumber", interData.getFnumber()); |
| | | object.put("FInterID", interData.getFInterID()); |
| | | object.put("code", 200); |
| | | object.put("msg", "删除成功"); |
| | | jsonArray.add(object); |
| | | } else { |
| | | waitPakin.setAnfme(interData.getFQty().doubleValue()); |
| | | waitPakinService.update(waitPakin, wrapper); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("Fnumber", interData.getFnumber()); |
| | | object.put("FInterID", interData.getFInterID()); |
| | | object.put("code", 200); |
| | | object.put("msg", "修改成功"); |
| | | jsonArray.add(object); |
| | | } |
| | | |
| | | } else { |
| | | JSONObject object = new JSONObject(); |
| | | object.put("FInterID", interData.getFInterID()); |
| | | object.put("Fnumber", interData.getFnumber()); |
| | | object.put("code", 500); |
| | | object.put("msg", "已在入库中,无法取消"); |
| | | jsonArray.add(object); |
| | | } |
| | | } |
| | | |
| | | if (interData.getIoType() == 3) { |
| | | Wrapper wrapper1 = new EntityWrapper<OutStockBillEntry>().eq("FInterID", interData.getFInterID()).and().eq("Fnumber", interData.getFnumber()); |
| | | OutStockBillEntry outStockBillEntry = outStockService.selectOne(wrapper1); |
| | | if (Cools.isEmpty(outStockBillEntry)) { |
| | | JSONObject object = new JSONObject(); |
| | | object.put("FInterID", interData.getFInterID()); |
| | | object.put("Fnumber", interData.getFnumber()); |
| | | object.put("code", 500); |
| | | object.put("msg", "单据不存在或单据已被删除"); |
| | | jsonArray.add(object); |
| | | continue; |
| | | } |
| | | //判断出库数量回传字段和出库数量字段是否为0 |
| | | if (outStockBillEntry.getFAuxCommitQty().compareTo(BigDecimal.ZERO) == 0 && outStockBillEntry.getFAmount().compareTo(BigDecimal.ZERO) == 0) { |
| | | //判断传入的数量是否为0来执行删除或者修改 |
| | | if (interData.getFQty().compareTo(BigDecimal.ZERO) == 0) { |
| | | outStockService.delete(wrapper1); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("Fnumber", interData.getFnumber()); |
| | | object.put("FInterID", interData.getFInterID()); |
| | | object.put("code", 200); |
| | | object.put("msg", "删除成功"); |
| | | jsonArray.add(object); |
| | | } else { |
| | | outStockBillEntry.setFAuxQty(interData.getFQty()); |
| | | outStockService.update(outStockBillEntry, wrapper1); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("Fnumber", interData.getFnumber()); |
| | | object.put("FInterID", interData.getFInterID()); |
| | | object.put("code", 200); |
| | | object.put("msg", "修改成功"); |
| | | jsonArray.add(object); |
| | | } |
| | | } else { |
| | | if (outStockBillEntry.getFAuxCommitQty().compareTo(BigDecimal.ZERO) > 0) { |
| | | JSONObject object = new JSONObject(); |
| | | object.put("Fnumber", interData.getFnumber()); |
| | | object.put("FInterID", interData.getFInterID()); |
| | | object.put("code", 500); |
| | | object.put("msg", "已在出库中,无法取消"); |
| | | jsonArray.add(object); |
| | | } |
| | | } |
| | | } |
| | | if (Cools.isEmpty(jsonArray)) { |
| | | JSONObject object = new JSONObject(); |
| | | object.put("Fnumber", interData.getFnumber()); |
| | | object.put("FInterID", interData.getFInterID()); |
| | | object.put("code", 500); |
| | | object.put("msg", "单据有错误,请核对"); |
| | | jsonArray.add(object); |
| | | } |
| | | } |
| | | |
| | | jsonObject1.put("data", jsonArray); |
| | | return jsonObject1; |
| | | |
| | | } |
| | | // if (Cools.isEmpty(param.getIoType())) { |
| | | // return R.error("入出库类型不能为空"); |
| | | // } |
| | | // if (Cools.isEmpty(param.getSourceStaNo())) { |
| | | // return R.error("源站编号不能为空"); |
| | | // } |
| | | // List<WaitPakin> waitPakins = new ArrayList<WaitPakin>(); |
| | | // if (param.getIoType() == 1) { |
| | | // if (Cools.isEmpty(param.getBarcode())) { |
| | | // return R.error("条码不能为空"); |
| | | // } |
| | | //// waitPakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode())); |
| | | //// if (Cools.isEmpty(waitPakins)) { |
| | | //// return R.error("条码数据错误"); |
| | | //// } |
| | | // int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode())); |
| | | // int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getBarcode())); |
| | | // if (countLoc > 0 || countWrk > 0) { |
| | | // return R.error("工作档/库存条码数据已存在"); |
| | | // } |
| | | // } |
| | | // if (Cools.isEmpty(param.getLocType1())){ |
| | | // return R.error("高低检测信号不能为空"); |
| | | // } |
| | | // |
| | | // LocTypeDto locTypeDto = new LocTypeDto(); |
| | | // locTypeDto.setLocType1(param.getLocType1()); |
| | | // |
| | | // StartupDto dto = null; |
| | | // switch (param.getIoType()) { |
| | | // case 1: |
| | | // WaitPakin waitPakin = new WaitPakin(); |
| | | // waitPakin.setMatnr(param.getBarcode()); |
| | | // waitPakin.setAnfme(1D); |
| | | // waitPakins.add(waitPakin); |
| | | // dto = startupFullPutStore(param.getSourceStaNo(), param.getBarcode(), locTypeDto, waitPakins); |
| | | // break; |
| | | // case 10: |
| | | // dto = emptyPlateIn(param.getSourceStaNo(), locTypeDto); |
| | | // break; |
| | | // default: |
| | | // break; |
| | | // } |
| | | |
| | | |
| | | } |