|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.entity.WrkDetl; | 
|---|
|  |  |  | import com.zy.asrs.entity.WrkMast; | 
|---|
|  |  |  | import com.zy.asrs.service.OrderDetlService; | 
|---|
|  |  |  | import com.zy.asrs.service.OrderService; | 
|---|
|  |  |  | import com.zy.asrs.service.WaitPakinService; | 
|---|
|  |  |  | import com.zy.asrs.service.WrkMastService; | 
|---|
|  |  |  | import com.zy.common.web.BaseController; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | public class WaitPakinController extends BaseController { | 
|---|
|  |  |  | 
|---|
|  |  |  | private OrderDetlService orderDetlService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WrkMastService wrkMastService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderService orderService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/waitPakin/{id}/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | 
|---|
|  |  |  | if (Cools.isEmpty(list)){ | 
|---|
|  |  |  | return R.error("数据为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //通过HashSet的非重复特性, 存储不同的order编号, 然后遍历,将符合条件的order状态恢复到待处理 | 
|---|
|  |  |  | HashSet<String> orderNos = new HashSet<>(); | 
|---|
|  |  |  | for (WaitPakin entity : list){ | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("barcode", entity.getZpallet())); | 
|---|
|  |  |  | if(!Cools.isEmpty(wrkMasts) || wrkMasts.size() > 0){ | 
|---|
|  |  |  | 
|---|
|  |  |  | //订单关联,修改订单作业数量 | 
|---|
|  |  |  | if (!Cools.isEmpty(entity.getOrderNo())) { | 
|---|
|  |  |  | if (!orderDetlService.decrease(entity.getOrderNo(), entity.getMatnr(), entity.getBatch(), entity.getAnfme())) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.error("订单数据回滚失败"); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | orderNos.add(entity.getOrderNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (String orderNo : orderNos) { | 
|---|
|  |  |  | orderService.BackToInit(orderNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|