| | |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.common.DateUtils; |
| | | import com.zy.asrs.entity.SaleOrder; |
| | | import com.zy.asrs.entity.WaitPakin; |
| | | import com.zy.asrs.service.SaleOrderService; |
| | | import com.zy.asrs.service.WaitPakinService; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | |
| | | |
| | | @Autowired |
| | | private SaleOrderService saleOrderService; |
| | | @Autowired |
| | | private WaitPakinService waitPakinService; |
| | | |
| | | @RequestMapping(value = "/saleOrder/{id}/auth") |
| | | @ManagerAuth |
| | |
| | | // 保存或更新 |
| | | if (isUpdate) { |
| | | saleOrderService.updateById(saleOrder); |
| | | // 销售订单更新后,顺带更新 xtyasrs 库 cust_wait_pakin 的数量(mobile/bill/query 的 count 取自 anfme),仅更新、不插入,失败不影响主流程 |
| | | updateWaitPakinQuantity(data); |
| | | } else { |
| | | saleOrderService.insert(saleOrder); |
| | | } |
| | |
| | | return Math.abs(d1 - d2) < 0.0001; |
| | | } |
| | | |
| | | /** |
| | | * 销售订单数量更新后,顺带更新 cust_wait_pakin 的 anfme/nqty(mobile/bill/query 的 count 取自 anfme)。 |
| | | * 仅按 matnr+mnemonic 更新,不插入;无匹配或异常不影响主流程。 |
| | | */ |
| | | private void updateWaitPakinQuantity(Map<String, Object> data) { |
| | | try { |
| | | String invCode = data.get("invCode") != null ? String.valueOf(data.get("invCode")).trim() : null; |
| | | String orderCode = data.get("orderCode") != null ? String.valueOf(data.get("orderCode")).trim() : null; |
| | | if (Cools.isEmpty(invCode) || Cools.isEmpty(orderCode)) { |
| | | return; |
| | | } |
| | | Double productQty = parseDoubleSafely(data.get("productQty")); |
| | | if (productQty == null) { |
| | | productQty = parseDoubleSafely(data.get("orderQty")); |
| | | } |
| | | String invName = data.get("invName") != null ? String.valueOf(data.get("invName")) : null; |
| | | WaitPakin updateEntity = new WaitPakin(); |
| | | updateEntity.setMaktx(invName); |
| | | updateEntity.setAnfme(productQty); |
| | | updateEntity.setNqty(productQty); |
| | | updateEntity.setModiTime(new Date()); |
| | | Wrapper<WaitPakin> wrapper = new EntityWrapper<WaitPakin>().eq("matnr", invCode).eq("mnemonic", orderCode); |
| | | waitPakinService.update(updateEntity, wrapper); |
| | | } catch (Exception e) { |
| | | // 不抛异常,避免影响销售订单保存 |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/saleOrder/update/auth") |
| | | @ManagerAuth |
| | | public R update(SaleOrder saleOrder) { |