package com.fzzy.igds.sys;
|
|
import com.fzzy.igds.dzhwk.domain.DepotStatusConfirm;
|
import com.fzzy.igds.dzhwk.domain.DepotStore;
|
import com.fzzy.igds.sys.repository.DepotStoreRepository;
|
import com.fzzy.igds.util.ContextUtil;
|
import com.ruoyi.common.utils.StringUtils;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* @Description
|
* @Author CZT
|
* @Date 2024/11/23 11:29
|
*/
|
@Slf4j
|
@Service("sys.depotStoreService")
|
public class DepotStoreService {
|
|
@Resource
|
private DepotStoreRepository depotStoreRepository;
|
|
/**
|
* JPA分页查询数据
|
*
|
* @param specification
|
* @param pageable
|
* @return
|
*/
|
public Page<DepotStore> findAll(Specification<DepotStore> specification, Pageable pageable) {
|
return depotStoreRepository.findAll(specification, pageable);
|
}
|
|
/**
|
* JPA更新保存数据
|
* @param data
|
*/
|
public void saveDepotStore(DepotStore data) {
|
if (StringUtils.isEmpty(data.getCompanyId())) {
|
data.setCompanyId(ContextUtil.getCompanyId());
|
}
|
if (StringUtils.isEmpty(data.getDeptId())) {
|
data.setDeptId(ContextUtil.subDeptId(null));
|
}
|
data.setUpdateUser(ContextUtil.getLoginUserCName());
|
data.setUpdateDate(new Date());
|
|
data.setId(data.getDepotId() + "_" + DateFormatUtils.format(data.getStoreDate(), "yyyyMMddHHmmss") + "_" + DateFormatUtils.format(data.getUpdateDate(), "yyyyMMddHHmmss"));
|
data.setCreateDate(new Date());
|
data.setRemark("系统生成");
|
|
depotStoreRepository.save(data);
|
}
|
|
/**
|
* JPA删除数据
|
* @param data
|
* @return
|
*/
|
public String delDepotStore(DepotStore data) {
|
depotStoreRepository.delete(data);
|
return null;
|
}
|
|
/**
|
* JPA获取仓库最后一条库存数据
|
* @param depotId
|
* @param time
|
* @return
|
*/
|
public DepotStore getLastData(String depotId, Date time) {
|
List<DepotStore> list = depotStoreRepository.getDataByDepotId(depotId, time);
|
if(null == list || list.isEmpty()){
|
return null;
|
}
|
return list.get(0);
|
}
|
|
/**
|
* 根据封仓确认单信息增加库存
|
* @param data
|
*/
|
public void depotStoreStatus(DepotStatusConfirm data) {
|
// 根据最后一车进行汇总统计,开始时间是仓库库存最后一个时间截止到当前
|
DepotStore lastStore = this.getLastData(data.getDepotId(), new Date());
|
|
lastStore.setRemark("封仓确认");
|
lastStore.setFullDate(data.getFcrq());
|
lastStore.setDepotStatus("3");
|
lastStore.setUpdateUser("系统管理员");
|
lastStore.setStorageReal(data.getFcsl());
|
lastStore.setUpdateDate(new Date());
|
lastStore.setCreateDate(new Date());
|
lastStore.setId(null);
|
this.saveDepotStore(lastStore);
|
}
|
|
public void addDepotStore(DepotStore store, boolean updateDepot) {
|
// if (null == store.getUpdateDate()) store.setUpdateDate(new Date());
|
// if (null == store.getId()) store.setId(ContextUtil.getUUID());
|
// if (null == store.getManageType() || "".equals(store.getManageType())) {
|
// store.setManageType("01");
|
// }
|
//
|
// commonMapper.addDepotStore(store);
|
//
|
//
|
// if (updateDepot) {
|
// DepotParam param = new DepotParam();
|
// param.setCompanyId(store.getCompanyId());
|
// param.setDepotId(store.getDepotId());
|
// param.setWeight(store.getStorageReal());
|
// param.setDepotStatus(store.getDepotStatus());
|
//
|
// commonMapper.updateDepotStorage(param);
|
// }
|
}
|
|
|
|
}
|