| | |
| | | package com.vincent.rsf.server.manager.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.manager.controller.params.QlyInspectAndItem; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrder; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrderItem; |
| | | import com.vincent.rsf.server.manager.entity.QlyIsptItem; |
| | | import com.vincent.rsf.server.manager.mapper.QlyInspectMapper; |
| | | import com.vincent.rsf.server.manager.entity.QlyInspect; |
| | | import com.vincent.rsf.server.manager.service.AsnOrderItemService; |
| | | import com.vincent.rsf.server.manager.service.AsnOrderService; |
| | | import com.vincent.rsf.server.manager.service.QlyInspectService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vincent.rsf.server.manager.service.QlyIsptItemService; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | @Service("qlyInspectService") |
| | | public class QlyInspectServiceImpl extends ServiceImpl<QlyInspectMapper, QlyInspect> implements QlyInspectService { |
| | | |
| | | @Autowired |
| | | private AsnOrderItemService asnOrderItemService; |
| | | |
| | | @Autowired |
| | | private AsnOrderService asnOrderService; |
| | | |
| | | @Autowired |
| | | private QlyIsptItemService qlyIsptItemService; |
| | | |
| | | @Override |
| | | public List<AsnOrderItem> listByAsn(Map<String, Object> map) { |
| | | if (Objects.isNull(map.get("asnCode"))) { |
| | | throw new CoolException("收货单据明细编码不能为空!!"); |
| | | } |
| | | AsnOrder asnOrder = asnOrderService.getOne(new LambdaQueryWrapper<AsnOrder>() |
| | | .eq(AsnOrder::getCode, map.get("asnCode")) |
| | | .ne(AsnOrder::getNtyStatus, 0)); |
| | | if (Objects.isNull(asnOrder)) { |
| | | throw new CoolException("单据不存在!!"); |
| | | } |
| | | List<AsnOrderItem> asnOrderItems = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>() |
| | | .eq(AsnOrderItem::getAsnCode, map.get("asnCode")) |
| | | .eq(AsnOrderItem::getNtyStatus, 1)); |
| | | if (asnOrderItems.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return asnOrderItems; |
| | | } |
| | | |
| | | @Override |
| | | public R allSave(QlyInspectAndItem params) { |
| | | if (Objects.isNull(params.getQlyInspect())) { |
| | | throw new CoolException("质检单据不能为空!!"); |
| | | } |
| | | QlyInspect inspect = params.getQlyInspect(); |
| | | if (Objects.isNull(inspect.getWkType())) { |
| | | throw new CoolException("业务类型不能为空!!"); |
| | | } |
| | | String code = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_INSPECT_WK_TYPE, inspect); |
| | | inspect.setCode(code); |
| | | if (!this.saveOrUpdate(inspect)) { |
| | | throw new CoolException("质检单保存失败!!"); |
| | | } |
| | | List<QlyIsptItem> isptItems = params.getQlyIsptItems(); |
| | | if (isptItems.isEmpty()) { |
| | | return R.ok("保存成功!!"); |
| | | } |
| | | List<QlyIsptItem> items = new ArrayList<>(); |
| | | for (QlyIsptItem isptItem : isptItems) { |
| | | if (Objects.isNull(isptItem.getMatnrCode())) { |
| | | continue; |
| | | } |
| | | isptItem.setIspectId(inspect.getId()); |
| | | items.add(isptItem); |
| | | } |
| | | if (!qlyIsptItemService.saveOrUpdateBatch(items)) { |
| | | throw new CoolException("质检明细保存失败!!"); |
| | | } |
| | | return R.ok("保存成功!!"); |
| | | } |
| | | } |