|
|
@@ -42,561 +42,620 @@ import java.util.UUID;
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * @desc : 采购入库业务层
|
|
|
- * @date : 2024/3/7 14:11
|
|
|
* @author : 寇珊珊
|
|
|
+ * @desc : 采购入库业务层
|
|
|
+ * @date : 2024/3/7 14:11
|
|
|
*/
|
|
|
@Service
|
|
|
public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
|
|
|
- @Override
|
|
|
- public BaseMapper<Inbound> getRepository() {
|
|
|
- return inboundMapper;
|
|
|
- }
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private InboundMapper inboundMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private InboundConvert inboundConvert;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private InboundItemMapper inboundItemMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private InboundItemConvert inboundItemConvert;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private PurchaseMapper purchaseMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private PurchaseItemMapper purchaseItemMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private CommonService commonService;
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * @desc : 条件查询
|
|
|
- * @date : 2024/3/7 14:12
|
|
|
- * @author : 寇珊珊
|
|
|
- */
|
|
|
- @Pagination
|
|
|
- public ResponseResultVO<PageList<InboundResponse>> selectByCond(InboundQuery inboundQuery) {
|
|
|
- return super.mergeListWithCount(inboundQuery, inboundMapper.selectByCond(inboundQuery),
|
|
|
- inboundMapper.countByCond(inboundQuery));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * @desc : 查询明细
|
|
|
- * @date : 2024/3/9 15:43
|
|
|
- * @author : 寇珊珊
|
|
|
- */
|
|
|
- @Pagination
|
|
|
- public ResponseResultVO<Map<String, Object>> selectPurchaseInboundItemInfoById(String id) {
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- // 商品明细
|
|
|
- List<InboundItemResponse> inboundItemResponses = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(id));
|
|
|
- result.put("itemList", inboundItemResponses);
|
|
|
- // 收款
|
|
|
-
|
|
|
- // 附件
|
|
|
- return ResponseResultUtil.success(result);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @desc : 采购入库新建
|
|
|
- * @date : 2024/3/7 14:13
|
|
|
- * 入库中数量/金额 已入库数量/金额 由调用方传入
|
|
|
- * @author : 寇珊珊
|
|
|
- */
|
|
|
- @Transactional(rollbackFor = {Exception.class})
|
|
|
- public ResponseResultVO<?> purchaseInboundInsert(InboundVO inboundVO) {
|
|
|
- //region 总单
|
|
|
- //获取 id/单号
|
|
|
- Map<String , Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.PURCASEINBOUND.getName(),false);
|
|
|
- inboundVO.setIntoId(codeMap.get("outId").toString()).
|
|
|
- setIntoNo(codeMap.get("outNote").toString());
|
|
|
- //入库类型
|
|
|
- inboundVO.setIntoType(Constant.IntoType.SALE.getName());
|
|
|
- //自动入库标识
|
|
|
- if (inboundVO.getAutomaticFlg()) {
|
|
|
- //已入库
|
|
|
- inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
|
|
|
- } else {
|
|
|
- //入库中
|
|
|
- inboundVO.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
|
|
|
- }
|
|
|
- //入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
|
|
|
- if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
|
|
|
- inboundVO.setIntoQty(inboundVO.getIntoingQty())
|
|
|
- .setIntoAmt(inboundVO.getIntoingAmt())
|
|
|
- .setIntoingQty(BigDecimal.ZERO)
|
|
|
- .setIntoingAmt(BigDecimal.ZERO)
|
|
|
- ;
|
|
|
- }else{
|
|
|
- inboundVO.setIntoQty(BigDecimal.ZERO)
|
|
|
- .setIntoAmt(BigDecimal.ZERO)
|
|
|
- ;
|
|
|
- }
|
|
|
- //实体转换
|
|
|
- Inbound inbound = inboundConvert.convertToPo(inboundVO);
|
|
|
- inboundMapper.insert(inbound);
|
|
|
- //endregion
|
|
|
-
|
|
|
- //region 采购总单
|
|
|
- if(inboundVO.getFromId()!=null){
|
|
|
- //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
- Purchase purchaseUpdate = new Purchase();
|
|
|
- purchaseUpdate.setPurId(inboundVO.getFromId());
|
|
|
- //根据id查询
|
|
|
- PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
|
|
|
- //已入库
|
|
|
- if(Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())){
|
|
|
- //直接已入库
|
|
|
- if(purchaseResponse.getIntoingQty().compareTo(BigDecimal.ZERO)==0){
|
|
|
- purchaseUpdate.setIntoingQty(BigDecimal.ZERO);
|
|
|
- purchaseUpdate.setIntoingAmt(BigDecimal.ZERO);
|
|
|
- }
|
|
|
- //多次已入库
|
|
|
- else{
|
|
|
- purchaseUpdate.setIntoingQty(inboundVO.getIntoQty().negate());
|
|
|
- purchaseUpdate.setIntoingAmt(inboundVO.getIntoAmt().negate());
|
|
|
- }
|
|
|
- purchaseUpdate.setIntoQty(inboundVO.getIntoQty());
|
|
|
- purchaseUpdate.setIntoAmt(inboundVO.getIntoAmt());
|
|
|
- }
|
|
|
- //入库中
|
|
|
- else{
|
|
|
- purchaseUpdate.setIntoingQty(inboundVO.getIntoingQty());
|
|
|
- purchaseUpdate.setIntoingAmt(inboundVO.getIntoingAmt());
|
|
|
- purchaseUpdate.setIntoQty(BigDecimal.ZERO);
|
|
|
- purchaseUpdate.setIntoAmt(BigDecimal.ZERO);
|
|
|
- }
|
|
|
- //入库状态
|
|
|
- String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchaseUpdate.getIntoingQty()),
|
|
|
- purchaseResponse.getIntoQty().add(purchaseUpdate.getIntoQty()));
|
|
|
- purchaseUpdate.setIntoStatus(intoStatus);
|
|
|
- //修改
|
|
|
- int countRow = purchaseMapper.updateById(purchaseUpdate);
|
|
|
- //数量超出
|
|
|
- if (countRow == 0) {
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- //endregion
|
|
|
-
|
|
|
-
|
|
|
- //region 明细
|
|
|
- //校验明细
|
|
|
- if (inboundVO.getItemList().size() == 0) {
|
|
|
- return ResponseResultUtil.error(ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getCode(),
|
|
|
- ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
|
|
|
- }
|
|
|
- for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
|
- //总单id
|
|
|
- inboundItemVO.setIntoId(inboundVO.getIntoId());
|
|
|
- //入库类型
|
|
|
- inboundItemVO.setIntoType(inboundVO.getIntoType());
|
|
|
- //入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
|
|
|
- if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
|
|
|
- inboundItemVO
|
|
|
- .setIntoQty(inboundItemVO.getIntoingQty())
|
|
|
- .setIntoAmt(inboundItemVO.getIntoingAmt())
|
|
|
- .setIntoingQty(BigDecimal.ZERO)
|
|
|
- .setIntoingAmt(BigDecimal.ZERO)
|
|
|
- .setCostPrice(inboundItemVO.getPriceInto())
|
|
|
- .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
- ;
|
|
|
- }else{
|
|
|
- inboundItemVO
|
|
|
- .setIntoQty(BigDecimal.ZERO)
|
|
|
- .setIntoAmt(BigDecimal.ZERO);
|
|
|
- }
|
|
|
- //入库状态
|
|
|
- inboundItemVO.setIntoStatus(inboundVO.getIntoStatus());
|
|
|
- //实体转换
|
|
|
- InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
- inboundItemMapper.insert(inboundItem);
|
|
|
- //endregion
|
|
|
-
|
|
|
- //region 采购明细
|
|
|
- if(inboundItemVO.getFromItemId()!=null){
|
|
|
- //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
- PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
- purchaseItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
- //根据id查询
|
|
|
- PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
- //已入库
|
|
|
- if(Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())){
|
|
|
- //第一次已入库
|
|
|
- if(purchaseItemResponse.getIntoingQty().compareTo(BigDecimal.ZERO)==0){
|
|
|
- purchaseItem.setIntoingQty(BigDecimal.ZERO);
|
|
|
- purchaseItem.setIntoingAmt(BigDecimal.ZERO);
|
|
|
- }
|
|
|
- //多次已入库
|
|
|
- else{
|
|
|
- purchaseItem.setIntoingQty(inboundItemVO.getIntoQty().negate());
|
|
|
- purchaseItem.setIntoingAmt(inboundItemVO.getIntoAmt().negate());
|
|
|
- }
|
|
|
- purchaseItem.setIntoQty(inboundItemVO.getIntoQty());
|
|
|
- purchaseItem.setIntoAmt(inboundItemVO.getIntoAmt());
|
|
|
- }
|
|
|
- //入库中
|
|
|
- else{
|
|
|
- purchaseItem.setIntoingQty(inboundItemVO.getIntoingQty());
|
|
|
- purchaseItem.setIntoingAmt(inboundItemVO.getIntoingAmt());
|
|
|
- purchaseItem.setIntoQty(BigDecimal.ZERO);
|
|
|
- purchaseItem.setIntoAmt(BigDecimal.ZERO);
|
|
|
- }
|
|
|
- //入库状态
|
|
|
- String intoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
|
|
|
- purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()));
|
|
|
- purchaseItem.setIntoStatus(intoStatus);
|
|
|
- int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
- //数量超出
|
|
|
- if (countRow == 0) {
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- //endregion
|
|
|
- }
|
|
|
- //endregion
|
|
|
-
|
|
|
- //todo 如果是已入库 调用库存 后续写库存这里补上
|
|
|
- //region 库存
|
|
|
-
|
|
|
-
|
|
|
- //endregion
|
|
|
-
|
|
|
-
|
|
|
- return ResponseResultUtil.success(inboundVO);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * @desc : 采购入库办理
|
|
|
- * @date : 2024/3/7 15:47
|
|
|
- * @author : 寇珊珊
|
|
|
- */
|
|
|
- @Transactional(rollbackFor = {Exception.class})
|
|
|
- public ResponseResultVO<?> purchaseHandleInbound(InboundVO inboundVO) {
|
|
|
- //region 编辑明细
|
|
|
- //校验明细
|
|
|
- if (inboundVO.getItemList().size() == 0) {
|
|
|
- return ResponseResultUtil.error(ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getCode(),
|
|
|
- ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
|
|
|
- }
|
|
|
- for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
|
- if (inboundItemVO.getIntoId() != null) {
|
|
|
- InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId());
|
|
|
- //编辑明细
|
|
|
- inboundItemVO
|
|
|
- .setIntoQty(inboundItemResponse.getIntoQty().add(inboundItemVO.getIntoingQty()))
|
|
|
- .setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
|
|
|
- .setIntoQty(inboundItemResponse.getOutQty().add(inboundItemVO.getIntoQty()))
|
|
|
- .setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoAmt()))
|
|
|
- .setIntoingQty(inboundItemResponse.getIntoingQty().subtract(inboundItemVO.getIntoingQty()))
|
|
|
- .setIntoingAmt(inboundItemResponse.getIntoingAmt().subtract(inboundItemVO.getIntoingAmt()))
|
|
|
- .setCostPrice(inboundItemVO.getPriceInto())
|
|
|
- .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
- ;
|
|
|
- //入库状态
|
|
|
- String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
|
|
|
- inboundItemVO.setIntoStatus(intoStatus);
|
|
|
- //实体转换
|
|
|
- InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
- //修改
|
|
|
- inboundItemMapper.update(inboundItem,
|
|
|
- new UpdateWrapper<InboundItem>().lambda()
|
|
|
- .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
- );
|
|
|
- }
|
|
|
- //endregion
|
|
|
- //region 新建明细
|
|
|
- else {
|
|
|
- inboundItemVO
|
|
|
- .setIntoQty(inboundItemVO.getIntoingQty())
|
|
|
- .setIntoAmt(inboundItemVO.getIntoingAmt())
|
|
|
- .setIntoId(inboundVO.getIntoId())
|
|
|
- .setCostPrice(inboundItemVO.getPriceInto())
|
|
|
- .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
- .setIntoType(Constant.IntoType.SALE.getName());
|
|
|
- //入库状态
|
|
|
- String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
|
|
|
- inboundItemVO.setIntoStatus(intoStatus);
|
|
|
- //实体转换
|
|
|
- InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
- //新建
|
|
|
- inboundItemMapper.insert(inboundItem);
|
|
|
- }
|
|
|
- //region 采购
|
|
|
- //采购明细
|
|
|
- if (inboundItemVO.getFromItemId() != null) {
|
|
|
- //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
- PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
- purchaseItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
- purchaseItem.setIntoingQty(inboundItemVO.getIntoQty().negate());
|
|
|
- purchaseItem.setIntoingAmt(inboundItemVO.getIntoAmt().negate());
|
|
|
- purchaseItem.setIntoQty(inboundItemVO.getIntoQty());
|
|
|
- purchaseItem.setIntoAmt(inboundItemVO.getIntoAmt());
|
|
|
- //根据id查询
|
|
|
- PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
- //入库状态
|
|
|
- String intoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
|
|
|
- purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()));
|
|
|
- purchaseItem.setIntoStatus(intoStatus);
|
|
|
- int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
- //数量超出
|
|
|
- if (countRow == 0) {
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- //endregion
|
|
|
- }
|
|
|
- //endregion
|
|
|
-
|
|
|
- //region 删除明细 todo 2024年3月20日13:14:20 这里可能用不到
|
|
|
-// BigDecimal sumDelIntoQty = BigDecimal.ZERO;
|
|
|
-// BigDecimal sumDelIntoAmt = BigDecimal.ZERO;
|
|
|
-// BigDecimal sumDelIntoingQty = BigDecimal.ZERO;
|
|
|
-// BigDecimal sumDelIntoingAmt = BigDecimal.ZERO;
|
|
|
-// if (inboundVO.getDeleteItemList() != null) {
|
|
|
-// sumDelIntoQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
-// sumDelIntoAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
-// sumDelIntoingQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
-// sumDelIntoingAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
-// for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
|
|
|
-// if (inboundItemVO.getItemId() != null) {
|
|
|
-// InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
-// inboundItem.setFlgValid(false);
|
|
|
-// //修改
|
|
|
-// inboundItemMapper.update(inboundItem,
|
|
|
-// new UpdateWrapper<InboundItem>().lambda()
|
|
|
-// .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
-// );
|
|
|
+ @Override
|
|
|
+ public BaseMapper<Inbound> getRepository() {
|
|
|
+ return inboundMapper;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InboundMapper inboundMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InboundConvert inboundConvert;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InboundItemMapper inboundItemMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InboundItemConvert inboundItemConvert;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PurchaseMapper purchaseMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PurchaseItemMapper purchaseItemMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CommonService commonService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 条件查询
|
|
|
+ * @date : 2024/3/7 14:12
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Pagination
|
|
|
+ public ResponseResultVO<PageList<InboundResponse>> selectByCond(InboundQuery inboundQuery) {
|
|
|
+ return super.mergeListWithCount(inboundQuery, inboundMapper.selectByCond(inboundQuery),
|
|
|
+ inboundMapper.countByCond(inboundQuery));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 查询明细
|
|
|
+ * @date : 2024/3/9 15:43
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Pagination
|
|
|
+ public ResponseResultVO<Map<String, Object>> selectPurchaseInboundItemInfoById(String id) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ // 商品明细
|
|
|
+ List<InboundItemResponse> inboundItemResponses = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(id));
|
|
|
+ result.put("itemList", inboundItemResponses);
|
|
|
+ // 收款
|
|
|
+
|
|
|
+ // 附件
|
|
|
+ return ResponseResultUtil.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 采购入库新建
|
|
|
+ * @date : 2024/3/7 14:13
|
|
|
+ * 入库中数量/金额 已入库数量/金额 由调用方传入
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ public ResponseResultVO<?> purchaseInboundInsert(InboundVO inboundVO) {
|
|
|
+ //region 总单
|
|
|
+ //获取 id/单号
|
|
|
+ Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.PURCASEINBOUND.getName(), false);
|
|
|
+ inboundVO.setIntoId(codeMap.get("outId").toString()).
|
|
|
+ setIntoNo(codeMap.get("outNote").toString());
|
|
|
+ //入库类型
|
|
|
+ inboundVO.setIntoType(Constant.IntoType.SALE.getName());
|
|
|
+ //自动入库标识
|
|
|
+ if (inboundVO.getAutomaticFlg()) {
|
|
|
+ //已入库
|
|
|
+ inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
|
|
|
+ } else {
|
|
|
+ //入库中
|
|
|
+ inboundVO.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
|
|
|
+ }
|
|
|
+ //入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
|
|
|
+ if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
|
|
|
+ inboundVO.setIntoQty(inboundVO.getIntoingQty())
|
|
|
+ .setIntoAmt(inboundVO.getIntoingAmt())
|
|
|
+ .setIntoingQty(BigDecimal.ZERO)
|
|
|
+ .setIntoingAmt(BigDecimal.ZERO)
|
|
|
+ ;
|
|
|
+ } else {
|
|
|
+ inboundVO.setIntoQty(BigDecimal.ZERO)
|
|
|
+ .setIntoAmt(BigDecimal.ZERO)
|
|
|
+ ;
|
|
|
+ }
|
|
|
+ //实体转换
|
|
|
+ Inbound inbound = inboundConvert.convertToPo(inboundVO);
|
|
|
+ inboundMapper.insert(inbound);
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 采购总单
|
|
|
+ if (inboundVO.getFromId() != null) {
|
|
|
+ //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
+ Purchase purchaseUpdate = new Purchase();
|
|
|
+ purchaseUpdate.setPurId(inboundVO.getFromId());
|
|
|
+ //根据id查询
|
|
|
+ PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
|
|
|
+ //已入库
|
|
|
+ if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
|
|
|
+// //直接已入库
|
|
|
+// if(purchaseResponse.getIntoingQty().compareTo(BigDecimal.ZERO)==0){
|
|
|
+// purchaseUpdate.setIntoingQty(BigDecimal.ZERO);
|
|
|
+// purchaseUpdate.setIntoingAmt(BigDecimal.ZERO);
|
|
|
// }
|
|
|
-// //region 采购
|
|
|
-// if (inboundItemVO.getFromItemId() != null) {
|
|
|
-// //region 采购订单明细
|
|
|
-// //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
-// PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
-// purchaseItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
-// purchaseItem.setIntoingQty(inboundItemVO.getIntoingQty().negate());
|
|
|
-// purchaseItem.setIntoingAmt(inboundItemVO.getIntoingAmt().negate());
|
|
|
-// purchaseItem.setIntoQty(inboundItemVO.getIntoQty().negate());
|
|
|
-// purchaseItem.setIntoAmt(inboundItemVO.getIntoAmt().negate());
|
|
|
-// //根据id查询
|
|
|
-// PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
-// //入库状态
|
|
|
-// String intoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
|
|
|
-// purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()));
|
|
|
-// purchaseItem.setIntoStatus(intoStatus);
|
|
|
-// int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
-// //数量超出
|
|
|
-// if (countRow == 0) {
|
|
|
-// throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+// //多次已入库
|
|
|
+// else{
|
|
|
+// purchaseUpdate.setIntoingQty(inboundVO.getIntoQty().negate());
|
|
|
+// purchaseUpdate.setIntoingAmt(inboundVO.getIntoAmt().negate());
|
|
|
+// }
|
|
|
+ //todo 2024年3月25日11:31:52 这里直接赋值0
|
|
|
+ purchaseUpdate.setIntoingQty(BigDecimal.ZERO);
|
|
|
+ purchaseUpdate.setIntoingAmt(BigDecimal.ZERO);
|
|
|
+ purchaseUpdate.setIntoQty(inboundVO.getIntoQty());
|
|
|
+ purchaseUpdate.setIntoAmt(inboundVO.getIntoAmt());
|
|
|
+ }
|
|
|
+ //入库中
|
|
|
+ else {
|
|
|
+ purchaseUpdate.setIntoingQty(inboundVO.getIntoingQty());
|
|
|
+ purchaseUpdate.setIntoingAmt(inboundVO.getIntoingAmt());
|
|
|
+ purchaseUpdate.setIntoQty(BigDecimal.ZERO);
|
|
|
+ purchaseUpdate.setIntoAmt(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ //入库状态
|
|
|
+ String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchaseUpdate.getIntoingQty()),
|
|
|
+ purchaseResponse.getIntoQty().add(purchaseUpdate.getIntoQty()));
|
|
|
+ purchaseUpdate.setIntoStatus(intoStatus);
|
|
|
+ //修改
|
|
|
+ int countRow = purchaseMapper.updateById(purchaseUpdate);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+
|
|
|
+ //region 明细
|
|
|
+ //校验明细
|
|
|
+ if (inboundVO.getItemList().size() == 0) {
|
|
|
+ return ResponseResultUtil.error(ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getCode(),
|
|
|
+ ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
|
|
|
+ }
|
|
|
+ for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
|
+ //总单id
|
|
|
+ inboundItemVO.setIntoId(inboundVO.getIntoId());
|
|
|
+ //入库类型
|
|
|
+ inboundItemVO.setIntoType(inboundVO.getIntoType());
|
|
|
+ //入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
|
|
|
+ if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
|
|
|
+ inboundItemVO
|
|
|
+ .setIntoQty(inboundItemVO.getIntoingQty())
|
|
|
+ .setIntoAmt(inboundItemVO.getIntoingAmt())
|
|
|
+ .setIntoingQty(BigDecimal.ZERO)
|
|
|
+ .setIntoingAmt(BigDecimal.ZERO)
|
|
|
+ .setCostPrice(inboundItemVO.getPriceInto())
|
|
|
+ .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
+ ;
|
|
|
+ } else {
|
|
|
+ inboundItemVO
|
|
|
+ .setIntoQty(BigDecimal.ZERO)
|
|
|
+ .setIntoAmt(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ //入库状态
|
|
|
+ inboundItemVO.setIntoStatus(inboundVO.getIntoStatus());
|
|
|
+ //实体转换
|
|
|
+ InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
+ inboundItemMapper.insert(inboundItem);
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 采购明细
|
|
|
+ if (inboundItemVO.getFromItemId() != null) {
|
|
|
+ //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
+ PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
+ purchaseItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
+ //根据id查询
|
|
|
+ PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
+ //已入库
|
|
|
+ if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
|
|
|
+// //第一次已入库
|
|
|
+// if(purchaseItemResponse.getIntoingQty().compareTo(BigDecimal.ZERO)==0){
|
|
|
+// purchaseItem.setIntoingQty(BigDecimal.ZERO);
|
|
|
+// purchaseItem.setIntoingAmt(BigDecimal.ZERO);
|
|
|
+// }
|
|
|
+// //多次已入库
|
|
|
+// else{
|
|
|
+// purchaseItem.setIntoingQty(inboundItemVO.getIntoQty().negate());
|
|
|
+// purchaseItem.setIntoingAmt(inboundItemVO.getIntoAmt().negate());
|
|
|
// }
|
|
|
-// //endregion
|
|
|
+ //2024年3月25日11:49:17 直接赋值为0
|
|
|
+ purchaseItem.setIntoingQty(BigDecimal.ZERO);
|
|
|
+ purchaseItem.setIntoingAmt(BigDecimal.ZERO);
|
|
|
+ purchaseItem.setIntoQty(inboundItemVO.getIntoQty());
|
|
|
+ purchaseItem.setIntoAmt(inboundItemVO.getIntoAmt());
|
|
|
+ }
|
|
|
+ //入库中
|
|
|
+ else {
|
|
|
+ purchaseItem.setIntoingQty(inboundItemVO.getIntoingQty());
|
|
|
+ purchaseItem.setIntoingAmt(inboundItemVO.getIntoingAmt());
|
|
|
+ purchaseItem.setIntoQty(BigDecimal.ZERO);
|
|
|
+ purchaseItem.setIntoAmt(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ //入库状态
|
|
|
+ String intoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
|
|
|
+ purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()));
|
|
|
+ purchaseItem.setIntoStatus(intoStatus);
|
|
|
+ int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //todo 如果是已入库 调用库存 后续写库存这里补上
|
|
|
+ //region 库存
|
|
|
+
|
|
|
+
|
|
|
+ //endregion
|
|
|
+
|
|
|
+
|
|
|
+ return ResponseResultUtil.success(inboundVO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 采购入库办理
|
|
|
+ * @date : 2024/3/7 15:47
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ public ResponseResultVO<?> purchaseHandleInbound(InboundVO inboundVO) {
|
|
|
+ //region 根据订单id查询入库数据
|
|
|
+ List<InboundResponse> inboundResponses = inboundMapper.selectByCond(new InboundQuery().setFromId(inboundVO.getFromId()));
|
|
|
+ BigDecimal intoingQtyTotal = BigDecimal.ZERO;
|
|
|
+ BigDecimal intoingAmtTotal = BigDecimal.ZERO;
|
|
|
+ if (inboundResponses != null && inboundResponses.size() > 0) {
|
|
|
+ //入库中数据 汇总
|
|
|
+ intoingQtyTotal = inboundResponses.stream().map(InboundResponse::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ intoingAmtTotal = inboundResponses.stream().map(InboundResponse::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ //region 根据id查询 此条入库单的数据还未更改前的数据
|
|
|
+ InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 编辑明细
|
|
|
+ //校验明细
|
|
|
+ if (inboundVO.getItemList().size() == 0) {
|
|
|
+ return ResponseResultUtil.error(ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getCode(),
|
|
|
+ ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
|
|
|
+ }
|
|
|
+ for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
|
+ //入库明细根据id查询
|
|
|
+ InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId());
|
|
|
+ if (inboundItemVO.getIntoId() != null) {
|
|
|
+ //region 采购明细
|
|
|
+ //根据id查询
|
|
|
+ PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
+ //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
+ PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
+ purchaseItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
+ //todo 取入库单的入库中数据
|
|
|
+// purchaseItem.setIntoingQty(inboundItemVO.getIntoQty().negate());
|
|
|
+// purchaseItem.setIntoingAmt(inboundItemVO.getIntoAmt().negate());
|
|
|
+ purchaseItem.setIntoingQty(inboundItemResponse.getIntoingQty().negate());
|
|
|
+ purchaseItem.setIntoingAmt(inboundItemResponse.getIntoingAmt().negate());
|
|
|
+ purchaseItem.setIntoQty(inboundItemVO.getIntoQty());
|
|
|
+ purchaseItem.setIntoAmt(inboundItemVO.getIntoAmt());
|
|
|
+ //入库状态
|
|
|
+ String purItemIntoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
|
|
|
+ purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()));
|
|
|
+ purchaseItem.setIntoStatus(purItemIntoStatus);
|
|
|
+ int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ //region 编辑入库明细
|
|
|
+ inboundItemVO
|
|
|
+ .setIntoQty(inboundItemResponse.getIntoQty().add(inboundItemVO.getIntoingQty()))
|
|
|
+ .setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
|
|
|
+ .setIntoQty(inboundItemResponse.getOutQty().add(inboundItemVO.getIntoQty()))
|
|
|
+ .setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoAmt()))
|
|
|
+// .setIntoingQty(inboundItemResponse.getIntoingQty().subtract(inboundItemVO.getIntoingQty()))
|
|
|
+// .setIntoingAmt(inboundItemResponse.getIntoingAmt().subtract(inboundItemVO.getIntoingAmt()))
|
|
|
+ //todo 2024年3月25日12:57:07 直接赋值为0
|
|
|
+ .setIntoingQty(BigDecimal.ZERO)
|
|
|
+ .setIntoingAmt(BigDecimal.ZERO)
|
|
|
+ .setCostPrice(inboundItemVO.getPriceInto())
|
|
|
+ .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
+ ;
|
|
|
+ //入库状态
|
|
|
+ String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
|
|
|
+ inboundItemVO.setIntoStatus(intoStatus);
|
|
|
+ //实体转换
|
|
|
+ InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
+ //修改
|
|
|
+ inboundItemMapper.update(inboundItem,
|
|
|
+ new UpdateWrapper<InboundItem>().lambda()
|
|
|
+ .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
+ );
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+// //region 新建明细 todo 注释掉
|
|
|
+// else {
|
|
|
+// inboundItemVO
|
|
|
+// .setIntoQty(inboundItemVO.getIntoingQty())
|
|
|
+// .setIntoAmt(inboundItemVO.getIntoingAmt())
|
|
|
+// //todo 2024年3月25日12:58:01 赋值0
|
|
|
+// .setIntoingQty(BigDecimal.ZERO)
|
|
|
+// .setIntoAmt(BigDecimal.ZERO)
|
|
|
+// .setIntoId(inboundVO.getIntoId())
|
|
|
+// .setCostPrice(inboundItemVO.getPriceInto())
|
|
|
+// .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
+// .setIntoType(Constant.IntoType.SALE.getName());
|
|
|
+// //入库状态
|
|
|
+// String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
|
|
|
+// inboundItemVO.setIntoStatus(intoStatus);
|
|
|
+// //实体转换
|
|
|
+// InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
+// //新建
|
|
|
+// inboundItemMapper.insert(inboundItem);
|
|
|
+// }
|
|
|
+// //endregion
|
|
|
+
|
|
|
+ //region 采购 todo 注释掉
|
|
|
+ //采购明细
|
|
|
+// if (inboundItemVO.getFromItemId() != null) {
|
|
|
+// //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
+// PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
+// purchaseItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
+// purchaseItem.setIntoingQty(inboundItemVO.getIntoQty().negate());
|
|
|
+// purchaseItem.setIntoingAmt(inboundItemVO.getIntoAmt().negate());
|
|
|
+// purchaseItem.setIntoQty(inboundItemVO.getIntoQty());
|
|
|
+// purchaseItem.setIntoAmt(inboundItemVO.getIntoAmt());
|
|
|
+// //根据id查询
|
|
|
+// PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
+// //入库状态
|
|
|
+// String intoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
|
|
|
+// purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()));
|
|
|
+// purchaseItem.setIntoStatus(intoStatus);
|
|
|
+// int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
+// //数量超出
|
|
|
+// if (countRow == 0) {
|
|
|
+// throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
// }
|
|
|
-// //endregion
|
|
|
-//
|
|
|
// }
|
|
|
-// }
|
|
|
- //endregion
|
|
|
-
|
|
|
- //region 编辑总单
|
|
|
- InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
|
|
|
- BigDecimal sumIntoQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal sumIntoAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- inboundVO.setIntoQty(sumIntoQty);
|
|
|
- inboundVO.setIntoAmt(sumIntoAmt);
|
|
|
- inboundVO.setIntoingQty(inboundResponse.getIntoingQty().subtract(sumIntoQty));
|
|
|
- inboundVO.setIntoingAmt(inboundResponse.getIntoingAmt().subtract(sumIntoAmt));
|
|
|
- //入库状态
|
|
|
- String intoStatus = this.setIntoStatus(inboundVO.getIntoingQty(), inboundVO.getIntoQty());
|
|
|
- inboundVO.setIntoStatus(intoStatus);
|
|
|
- //实体转换
|
|
|
- Inbound inbound = inboundConvert.convertToPo(inboundVO);
|
|
|
- //修改
|
|
|
- inboundMapper.update(inbound,
|
|
|
- new UpdateWrapper<Inbound>().lambda()
|
|
|
- .eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
|
|
|
- );
|
|
|
- //endregion
|
|
|
-
|
|
|
- //region 修改采购订单
|
|
|
- if (inboundVO.getFromId() != null) {
|
|
|
- //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
- Purchase purchase = new Purchase();
|
|
|
- purchase.setPurId(inboundVO.getFromId());
|
|
|
- //region todo 2024年3月20日13:14:51 这里可能用不到
|
|
|
+ //endregion
|
|
|
+// }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 删除明细 todo 2024年3月20日13:14:20 这里可能用不到
|
|
|
+// BigDecimal sumDelIntoQty = BigDecimal.ZERO;
|
|
|
+// BigDecimal sumDelIntoAmt = BigDecimal.ZERO;
|
|
|
+// BigDecimal sumDelIntoingQty = BigDecimal.ZERO;
|
|
|
+// BigDecimal sumDelIntoingAmt = BigDecimal.ZERO;
|
|
|
+ if (inboundVO.getDeleteItemList() != null) {
|
|
|
+// sumDelIntoQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+// sumDelIntoAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+// sumDelIntoingQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+// sumDelIntoingAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
|
|
|
+ if (inboundItemVO.getItemId() != null) {
|
|
|
+ InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
+ inboundItem.setFlgValid(false);
|
|
|
+ //修改
|
|
|
+ inboundItemMapper.update(inboundItem,
|
|
|
+ new UpdateWrapper<InboundItem>().lambda()
|
|
|
+ .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
+ );
|
|
|
+ }
|
|
|
+ //region 采购
|
|
|
+ if (inboundItemVO.getFromItemId() != null) {
|
|
|
+ //region 采购订单明细
|
|
|
+ //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
+ PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
+ purchaseItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
+ purchaseItem.setIntoingQty(inboundItemVO.getIntoingQty().negate());
|
|
|
+ purchaseItem.setIntoingAmt(inboundItemVO.getIntoingAmt().negate());
|
|
|
+ purchaseItem.setIntoQty(inboundItemVO.getIntoQty().negate());
|
|
|
+ purchaseItem.setIntoAmt(inboundItemVO.getIntoAmt().negate());
|
|
|
+ //根据id查询
|
|
|
+ PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
+ //入库状态
|
|
|
+ String intoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
|
|
|
+ purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()));
|
|
|
+ purchaseItem.setIntoStatus(intoStatus);
|
|
|
+ int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 编辑总单
|
|
|
+ BigDecimal sumIntoQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal sumIntoAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ inboundVO.setIntoQty(sumIntoQty);
|
|
|
+ inboundVO.setIntoAmt(sumIntoAmt);
|
|
|
+ inboundVO.setIntoingQty(BigDecimal.ZERO);
|
|
|
+ inboundVO.setIntoingAmt(BigDecimal.ZERO);
|
|
|
+// inboundVO.setIntoingQty(inboundResponse.getIntoingQty());
|
|
|
+// inboundVO.setIntoingAmt(inboundResponse.getIntoingAmt().subtract(sumIntoAmt));
|
|
|
+ //入库状态
|
|
|
+ String intoStatus = this.setIntoStatus(inboundVO.getIntoingQty(), inboundVO.getIntoQty());
|
|
|
+ inboundVO.setIntoStatus(intoStatus);
|
|
|
+ //实体转换
|
|
|
+ Inbound inbound = inboundConvert.convertToPo(inboundVO);
|
|
|
+ //修改
|
|
|
+ inboundMapper.update(inbound,
|
|
|
+ new UpdateWrapper<Inbound>().lambda().eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
|
|
|
+ );
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 修改采购订单
|
|
|
+ if (inboundVO.getFromId() != null) {
|
|
|
+ //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
+ Purchase purchase = new Purchase();
|
|
|
+ purchase.setPurId(inboundVO.getFromId());
|
|
|
+ //region todo 2024年3月20日13:14:51 这里可能用不到
|
|
|
// purchase.setIntoQty(sumIntoQty.subtract(sumDelIntoQty));
|
|
|
// purchase.setIntoAmt(sumIntoAmt.subtract(sumDelIntoAmt));
|
|
|
// purchase.setIntoingQty((sumIntoingQty.add(sumDelIntoingQty)).negate());
|
|
|
// purchase.setIntoingAmt((sumIntoingAmt.add(sumDelIntoingAmt)).negate());
|
|
|
- //endregion
|
|
|
- purchase.setIntoQty(sumIntoQty);
|
|
|
- purchase.setIntoAmt(sumIntoAmt);
|
|
|
- purchase.setIntoingQty(sumIntoQty.negate());
|
|
|
- purchase.setIntoingAmt(sumIntoAmt.negate());
|
|
|
- //根据id查询
|
|
|
- PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
|
|
|
- //入库状态
|
|
|
- String purIntoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
- purchaseResponse.getIntoQty().add(purchase.getIntoQty()));
|
|
|
- purchase.setIntoStatus(purIntoStatus);
|
|
|
- //修改
|
|
|
- int countRow = purchaseMapper.updateById(purchase);
|
|
|
- //数量超出
|
|
|
- if (countRow == 0) {
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- //endregion
|
|
|
-
|
|
|
- //todo 如果是已入库 调用库存 后续写库存这里补上
|
|
|
- //region 修改库存
|
|
|
-
|
|
|
- //endregion
|
|
|
- return ResponseResultUtil.success(inboundVO);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * @desc : 采购入库撤销
|
|
|
- * @date : 2024/3/7 17:06
|
|
|
- * @author : 寇珊珊
|
|
|
- */
|
|
|
- @Transactional(rollbackFor = {Exception.class})
|
|
|
- public ResponseResultVO<?> purchaseInboundCancel(InboundVO inboundVO) {
|
|
|
- //region 查询入库总单数据信息
|
|
|
- InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
|
|
|
- //endregion
|
|
|
-
|
|
|
- //region 修改订单数据信息
|
|
|
- if (inboundResponse.getFromId() != null) {
|
|
|
- //赋值 (这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
- Purchase purchase = new Purchase();
|
|
|
- purchase.setPurId(inboundResponse.getFromId());
|
|
|
- purchase.setIntoQty(inboundResponse.getIntoQty().negate());
|
|
|
- purchase.setIntoAmt(inboundResponse.getIntoAmt().negate());
|
|
|
- purchase.setIntoingQty(inboundResponse.getIntoQty());
|
|
|
- purchase.setIntoingAmt(inboundResponse.getIntoAmt());
|
|
|
- //根据id查询
|
|
|
- PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
|
|
|
- //入库状态
|
|
|
- String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
- purchaseResponse.getIntoQty().add(purchase.getIntoQty()));
|
|
|
- purchase.setIntoStatus(intoStatus);
|
|
|
- int countRow = purchaseMapper.updateById(purchase);
|
|
|
- //数量超出
|
|
|
- if (countRow == 0) {
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- //endregion
|
|
|
-
|
|
|
- //region 修改总单数据信息
|
|
|
- Inbound inbound = new Inbound();
|
|
|
- inbound.setIntoId(inboundVO.getIntoId());
|
|
|
- inbound.setIntoDate(null);
|
|
|
- inbound.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
|
|
|
- inbound.setIntoingQty(inboundResponse.getIntoingQty().add(inboundResponse.getIntoQty()));
|
|
|
- inbound.setIntoingAmt(inboundResponse.getIntoingAmt().add(inboundResponse.getIntoAmt()));
|
|
|
- inbound.setIntoQty(BigDecimal.ZERO);
|
|
|
- inbound.setIntoAmt(BigDecimal.ZERO);
|
|
|
- //修改
|
|
|
- inboundMapper.update(inbound,
|
|
|
- new UpdateWrapper<Inbound>().lambda()
|
|
|
- .eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
|
|
|
- );
|
|
|
- //endregion
|
|
|
-
|
|
|
- //region 明细数据
|
|
|
- //根据总单id查明细
|
|
|
- List<InboundItemResponse> orderEntryItemResponsesList = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(inbound.getIntoId()));
|
|
|
- for (InboundItemResponse inboundItemResponse : orderEntryItemResponsesList) {
|
|
|
- //region 修改采购明细数据信息
|
|
|
- if(inboundItemResponse.getFromItemId()!=null){
|
|
|
- //赋值 (这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
- PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
- purchaseItem.setItemId(inboundItemResponse.getFromItemId());
|
|
|
- purchaseItem.setIntoQty(inboundItemResponse.getIntoQty().negate());
|
|
|
- purchaseItem.setIntoAmt(inboundItemResponse.getIntoAmt().negate());
|
|
|
- purchaseItem.setIntoingQty(inboundItemResponse.getIntoQty());
|
|
|
- purchaseItem.setIntoingAmt(inboundItemResponse.getIntoAmt());
|
|
|
- //根据id查询
|
|
|
- PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemResponse.getFromItemId());
|
|
|
- //入库状态
|
|
|
- String intoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
|
|
|
- purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()));
|
|
|
- purchaseItem.setIntoStatus(intoStatus);
|
|
|
- //修改
|
|
|
- int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
- //数量超出
|
|
|
- if (countRow == 0) {
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- //endregion
|
|
|
-
|
|
|
- //region修改入库明细信息
|
|
|
- InboundItem inboundItem = new InboundItem();
|
|
|
- inboundItem
|
|
|
- .setIntoId(inbound.getIntoId())
|
|
|
- .setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName())
|
|
|
- .setIntoingQty(inboundItemResponse.getIntoingQty().add(inboundItemResponse.getIntoQty()))
|
|
|
- .setIntoingAmt(inboundItemResponse.getIntoingAmt().add(inboundItemResponse.getIntoAmt()))
|
|
|
- .setIntoQty(BigDecimal.ZERO)
|
|
|
- .setIntoAmt(BigDecimal.ZERO)
|
|
|
- .setCostPrice(BigDecimal.ZERO)
|
|
|
- .setCostAmt(BigDecimal.ZERO)
|
|
|
- .setItemId(inboundItemResponse.getItemId());
|
|
|
- //修改
|
|
|
- inboundItemMapper.update(inboundItem,
|
|
|
- new UpdateWrapper<InboundItem>().lambda()
|
|
|
- .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
- );
|
|
|
- //endregion
|
|
|
- }
|
|
|
- //endregion
|
|
|
-
|
|
|
-
|
|
|
- //todo 调用库存 后续写库存这里补上
|
|
|
- //region 修改库存
|
|
|
-
|
|
|
- //endregion
|
|
|
-
|
|
|
- return ResponseResultUtil.success();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * @desc : 入库状态通用(目前本页面)
|
|
|
- * @date : 2024/3/9 8:59
|
|
|
- * @author : 寇珊珊
|
|
|
- */
|
|
|
- public String setIntoStatus(BigDecimal intoingQty, BigDecimal intoQty) {
|
|
|
- //入库状态
|
|
|
- String intoStatus = null;
|
|
|
- //已入库数量>0 入库中数量>0
|
|
|
- if (intoQty.compareTo(BigDecimal.ZERO) >= 0 && intoingQty.compareTo(BigDecimal.ZERO) > 0 ) {
|
|
|
- //入库中
|
|
|
- intoStatus = Constant.IntoStatus.RUKUZHONG.getName();
|
|
|
- }
|
|
|
- //已入库数量=0 入库中数量=0
|
|
|
- else if (intoQty.compareTo(BigDecimal.ZERO) == 0 && intoingQty.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
- //待入库
|
|
|
- intoStatus = Constant.IntoStatus.DAIRUKU.getName();
|
|
|
- }
|
|
|
- //已入库数量>0 入库中数量=0
|
|
|
- else if (intoQty.compareTo(BigDecimal.ZERO) >0 && intoingQty.compareTo(BigDecimal.ZERO)==0) {
|
|
|
- //已入库
|
|
|
- intoStatus = Constant.IntoStatus.YIRUKU.getName();
|
|
|
- }
|
|
|
- return intoStatus;
|
|
|
- }
|
|
|
-
|
|
|
+ //endregion
|
|
|
+ purchase.setIntoQty(sumIntoQty);
|
|
|
+ purchase.setIntoAmt(sumIntoAmt);
|
|
|
+ //todo 2024年3月25日14:50:41 取
|
|
|
+ if (inboundResponse != null) {
|
|
|
+ purchase.setIntoingQty(inboundResponse.getIntoingQty().negate());
|
|
|
+ purchase.setIntoingAmt(inboundResponse.getIntoingAmt().negate());
|
|
|
+ }
|
|
|
+// purchase.setIntoingQty(sumIntoQty.negate());
|
|
|
+// purchase.setIntoingAmt(sumIntoAmt.negate());
|
|
|
+ //根据id查询
|
|
|
+ PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
|
|
|
+ //入库状态
|
|
|
+ String purIntoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
+ purchaseResponse.getIntoQty().add(purchase.getIntoQty()));
|
|
|
+ purchase.setIntoStatus(purIntoStatus);
|
|
|
+ //修改
|
|
|
+ int countRow = purchaseMapper.updateById(purchase);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //todo 如果是已入库 调用库存 后续写库存这里补上
|
|
|
+ //region 修改库存
|
|
|
+
|
|
|
+ //endregion
|
|
|
+ return ResponseResultUtil.success(inboundVO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 采购入库撤销
|
|
|
+ * @date : 2024/3/7 17:06
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ public ResponseResultVO<?> purchaseInboundCancel(InboundVO inboundVO) {
|
|
|
+ //region 查询入库总单数据信息
|
|
|
+ InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 修改订单数据信息
|
|
|
+ if (inboundResponse.getFromId() != null) {
|
|
|
+ //赋值 (这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
+ Purchase purchase = new Purchase();
|
|
|
+ purchase.setPurId(inboundResponse.getFromId());
|
|
|
+ purchase.setIntoQty(inboundResponse.getIntoQty().negate());
|
|
|
+ purchase.setIntoAmt(inboundResponse.getIntoAmt().negate());
|
|
|
+ purchase.setIntoingQty(inboundResponse.getIntoQty());
|
|
|
+ purchase.setIntoingAmt(inboundResponse.getIntoAmt());
|
|
|
+ //根据id查询
|
|
|
+ PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
|
|
|
+ //入库状态
|
|
|
+ String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
+ purchaseResponse.getIntoQty().add(purchase.getIntoQty()));
|
|
|
+ purchase.setIntoStatus(intoStatus);
|
|
|
+ int countRow = purchaseMapper.updateById(purchase);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 修改总单数据信息
|
|
|
+ Inbound inbound = new Inbound();
|
|
|
+ inbound.setIntoId(inboundVO.getIntoId());
|
|
|
+ inbound.setIntoDate(null);
|
|
|
+ inbound.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
|
|
|
+ inbound.setIntoingQty(inboundResponse.getIntoingQty().add(inboundResponse.getIntoQty()));
|
|
|
+ inbound.setIntoingAmt(inboundResponse.getIntoingAmt().add(inboundResponse.getIntoAmt()));
|
|
|
+ inbound.setIntoQty(BigDecimal.ZERO);
|
|
|
+ inbound.setIntoAmt(BigDecimal.ZERO);
|
|
|
+ //修改
|
|
|
+ inboundMapper.update(inbound,
|
|
|
+ new UpdateWrapper<Inbound>().lambda()
|
|
|
+ .eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
|
|
|
+ );
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 明细数据
|
|
|
+ //根据总单id查明细
|
|
|
+ List<InboundItemResponse> orderEntryItemResponsesList = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(inbound.getIntoId()));
|
|
|
+ for (InboundItemResponse inboundItemResponse : orderEntryItemResponsesList) {
|
|
|
+ //region 修改采购明细数据信息
|
|
|
+ if (inboundItemResponse.getFromItemId() != null) {
|
|
|
+ //赋值 (这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
+ PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
+ purchaseItem.setItemId(inboundItemResponse.getFromItemId());
|
|
|
+ purchaseItem.setIntoQty(inboundItemResponse.getIntoQty().negate());
|
|
|
+ purchaseItem.setIntoAmt(inboundItemResponse.getIntoAmt().negate());
|
|
|
+ purchaseItem.setIntoingQty(inboundItemResponse.getIntoQty());
|
|
|
+ purchaseItem.setIntoingAmt(inboundItemResponse.getIntoAmt());
|
|
|
+ //根据id查询
|
|
|
+ PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemResponse.getFromItemId());
|
|
|
+ //入库状态
|
|
|
+ String intoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
|
|
|
+ purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()));
|
|
|
+ purchaseItem.setIntoStatus(intoStatus);
|
|
|
+ //修改
|
|
|
+ int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region修改入库明细信息
|
|
|
+ InboundItem inboundItem = new InboundItem();
|
|
|
+ inboundItem
|
|
|
+ .setIntoId(inbound.getIntoId())
|
|
|
+ .setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName())
|
|
|
+ .setIntoingQty(inboundItemResponse.getIntoingQty().add(inboundItemResponse.getIntoQty()))
|
|
|
+ .setIntoingAmt(inboundItemResponse.getIntoingAmt().add(inboundItemResponse.getIntoAmt()))
|
|
|
+ .setIntoQty(BigDecimal.ZERO)
|
|
|
+ .setIntoAmt(BigDecimal.ZERO)
|
|
|
+ .setCostPrice(BigDecimal.ZERO)
|
|
|
+ .setCostAmt(BigDecimal.ZERO)
|
|
|
+ .setItemId(inboundItemResponse.getItemId());
|
|
|
+ //修改
|
|
|
+ inboundItemMapper.update(inboundItem,
|
|
|
+ new UpdateWrapper<InboundItem>().lambda()
|
|
|
+ .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
+ );
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+
|
|
|
+ //todo 调用库存 后续写库存这里补上
|
|
|
+ //region 修改库存
|
|
|
+
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ return ResponseResultUtil.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 入库状态通用(目前本页面)
|
|
|
+ * @date : 2024/3/9 8:59
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ public String setIntoStatus(BigDecimal intoingQty, BigDecimal intoQty) {
|
|
|
+ //入库状态
|
|
|
+ String intoStatus = null;
|
|
|
+ //已入库数量>0 入库中数量>0
|
|
|
+ if (intoQty.compareTo(BigDecimal.ZERO) >= 0 && intoingQty.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ //入库中
|
|
|
+ intoStatus = Constant.IntoStatus.RUKUZHONG.getName();
|
|
|
+ }
|
|
|
+ //已入库数量=0 入库中数量=0
|
|
|
+ else if (intoQty.compareTo(BigDecimal.ZERO) == 0 && intoingQty.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ //待入库
|
|
|
+ intoStatus = Constant.IntoStatus.DAIRUKU.getName();
|
|
|
+ }
|
|
|
+ //已入库数量>0 入库中数量=0
|
|
|
+ else if (intoQty.compareTo(BigDecimal.ZERO) > 0 && intoingQty.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ //已入库
|
|
|
+ intoStatus = Constant.IntoStatus.YIRUKU.getName();
|
|
|
+ }
|
|
|
+ return intoStatus;
|
|
|
+ }
|
|
|
+
|
|
|
}
|