| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.AgvBasDevp; |
| | | import com.zy.asrs.entity.AgvWaitPakin; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.entity.WaitPakin; |
| | | import com.zy.asrs.service.AgvBasDevpService; |
| | | import com.zy.asrs.service.AgvWaitPakinService; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | private AgvWaitPakinService agvWaitPakinService; |
| | | @Autowired |
| | | private AgvBasDevpService agvBasDevpService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | |
| | | @RequestMapping(value = "/waitPakin/{id}/auth") |
| | | @ManagerAuth |
| | |
| | | |
| | | @RequestMapping(value = "/waitPakin/delete/auth") |
| | | @ManagerAuth |
| | | @Transactional |
| | | public R delete(@RequestParam String param){ |
| | | List<AgvWaitPakin> list = JSONArray.parseArray(param, AgvWaitPakin.class); |
| | | if (Cools.isEmpty(list)){ |
| | |
| | | } |
| | | for (AgvWaitPakin entity : list){ |
| | | AgvBasDevp agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("barcode", entity.getSuppCode())); |
| | | if(Cools.isEmpty(agvBasDevp)){ |
| | | agvWaitPakinService.delete(new EntityWrapper<>(entity)); |
| | | }else { |
| | | return R.error("料箱码为" + entity.getSuppCode() + "已绑定站点,请先从AGV站点管理解绑该料箱"); |
| | | |
| | | if(!Cools.isEmpty(agvBasDevp)){ |
| | | if(!Cools.eq("F",agvBasDevp.getLocSts())){ |
| | | throw new CoolException("该入库通知档已经在作业中,无法删除"); |
| | | } |
| | | //解绑站点 |
| | | agvBasDevp.setLocSts("O"); |
| | | agvBasDevp.setBarcode(""); |
| | | agvBasDevp.setLocType2(null); |
| | | agvBasDevpService.update(agvBasDevp,new EntityWrapper<AgvBasDevp>().eq("dev_no",agvBasDevp.getDevNo())); |
| | | } |
| | | agvWaitPakinService.delete(new EntityWrapper<>(entity)); |
| | | |
| | | //订单回滚 |
| | | if(!Cools.isEmpty(entity.getOrderNo())){ |
| | | String orderNo = entity.getOrderNo(); |
| | | if(orderNo.contains("{")){ |
| | | JSONArray orderArray = JSON.parseArray(orderNo); |
| | | for (Object o : orderArray){ |
| | | JSONObject jsonobject = (JSONObject) o; |
| | | OrderDetl orderDetl = orderDetlService.selectByOrderNoAndMatnr(jsonobject.get("orderNo").toString(),entity.getMatnr(),entity.getThreeCode(),entity.getDeadTime()); |
| | | orderDetl.setQty(orderDetl.getQty() - entity.getAnfme()); |
| | | orderDetlService.updateById(orderDetl); |
| | | } |
| | | |
| | | }else { |
| | | OrderDetl orderDetl = orderDetlService.selectByOrderNoAndMatnr(entity.getOrderNo(),entity.getMatnr(),entity.getThreeCode(),entity.getDeadTime()); |
| | | orderDetl.setQty(orderDetl.getQty() - entity.getAnfme()); |
| | | orderDetlService.updateById(orderDetl); |
| | | } |
| | | } |
| | | |
| | | } |