|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.common.utils.Assert;
|
|
|
import com.fjhx.sale.entity.pack.dto.PackDetailDto;
|
|
|
import com.fjhx.sale.entity.pack.dto.PackDetailSelectDto;
|
|
|
import com.fjhx.sale.entity.pack.enums.PackShipmentStatusEnum;
|
|
@@ -25,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -32,7 +34,7 @@ import java.util.List;
|
|
|
* 装箱出货明细表 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
- * @author
|
|
|
+ * @author
|
|
|
* @since 2023-04-18
|
|
|
*/
|
|
|
@Service
|
|
@@ -40,8 +42,10 @@ public class PackDetailServiceImpl extends ServiceImpl<PackDetailMapper, PackDet
|
|
|
|
|
|
@Autowired
|
|
|
private PackShipmentService packShipmentService;
|
|
|
+
|
|
|
/**
|
|
|
* 分页
|
|
|
+ *
|
|
|
* @param dto
|
|
|
* @return
|
|
|
*/
|
|
@@ -50,11 +54,11 @@ public class PackDetailServiceImpl extends ServiceImpl<PackDetailMapper, PackDet
|
|
|
IWrapper<PackDetail> wrapper = getWrapper();
|
|
|
wrapper.groupBy("t1.pack_id");
|
|
|
wrapper.orderByDesc("t1.create_time");
|
|
|
- if(ObjectUtil.isNotEmpty(dto.getShipmentStatus())){
|
|
|
- wrapper.eq("t1",PackDetailVo::getShipmentStatus,dto.getShipmentStatus());
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getShipmentStatus())) {
|
|
|
+ wrapper.eq("t1", PackDetailVo::getShipmentStatus, dto.getShipmentStatus());
|
|
|
}
|
|
|
- if(StringUtils.isNotEmpty(dto.getKeyword())){
|
|
|
- wrapper.keyword(dto.getKeyword(),new SqlField("t3.`code`"),new SqlField("t2.`product_name`"));
|
|
|
+ if (StringUtils.isNotEmpty(dto.getKeyword())) {
|
|
|
+ wrapper.keyword(dto.getKeyword(), new SqlField("t3.`code`"), new SqlField("t2.`product_name`"));
|
|
|
}
|
|
|
Page<PackDetailVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
return page;
|
|
@@ -84,24 +88,32 @@ public class PackDetailServiceImpl extends ServiceImpl<PackDetailMapper, PackDet
|
|
|
|
|
|
/**
|
|
|
* 出货
|
|
|
+ *
|
|
|
* @param ids
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void shipment(List<Long> ids,Long contractId) {
|
|
|
- if(CollectionUtils.isEmpty(ids)){
|
|
|
+ public void shipment(List<Long> ids, Long contractId) {
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
throw new ServiceException("最少选中一条记录");
|
|
|
}
|
|
|
- if(ObjectUtil.isEmpty(contractId)){
|
|
|
+ if (ObjectUtil.isEmpty(contractId)) {
|
|
|
throw new ServiceException("必须选择一条主合同");
|
|
|
}
|
|
|
+ //查询id对应的装箱id 把装箱id下的记录都出货
|
|
|
+ List<PackDetail> packDetails = this.listByIds(ids);
|
|
|
+ Assert.notEmpty(packDetails, "查询不到装箱明细信息");
|
|
|
+ if (packDetails.size() != ids.size()) {
|
|
|
+ throw new ServiceException("存在未知装箱明细");
|
|
|
+ }
|
|
|
+ List<Long> packIds = packDetails.stream().map(PackDetail::getPackId).collect(Collectors.toList());
|
|
|
this.update(Wrappers.<PackDetail>update().lambda()
|
|
|
- .set(PackDetail::getShipmentStatus,PackShipmentStatusEnum.STATUS_1.getKey())
|
|
|
- .set(PackDetail::getShipmentTime,new Date())
|
|
|
- .in(PackDetail::getId,ids));
|
|
|
+ .set(PackDetail::getShipmentStatus, PackShipmentStatusEnum.STATUS_1.getKey())
|
|
|
+ .set(PackDetail::getShipmentTime, new Date())
|
|
|
+ .in(PackDetail::getPackId, packIds));
|
|
|
//添加一条绑定主合同记录
|
|
|
PackShipment packShipment = new PackShipment();
|
|
|
- packShipment.setPackDetailIds(StringUtils.join(ids,","));
|
|
|
+ packShipment.setPackDetailIds(StringUtils.join(ids, ","));
|
|
|
packShipment.setContractId(contractId);
|
|
|
packShipmentService.save(packShipment);
|
|
|
}
|