|
@@ -19,6 +19,7 @@ import com.platform.dao.enums.*;
|
|
import com.platform.dao.mapper.store.*;
|
|
import com.platform.dao.mapper.store.*;
|
|
import com.platform.dao.util.MessageTemplateUtil;
|
|
import com.platform.dao.util.MessageTemplateUtil;
|
|
import com.platform.dao.vo.query.store.*;
|
|
import com.platform.dao.vo.query.store.*;
|
|
|
|
+import com.platform.dao.vo.sb.SbInfoVO;
|
|
import com.platform.service.event.WorkplaceBacklogEvent;
|
|
import com.platform.service.event.WorkplaceBacklogEvent;
|
|
import com.platform.service.store.InStoreFormService;
|
|
import com.platform.service.store.InStoreFormService;
|
|
import com.platform.service.store.OutStoreFormService;
|
|
import com.platform.service.store.OutStoreFormService;
|
|
@@ -98,10 +99,10 @@ public class OutStoreFormServiceImpl extends BaseServiceImpl<OutStoreFormMapper,
|
|
OutStoreFormVO outStoreFormVO = new OutStoreFormVO();
|
|
OutStoreFormVO outStoreFormVO = new OutStoreFormVO();
|
|
BeanConverterUtil.copyObjectProperties(outStoreForm, outStoreFormVO);
|
|
BeanConverterUtil.copyObjectProperties(outStoreForm, outStoreFormVO);
|
|
// 详情列表
|
|
// 详情列表
|
|
- if (StringUtils.isNotBlank(outStoreForm.getStoreId())) {
|
|
|
|
|
|
+ /* if (StringUtils.isNotBlank(outStoreForm.getStoreId())) {
|
|
Store store = storeService.getModelById(outStoreForm.getStoreId());
|
|
Store store = storeService.getModelById(outStoreForm.getStoreId());
|
|
outStoreFormVO.setStoreName(store.getName());
|
|
outStoreFormVO.setStoreName(store.getName());
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
outStoreFormVO.setDetailList(mapper.selectDetailList(id));
|
|
outStoreFormVO.setDetailList(mapper.selectDetailList(id));
|
|
return outStoreFormVO;
|
|
return outStoreFormVO;
|
|
}
|
|
}
|
|
@@ -154,6 +155,11 @@ public class OutStoreFormServiceImpl extends BaseServiceImpl<OutStoreFormMapper,
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 判断出库是否是同一个仓库,不是则提示不能提交,请改
|
|
|
|
+ * @param model
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
public OutStoreForm saveModelByDTO(OutStoreFormDTO model) {
|
|
public OutStoreForm saveModelByDTO(OutStoreFormDTO model) {
|
|
UserInfo userInfo = SecurityUtils.getUserInfo();
|
|
UserInfo userInfo = SecurityUtils.getUserInfo();
|
|
@@ -167,13 +173,13 @@ public class OutStoreFormServiceImpl extends BaseServiceImpl<OutStoreFormMapper,
|
|
OutStoreForm outStoreForm = super.saveModelByDTO(model);
|
|
OutStoreForm outStoreForm = super.saveModelByDTO(model);
|
|
// 出库单详情
|
|
// 出库单详情
|
|
List<OutStoreDetailDTO> detailList = model.getDetailList();
|
|
List<OutStoreDetailDTO> detailList = model.getDetailList();
|
|
-
|
|
|
|
- // 获取领用单详情
|
|
|
|
- /*SparePickForm sparePickForm = null;
|
|
|
|
- if(model.getType().equals(OutStoreTypeEnum.CHUKU_LINGYONG.getValue())){
|
|
|
|
- sparePickForm = sparePickFormMapper.selectByPrimaryKey(model.getPickId());
|
|
|
|
- }*/
|
|
|
|
- BigDecimal totalPrice = new BigDecimal(0);
|
|
|
|
|
|
+ List<String> storeIds = detailList.stream().map(OutStoreDetailDTO::getStoreId).distinct().collect(Collectors.toList());
|
|
|
|
+ if(CollectionUtils.isEmpty(storeIds)){
|
|
|
|
+ throw new BusinessException("请选择仓库备件");
|
|
|
|
+ }
|
|
|
|
+ if(storeIds.size()>1){
|
|
|
|
+ throw new BusinessException("请从同一个仓库选择备件");
|
|
|
|
+ }
|
|
|
|
|
|
// 判断备件是否在该仓库里面,出库单已经勾选了仓库。这个不允许了,pc和移动端都不允许
|
|
// 判断备件是否在该仓库里面,出库单已经勾选了仓库。这个不允许了,pc和移动端都不允许
|
|
for (OutStoreDetailDTO detail : detailList) {
|
|
for (OutStoreDetailDTO detail : detailList) {
|
|
@@ -198,8 +204,6 @@ public class OutStoreFormServiceImpl extends BaseServiceImpl<OutStoreFormMapper,
|
|
}
|
|
}
|
|
// detail.setStoreId(outStoreForm.getStoreId());
|
|
// detail.setStoreId(outStoreForm.getStoreId());
|
|
detail.setId(IdGeneratorUtils.getObjectId());
|
|
detail.setId(IdGeneratorUtils.getObjectId());
|
|
- detail.setTotalPrice(detail.getNum().multiply(detail.getPrice()));
|
|
|
|
- totalPrice = totalPrice.add(detail.getTotalPrice());
|
|
|
|
detail.setOutNo(outStoreForm.getOutNo());
|
|
detail.setOutNo(outStoreForm.getOutNo());
|
|
OutStoreDetail storeDetail = new OutStoreDetail();
|
|
OutStoreDetail storeDetail = new OutStoreDetail();
|
|
BeanConverterUtil.copyObjectProperties(detail, storeDetail);
|
|
BeanConverterUtil.copyObjectProperties(detail, storeDetail);
|
|
@@ -208,13 +212,52 @@ public class OutStoreFormServiceImpl extends BaseServiceImpl<OutStoreFormMapper,
|
|
detailMapper.insertSelective(storeDetail);
|
|
detailMapper.insertSelective(storeDetail);
|
|
|
|
|
|
}
|
|
}
|
|
- ;
|
|
|
|
- outStoreForm.setTotalPrice(totalPrice);
|
|
|
|
mapper.updateByPrimaryKey(outStoreForm);
|
|
mapper.updateByPrimaryKey(outStoreForm);
|
|
updateStore(outStoreForm.getId());
|
|
updateStore(outStoreForm.getId());
|
|
return outStoreForm;
|
|
return outStoreForm;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 判断出库是否是同一个仓库,不是则提示不能提交,请改
|
|
|
|
+ * @param model
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public OutStoreForm saveModelByDTOYY(OutStoreFormDTO model) {
|
|
|
|
+ UserInfo userInfo = SecurityUtils.getUserInfo();
|
|
|
|
+ Weekend<OutStoreForm> weekend = new Weekend<>(OutStoreForm.class);
|
|
|
|
+ weekend.weekendCriteria().andIsNotNull(OutStoreForm::getId);
|
|
|
|
+ Integer count = mapper.selectCountByExample(weekend);
|
|
|
|
+ model.setOutNo(IdGeneratorUtils.getOutStoreNo(++count));
|
|
|
|
+ model.setDelFlag(false);
|
|
|
|
+ model.setUserInfo(userInfo);
|
|
|
|
+ model.setStatus(OutStoreStatusEnum.NOT_EXECUTE.getValue());
|
|
|
|
+ // 出库单详情
|
|
|
|
+ List<OutStoreDetailDTO> detailList = model.getDetailList();
|
|
|
|
+ List<String> storeIds = detailList.stream().map(OutStoreDetailDTO::getStoreId).distinct().collect(Collectors.toList());
|
|
|
|
+ if(CollectionUtils.isEmpty(storeIds)){
|
|
|
|
+ throw new BusinessException("请选择仓库备件");
|
|
|
|
+ }
|
|
|
|
+ if(storeIds.size()>1){
|
|
|
|
+ throw new BusinessException("请从同一个仓库选择备件");
|
|
|
|
+ }
|
|
|
|
+ model.setStoreId(detailList.get(0).getStoreId());
|
|
|
|
+ model.setStoreName(detailList.get(0).getStoreName());
|
|
|
|
+ OutStoreForm outStoreForm = super.saveModelByDTO(model);
|
|
|
|
+ // 插
|
|
|
|
+ for (OutStoreDetailDTO detail : detailList) {
|
|
|
|
+ detail.setUserInfo(userInfo);
|
|
|
|
+ detail.setOutId(outStoreForm.getId());
|
|
|
|
+ detail.setOutNo(outStoreForm.getOutNo());
|
|
|
|
+ OutStoreDetail storeDetail = new OutStoreDetail();
|
|
|
|
+ BeanConverterUtil.copyObjectProperties(detail, storeDetail);
|
|
|
|
+ storeDetail.setId(IdGeneratorUtils.getObjectId());
|
|
|
|
+ detailMapper.insertSelective(storeDetail);
|
|
|
|
+ }
|
|
|
|
+ // mapper.updateByPrimaryKey(outStoreForm);
|
|
|
|
+ return outStoreForm;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 更新出库单状态,更新库存信息,当仓库员点击确定后,领用时申请触发的出库单则自动出库
|
|
* 更新出库单状态,更新库存信息,当仓库员点击确定后,领用时申请触发的出库单则自动出库
|
|
* 在之前还没有出库
|
|
* 在之前还没有出库
|
|
@@ -390,6 +433,71 @@ public class OutStoreFormServiceImpl extends BaseServiceImpl<OutStoreFormMapper,
|
|
super.modModelByDTO(model);
|
|
super.modModelByDTO(model);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 更新和新增不涉及到库存,只有在提交动作更新库存,且提交后不能更改(不用回滚库存)
|
|
|
|
+ *
|
|
|
|
+ * @param model
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void updateModelByDTOYY(OutStoreFormDTO model) {
|
|
|
|
+
|
|
|
|
+ // 出库单详情
|
|
|
|
+ UserInfo userInfo = SecurityUtils.getUserInfo();
|
|
|
|
+ List<OutStoreDetailDTO> detailList = model.getDetailList();
|
|
|
|
+ List<String> storeIds = detailList.stream().map(OutStoreDetailDTO::getStoreId).distinct().collect(Collectors.toList());
|
|
|
|
+ if(CollectionUtils.isEmpty(storeIds)){
|
|
|
|
+ throw new BusinessException("请选择仓库备件");
|
|
|
|
+ }
|
|
|
|
+ if(storeIds.size()>1){
|
|
|
|
+ throw new BusinessException("请从同一个仓库选择备件");
|
|
|
|
+ }
|
|
|
|
+ // 先删后插,前端删除的不存在与ids里面,说明被删掉了,需要删除,同时要更新对应的库存
|
|
|
|
+ Weekend<OutStoreDetail> detailWeekend = new Weekend<>(OutStoreDetail.class);
|
|
|
|
+ List<String> ids = detailList.stream().map(OutStoreDetailDTO::getId).collect(Collectors.toList());
|
|
|
|
+ detailWeekend.weekendCriteria().andNotIn(OutStoreDetail::getId, ids).andEqualTo(OutStoreDetail::getOutId, model.getId());
|
|
|
|
+ detailMapper.deleteByExample(detailWeekend);
|
|
|
|
+
|
|
|
|
+ // 更新和新增
|
|
|
|
+ List<OutStoreDetail> updateDetailList = new ArrayList<OutStoreDetail>();
|
|
|
|
+ List<OutStoreDetail> addDetailList = new ArrayList<OutStoreDetail>();
|
|
|
|
+
|
|
|
|
+ BigDecimal totalPrice = new BigDecimal(0);
|
|
|
|
+ // 新增
|
|
|
|
+ for (OutStoreDetailDTO detail : detailList) {
|
|
|
|
+ OutStoreDetail realDetail = detailMapper.selectByPrimaryKey(detail.getId());
|
|
|
|
+ if (ObjectUtil.isNull(realDetail)) {
|
|
|
|
+ detail.setUserInfo(userInfo);
|
|
|
|
+ detail.setOutId(model.getId());
|
|
|
|
+ if (StringUtils.isNotBlank(model.getStoreId())) {
|
|
|
|
+ detail.setStoreId(model.getStoreId());
|
|
|
|
+ }
|
|
|
|
+ //detail.setStoreId(model.getStoreId());
|
|
|
|
+ detail.setOutNo(model.getOutNo());
|
|
|
|
+ OutStoreDetail storeDetail = new OutStoreDetail();
|
|
|
|
+ BeanConverterUtil.copyObjectProperties(detail, storeDetail);
|
|
|
|
+ storeDetail.setId(IdGeneratorUtils.getObjectId());
|
|
|
|
+ addDetailList.add(storeDetail);
|
|
|
|
+ } else {// 修改数量的
|
|
|
|
+ detail.setTotalPrice(detail.getNum().multiply(detail.getPrice()));
|
|
|
|
+ totalPrice = totalPrice.add(detail.getTotalPrice());
|
|
|
|
+ OutStoreDetail storeDetail = new OutStoreDetail();
|
|
|
|
+ BeanConverterUtil.copyObjectProperties(detail, storeDetail);
|
|
|
|
+ updateDetailList.add(storeDetail);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ;
|
|
|
|
+
|
|
|
|
+ if (!CollectionUtils.isEmpty(addDetailList)) {
|
|
|
|
+ detailMapper.insertListforComplex(addDetailList);
|
|
|
|
+ }
|
|
|
|
+ if (!CollectionUtils.isEmpty(updateDetailList)) {
|
|
|
|
+ detailMapper.updateBatch(updateDetailList);
|
|
|
|
+ }
|
|
|
|
+ // 更新
|
|
|
|
+ model.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ super.modModelByDTO(model);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 领用直接生成出库单,但是出库单未提交,不修改实际库存
|
|
* 领用直接生成出库单,但是出库单未提交,不修改实际库存
|
|
*
|
|
*
|