|
|
@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.StringUtils; |
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.time.*; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.Set; |
|
|
import java.util.Set; |
|
|
@ -1868,6 +1869,77 @@ public class PhysicalInventoryServiceImpl extends ServiceImpl<PhysicalInventoryM |
|
|
return updateCount; |
|
|
return updateCount; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void manualHandleCount( CountResultData data){ |
|
|
|
|
|
CountResultData result = baseMapper.getCountResultById(data.getId()); |
|
|
|
|
|
if(result==null){ |
|
|
|
|
|
throw new RuntimeException("盘点结果标签不存在"); |
|
|
|
|
|
} |
|
|
|
|
|
if( "Y".equals(result.getHandleFlag())){ |
|
|
|
|
|
throw new RuntimeException("盘点结果标签已处理"); |
|
|
|
|
|
} |
|
|
|
|
|
if( CountResult.HANDLE_TYPE_SYSTEM.equals(data.getHandleType())){ |
|
|
|
|
|
throw new RuntimeException("后台数据不一致,请刷新界面"); |
|
|
|
|
|
} |
|
|
|
|
|
baseMapper.updateCountResultHandleFlagForId(data.getId(), "Y"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public String getSysIfCount(String site){ |
|
|
|
|
|
return baseMapper.getSysIfCount(site); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void updateSysIfCount(String site, String value) { |
|
|
|
|
|
String nowStatus=baseMapper.getSysIfCount(site); |
|
|
|
|
|
if("Y".equals( value)){ |
|
|
|
|
|
if("Y".equals(nowStatus)){ |
|
|
|
|
|
throw new RuntimeException("盘点模式已开启,无需重复开启"); |
|
|
|
|
|
} |
|
|
|
|
|
String strCycle=baseMapper.getSysCountCycle(site); |
|
|
|
|
|
Integer cycle=Integer.parseInt(strCycle); |
|
|
|
|
|
if (cycle <= 0 || cycle > 12) { |
|
|
|
|
|
throw new RuntimeException("盘点周期必须在1-12之间"); |
|
|
|
|
|
} |
|
|
|
|
|
YearMonth now = YearMonth.now(); // 获取当前年月 |
|
|
|
|
|
int currentMonth = now.getMonthValue(); // 1~12 |
|
|
|
|
|
// 计算当前处于第几个周期(从0开始) |
|
|
|
|
|
int lastCompletedCycleIndex = (currentMonth - 1) / cycle; |
|
|
|
|
|
|
|
|
|
|
|
int month; |
|
|
|
|
|
if (lastCompletedCycleIndex < 0) { |
|
|
|
|
|
month= 0; |
|
|
|
|
|
} else { |
|
|
|
|
|
// 上一周期的最后一个月 |
|
|
|
|
|
month= (lastCompletedCycleIndex ) * cycle; |
|
|
|
|
|
} |
|
|
|
|
|
// 获取当前年份 |
|
|
|
|
|
int currentYear = LocalDate.now().getYear(); |
|
|
|
|
|
YearMonth yearMonth = YearMonth.of(currentYear, month); |
|
|
|
|
|
LocalDate lastDay = yearMonth.atEndOfMonth(); |
|
|
|
|
|
LocalDateTime lastDayTime = lastDay.atTime(23, 59, 59); |
|
|
|
|
|
Date lastPandian=Date.from(lastDayTime.atZone(ZoneId.of("Asia/Shanghai")).toInstant()); |
|
|
|
|
|
log.info("获得上次盘点结束日期: {}", lastPandian.toString()); |
|
|
|
|
|
baseMapper.updateLastPandianHU(site, lastPandian); |
|
|
|
|
|
//开启盘点模式 |
|
|
|
|
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
if("N".equals(nowStatus)){ |
|
|
|
|
|
throw new RuntimeException("盘点模式已关闭,无需重复关闭"); |
|
|
|
|
|
} |
|
|
|
|
|
// 盘点单结束才能退出盘点)- rqrq |
|
|
|
|
|
CountHeaderData activeCount = baseMapper.checkActiveCountExists(site); |
|
|
|
|
|
if (activeCount != null) { |
|
|
|
|
|
throw new RuntimeException("存在进行中的盘点单:" + activeCount.getCountNo() + "(" + activeCount.getStatusDesc() + "),请先完成或取消该盘点单"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
baseMapper.updateSysIfCount(site, value); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Description 盘点完成后处理任务单(与RFID接口逻辑一致)- rqrq |
|
|
* @Description 盘点完成后处理任务单(与RFID接口逻辑一致)- rqrq |
|
|
* |
|
|
* |
|
|
|