Merge remote-tracking branch 'origin/master'

master
郑明梁 2 years ago
commit 45b2296ded

@ -1,5 +1,6 @@
package com.glxp.api.controller.inv;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageInfo;
import com.glxp.api.common.enums.ResultEnum;
@ -59,6 +60,9 @@ public class InvRemindSetController {
*/
@PostMapping("/udiwms/inv/remind/set/batchAddInvRemindSet")
public BaseResponse batchAddInvRemindSet(@RequestBody AddInvRemindSetRequest addInvRemindSetRequest) {
if (null == addInvRemindSetRequest || CollUtil.isEmpty(addInvRemindSetRequest.getRelIdList())) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
return invRemindSetService.batchAddInvRemindSet(addInvRemindSetRequest);
}

@ -0,0 +1,48 @@
package com.glxp.api.controller.sync;
import cn.hutool.core.collection.CollUtil;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.entity.sync.BasicExportStatusEntity;
import com.glxp.api.req.sync.SpsSyncDataRequest;
import com.glxp.api.res.sync.SpsSyncOrderResponse;
import com.glxp.api.service.sync.BasicExportService;
import com.glxp.api.service.sync.SpsSyncDownloadService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
public class SpsSyncDownloadController {
@Resource
SpsSyncDownloadService spsSyncDownloadService;
@Resource
BasicExportService basicExportService;
@AuthRuleAnnotation("")
@GetMapping("sps/sync/order")
public BaseResponse findOrder(SpsSyncDataRequest spsSyncDataRequest) {
BaseResponse<SpsSyncOrderResponse> baseResponse = spsSyncDownloadService.findOrder(spsSyncDataRequest);
BasicExportStatusEntity basicExportStatusEntity = basicExportService.findByData(ConstantStatus.SYNC_SCAN_ORDER, 0);
String logs = "";
if (basicExportStatusEntity != null) {
logs = logs + "单据:" + baseResponse.getData().getOrderEntities().size() + "条\n";
if (CollUtil.isNotEmpty(baseResponse.getData().getOrderDetailBizEntities()))
logs = logs + "单据详情:" + baseResponse.getData().getOrderDetailBizEntities().size() + "条\n";
if (CollUtil.isNotEmpty(baseResponse.getData().getCodeEntities()))
logs = logs + "单据条码信息:" + baseResponse.getData().getCodeEntities().size() + "条\n";
basicExportStatusEntity.setRemark(logs);
basicExportService.updateExportStatus(basicExportStatusEntity);
SpsSyncOrderResponse spsSyncOrderResponse = baseResponse.getData();
spsSyncOrderResponse.setTaskId(basicExportStatusEntity.getId());
baseResponse.setData(spsSyncOrderResponse);
}
return baseResponse;
}
}

@ -0,0 +1,22 @@
package com.glxp.api.res.sync;
import com.glxp.api.entity.inout.*;
import lombok.Data;
import java.util.List;
@Data
public class SpsSyncOrderResponse {
//同步任务ID
private String taskId;
List<IoOrderEntity> orderEntities;
List<IoCodeEntity> codeEntities;
List<IoOrderDetailBizEntity> orderDetailBizEntities;
List<IoOrderDetailCodeEntity> orderDetailCodeEntities;
List<IoOrderDetailResultEntity> orderDetailResultEntities;
}

@ -161,12 +161,13 @@ public class InvRemindSetServiceImpl implements InvRemindSetService {
InvRemindSetEntity invRemindSetEntity = invRemindSetDao.selectOne(new QueryWrapper<InvRemindSetEntity>()
.eq("invCode", addInvRemindSetRequest.getInvCode())
.eq(StrUtil.isNotBlank(addInvRemindSetRequest.getInvSpaceCode()), "invSpaceCode", addInvRemindSetRequest.getInvSpaceCode())
.eq(StrUtil.isNotBlank(addInvRemindSetRequest.getRelId()), "relId", addInvRemindSetRequest.getRelId())
.eq("relId", relId)
.eq(StrUtil.isNotBlank(addInvRemindSetRequest.getGgxh()), "ggxh", addInvRemindSetRequest.getGgxh())
);
if (null == invRemindSetEntity) {
invRemindSetEntity = new InvRemindSetEntity();
BeanUtil.copyProperties(addInvRemindSetRequest, invRemindSetEntity);
invRemindSetEntity.setRelId(relId);
verifySetParams(invRemindSetEntity);
setUpdateInfo(invRemindSetEntity);
invRemindSetDao.insert(invRemindSetEntity);
@ -184,10 +185,13 @@ public class InvRemindSetServiceImpl implements InvRemindSetService {
//查询有无相同设置,有则更新时间
InvRemindSetEntity invRemindSetEntity = invRemindSetDao.selectOne(new QueryWrapper<InvRemindSetEntity>()
.eq("invCode", addInvRemindSetRequest.getInvCode())
.eq(StrUtil.isNotBlank(addInvRemindSetRequest.getInvSpaceCode()), "invSpaceCode", addInvRemindSetRequest.getInvSpaceCode()));
.eq(StrUtil.isNotBlank(addInvRemindSetRequest.getInvSpaceCode()), "invSpaceCode", addInvRemindSetRequest.getInvSpaceCode())
.isNull("relId")
);
if (null == invRemindSetEntity) {
invRemindSetEntity = new InvRemindSetEntity();
BeanUtil.copyProperties(addInvRemindSetRequest, invRemindSetEntity);
invRemindSetEntity.setStatus(1);
setUpdateInfo(invRemindSetEntity);
invRemindSetDao.insert(invRemindSetEntity);
} else {

@ -0,0 +1,204 @@
package com.glxp.api.service.sync;
import cn.hutool.core.collection.CollUtil;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BasicProcessStatus;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.entity.inout.*;
import com.glxp.api.entity.sync.BasicExportStatusEntity;
import com.glxp.api.entity.sync.BasicExportStatusTimeEntity;
import com.glxp.api.entity.sync.SyncDataBustypeEntity;
import com.glxp.api.req.inout.FilterOrderRequest;
import com.glxp.api.req.sync.SpsSyncDataRequest;
import com.glxp.api.res.sync.SpsSyncOrderResponse;
import com.glxp.api.res.system.SyncDataSetResponse;
import com.glxp.api.service.inout.*;
import com.glxp.api.util.CustomUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Slf4j
@Service
public class SpsSyncDownloadService {
//已完成扫码单据
@Resource
IoOrderService orderService;
@Resource
IoCodeService codesService;
@Resource
SyncDataSetService syncDataSetService;
@Resource
IoOrderDetailBizService orderDetailBizService;
@Resource
IoOrderDetailCodeService orderDetailCodeService;
@Resource
IoOrderDetailResultService orderDetailResultService;
@Resource
BasicExportService basicExportService;
@Resource
BasicExportTimeService basicExportTimeService;
public void syncOrderUpdateTime() {
log.info("创建单据同步任务");
//自动创建要求被下载已完成单据任务
BasicExportStatusEntity basicExportStatusEntity1 = basicExportService.findByData(ConstantStatus.SYNC_SCAN_ORDER, 0);
if (basicExportStatusEntity1 == null) {
BaseResponse<SpsSyncOrderResponse> baseResponse = findOrder(getRequest(ConstantStatus.SYNC_SCAN_ORDER));
SpsSyncOrderResponse syncOrderResponse = baseResponse.getData();
if (CollUtil.isNotEmpty(syncOrderResponse.getOrderEntities())) {
BasicExportStatusEntity orderStatusEntity = new BasicExportStatusEntity();
orderStatusEntity.setId(CustomUtil.getId());
orderStatusEntity.setIdDatas(ConstantStatus.SYNC_SCAN_ORDER);
orderStatusEntity.setType(BasicProcessStatus.NEW_ALL_ORDER);
orderStatusEntity.setUpdateTime(new Date());
orderStatusEntity.setStatus(0);
orderStatusEntity.setStartTime(new Date());
orderStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
basicExportService.insertExportStatus(orderStatusEntity);
}
}
}
public BaseResponse findOrder(SpsSyncDataRequest spsSyncDataRequest) {
SpsSyncOrderResponse syncOrderResponse = new SpsSyncOrderResponse();
//查询数据同步设置
SyncDataSetResponse syncDataSetEntity = syncDataSetService.selectSet();
List<IoOrderEntity> orderEntities = new ArrayList<>();
//待校验
if (syncDataSetEntity.isOrderUnCheck()) {
FilterOrderRequest orderFilterRequest = new FilterOrderRequest();
BeanUtils.copyProperties(spsSyncDataRequest, orderFilterRequest);
if (CollUtil.isNotEmpty(syncDataSetEntity.getBusTypes())) {
for (SyncDataBustypeEntity syncDataBustypeEntity : syncDataSetEntity.getBusTypes()) {
List<String> filterList = new ArrayList<>();
filterList.add(syncDataBustypeEntity.getAction());
orderFilterRequest.setActions(filterList);
orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_CHECK);
List<IoOrderEntity> temps = orderService.filterOrderList(orderFilterRequest);
if (CollUtil.isNotEmpty(temps)) {
orderEntities.addAll(temps);
}
}
}
}
//待核对
if (syncDataSetEntity.isOrderUnCheck()) {
FilterOrderRequest orderFilterRequest = new FilterOrderRequest();
BeanUtils.copyProperties(spsSyncDataRequest, orderFilterRequest);
if (CollUtil.isNotEmpty(syncDataSetEntity.getBusTypes())) {
for (SyncDataBustypeEntity syncDataBustypeEntity : syncDataSetEntity.getBusTypes()) {
List<String> filterList = new ArrayList<>();
filterList.add(syncDataBustypeEntity.getAction());
orderFilterRequest.setActions(filterList);
orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_CHECK_SUCCESS);
List<IoOrderEntity> temps = orderService.filterOrderList(orderFilterRequest);
if (CollUtil.isNotEmpty(temps)) {
orderEntities.addAll(temps);
}
}
}
}
//待审核
if (syncDataSetEntity.isOrderUnReceive()) {
FilterOrderRequest orderFilterRequest = new FilterOrderRequest();
BeanUtils.copyProperties(spsSyncDataRequest, orderFilterRequest);
if (CollUtil.isNotEmpty(syncDataSetEntity.getBusTypes())) {
for (SyncDataBustypeEntity syncDataBustypeEntity : syncDataSetEntity.getBusTypes()) {
List<String> filterList = new ArrayList<>();
filterList.add(syncDataBustypeEntity.getAction());
orderFilterRequest.setActions(filterList);
orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_CHECK_REW);
List<IoOrderEntity> temps = orderService.filterOrderList(orderFilterRequest);
if (CollUtil.isNotEmpty(temps)) {
orderEntities.addAll(temps);
}
}
}
}
//已完成
if (syncDataSetEntity.isOrderScanFinish()) {
FilterOrderRequest orderFilterRequest = new FilterOrderRequest();
BeanUtils.copyProperties(spsSyncDataRequest, orderFilterRequest);
if (CollUtil.isNotEmpty(syncDataSetEntity.getBusTypes())) {
for (SyncDataBustypeEntity syncDataBustypeEntity : syncDataSetEntity.getBusTypes()) {
List<String> filterList = new ArrayList<>();
filterList.add(syncDataBustypeEntity.getAction());
orderFilterRequest.setActions(filterList);
orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_AUDITED);
List<IoOrderEntity> temps = orderService.filterOrderList(orderFilterRequest);
if (CollUtil.isNotEmpty(temps)) {
orderEntities.addAll(temps);
}
}
}
}
syncOrderResponse.setOrderEntities(orderEntities);
List<IoCodeEntity> codeEntities = new ArrayList<>();
List<IoOrderDetailBizEntity> orderDetailBizEntities = new ArrayList<>();
List<IoOrderDetailCodeEntity> orderDetailCodeEntities = new ArrayList<>();
List<IoOrderDetailResultEntity> orderDetailResultEntities = new ArrayList<>();
if (CollUtil.isNotEmpty(orderEntities)) {
for (IoOrderEntity orderEntity : orderEntities) {
List<IoCodeEntity> codes = codesService.findByOrderId(orderEntity.getBillNo());
if (CollUtil.isNotEmpty(codes)) {
codeEntities.addAll(codes);
}
List<IoOrderDetailBizEntity> bizEntities = orderDetailBizService.findByOrderId(orderEntity.getBillNo());
if (CollUtil.isNotEmpty(bizEntities)) {
orderDetailBizEntities.addAll(bizEntities);
}
List<IoOrderDetailCodeEntity> detailCodeEntities = orderDetailCodeService.findByOrderId(orderEntity.getBillNo());
if (CollUtil.isNotEmpty(detailCodeEntities)) {
orderDetailCodeEntities.addAll(detailCodeEntities);
}
List<IoOrderDetailResultEntity> detailResultEntities = orderDetailResultService.findByOrderId(orderEntity.getBillNo());
if (CollUtil.isNotEmpty(detailResultEntities)) {
orderDetailResultEntities.addAll(detailResultEntities);
}
}
}
syncOrderResponse.setOrderDetailBizEntities(orderDetailBizEntities);
syncOrderResponse.setOrderDetailCodeEntities(orderDetailCodeEntities);
syncOrderResponse.setOrderDetailResultEntities(orderDetailResultEntities);
return ResultVOUtils.success(syncOrderResponse);
}
public SpsSyncDataRequest getRequest(String type) {
SpsSyncDataRequest spsSyncDataRequest = new SpsSyncDataRequest();
spsSyncDataRequest.setPage(1);
spsSyncDataRequest.setLimit(1);
BasicExportStatusTimeEntity basicExportStatusTimeEntity = basicExportTimeService.findByType(type);
spsSyncDataRequest.setLastUpdateTime(basicExportStatusTimeEntity.getLastUpdateTime());
return spsSyncDataRequest;
}
}

