| | |
| | | import com.gkhy.exam.system.service.PurchaseApplyService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | |
| | | purchaseApply.setCreateTime(LocalDateTime.now()); |
| | | purchaseApply.setCreateBy(SecurityUtils.getUsername()); |
| | | applyMapper.insert(purchaseApply); |
| | | List<PurchaseApplyPlan> purchaseApplyPlans = purchaseApply.getPurchaseApplyPlans(); |
| | | for (PurchaseApplyPlan purchaseApplyPlan : purchaseApplyPlans) { |
| | | purchaseApplyPlan.setApplyId(purchaseApply.getId()); |
| | | if (!CollectionUtils.isEmpty(purchaseApply.getPurchaseApplyPlans())){ |
| | | List<PurchaseApplyPlan> purchaseApplyPlans = purchaseApply.getPurchaseApplyPlans(); |
| | | for (PurchaseApplyPlan purchaseApplyPlan : purchaseApplyPlans) { |
| | | purchaseApplyPlan.setApplyId(purchaseApply.getId()); |
| | | } |
| | | applyPlanMapper.insertPlans(purchaseApplyPlans); |
| | | } |
| | | applyPlanMapper.insertPlans(purchaseApplyPlans); |
| | | return CommonResult.success(); |
| | | } |
| | | |
| | |
| | | purchaseApply.setUpdateTime(LocalDateTime.now()); |
| | | purchaseApply.setUpdateBy(SecurityUtils.getUsername()); |
| | | applyMapper.updateById(purchaseApply); |
| | | List<PurchaseApplyPlan> purchaseApplyPlans = purchaseApply.getPurchaseApplyPlans(); |
| | | applyPlanMapper.deletedByIds(purchaseApply.getId()); |
| | | applyPlanMapper.insertPlans(purchaseApplyPlans); |
| | | if (!CollectionUtils.isEmpty(purchaseApply.getPurchaseApplyPlans())){ |
| | | List<PurchaseApplyPlan> purchaseApplyPlans = purchaseApply.getPurchaseApplyPlans(); |
| | | applyPlanMapper.deletedByIds(purchaseApply.getId()); |
| | | applyPlanMapper.insertPlans(purchaseApplyPlans); |
| | | } |
| | | return CommonResult.success(); |
| | | } |
| | | |