package com.ld.igds.m.service.impl;
|
|
import java.util.List;
|
|
import com.ld.igds.constant.RedisConst;
|
import com.ld.igds.inout.InoutConstant;
|
import com.ld.igds.inout.dto.InoutParam;
|
import com.ld.igds.m.dto.NoticeInData;
|
import com.ld.igds.m.dto.NoticeParam;
|
import com.ld.igds.m.service.InoutCommonService;
|
import com.ld.igds.m.mapper.InoutCommonMapper;
|
import com.ld.igds.models.*;
|
import com.ld.igds.util.ContextUtil;
|
import com.ld.igds.util.RedisUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.stereotype.Repository;
|
|
import javax.annotation.Resource;
|
|
/**
|
* 出入库开始前的各种配置 --- 包含流程配置、出入库设备配置、通知单等
|
*
|
* @author chen
|
*/
|
@Slf4j
|
@Repository(InoutCommonService.BEAN_ID)
|
public class InoutCommonServiceImpl implements InoutCommonService {
|
|
@Resource
|
private RedisUtil redisUtil;
|
@Resource
|
private InoutCommonMapper inoutCommonMapper;
|
|
@Override
|
public void flushInoutSysConfCache(InoutSysConf data) {
|
String key = RedisConst.buildKey(data.getDeptId(), InoutConstant.CACHE_INOUT_SYS_CONF);
|
redisUtil.set(key, data);
|
}
|
|
@Override
|
public InoutSysConf getCacheInoutSysConf(String companyId, String deptId) {
|
String key = RedisConst.buildKey(deptId, InoutConstant.CACHE_INOUT_SYS_CONF);
|
return (InoutSysConf) redisUtil.get(key);
|
}
|
|
|
@Override
|
public void flushInoutConfCache(String companyId, String deptId) {
|
List<InoutConf> list = inoutCommonMapper.listInoutConf(companyId, deptId);
|
|
String key = RedisConst.buildKey(companyId, InoutConstant.CACHE_INOUT_CONF_LIST, deptId);
|
redisUtil.set(key, list);
|
}
|
|
|
@SuppressWarnings("unchecked")
|
@Override
|
public List<InoutConf> getCacheInoutConf(String companyId, String deptId) {
|
String key = RedisConst.buildKey(companyId, InoutConstant.CACHE_INOUT_CONF_LIST, deptId);
|
return (List<InoutConf>) redisUtil.get(key);
|
}
|
|
@Override
|
public InoutConf getCacheInoutConf(String companyId, String deptId, String confId) {
|
|
if (null == companyId || null == deptId || null == confId) {
|
return null;
|
}
|
|
List<InoutConf> list = getCacheInoutConf(companyId, deptId);
|
|
if (list != null && list.size() > 0) {
|
for (InoutConf inoutConf : list) {
|
if (inoutConf.getId().equals(confId)) {
|
return inoutConf;
|
}
|
}
|
}
|
return null;
|
}
|
|
@Override
|
public void updateInoutConfStatus(String ip, Integer port, String status) {
|
inoutCommonMapper.updateInoutConfStatus(ip, port, status);
|
}
|
|
@Override
|
public List<InoutCustomer> listCustomer(InoutParam param) {
|
if (StringUtils.isEmpty(param.getCompanyId())) {
|
param.setCompanyId(ContextUtil.getCompanyId());
|
}
|
if (StringUtils.isNotEmpty(param.getKey())) {
|
param.setKey("%" + param.getKey() + "%");
|
}
|
return inoutCommonMapper.listCustomer(param);
|
}
|
|
@Override
|
public int updateCustomer(NoticeInData data) {
|
return inoutCommonMapper.updateCustomer(data);
|
}
|
|
@Override
|
public String getMaxCustomerId(String companyId) {
|
if (StringUtils.isEmpty(companyId)) {
|
companyId = ContextUtil.getCompanyId();
|
}
|
|
return inoutCommonMapper.getMaxCustomerId(companyId);
|
}
|
|
|
@Override
|
public int updateNoticeIn(NoticeInData data) {
|
int i = inoutCommonMapper.updateNoticeIn(data);
|
if (i == 0) {
|
log.info("系统中没有更新到当前用户任务信息,新增一个客户任务!");
|
|
InoutNoticeIn param = new InoutNoticeIn();
|
param.setCompanyId(data.getCompanyId());
|
param.setCustomerId(data.getCustomerId());
|
param.setCustomerName(data.getCustomerName());
|
param.setDeptId(data.getDeptId());
|
param.setFoodVariety(data.getFoodVariety());
|
param.setTargetNumber(data.getTargetNumber());
|
param.setCompleteStatus(InoutConstant.COMPLETE_STATUS_NONE);
|
param.setYear(data.getYear());
|
param.setName("入库通知单");
|
param.setCreateUser(data.getCreateUser());
|
param.setId(data.getId());
|
inoutCommonMapper.addNoticeIn(param);
|
}
|
return i;
|
}
|
|
@Override
|
public List<InoutNoticeIn> getUnComNoticeIn(String companyId) {
|
return inoutCommonMapper.getUnComNoticeIn(companyId);
|
}
|
|
@Override
|
public String reSumNoticeInComplete(NoticeParam param) {
|
if (StringUtils.isEmpty(param.getCustomerId())) {
|
return "客户编码为空!";
|
}
|
if (StringUtils.isEmpty(param.getFoodVariety())) {
|
return "粮食品种为空!";
|
}
|
if (StringUtils.isEmpty(param.getCompanyId())) {
|
param.setCompanyId(ContextUtil.getCompanyId());
|
}
|
if (StringUtils.isEmpty(param.getDeptId())) {
|
param.setDeptId(ContextUtil.subDeptId(null));
|
}
|
inoutCommonMapper.reSumNoticeInComplete(param);
|
return null;
|
}
|
|
@Override
|
public Integer queryNoticeOut(NoticeParam param) {
|
return inoutCommonMapper.queryNoticeOut(param);
|
}
|
|
@Override
|
public Integer queryNoticeIn(NoticeParam param) {
|
return inoutCommonMapper.queryNoticeIn(param);
|
}
|
|
|
@Override
|
public List<InoutNoticeOut> getUnComNoticeOut(String companyId) {
|
return inoutCommonMapper.getUnComNoticeOut(companyId);
|
}
|
|
|
@Override
|
public String reSumNoticeOutComplete(NoticeParam param) {
|
if (StringUtils.isEmpty(param.getCustomerId())) {
|
return "客户编码为空!";
|
}
|
if (StringUtils.isEmpty(param.getFoodVariety())) {
|
return "粮食品种为空!";
|
}
|
if (StringUtils.isEmpty(param.getDepotId())) {
|
return "仓库编码为空!";
|
}
|
if (StringUtils.isEmpty(param.getCompanyId())) {
|
param.setCompanyId(ContextUtil.getCompanyId());
|
}
|
if (StringUtils.isEmpty(param.getDeptId())) {
|
param.setDeptId(ContextUtil.subDeptId(null));
|
}
|
inoutCommonMapper.reSumNoticeOutComplete(param);
|
return null;
|
}
|
|
@Override
|
public void updateSumNoticeIn(String deptId, List<InoutNoticeIn> noticeInList) {
|
|
if (null == noticeInList || noticeInList.isEmpty()) {
|
return;
|
}
|
|
//遍历通知单
|
NoticeParam param;
|
for (InoutNoticeIn noticeIn : noticeInList) {
|
|
if (!deptId.equals(noticeIn.getDeptId())) {
|
continue;
|
}
|
|
param = new NoticeParam(noticeIn.getCompanyId(), noticeIn.getDeptId(),
|
noticeIn.getCustomerId(), noticeIn.getFoodVariety(), noticeIn.getId());
|
|
log.info("开始更新出库通知单={}", param.toString());
|
|
String msg = this.reSumNoticeInComplete(param);
|
if (msg != null) {
|
log.info("入库通知单完成量统计失败={},失败原因={}", param.toString(), msg);
|
}
|
}
|
}
|
|
@Override
|
public void updateSumNoticeOut(String deptId, List<InoutNoticeOut> noticeOutList) {
|
|
if (null == noticeOutList || noticeOutList.isEmpty()) {
|
return;
|
}
|
|
//遍历通知单
|
NoticeParam param;
|
for (InoutNoticeOut noticeOut : noticeOutList) {
|
|
if (!deptId.equals(noticeOut.getDeptId())) {
|
continue;
|
}
|
|
param = new NoticeParam(noticeOut.getCompanyId(), noticeOut.getDeptId(), noticeOut.getDepotId(),
|
noticeOut.getCustomerId(), noticeOut.getFoodVariety(), noticeOut.getId());
|
|
log.info("开始更新出库通知单={}", param.toString());
|
|
String msg = this.reSumNoticeOutComplete(param);
|
if (msg != null) {
|
log.info("出库通知单完成量统计失败={},失败原因={}", param.toString(), msg);
|
}
|
}
|
}
|
|
@Override
|
public List<InoutNoticeIn> listNoticeIn(NoticeParam param) {
|
return inoutCommonMapper.listNoticeIn(param);
|
}
|
|
@Override
|
public List<InoutNoticeOut> listNoticeOut(NoticeParam param) {
|
return inoutCommonMapper.listNoticeOut(param);
|
}
|
}
|