| | |
| | | import com.yuanchu.mom.pojo.vo.SaleVo; |
| | | import com.yuanchu.mom.service.SaleService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | //根据销售单id修改信息 |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateSaleById(String saleman, Integer id, SaleVo saleVo) { |
| | | public String updateSaleById(String saleman, Integer id, SaleVo saleVo) { |
| | | //校验,同一个产品的规格型号不能相同 |
| | | List<SaleMaterialDto> saleMaterialList = saleVo.getSaleMaterialList(); |
| | | // 使用哈希集合来判断是否存在相同字段值组合 |
| | | Set<String> seen = new HashSet<>(); |
| | | for (SaleMaterialDto saleMaterial: saleMaterialList) { |
| | | String key = saleMaterial.getName() + "," + saleMaterial.getSpecifications(); |
| | | if (seen.contains(key)) { |
| | | return "同一个产品的规格型号不能相同"; |
| | | } else { |
| | | seen.add(key); |
| | | } |
| | | } |
| | | Sale sale = saleMapper.selectById(id); |
| | | sale.setSaleman(saleman); |
| | | BeanUtils.copyProperties(saleVo, sale); |
| | |
| | | BeanUtils.copyProperties(saleMaterialDto, saleMaterial); |
| | | saleMaterialMapper.updateById(saleMaterial); |
| | | } |
| | | return "修改成功!"; |
| | | } |
| | | |
| | | //审核 |