| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.mapper.InspectUnacceptedMapper; |
| | | import com.yuanchu.mom.mapper.RepertoryMapper; |
| | | import com.yuanchu.mom.pojo.FinishedInspect; |
| | | import com.yuanchu.mom.mapper.FinishedInspectMapper; |
| | | import com.yuanchu.mom.pojo.InspectUnaccepted; |
| | | import com.yuanchu.mom.pojo.Repertory; |
| | | import com.yuanchu.mom.service.FinishedInspectService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.service.InspectionItemService; |
| | | import com.yuanchu.mom.service.ProductService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author 江苏鵷雏网络科技有限公司 |
| | |
| | | @Resource |
| | | InspectUnacceptedMapper inspectUnacceptedMapper; |
| | | |
| | | @Resource |
| | | RepertoryMapper repertoryMapper; |
| | | |
| | | @Override |
| | | public Integer addProcessInspectionSheet(FinishedInspect finishedInspect) { |
| | | finishedInspect.setType(0); |
| | | int insert = finishedInspectMapper.insert(finishedInspect); |
| | | if (insert == 1){ |
| | | if (insert == 1) { |
| | | List<Map<String, Object>> maps = productService.selectProductList(finishedInspect.getSpecificationsId()); |
| | | inspectionItemService.insertList(finishedInspect.getId(), maps); |
| | | return insert; |
| | |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Integer inspectionConclusion(Integer finishedInspectId, Integer result) { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Integer inspectionConclusion(String username, Integer finishedInspectId, Integer result) { |
| | | //更新检验单里面的检验结论 |
| | | LambdaUpdateWrapper<FinishedInspect> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(FinishedInspect::getId, finishedInspectId); |
| | | updateWrapper.set(FinishedInspect::getResult, result); |
| | | finishedInspectMapper.update(new FinishedInspect(), updateWrapper); |
| | | //如果检验结论为不合格,则需要新增不合格检验单 |
| | | //如果检验结论为不合格,则需要新增不合格检验单,还需要新增半成品库存 |
| | | FinishedInspect finishedInspect = finishedInspectMapper.selectById(finishedInspectId); |
| | | if (result == 0) { |
| | | /*新增不合格检验单*/ |
| | | InspectUnaccepted inspectUnaccepted = InspectUnaccepted.builder() |
| | | .reason(finishedInspect.getProjectName() + "不合格") //暂且定义为工程名称不合格 |
| | | .rawInspectId(finishedInspectId) |
| | | .type(finishedInspect.getType()) |
| | | .build(); |
| | | inspectUnacceptedMapper.insert(inspectUnaccepted); |
| | | /*新增半成品(1)库存*/ |
| | | //如果入库的信息一样只有库存不一样,则在原来的库存数量上加上相应的数量 |
| | | LambdaQueryWrapper<Repertory> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Repertory::getOrderCode, finishedInspect.getOrderNumber()) |
| | | .eq(Repertory::getCode, finishedInspect.getMaterialCode()) |
| | | .eq(Repertory::getName, finishedInspect.getMaterial()) |
| | | .eq(Repertory::getSpecifications, finishedInspect.getSpecificationsModel()) |
| | | .eq(Repertory::getUnit, finishedInspect.getUnit()) |
| | | .eq(Repertory::getType, 1); |
| | | Repertory rep = repertoryMapper.selectOne(queryWrapper); |
| | | if (rep != null && rep.getCheckState()==1) { |
| | | rep.setNumber(rep.getNumber() + finishedInspect.getQuantity()); |
| | | rep.setUserName(username); |
| | | repertoryMapper.updateById(rep); |
| | | } else { |
| | | //如果除了库存别的信息有任何一个不一样,则新增一条半成品库存 |
| | | Repertory repertory = Repertory.builder() |
| | | .orderCode(finishedInspect.getOrderNumber()) |
| | | .code(finishedInspect.getMaterialCode()) |
| | | .name(finishedInspect.getMaterial()) |
| | | .specifications(finishedInspect.getSpecificationsModel()) |
| | | .unit(finishedInspect.getUnit()) |
| | | .number(finishedInspect.getQuantity()) |
| | | .userName(username) |
| | | .type(1) |
| | | .checkState(1) |
| | | .build(); |
| | | repertoryMapper.insert(repertory); |
| | | } |
| | | } |
| | | //如果检验合格,需要新增成品(0)库存 |
| | | if (result == 1) { |
| | | //如果入库的信息一样只有库存不一样,则在原来的库存数量上加上相应的数量 |
| | | LambdaQueryWrapper<Repertory> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Repertory::getOrderCode, finishedInspect.getOrderNumber()) |
| | | .eq(Repertory::getCode, finishedInspect.getMaterialCode()) |
| | | .eq(Repertory::getName, finishedInspect.getMaterial()) |
| | | .eq(Repertory::getSpecifications, finishedInspect.getSpecificationsModel()) |
| | | .eq(Repertory::getUnit, finishedInspect.getUnit()) |
| | | .eq(Repertory::getType, 0); |
| | | Repertory rep = repertoryMapper.selectOne(queryWrapper); |
| | | if (rep != null && rep.getCheckState()==1) { |
| | | rep.setNumber(rep.getNumber() + finishedInspect.getQuantity()); |
| | | rep.setUserName(username); |
| | | repertoryMapper.updateById(rep); |
| | | } else { |
| | | //如果除了库存别的信息有任何一个不一样,则新增一条成品库存 |
| | | Repertory repertory = Repertory.builder() |
| | | .orderCode(finishedInspect.getOrderNumber()) |
| | | .code(finishedInspect.getMaterialCode()) |
| | | .name(finishedInspect.getMaterial()) |
| | | .specifications(finishedInspect.getSpecificationsModel()) |
| | | .unit(finishedInspect.getUnit()) |
| | | .number(finishedInspect.getQuantity()) |
| | | .userName(username) |
| | | .type(0) |
| | | .checkState(1) |
| | | .build(); |
| | | repertoryMapper.insert(repertory); |
| | | } |
| | | } |
| | | return 1; |
| | | } |