@ -0,0 +1,76 @@
package com.glxp.api.task;
import com.glxp.api.dao.schedule.ScheduledDao;
import com.glxp.api.entity.system.ScheduledEntity;
import com.glxp.api.req.system.ScheduledRequest;
import com.glxp.api.res.system.SyncDataSetResponse;
import com.glxp.api.service.basic.BasicBackUpdateProductService;
import com.glxp.api.service.sync.SpsSyncDownloadService;
import com.glxp.api.service.sync.SyncDataSetService;
import com.glxp.api.util.RedisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
@Component
@EnableScheduling
public class AsyncHeartTask implements SchedulingConfigurer {
final Logger logger = LoggerFactory.getLogger(AsyncHeartTask.class);
@Resource
protected ScheduledDao scheduledDao;
@Resource
RedisUtil redisUtil;
@Resource
private SyncDataSetService syncDataSetService;
@Resource
SpsSyncDownloadService spsSyncDownloadService;
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
scheduledTaskRegistrar.addTriggerTask(() -> process(),
triggerContext -> {
ScheduledRequest scheduledRequest = new ScheduledRequest();
scheduledRequest.setCronName("heartTask");
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
String cron = scheduledEntity.getCron();
if (cron.isEmpty()) {
logger.error("cron is null");
}
return new CronTrigger(cron).nextExecutionTime(triggerContext);
});
}
private void process() {
SyncDataSetResponse syncDataSetEntity = syncDataSetService.selectSet();
if (syncDataSetEntity.isDownstreamEnable()) {
//定时同步单据最近更新数据至任务表,等待下载
if (syncDataSetEntity.getOrderSyncTime() != null) {
long timeInterval = syncDataSetEntity.getOrderSyncTime() * 60 * 1000;
long curTime = System.currentTimeMillis();
Long lastTime = (Long) redisUtil.get("SPS_ORDER_SYNC_GEN_DATA");
if (lastTime == null) {
lastTime = System.currentTimeMillis();
redisUtil.set("SPS_ORDER_SYNC_GEN_DATA", lastTime);
}
if (curTime - lastTime > timeInterval) {
spsSyncDownloadService.syncOrderUpdateTime();
redisUtil.set("SPS_ORDER_SYNC_GEN_DATA", curTime);
}
}
}
}
}

