1.提交自动补单代码

master
MrZhai 3 years ago
parent c3afd4b83e
commit 6f3f7f9214

@ -119,8 +119,18 @@ public class SystemParamConfigController {
} catch (Exception e) {
return ResultVOUtils.error(500, "格式错误!");
}
} else if (systemParamConfigSaveRequest.getParamKey().equals("supplement_order_interval")) {
try {
int time = Integer.parseInt(systemParamConfigSaveRequest.getParamValue());
String cornStr = CronUtils.parseMinuteIntervel(time);
ScheduledEntity scheduledEntity = new ScheduledEntity();
scheduledEntity.setCron(cornStr);
scheduledEntity.setCronName("supplementOrderTask");
scheduledDao.modifyScheduled(scheduledEntity);
} catch (Exception e) {
return ResultVOUtils.error(500, "格式错误!");
}
}
return ResultVOUtils.success("修改成功");
}

@ -34,4 +34,11 @@ public interface StockOrderDao {
void updateSupplementNoByBillNo(@Param("billNo") String billNo, @Param("supplementOrderNo") String supplementOrderNo);
/**
*
*
* @return
*/
List<StockOrderEntity> selectSupplementOrderList();
}

@ -1,12 +1,12 @@
package com.glxp.sale.admin.service.inout;
import java.util.List;
import com.glxp.sale.admin.entity.inout.StockOrderEntity;
import com.glxp.sale.admin.entity.inout.StockOrderPrintEntity;
import com.glxp.sale.admin.req.inout.StockOrderFilterRequest;
import com.glxp.sale.admin.req.inout.StockOrderQueryRequest;
import java.util.List;
public interface StockOrderService {
List<StockOrderEntity> listStockOrders(StockOrderQueryRequest stockOrderQueryRequest);
@ -35,4 +35,12 @@ public interface StockOrderService {
List<StockOrderPrintEntity> listOrderPrint(String orderId);
/**
*
*
* @return
*/
List<StockOrderEntity> getSupplementOrderBillNoList();
}

@ -1,12 +1,5 @@
package com.glxp.sale.admin.service.inout.impl;
import java.util.Collections;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.glxp.sale.admin.dao.inout.StockOrderDao;
import com.glxp.sale.admin.entity.inout.StockOrderEntity;
@ -14,6 +7,11 @@ import com.glxp.sale.admin.entity.inout.StockOrderPrintEntity;
import com.glxp.sale.admin.req.inout.StockOrderFilterRequest;
import com.glxp.sale.admin.req.inout.StockOrderQueryRequest;
import com.glxp.sale.admin.service.inout.StockOrderService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class StockOrderServiceImpl implements StockOrderService {
@ -109,4 +107,9 @@ public class StockOrderServiceImpl implements StockOrderService {
return stockOrderDao.listOrderPrint(stockOrderFilterRequest);
}
@Override
public List<StockOrderEntity> getSupplementOrderBillNoList() {
return stockOrderDao.selectSupplementOrderList();
}
}

@ -0,0 +1,72 @@
package com.glxp.sale.admin.thread;
import cn.hutool.core.collection.CollUtil;
import com.glxp.sale.admin.dao.info.ScheduledDao;
import com.glxp.sale.admin.entity.info.ScheduledEntity;
import com.glxp.sale.admin.entity.inout.StockOrderEntity;
import com.glxp.sale.admin.req.udid.ScheduledRequest;
import com.glxp.sale.admin.res.inout.StockOrderResponse;
import com.glxp.sale.admin.service.inout.OrderService;
import com.glxp.sale.admin.service.inout.StockOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
/**
*
*/
@Slf4j
@Component
@EnableScheduling
public class SupplementOrderTask implements SchedulingConfigurer {
@Resource
ScheduledDao scheduledDao;
@Resource
StockOrderService stockOrderService;
@Resource
OrderService orderService;
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.addTriggerTask(() -> process(),
triggerContext -> {
ScheduledRequest scheduledRequest = new ScheduledRequest();
scheduledRequest.setCronName("supplementOrderTask");
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
String cron = scheduledEntity.getCron();
if (cron.isEmpty()) {
log.error("cron is null");
}
return new CronTrigger(cron).nextExecutionTime(triggerContext);
});
}
private void process() {
log.info("开始扫描补单数据");
//计数器
AtomicInteger counter = new AtomicInteger(0);
List<StockOrderEntity> orderEntities = stockOrderService.getSupplementOrderBillNoList();
if (CollUtil.isNotEmpty(orderEntities)) {
List<StockOrderResponse> stockOrderResponses = orderService.checkSupplementOrder(orderEntities);
for (StockOrderResponse stockOrderRespons : stockOrderResponses) {
if (stockOrderRespons.isEnableSupplementOrder()) {
//此单据可以补单
orderService.supplementOrder(stockOrderRespons.getBillNo());
counter.addAndGet(1);
}
}
}
log.info("补单结束,此次补单数量为:{}", counter.get());
}
}

@ -20,7 +20,7 @@
where id = #{id}
</delete>
<update id="modifyScheduled" parameterType="com.glxp.sale.admin.entity.info.ScheduledEntity">
UPDATE sys_scheduled
UPDATE scheduled
<set>
<if test="cron != null">cron=#{cron},</if>
</set>

@ -217,4 +217,7 @@
</where>
</select>
<select id="selectSupplementOrderList" resultType="com.glxp.sale.admin.entity.inout.StockOrderEntity">
select billNo from stock_order where supplementNo is null or supplementNo = ''
</select>
</mapper>
Loading…
Cancel
Save