|  |  | 
 |  |  | import com.core.annotations.ManagerAuth; | 
 |  |  | import com.core.common.*; | 
 |  |  | import com.core.exception.CoolException; | 
 |  |  | import com.zy.asrs.entity.DocType; | 
 |  |  | import com.zy.asrs.entity.Order; | 
 |  |  | import com.zy.asrs.entity.OrderDetl; | 
 |  |  | import com.zy.asrs.entity.*; | 
 |  |  | import com.zy.asrs.entity.param.OrderDomainParam; | 
 |  |  | import com.zy.asrs.service.DocTypeService; | 
 |  |  | import com.zy.asrs.service.OrderDetlService; | 
 |  |  | import com.zy.asrs.service.OrderService; | 
 |  |  | import com.zy.asrs.service.*; | 
 |  |  | import com.zy.common.model.DetlDto; | 
 |  |  | import com.zy.common.web.BaseController; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | 
 |  |  |     private SnowflakeIdWorker snowflakeIdWorker; | 
 |  |  |     @Autowired | 
 |  |  |     private DocTypeService docTypeService; | 
 |  |  |     @Autowired | 
 |  |  |     private WrkDetlService wrkDetlService; | 
 |  |  |     @Autowired | 
 |  |  |     private WaitPakinService waitPakinService; | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/order/nav/list/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  | 
 |  |  |     @ManagerAuth(memo = "手动添加订单") | 
 |  |  |     @Transactional | 
 |  |  |     public R formAdd(@RequestBody OrderDomainParam param){ | 
 |  |  |         if(Cools.isEmpty(param.getOrderNo())){ | 
 |  |  |             String prefix = ""; | 
 |  |  |             DocType docType = docTypeService.selectById(param.getDocType()); | 
 |  |  |             if(!Cools.isEmpty(docType)){ | 
 |  |  |                 prefix = docType.getPakin() == 1 ? "RK" : "CK"; | 
 |  |  |             } | 
 |  |  |             param.setOrderNo(prefix + snowflakeIdWorker.nextId()); | 
 |  |  |         } | 
 |  |  |         Order order = orderService.selectByNo(param.getOrderNo()); | 
 |  |  |         if (order != null) { | 
 |  |  |             return R.error("单据编号已存在"); | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     // ------------------------------------------------------------------------------------------------ | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/order/{id}/auth") | 
 |  |  | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/order/update/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R update(Order order){ | 
 |  |  |         if (Cools.isEmpty(order) || null == order.getId()){ | 
 |  |  |             return R.error(); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //订单完结前,判断是否存在作业中数据,存在则不能完结 | 
 |  |  |         if(order.getSettle() == 4){ | 
 |  |  |             int wrkCount = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("order_no",order.getOrderNo())); | 
 |  |  |             int pakinCount = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("order_no",order.getOrderNo())); | 
 |  |  |             if (wrkCount > 0 || pakinCount > 0) { | 
 |  |  |                 throw new CoolException("存在作业中数据,不能完结。请检查入库通知档和工作档"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         order.setUpdateBy(getUserId()); | 
 |  |  |         order.setUpdateTime(new Date()); | 
 |  |  |         if (!orderService.updateById(order)) { | 
 |  |  |             throw new CoolException("修改订单失败"); | 
 |  |  |         } | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/order/delete/auth") | 
 |  |  |     @ManagerAuth(memo = "手动删除订单") | 
 |  |  |     @Transactional | 
 |  |  |     public R delete(@RequestParam Long orderId){ | 
 |  |  |         Order order = orderService.selectById(orderId); | 
 |  |  |         if (order != null) { | 
 |  |  |             order.setStatus(0); | 
 |  |  |         } | 
 |  |  |         if (!orderService.updateById(order)) { | 
 |  |  |             throw new CoolException("删除订单失败"); | 
 |  |  |         } | 
 |  |  |         orderDetlService.modifyStatus(orderId, 0); | 
 |  |  |         orderService.remove(orderId); | 
 |  |  | //        Order order = orderService.selectById(orderId); | 
 |  |  | //        if (order != null) { | 
 |  |  | //            order.setStatus(0); | 
 |  |  | //        } | 
 |  |  | //        if (!orderService.updateById(order)) { | 
 |  |  | //            throw new CoolException("删除订单失败"); | 
 |  |  | //        } | 
 |  |  | //        orderDetlService.modifyStatus(orderId, 0); | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  |  |