@ -1090,7 +1090,7 @@
<select id="selectRemindParams" resultType="com.glxp.api.entity.basic.UdiRelevanceEntity">
select lowStockNum, overStockNum, recentDateTime
select id, lowStockNum, overStockNum, recentDateTime
from basic_udirel
where id = #{relId}
</select>

@ -316,11 +316,13 @@
ip.deptCode,
ip.invCode
from inv_product ip
inner join basic_udirel on ip.relIdFk = basic_udirel.id
inner join basic_products bp on basic_udirel.uuid = bp.uuid
left join basic_corp on ip.supId = basic_corp.erpId
left join auth_dept on auth_dept.code = ip.deptCode
left join auth_warehouse on auth_warehouse.code = ip.invCode
inner join basic_udirel on ip.relIdFk = basic_udirel.id
inner join basic_products bp on basic_udirel.uuid = bp.uuid
left join basic_corp on ip.supId = basic_corp.erpId
left join auth_dept on auth_dept.code = ip.deptCode
left join auth_warehouse on auth_warehouse.code = ip.invCode
left join inv_product_detail ipd on ip.invCode = ipd.invCode and ip.relIdFk = ipd.relId and
ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty')
<where>
bp.diType = 1
<if test="cpmctymc != null and cpmctymc != ''">
@ -371,6 +373,9 @@
<if test="supName != null and supName != ''">
AND basic_corp.name like concat('%', #{supName}, '%')
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND ipd.invSpaceCode = #{invSpaceCode}
</if>
</where>
group by ip.relIdFk
order by ip.updateTime desc

Loading…
Cancel
Save