|
|
@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.win.framework.common.exception.ServiceException; |
|
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
|
import com.win.framework.quartz.core.scheduler.SchedulerManager; |
|
|
|
import com.win.framework.quartz.core.util.CronUtils; |
|
|
|
import com.win.module.infra.api.trends.TrendsApi; |
|
|
|
import com.win.module.infra.enums.TrendsTypeEnum; |
|
|
|
import com.win.module.system.api.serialnumber.SerialNumberApi; |
|
|
@ -33,6 +35,7 @@ import com.win.module.wms.service.countRequest.CountRequestMainService; |
|
|
|
import com.win.module.wms.service.itembasic.ItembasicService; |
|
|
|
import com.win.module.wms.service.location.LocationService; |
|
|
|
import com.win.module.wms.util.JobUtils; |
|
|
|
import org.quartz.SchedulerException; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -44,6 +47,7 @@ import java.time.LocalDateTime; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
|
import static com.win.module.infra.enums.ErrorCodeConstants.JOB_CRON_EXPRESSION_VALID; |
|
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.*; |
|
|
|
|
|
|
|
/** |
|
|
@ -75,9 +79,16 @@ public class CountPlanMainServiceImpl implements CountPlanMainService { |
|
|
|
private CountRequestMainService countRequestMainService; |
|
|
|
@Resource |
|
|
|
private LocationService locationService; |
|
|
|
@Resource |
|
|
|
private SchedulerManager schedulerManager; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Long createCountPlanMain(CountPlanMainCreateReqVO createReqVO) { |
|
|
|
if(!createReqVO.getType().equals("MANUAL")) { |
|
|
|
if (!CronUtils.isValid(createReqVO.getCrontab())) { |
|
|
|
throw exception(JOB_CRON_EXPRESSION_VALID); |
|
|
|
} |
|
|
|
} |
|
|
|
// 插入
|
|
|
|
CountPlanMainDO countPlanMain = CountPlanMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.COUNT_PLAN.getCode()); |
|
|
@ -262,7 +273,16 @@ public class CountPlanMainServiceImpl implements CountPlanMainService { |
|
|
|
} |
|
|
|
mainDO.setStatus(planStatusState.getState().getCode());//增加操作记录
|
|
|
|
trendsApi.createTrends(id, "countPlan", "发布了盘点计划", TrendsTypeEnum.UPDATE); |
|
|
|
this.generateRequest(mainDO); |
|
|
|
if(mainDO.getType().equals("MANUAL")) {//指定盘点
|
|
|
|
this.generateRequest(mainDO); |
|
|
|
} else if (mainDO.getType().equals("CYCLE")) {//循环盘点
|
|
|
|
// 添加 Job 到 Quartz 中
|
|
|
|
try { |
|
|
|
schedulerManager.addJob(mainDO.getId() + 10000, "countPlanJob", String.valueOf(mainDO.getId()), mainDO.getCrontab(), 3, 60*10); |
|
|
|
} catch (SchedulerException e) { |
|
|
|
throw new ServiceException(COUNT_PLAN_CRON_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
return countPlanMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
@ -285,7 +305,8 @@ public class CountPlanMainServiceImpl implements CountPlanMainService { |
|
|
|
* 生成盘点申请 |
|
|
|
* @param mainDO 盘点申请主 |
|
|
|
*/ |
|
|
|
private void generateRequest(CountPlanMainDO mainDO) { |
|
|
|
@Override |
|
|
|
public void generateRequest(CountPlanMainDO mainDO) { |
|
|
|
List<CountPlanDetailDO> detailDOList = countPlanDetailMapper.selectList(mainDO.getId()); |
|
|
|
List<BalanceDO> balanceDOList = this.getBalanceDOList(detailDOList); |
|
|
|
CountRequestMainCreateReqVO countRequestMainCreateReqVO = new CountRequestMainCreateReqVO(); |
|
|
|