同步数据bug相关修复

master
anthonywj 2 years ago
parent 2f826221e4
commit 4ea1efaa92

@ -27,7 +27,7 @@ public class BasicProcessStatus {
public static final int BASIC_THIRD_ORDER = 6; //往来单位 public static final int BASIC_THIRD_ORDER = 6; //往来单位
public static final String NEW_ALL_DATA = "7"; //所有最新数据 public static final String NEW_ALL_DATA = "7"; //所有最新数据
public static final String NEW_ALL_BUS = "8"; public static final String NEW_ALL_BUS = "8";
public static final String NEW_ALL_ORDER = "9"; public static final String NEW_ALL_ORDER = "出入库扫码单据";
/** /**
* *
*/ */

@ -251,8 +251,8 @@ public class ConstantStatus {
//自动下载其他数据 //自动下载其他数据
public static final String SYNC_DOWNLOAD_OTHER_DATA = "AutoDownloadOtherData"; public static final String SYNC_DOWNLOAD_OTHER_DATA = "AutoDownloadOtherData";
public static final int SYNC_STATUS_SUCCESS = 1; //处理成功 public static final int SYNC_STATUS_SUCCESS = 2; //处理成功
public static final int SYNC_STATUS_FAIL = 2; //处理失败 public static final int SYNC_STATUS_FAIL = 1; //处理失败
public static final int SYNC_STATUS_WAIT = 0; //等待处理 public static final int SYNC_STATUS_WAIT = 0; //等待处理
public static final int THIRD_ORDER_UPLOAD = 1; //业务单据上传至第三方 public static final int THIRD_ORDER_UPLOAD = 1; //业务单据上传至第三方

@ -3,6 +3,7 @@ package com.glxp.api.controller.sync;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.entity.sync.BasicExportStatusEntity; import com.glxp.api.entity.sync.BasicExportStatusEntity;
@ -22,6 +23,13 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -111,4 +119,57 @@ public class SpsSyncExportStatusController {
} }
@AuthRuleAnnotation("")
@PostMapping("/spssync/basic/udiinfo/infoByStatus")
public void infoByStatus(HttpServletResponse response, @RequestBody DeleteRequest deleteRequest) throws IOException {
if (StrUtil.isBlank(deleteRequest.getId())) {
throw new RuntimeException("缺少唯一标识");
}
BasicExportStatusEntity info = basicExportService.getById(deleteRequest.getId());
if (info == null) {
throw new RuntimeException("数据不存在");
}
if (StrUtil.isBlank(info.getCacheFilePath())) {
throw new RuntimeException("文件未生成");
}
File file = new File(info.getCacheFilePath());
if (!file.exists()) {
throw new RuntimeException("文件丢失");
}
String[] split = info.getCacheFilePath().split("/");
String enFileName = URLEncoder.encode(split[split.length - 1], StandardCharsets.UTF_8);
// 设值返回文件属性,浏览器会根据属性调用下载文件方法
response.addHeader("Content-Disposition", "attachment;filename=" + enFileName);
// 前端获取文件名,需要解码
response.addHeader("downLoadName", enFileName);
// 定义输出流
ServletOutputStream outputStream = null;
FileInputStream fileInputStream = null;
try {
outputStream = response.getOutputStream();
// 定义输出类型为二进制流输出
response.setContentType("application/octet-stream");
fileInputStream = new FileInputStream(file);
byte[] bytes = new byte[fileInputStream.available()];
fileInputStream.read(bytes);
// 把流写入response
outputStream.write(bytes);
// flush落盘
outputStream.flush();
// 关闭输出流
outputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (outputStream != null) {
outputStream.close();
}
if (fileInputStream != null) {
fileInputStream.close();
}
}
}
} }

