|
@@ -19,6 +19,7 @@ import com.usoftchina.saas.exception.BizException;
|
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
@@ -32,6 +33,8 @@ public class WarehouseServiceImpl extends CommonBaseServiceImpl<WarehouseMapper,
|
|
|
private MessageLogService messageLogService;
|
|
private MessageLogService messageLogService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MaxnumberService maxnumberService;
|
|
private MaxnumberService maxnumberService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WarehouseMapper warehouseMapper;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public PageInfo<Warehouse> getListData(PageRequest page, ListReqDTO req) {
|
|
public PageInfo<Warehouse> getListData(PageRequest page, ListReqDTO req) {
|
|
@@ -195,11 +198,55 @@ public class WarehouseServiceImpl extends CommonBaseServiceImpl<WarehouseMapper,
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
|
|
for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
|
|
|
- getMapper().deleteByPrimaryKey(base.getId());
|
|
|
|
|
|
|
+ delete(base.getId());
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void delete(Long id) {
|
|
|
|
|
+ //删除前检测物料是否存在默认仓库
|
|
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
|
|
+ companyId = 1l;
|
|
|
|
|
+ Integer num = 0;
|
|
|
|
|
+ num = warehouseMapper.deleteCheckProduct(id, companyId);
|
|
|
|
|
+ if (num > 0) {
|
|
|
|
|
+ throw new BizException(BizExceptionCode.PRODUCT_HAS_WAREHOUSE);
|
|
|
|
|
+ }
|
|
|
|
|
+ //检测是否存在库存
|
|
|
|
|
+ num = warehouseMapper.deleteCheckWH(id, companyId);
|
|
|
|
|
+ if (num > 0) {
|
|
|
|
|
+ throw new BizException(BizExceptionCode.PRODUCTWH_HAS_WAREHOUSE);
|
|
|
|
|
+ }
|
|
|
|
|
+ singleDelete(id);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void singleDelete(Long id) {
|
|
|
|
|
+ if (null != id) {
|
|
|
|
|
+ //主表删除
|
|
|
|
|
+ getMapper().deleteByPrimaryKey(id);
|
|
|
|
|
+ DocBaseDTO docBaseDTO = getBaseDTOById(id);
|
|
|
|
|
+ //日志
|
|
|
|
|
+ messageLogService.delete(docBaseDTO);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @Description
|
|
|
|
|
+ * @Param: [id]
|
|
|
|
|
+ * @return: com.usoftchina.saas.commons.dto.DocBaseDTO
|
|
|
|
|
+ * @Author: guq
|
|
|
|
|
+ * @Date: 2018/10/22
|
|
|
|
|
+ */
|
|
|
|
|
+ private DocBaseDTO getBaseDTOById(Long id) {
|
|
|
|
|
+ if (null == id) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ String code = warehouseMapper.selectCodeById(id);
|
|
|
|
|
+ DocBaseDTO baseDTO = new DocBaseDTO(id, code, BillCodeSeq.WAREHOUSE.getCaller());
|
|
|
|
|
+ return baseDTO;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 构造 记录日志对象
|
|
* 构造 记录日志对象
|
|
|
* @param id
|
|
* @param id
|