|  |  |  | 
|---|
|  |  |  | import com.core.common.DateUtils; | 
|---|
|  |  |  | import com.core.common.R; | 
|---|
|  |  |  | import com.zy.asrs.entity.WaitPakin; | 
|---|
|  |  |  | import com.zy.asrs.entity.WrkDetl; | 
|---|
|  |  |  | import com.zy.asrs.entity.WrkMast; | 
|---|
|  |  |  | import com.zy.asrs.service.OrderDetlService; | 
|---|
|  |  |  | import com.zy.asrs.service.WaitPakinService; | 
|---|
|  |  |  | import com.zy.asrs.service.WrkMastService; | 
|---|
|  |  |  | import com.zy.asrs.utils.OrderInAndOutUtil; | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WaitPakinService waitPakinService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderDetlService orderDetlService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WrkMastService wrkMastService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/waitPakin/{id}/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/waitPakin/update/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R update(WaitPakin waitPakin){ | 
|---|
|  |  |  | if (Cools.isEmpty(waitPakin) || null==waitPakin.getId()){ | 
|---|
|  |  |  | if (Cools.isEmpty(waitPakin)){ | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | waitPakinService.updateById(waitPakin); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/waitPakin/delete/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public R delete(@RequestParam String param){ | 
|---|
|  |  |  | List<WaitPakin> list = JSONArray.parseArray(param, WaitPakin.class); | 
|---|
|  |  |  | if (Cools.isEmpty(list)){ | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | return R.error("数据为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (WaitPakin entity : list){ | 
|---|
|  |  |  | waitPakinService.delete(new EntityWrapper<>(entity)); | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("barcode", entity.getZpallet())); | 
|---|
|  |  |  | if(!Cools.isEmpty(wrkMasts) || wrkMasts.size() > 0){ | 
|---|
|  |  |  | return R.error("条码已生成入库工作档,禁止删除"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | waitPakinService.delete(new EntityWrapper<WaitPakin>() | 
|---|
|  |  |  | .eq("zpallet", entity.getZpallet())); | 
|---|
|  |  |  | //订单关联,修改订单作业数量 | 
|---|
|  |  |  | if (!Cools.isEmpty(entity.getOrderNo())) { | 
|---|
|  |  |  | //                if (!orderDetlService.decrease(entity.getOrderNo(), entity.getMatnr(), entity.getBatch(), entity.getAnfme())) { | 
|---|
|  |  |  | //                    return R.error("订单数据回滚失败"); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | OrderInAndOutUtil.decrease(Boolean.TRUE, entity.getOrderNo(), entity.getMatnr(), entity.getBatch(),entity.getBrand() | 
|---|
|  |  |  | ,entity.getStandby1(),entity.getStandby2(),entity.getStandby3() | 
|---|
|  |  |  | ,entity.getBoxType1(),entity.getBoxType2(),entity.getBoxType3() | 
|---|
|  |  |  | , entity.getAnfme()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | List<Map<String, Object>> result = new ArrayList<>(); | 
|---|
|  |  |  | for (WaitPakin waitPakin : page.getRecords()){ | 
|---|
|  |  |  | Map<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | map.put("id", waitPakin.getId()); | 
|---|
|  |  |  | map.put("value", waitPakin.getId()); | 
|---|
|  |  |  | map.put("id", waitPakin.getZpallet()); | 
|---|
|  |  |  | map.put("value", waitPakin.getZpallet()); | 
|---|
|  |  |  | result.add(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(result); | 
|---|