@ -42,7 +42,7 @@ public interface InvSpaceDao extends BaseMapperPlus<InvSpace, InvSpace, InvSpace
* @param invSpace * @param invSpace
* @return * @return
*/ */
List<InvSpace> selectList(InvSpace invSpace); List<InvSpace> selectAllList(InvSpace invSpace);
/** /**
* *

@ -1,5 +1,6 @@
package com.glxp.api.dao.sync; package com.glxp.api.dao.sync;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.api.entity.sync.BasicExportStatusEntity; import com.glxp.api.entity.sync.BasicExportStatusEntity;
import com.glxp.api.req.sync.BasicExportStatusRequest; import com.glxp.api.req.sync.BasicExportStatusRequest;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -8,8 +9,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface BasicExportDao { public interface BasicExportDao extends BaseMapper<BasicExportStatusEntity> {
List<BasicExportStatusEntity> filterExportStatus(BasicExportStatusRequest basicExportStatusRequest); List<BasicExportStatusEntity> filterExportStatus(BasicExportStatusRequest basicExportStatusRequest);
@ -17,10 +17,9 @@ public interface BasicExportDao {
boolean deleteById(@Param("id") String id); boolean deleteById(@Param("id") String id);
boolean updateExportStatus(BasicExportStatusEntity warehouseEntity);
boolean deleteByTime(); boolean deleteByTime();
boolean updateExportStatus(BasicExportStatusEntity warehouseEntity);
void deleteByDate(@Param("date") String date); void deleteByDate(@Param("date") String date);
} }

@ -33,13 +33,11 @@ public class InvSpace {
/** /**
* *
*/ */
@TableField("invStorageCode")
private String invStorageCode; private String invStorageCode;
/** /**
* *
*/ */
@TableField("invWarehouseCode")
private String invWarehouseCode; private String invWarehouseCode;
/** /**
@ -50,25 +48,21 @@ public class InvSpace {
/** /**
* *
*/ */
@TableField("createTime")
private Date createTime; private Date createTime;
/** /**
* *
*/ */
@TableField("updateTime")
private Date updateTime; private Date updateTime;
/** /**
* *
*/ */
@TableField("createUser")
private String createUser; private String createUser;
/** /**
* *
*/ */
@TableField("updateUser")
private String updateUser; private String updateUser;
/** /**

@ -2,6 +2,10 @@ package com.glxp.api.entity.sync;
import java.util.Date; import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.glxp.api.constant.BasicExportStatusEnum; import com.glxp.api.constant.BasicExportStatusEnum;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
@ -9,25 +13,31 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@Data @Data
@TableName("basic_export_status")
@Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Builder
public class BasicExportStatusEntity { public class BasicExportStatusEntity {
@TableId(type = IdType.INPUT)
private String id; private String id;
@TableField(value = "idDatas")
private String idDatas; private String idDatas;
private Integer status; private Integer status;
private String type; private String type;
@TableField(value = "updateTime")
private Date updateTime; private Date updateTime;
@TableField(value = "scheduleType")
private Integer scheduleType; private Integer scheduleType;
@TableField(value = "startTime")
private Date startTime; private Date startTime;
@TableField(value = "endTime")
private Date endTime; private Date endTime;
private String remark; private String remark;
private String cacheFilePath; @TableField(value = "receiveStatus")
/**
* 1 2
*/
private Integer receiveStatus; private Integer receiveStatus;
@TableField(value = "cacheFilePath")
private String cacheFilePath;
} }

@ -203,7 +203,6 @@ public class InvWarehouseServiceImpl extends ServiceImpl<InvWarehouseDao, InvWar
@Override @Override
public boolean unbindThrWarehouse(String id, String sysId) { public boolean unbindThrWarehouse(String id, String sysId) {
return invWarehouseDao.updateThridId(id, null, sysId); return invWarehouseDao.updateThridId(id, null, sysId);
} }

@ -1,12 +1,13 @@
package com.glxp.api.service.sync; package com.glxp.api.service.sync;
import com.baomidou.mybatisplus.extension.service.IService;
import com.glxp.api.entity.sync.BasicExportStatusEntity; import com.glxp.api.entity.sync.BasicExportStatusEntity;
import com.glxp.api.req.sync.BasicExportStatusRequest; import com.glxp.api.req.sync.BasicExportStatusRequest;
import java.util.List; import java.util.List;
public interface BasicExportService { public interface BasicExportService extends IService<BasicExportStatusEntity> {
BasicExportStatusEntity findByData(String idDatas, Integer status); BasicExportStatusEntity findByData(String idDatas, Integer status);

@ -3,6 +3,7 @@ package com.glxp.api.service.sync;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
@ -36,6 +37,7 @@ import com.glxp.api.service.inout.*;
import com.glxp.api.service.thrsys.*; import com.glxp.api.service.thrsys.*;
import com.glxp.api.util.CustomUtil; import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.DateUtil; import com.glxp.api.util.DateUtil;
import com.glxp.api.util.JsonUtils;
import com.glxp.api.util.RedisUtil; import com.glxp.api.util.RedisUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -50,6 +52,9 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.function.Function; import java.util.function.Function;
@ -129,9 +134,9 @@ public class HeartService {
spsSyncOrderResponse.setTaskId(basicExportStatusEntity1.getId()); spsSyncOrderResponse.setTaskId(basicExportStatusEntity1.getId());
BaseResponse<String> baseResponse1 = spGetHttp.postAllOrder(spsSyncOrderResponse); BaseResponse<String> baseResponse1 = spGetHttp.postAllOrder(spsSyncOrderResponse);
if (baseResponse1.getCode() == 20000) { if (baseResponse1.getCode() == 20000) {
basicExportStatusEntity1.setStatus(ConstantStatus.SYNC_STATUS_SUCCESS); basicExportStatusEntity1.setStatus(2);
} else { } else {
basicExportStatusEntity1.setStatus(ConstantStatus.SYNC_STATUS_FAIL); basicExportStatusEntity1.setStatus(1);
} }
basicExportStatusEntity1.setEndTime(new Date()); basicExportStatusEntity1.setEndTime(new Date());
basicExportTimeService.insertExportStatus(basicExportStatusTimeEntity); basicExportTimeService.insertExportStatus(basicExportStatusTimeEntity);
@ -422,7 +427,7 @@ public class HeartService {
if (needExec(info.getUdiCodeLost())) { if (needExec(info.getUdiCodeLost())) {
Map<String, Object> map; Map<String, Object> map;
if (syncTime == null) { if (syncTime == null) {
map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.BASIC_PRODUCTS); map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.IO_CODE_LOST);
} else { } else {
map = syncTimeMap; map = syncTimeMap;
} }
@ -463,6 +468,28 @@ public class HeartService {
return dataResponse; return dataResponse;
} }
private String writeFile(String filePath, String fileDesc, String content) throws IOException {
filePath = String.format("%s/%s", filePath, DateUtil.getDate());
String fileFullPath = String.format("%s/%s-%s.udi", filePath, fileDesc, IdUtil.fastSimpleUUID());
File file = new File(filePath);
if (!file.exists()) {
file.mkdirs();
}
file = new File(fileFullPath);
while (!file.createNewFile()) {
fileFullPath = String.format("%s/%s/%s-%s.udi", filePath, DateUtil.getDate(), fileDesc, IdUtil.fastSimpleUUID());
file = new File(fileFullPath);
}
FileWriter fileWriter = new FileWriter(file);
fileWriter.write(content);
fileWriter.flush();
fileWriter.close();
return fileFullPath;
}
private final IBasicBussinessTypeService bussinessTypeService; private final IBasicBussinessTypeService bussinessTypeService;
private final IBasicBusTypeChangeService busTypeChangeService; private final IBasicBusTypeChangeService busTypeChangeService;
private final IThrBusTypeOriginService thrBusTypeOriginService; private final IThrBusTypeOriginService thrBusTypeOriginService;

@ -1,6 +1,7 @@
package com.glxp.api.service.sync.impl; package com.glxp.api.service.sync.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.glxp.api.dao.sync.BasicExportDao; import com.glxp.api.dao.sync.BasicExportDao;
import com.glxp.api.entity.sync.BasicExportStatusEntity; import com.glxp.api.entity.sync.BasicExportStatusEntity;
@ -15,7 +16,7 @@ import java.util.List;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class BasicExportServiceImpl implements BasicExportService { public class BasicExportServiceImpl extends ServiceImpl<BasicExportDao, BasicExportStatusEntity> implements BasicExportService {
@Resource @Resource
BasicExportDao basicExportDao; BasicExportDao basicExportDao;
@ -55,12 +56,12 @@ public class BasicExportServiceImpl implements BasicExportService {
} }
@Override @Override
public boolean updateExportStatus(BasicExportStatusEntity basicExportStatusEntity) { public boolean deleteByTime() {
return basicExportDao.updateExportStatus(basicExportStatusEntity); return basicExportDao.deleteByTime();
} }
@Override @Override
public boolean deleteByTime() { public boolean updateExportStatus(BasicExportStatusEntity basicExportStatusEntity) {
return basicExportDao.deleteByTime(); return basicExportDao.updateExportStatus(basicExportStatusEntity);
} }
} }

@ -293,7 +293,7 @@
</where> </where>
</select> </select>
<select id="selectList" resultMap="BaseResultMap"> <select id="selectAllList" resultMap="BaseResultMap">
select * select *
from auth_space from auth_space
<where> <where>

@ -17,7 +17,7 @@
</select> </select>
<insert id="insertExportStatus" keyProperty="id" <insert id="insertExportStatus"
parameterType="com.glxp.api.entity.sync.BasicExportStatusTimeEntity"> parameterType="com.glxp.api.entity.sync.BasicExportStatusTimeEntity">
replace replace
INTO basic_export_status_time(`key`, lastUpdateTime, remark) INTO basic_export_status_time(`key`, lastUpdateTime, remark)

Loading…
Cancel
Save