库存货位查询

pro
anthonywj 2 years ago
parent e1c80c5360
commit be5f16b38d

@ -87,6 +87,7 @@ public class IdcServiceImpl implements IdcService {
private ScheduledDao scheduledDao; private ScheduledDao scheduledDao;
private String imagePath = FileConstant.COMMON_FILE_PATH; private String imagePath = FileConstant.COMMON_FILE_PATH;
/*获取拉取任务列表*/ /*获取拉取任务列表*/
@Override @Override
public BaseResponse taskList(HttpServletRequest request, Map<String, Object> params) { public BaseResponse taskList(HttpServletRequest request, Map<String, Object> params) {
@ -206,11 +207,11 @@ public class IdcServiceImpl implements IdcService {
private void fetchFailFile(String host) { private void fetchFailFile(String host) {
Map<String,Object> map = new HashMap<String,Object>(); Map<String, Object> map = new HashMap<String, Object>();
map.put("sql", "select * from idc_file where createTime<date_sub(now(),interval 30 minute) order by createTime"); map.put("sql", "select * from idc_file where createTime<date_sub(now(),interval 30 minute) order by createTime");
List<Map<String,Object>> list = dbDao.list(map); List<Map<String, Object>> list = dbDao.list(map);
for(int i=0;i<list.size();i++) { for (int i = 0; i < list.size(); i++) {
signleDownloadFile(host,list.get(i).get("filePath").toString()); signleDownloadFile(host, list.get(i).get("filePath").toString());
} }
} }
@ -230,7 +231,7 @@ public class IdcServiceImpl implements IdcService {
String[] syncTables = TableUtils.syncTables(); String[] syncTables = TableUtils.syncTables();
for (int i = 0; i < syncTables.length; i++) { for (int i = 0; i < syncTables.length; i++) {
String[] tnames = syncTables[i].split("/"); String[] tnames = syncTables[i].split("/");
boolean sync = (StringUtils.isEmpty(tnames[0])&&StringUtils.isEmpty(tnames[1])) || boolean sync = (StringUtils.isEmpty(tnames[0]) && StringUtils.isEmpty(tnames[1])) ||
(!StringUtils.isEmpty(tnames[0]) && map != null && map.get(tnames[0]) != null && map.get(tnames[0]).toString().equals("1")); (!StringUtils.isEmpty(tnames[0]) && map != null && map.get(tnames[0]) != null && map.get(tnames[0]).toString().equals("1"));
saveIdcLog("---", "", map.get(tnames[0]) + syncTables[i], 0, 0); saveIdcLog("---", "", map.get(tnames[0]) + syncTables[i], 0, 0);
if (sync) { if (sync) {
@ -245,21 +246,20 @@ public class IdcServiceImpl implements IdcService {
/*上传失败重新上传*/ /*上传失败重新上传*/
private void asyncFailTask(String host) { private void asyncFailTask(String host) {
try try {
{
String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/"; String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/";
String sql = "select * from basic_export_status where status='1' and receiveStatus='0' where updateTime<date_sub(now(),interval 6 minute) order by updateTime"; String sql = "select * from basic_export_status where status='1' and receiveStatus='0' where updateTime<date_sub(now(),interval 6 minute) order by updateTime";
Map<String,Object> map = new HashMap<String,Object>(); Map<String, Object> map = new HashMap<String, Object>();
map.put("sql", sql); map.put("sql", sql);
List<Map<String,Object>> list = dbDao.list(map); List<Map<String, Object>> list = dbDao.list(map);
ArrayList<String> files = new ArrayList<>(); ArrayList<String> files = new ArrayList<>();
for(int i=0;i<list.size();i++) { for (int i = 0; i < list.size(); i++) {
String json = FileUtils.readFileAll(list.get(i).get("cacheFilePath").toString()); String json = FileUtils.readFileAll(list.get(i).get("cacheFilePath").toString());
JSONObject object = JSONObject.parseObject(json); JSONObject object = JSONObject.parseObject(json);
List<Map> dataList = JSONObject.parseArray(JSON.toJSONString(object.get("data")), Map.class); List<Map> dataList = JSONObject.parseArray(JSON.toJSONString(object.get("data")), Map.class);
for (int m = 0; m < dataList.size(); m++) { for (int m = 0; m < dataList.size(); m++) {
if(object.get("filePathColumn")!=null&&!StringUtils.isEmpty(object.get("filePathColumn").toString())&& if (object.get("filePathColumn") != null && !StringUtils.isEmpty(object.get("filePathColumn").toString()) &&
dataList.get(m).get(object.get("filePathColumn").toString()) !=null ) { dataList.get(m).get(object.get("filePathColumn").toString()) != null) {
String fileNames = dataList.get(m).get(object.get("filePathColumn").toString()).toString(); String fileNames = dataList.get(m).get(object.get("filePathColumn").toString()).toString();
String[] str = fileNames.split(","); String[] str = fileNames.split(",");
for (int r = 0; r < str.length; r++) { for (int r = 0; r < str.length; r++) {
@ -267,14 +267,14 @@ public class IdcServiceImpl implements IdcService {
files.add(filePath + filePathSlash + imagePath + str[r]); files.add(filePath + filePathSlash + imagePath + str[r]);
} }
} }
for(int k=0;k<30;k++) { for (int k = 0; k < 30; k++) {
if(dataList.get(k).get("tableName"+k) == null) if (dataList.get(k).get("tableName" + k) == null)
break; break;
if(dataList.get(k).get("data"+k)!=null && dataList.get(k).get("filePathColumn"+k)!=null) { if (dataList.get(k).get("data" + k) != null && dataList.get(k).get("filePathColumn" + k) != null) {
List<Map> childList = JSONObject.parseArray(JSON.toJSONString(dataList.get(i).get("data"+k)), Map.class); List<Map> childList = JSONObject.parseArray(JSON.toJSONString(dataList.get(i).get("data" + k)), Map.class);
for(int x =0 ;x <childList.size();x++) { for (int x = 0; x < childList.size(); x++) {
if (childList.get(x).get(dataList.get(k).get("filePathColumn"+k).toString()) != null) { if (childList.get(x).get(dataList.get(k).get("filePathColumn" + k).toString()) != null) {
String[] str = childList.get(x).get(dataList.get(k).get("filePathColumn"+k).toString()).toString().split(","); String[] str = childList.get(x).get(dataList.get(k).get("filePathColumn" + k).toString()).toString().split(",");
for (int s = 0; s < str.length; s++) { for (int s = 0; s < str.length; s++) {
if (!StringUtils.isEmpty(str[s]) && FileUtils.isFileExist(filePath + filePathSlash + imagePath + str[s])) if (!StringUtils.isEmpty(str[s]) && FileUtils.isFileExist(filePath + filePathSlash + imagePath + str[s]))
files.add(filePath + filePathSlash + imagePath + str[s]); files.add(filePath + filePathSlash + imagePath + str[s]);
@ -293,7 +293,7 @@ public class IdcServiceImpl implements IdcService {
if (IDCUtils.isJson(result)) { if (IDCUtils.isJson(result)) {
JSONObject res = JSON.parseObject(result); JSONObject res = JSON.parseObject(result);
if (res.getInteger("code") == 20000) { if (res.getInteger("code") == 20000) {
executeSql("update basic_export_status set receiveStatus='1',endTime=now() where id='"+list.get(i).get("id")+"'"); executeSql("update basic_export_status set receiveStatus='1',endTime=now() where id='" + list.get(i).get("id") + "'");
saveIdcLog(object.getString("messageType"), list.get(i).get("id").toString(), object.getString("tableName") + ">reUpload->success", 0, 0); saveIdcLog(object.getString("messageType"), list.get(i).get("id").toString(), object.getString("tableName") + ">reUpload->success", 0, 0);
} else { } else {
saveIdcLog(object.getString("messageType"), list.get(i).get("id").toString(), object.getString("tableName") + ">reUpload->fail", 0, 0); saveIdcLog(object.getString("messageType"), list.get(i).get("id").toString(), object.getString("tableName") + ">reUpload->fail", 0, 0);
@ -308,42 +308,42 @@ public class IdcServiceImpl implements IdcService {
} }
/*数据删除同步*/ /*数据删除同步*/
private void asyncDelete(String tname,boolean isUpload,String syncIp) { private void asyncDelete(String tname, boolean isUpload, String syncIp) {
String[] tnames = tname.split("/"); String[] tnames = tname.split("/");
String lastUpdateTime = getUpdateTime(tnames[2] + "." + tnames[0]+"."+tnames[1]+".delete"); String lastUpdateTime = getUpdateTime(tnames[2] + "." + tnames[0] + "." + tnames[1] + ".delete");
Date nowUpdateTime = new Date(); Date nowUpdateTime = new Date();
String where = "tableName='"+tnames[2].toLowerCase()+"' and updateTime between cast('"+lastUpdateTime+"' as datetime) "+ String where = "tableName='" + tnames[2].toLowerCase() + "' and updateTime between cast('" + lastUpdateTime + "' as datetime) " +
" and cast('"+DateUtil.formatDate(nowUpdateTime, "yyyy-MM-dd HH:mm:ss")+"' as datetime)"; " and cast('" + DateUtil.formatDate(nowUpdateTime, "yyyy-MM-dd HH:mm:ss") + "' as datetime)";
Map<String,Object> count = new HashMap<String,Object>(); Map<String, Object> count = new HashMap<String, Object>();
count.put("sql", "select count(*) from idc_delete where "+where); count.put("sql", "select count(*) from idc_delete where " + where);
int total = dbDao.count(count); int total = dbDao.count(count);
int limit = 50; int limit = 50;
if (total > 0) { if (total > 0) {
boolean success = true; boolean success = true;
for (int i = 0; i < Math.ceil(total / limit) + 1; i++) { for (int i = 0; i < Math.ceil(total / limit) + 1; i++) {
Date startTime = new Date(); Date startTime = new Date();
Map<String,Object> map = new HashMap<String,Object>(); Map<String, Object> map = new HashMap<String, Object>();
map.put("sql", "select * from idc_delete"); map.put("sql", "select * from idc_delete");
map.put("sqlWhere", where); map.put("sqlWhere", where);
map.put("limit", limit); map.put("limit", limit);
map.put("page", i * limit); map.put("page", i * limit);
List<Map<String,Object>> list = dbDao.list(map); List<Map<String, Object>> list = dbDao.list(map);
if(list!=null&&map.size()>0) { if (list != null && map.size() > 0) {
List<Map<String,Object>> data = new ArrayList<>(); List<Map<String, Object>> data = new ArrayList<>();
for(int k=0;i<list.size();k++) { for (int k = 0; i < list.size(); k++) {
String line = list.get(k).get("uniqueValue").toString(); String line = list.get(k).get("uniqueValue").toString();
JSONObject obj = JSON.parseObject(line); JSONObject obj = JSON.parseObject(line);
String uniqueColumn = ""; String uniqueColumn = "";
for(String key : obj.keySet()){ for (String key : obj.keySet()) {
uniqueColumn += uniqueColumn.length()>0 ? ","+key : key; uniqueColumn += uniqueColumn.length() > 0 ? "," + key : key;
} }
obj.put("uniqueColumn", uniqueColumn); obj.put("uniqueColumn", uniqueColumn);
obj.put("operateMode", "D"); obj.put("operateMode", "D");
data.add(obj); data.add(obj);
} }
Map<String,Object> msg = new HashMap<String, Object>(); Map<String, Object> msg = new HashMap<String, Object>();
msg.put("messageId", CustomUtil.getId()); msg.put("messageId", CustomUtil.getId());
msg.put("messageType", tnames[9]+"(删除)"); msg.put("messageType", tnames[9] + "(删除)");
msg.put("apiCode", "common"); msg.put("apiCode", "common");
msg.put("tableName", DBAUtils.tableAliasName(tnames[2])); msg.put("tableName", DBAUtils.tableAliasName(tnames[2]));
msg.put("sendTime", new Date()); msg.put("sendTime", new Date());
@ -374,7 +374,7 @@ public class IdcServiceImpl implements IdcService {
} else { } else {
saveIdcLog(tnames[9], "", tnames[2] + ">success(delete)", i * limit, total); saveIdcLog(tnames[9], "", tnames[2] + ">success(delete)", i * limit, total);
} }
syncAddTaskStatus(msg, isUpload ? 1 : 0, true, startTime, isUpload,success); syncAddTaskStatus(msg, isUpload ? 1 : 0, true, startTime, isUpload, success);
} }
} }
} }
@ -409,7 +409,7 @@ public class IdcServiceImpl implements IdcService {
try { try {
String[] tnames = t.split("/"); String[] tnames = t.split("/");
String lastUpdateTime = getUpdateTime(tnames[2] + "." + tnames[0]+"."+tnames[1]); String lastUpdateTime = getUpdateTime(tnames[2] + "." + tnames[0] + "." + tnames[1]);
Date nowUpdateTime = new Date(); Date nowUpdateTime = new Date();
// if (!StringUtils.isEmpty(tnames[0])) { // if (!StringUtils.isEmpty(tnames[0])) {
@ -425,7 +425,7 @@ public class IdcServiceImpl implements IdcService {
if (!StringUtils.isEmpty(updateTimeColumn)) { if (!StringUtils.isEmpty(updateTimeColumn)) {
sqlWhere += " " + updateTimeColumn + " between cast('" + lastUpdateTime + "' as datetime) and cast('"+DateUtil.formatDate(nowUpdateTime, "yyyy-MM-dd HH:mm:ss")+"' as datetime)"; sqlWhere += " " + updateTimeColumn + " between cast('" + lastUpdateTime + "' as datetime) and cast('" + DateUtil.formatDate(nowUpdateTime, "yyyy-MM-dd HH:mm:ss") + "' as datetime)";
//sqlWhere += " and not exists (select fkId from idc_record where type='" + tnames[2] + "' and fkId=" + tnames[2] + "." + keyColumn + " and createTime>date_sub(now(),interval 15 MINUTE))"; //sqlWhere += " and not exists (select fkId from idc_record where type='" + tnames[2] + "' and fkId=" + tnames[2] + "." + keyColumn + " and createTime>date_sub(now(),interval 15 MINUTE))";
} else { } else {
sqlWhere = "not exists (select fkId from idc_record where type='" + tnames[2] + "' and fkId=" + tnames[2] + "." + keyColumn + ")"; sqlWhere = "not exists (select fkId from idc_record where type='" + tnames[2] + "' and fkId=" + tnames[2] + "." + keyColumn + ")";
@ -455,7 +455,7 @@ public class IdcServiceImpl implements IdcService {
if (sync) { if (sync) {
result = syncMasterData(map, isUpload, syncIp); result = syncMasterData(map, isUpload, syncIp);
if (result) { if (result) {
setUpdateTime(tnames[2] + "." + tnames[0]+"."+tnames[1], DateUtil.formatDate(nowUpdateTime, "yyyy-MM-dd HH:mm:ss")); setUpdateTime(tnames[2] + "." + tnames[0] + "." + tnames[1], DateUtil.formatDate(nowUpdateTime, "yyyy-MM-dd HH:mm:ss"));
} }
} }
//} //}
@ -493,11 +493,11 @@ public class IdcServiceImpl implements IdcService {
} else { } else {
success = false; success = false;
} }
syncAddTaskStatus(json.getJSONObject("data"), 3, true, startTime, true,success); syncAddTaskStatus(json.getJSONObject("data"), 3, true, startTime, true, success);
} else { } else {
if (json.get("code") != null && json.get("data") != null) { if (json.get("code") != null && json.get("data") != null) {
//logger.info("res1-->"+JSON.toJSONString(json)); //logger.info("res1-->"+JSON.toJSONString(json));
syncAddTaskStatus(json.getJSONObject("data"), 0, true, startTime, true,success); syncAddTaskStatus(json.getJSONObject("data"), 0, true, startTime, true, success);
analyMiddle(host, json.getJSONObject("data"), files, false, false); analyMiddle(host, json.getJSONObject("data"), files, false, false);
} }
} }
@ -553,7 +553,7 @@ public class IdcServiceImpl implements IdcService {
IDCUtils.createDirectory(filePath + filePathSlash + datePath + "/"); IDCUtils.createDirectory(filePath + filePathSlash + datePath + "/");
if (!FileUtils.makeDirectory(backFilePath + backFileSlash + datePath)) if (!FileUtils.makeDirectory(backFilePath + backFileSlash + datePath))
IDCUtils.createDirectory(filePath + backFileSlash + datePath + "/"); IDCUtils.createDirectory(filePath + backFileSlash + datePath + "/");
if(!FileUtils.makeDirectory(filePath + filePathSlash + imagePath)) if (!FileUtils.makeDirectory(filePath + filePathSlash + imagePath))
IDCUtils.createDirectory(filePath + filePathSlash + imagePath); IDCUtils.createDirectory(filePath + filePathSlash + imagePath);
FileUtils.SaveFileAs(content, fileName); FileUtils.SaveFileAs(content, fileName);
FileUtils.SaveFileAs(content, backFileName); FileUtils.SaveFileAs(content, backFileName);
@ -585,7 +585,7 @@ public class IdcServiceImpl implements IdcService {
boolean success = false; boolean success = false;
if (isLastLevel()) { if (isLastLevel()) {
success = analyMiddle("", json, files, true, true); success = analyMiddle("", json, files, true, true);
syncAddTaskStatus(json, 3, true, startTime, true,success); syncAddTaskStatus(json, 3, true, startTime, true, success);
if (!success) { if (!success) {
return ResultVOUtils.error(9000, "解析失败"); return ResultVOUtils.error(9000, "解析失败");
@ -596,11 +596,11 @@ public class IdcServiceImpl implements IdcService {
String host = getNextHost(); String host = getNextHost();
String result = relay(request.getHeader("reqNo"), content, saveFiles, host); String result = relay(request.getHeader("reqNo"), content, saveFiles, host);
if (IDCUtils.isJson(result)) { if (IDCUtils.isJson(result)) {
syncAddTaskStatus(json, 2, true, startTime, true,true); syncAddTaskStatus(json, 2, true, startTime, true, true);
BaseResponse object = JSON.parseObject(result, BaseResponse.class); BaseResponse object = JSON.parseObject(result, BaseResponse.class);
return object; return object;
} else { } else {
syncAddTaskStatus(json, 2, true, startTime, false,false); syncAddTaskStatus(json, 2, true, startTime, false, false);
return ResultVOUtils.error(9000, "转发失败"); return ResultVOUtils.error(9000, "转发失败");
} }
@ -630,7 +630,7 @@ public class IdcServiceImpl implements IdcService {
public void downloadFile(String fileName, HttpServletResponse response) { public void downloadFile(String fileName, HttpServletResponse response) {
OutputStream os; OutputStream os;
String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : fileName.substring(0, 1).equals("/") ? "" : "/"; String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : fileName.substring(0, 1).equals("/") ? "" : "/";
String sourceFileName = filePath +filePathSlash+imagePath +fileName; String sourceFileName = filePath + filePathSlash + imagePath + fileName;
try { try {
if (FileUtils.isFileExist(sourceFileName)) { if (FileUtils.isFileExist(sourceFileName)) {
byte[] bytes = FileUtils.readFileByBytes(sourceFileName); byte[] bytes = FileUtils.readFileByBytes(sourceFileName);
@ -639,7 +639,7 @@ public class IdcServiceImpl implements IdcService {
os.flush(); os.flush();
os.close(); os.close();
} else { } else {
logger.error("file not exists:"+sourceFileName); logger.error("file not exists:" + sourceFileName);
} }
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
@ -718,7 +718,7 @@ public class IdcServiceImpl implements IdcService {
Map<String, Object> whereParams = new HashMap<String, Object>(); Map<String, Object> whereParams = new HashMap<String, Object>();
whereParams.put("sqlWhere", params.get("sqlWhere")); whereParams.put("sqlWhere", params.get("sqlWhere"));
String dataWhere = params.get("dataWhere")!=null ? params.get("dataWhere").toString() : ""; String dataWhere = params.get("dataWhere") != null ? params.get("dataWhere").toString() : "";
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
String where = DBAUtils.convertWhere(column, whereParams, dataWhere); String where = DBAUtils.convertWhere(column, whereParams, dataWhere);
sql += !StringUtils.isEmpty(where) ? " where " + where : ""; sql += !StringUtils.isEmpty(where) ? " where " + where : "";
@ -827,7 +827,7 @@ public class IdcServiceImpl implements IdcService {
} }
saveIdcLog(messageType, "", tableName + ">success", i * limit, total); saveIdcLog(messageType, "", tableName + ">success", i * limit, total);
} }
syncAddTaskStatus(data, isUpload ? 1 : 0, true, startTime, isUpload,success); syncAddTaskStatus(data, isUpload ? 1 : 0, true, startTime, isUpload, success);
} }
} }
} }
@ -839,7 +839,7 @@ public class IdcServiceImpl implements IdcService {
/*增加同步任务状态*/ /*增加同步任务状态*/
private void syncAddTaskStatus(Map<String, Object> json, int scheduleType, boolean success, Date startTime, private void syncAddTaskStatus(Map<String, Object> json, int scheduleType, boolean success, Date startTime,
boolean isEnd,boolean isReceive) { boolean isEnd, boolean isReceive) {
try { try {
String content = JSON.toJSONString(json); String content = JSON.toJSONString(json);
String datePath = DateUtil.formatDate(new Date(), "yyyy-MM-dd"); String datePath = DateUtil.formatDate(new Date(), "yyyy-MM-dd");
@ -866,7 +866,7 @@ public class IdcServiceImpl implements IdcService {
map.put("status", success ? "1" : "0"); map.put("status", success ? "1" : "0");
map.put("receiveStatus", isReceive ? "1" : "0"); map.put("receiveStatus", isReceive ? "1" : "0");
map.put("startTime", startTime != null ? startTime : new Date()); map.put("startTime", startTime != null ? startTime : new Date());
if(isReceive) if (isReceive)
map.put("endTime", new Date()); map.put("endTime", new Date());
map.put("updateTime", new Date()); map.put("updateTime", new Date());
map.put("remark", json.get("messageType") + ": " + json.get("total") + "条"); map.put("remark", json.get("messageType") + ": " + json.get("total") + "条");
@ -928,7 +928,7 @@ public class IdcServiceImpl implements IdcService {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
if (!StringUtils.isEmpty(filePathColumn)) { if (!StringUtils.isEmpty(filePathColumn)) {
files[i] = list.get(i).get(filePathColumn) != null ? list.get(i).get(filePathColumn).toString() : ""; files[i] = list.get(i).get(filePathColumn) != null ? list.get(i).get(filePathColumn).toString() : "";
logger.info("file-->"+files[i]); logger.info("file-->" + files[i]);
} }
for (int z = 0; z < 30; z++) { for (int z = 0; z < 30; z++) {
if (list.get(i).get("data" + z) != null) { if (list.get(i).get("data" + z) != null) {
@ -960,7 +960,7 @@ public class IdcServiceImpl implements IdcService {
String[] keyColumn = new String[30]; String[] keyColumn = new String[30];
String[] keyDataType = new String[30]; String[] keyDataType = new String[30];
List<Map<String, String>> columnList = dbDao.listColumnsMysql(tName); List<Map<String, String>> columnList = dbDao.listColumnsMysql(tName);
Map<String,Object> column = getColumn(tName); Map<String, Object> column = getColumn(tName);
boolean result = false; boolean result = false;
int key = 0; int key = 0;
int col = 0; int col = 0;
@ -968,7 +968,7 @@ public class IdcServiceImpl implements IdcService {
if (col > 0) if (col > 0)
sql += ","; sql += ",";
columnList.get(i).put("attrName", columnList.get(i).get("columnName")); columnList.get(i).put("attrName", columnList.get(i).get("columnName"));
sql += "`"+columnList.get(i).get("columnName").toString()+"`"; sql += "`" + columnList.get(i).get("columnName").toString() + "`";
col++; col++;
if (uniqueColumn != null && columnList.get(i).get("columnKey") != null && ("," + uniqueColumn + ",").contains("," + columnList.get(i).get("columnName") + ",")) { if (uniqueColumn != null && columnList.get(i).get("columnKey") != null && ("," + uniqueColumn + ",").contains("," + columnList.get(i).get("columnName") + ",")) {
keyColumn[key] = columnList.get(i).get("columnName").toString(); keyColumn[key] = columnList.get(i).get("columnName").toString();
@ -998,13 +998,13 @@ public class IdcServiceImpl implements IdcService {
} }
if ("A,D,U".contains(operateMode)) { if ("A,D,U".contains(operateMode)) {
if(operateMode.equals("D")&&list.get(i).get("uniqueColumn")!=null) { if (operateMode.equals("D") && list.get(i).get("uniqueColumn") != null) {
String[] ucs = list.get(i).get("uniqueColumn").toString().split(","); String[] ucs = list.get(i).get("uniqueColumn").toString().split(",");
for(String str:ucs) { for (String str : ucs) {
Map<String,Object> map = (Map<String, Object>) column.get(str); Map<String, Object> map = (Map<String, Object>) column.get(str);
String dataType = map.get("dataType").toString(); String dataType = map.get("dataType").toString();
updateWhere += !StringUtils.isEmpty(updateWhere) ? " and " : " "; updateWhere += !StringUtils.isEmpty(updateWhere) ? " and " : " ";
updateWhere += str +" = "+(dataType.equals("C") ? "'" : "") + list.get(i).get(str) + (dataType.equals("C") ? "'" : ""); updateWhere += str + " = " + (dataType.equals("C") ? "'" : "") + list.get(i).get(str) + (dataType.equals("C") ? "'" : "");
} }
} else { } else {
for (int z = 0; z < keyColumn.length; z++) { for (int z = 0; z < keyColumn.length; z++) {
@ -1166,7 +1166,7 @@ public class IdcServiceImpl implements IdcService {
@Override @Override
public boolean signleDownloadFile(String syncIp, String fileName) { public boolean signleDownloadFile(String syncIp, String fileName) {
String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/"; String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/";
if(!FileUtils.makeDirectory(filePath + filePathSlash + imagePath)) if (!FileUtils.makeDirectory(filePath + filePathSlash + imagePath))
IDCUtils.createDirectory(filePath + filePathSlash + imagePath); IDCUtils.createDirectory(filePath + filePathSlash + imagePath);
OkHttpClient client = new OkHttpClient().newBuilder() OkHttpClient client = new OkHttpClient().newBuilder()
.build(); .build();
@ -1183,13 +1183,13 @@ public class IdcServiceImpl implements IdcService {
int total = 0; int total = 0;
try { try {
Response result = client.newCall(request).execute(); Response result = client.newCall(request).execute();
String msg = result!=null ? result.message().length()>200 ? result.message().substring(0,200) : result.message() : ""; String msg = result != null ? result.message().length() > 200 ? result.message().substring(0, 200) : result.message() : "";
if (result!=null&&result.isSuccessful()&&MediaType.parse("application/force-download").equals(result.body().contentType())) { if (result != null && result.isSuccessful() && MediaType.parse("application/force-download").equals(result.body().contentType())) {
try (InputStream inputStream = result.body().byteStream()) { try (InputStream inputStream = result.body().byteStream()) {
FileOutputStream outputStream = new FileOutputStream(filePath + filePathSlash + imagePath+fileName); FileOutputStream outputStream = new FileOutputStream(filePath + filePathSlash + imagePath + fileName);
byte b[] = new byte[1024]; byte b[] = new byte[1024];
@ -1202,18 +1202,17 @@ public class IdcServiceImpl implements IdcService {
outputStream.flush(); outputStream.flush();
outputStream.close(); outputStream.close();
if(!(total>0)) { if (!(total > 0)) {
new File(filePath + filePathSlash + imagePath+fileName).delete(); new File(filePath + filePathSlash + imagePath + fileName).delete();
executeSql("delete from idc_file where filePath='"+fileName+"'"); executeSql("delete from idc_file where filePath='" + fileName + "'");
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
} }
} }
if(!(total>0)) { if (!(total > 0)) {
String sql = "replace idc_file (filePath,createTime,msg) values ('"+fileName+"',now(),'"+msg+"')"; String sql = "replace idc_file (filePath,createTime,msg) values ('" + fileName + "',now(),'" + msg + "')";
executeSql(sql); executeSql(sql);
} }
@ -1221,7 +1220,7 @@ public class IdcServiceImpl implements IdcService {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return (total>0); return (total > 0);
} }
// @Override // @Override
// public boolean signleDownloadFile(String syncIp, String fileName) { // public boolean signleDownloadFile(String syncIp, String fileName) {
@ -1357,8 +1356,6 @@ public class IdcServiceImpl implements IdcService {
} }
/*把列数据转Map*/ /*把列数据转Map*/
private Map<String, Object> getColumn(String tableName) { private Map<String, Object> getColumn(String tableName) {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
@ -1465,6 +1462,7 @@ public class IdcServiceImpl implements IdcService {
} }
} }
private void writeFile(byte[] file, String filePath, String fileName) throws Exception { private void writeFile(byte[] file, String filePath, String fileName) throws Exception {
File targetFile = new File(filePath); File targetFile = new File(filePath);
if (!targetFile.exists()) { if (!targetFile.exists()) {

@ -104,6 +104,8 @@ public class HeartService {
@Resource @Resource
IoOrderInvoiceService orderInvoiceService; IoOrderInvoiceService orderInvoiceService;
@Resource
IoOrderInvoiceMapper ioOrderInvoiceMapper;
private final ApplicationContext applicationContext; private final ApplicationContext applicationContext;
//上传最近更新扫码单据 //上传最近更新扫码单据
@ -1396,6 +1398,7 @@ public class HeartService {
String fileFullPath = writeFile(filePrefix, NEW_ALL_ORDER, response.getData()); String fileFullPath = writeFile(filePrefix, NEW_ALL_ORDER, response.getData());
basicDownloadStatusEntity.setCacheFilePath(fileFullPath); basicDownloadStatusEntity.setCacheFilePath(fileFullPath);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -1625,8 +1628,6 @@ public class HeartService {
private final IoCodeLostMapper ioCodeLostMapper; private final IoCodeLostMapper ioCodeLostMapper;
private final IoCodeRelMapper ioCodeRelMapper; private final IoCodeRelMapper ioCodeRelMapper;
@Resource
private final IoOrderInvoiceMapper ioOrderInvoiceMapper;
/** /**
* *
@ -1902,7 +1903,7 @@ public class HeartService {
List<IoOrderInvoiceEntity> orderInvoiceEntities = syncDataResponse.getOrderInvoiceEntities(); List<IoOrderInvoiceEntity> orderInvoiceEntities = syncDataResponse.getOrderInvoiceEntities();
for (IoOrderInvoiceEntity orderInvoiceEntity : orderInvoiceEntities) { for (IoOrderInvoiceEntity orderInvoiceEntity : orderInvoiceEntities) {
if (orderInvoiceEntity.getOrderIdFk().equals(orderEntity.getBillNo())) { if (orderInvoiceEntity.getOrderIdFk().equals(orderEntity.getBillNo())) {
orderInvoiceService.insertInvoice(orderInvoiceEntity); ioOrderInvoiceMapper.insertOrUpdate(orderInvoiceEntity);
} }
} }
} }

@ -230,40 +230,37 @@
</select> </select>
<select id="filterSpaceList" resultType="com.glxp.api.res.inv.InvPlaceDetailResponse"> <select id="filterSpaceList" resultType="com.glxp.api.res.inv.InvPlaceDetailResponse">
SELECT SELECT t1.nameCode,
t1.nameCode, t1.relId,
t1.relId, (SELECT NAME FROM auth_dept WHERE auth_dept.`code` = t1.deptCode) AS deptName,
( SELECT NAME FROM auth_dept WHERE auth_dept.`code` = t1.deptCode ) AS deptName, (SELECT NAME FROM auth_warehouse WHERE auth_warehouse.`code` = t1.invCode) AS invName,
( SELECT NAME FROM auth_warehouse WHERE auth_warehouse.`code` = t1.invCode ) AS invName, (SELECT NAME FROM auth_space WHERE auth_space.`code` = t1.invSpaceCode) AS invSpaceName,
( SELECT NAME FROM auth_space WHERE auth_space.`code` = t1.invSpaceCode ) AS invSpaceName, SUM(t1.reCount) as count,
SUM( t1.reCount ) as count, bp.cpmctymc as productName,
bp.cpmctymc as productName, bp.ggxh,
bp.ggxh, t1.batchNo,
t1.batchNo, t1.produceDate as productionDate,
t1.produceDate as productionDate, t1.expireDate,
t1.expireDate, bp.measname,
bp.measname, bp.zczbhhzbapzbh,
bp.zczbhhzbapzbh, bp.ylqxzcrbarmc,
bp.ylqxzcrbarmc, bp.manufactory,
bp.manufactory, (SELECT `name` FROM basic_corp WHERE erpId = t1.supId) supName
( SELECT `name` FROM basic_corp WHERE erpId = t1.supId ) supName FROM inv_prein_product_detail t1
FROM LEFT JOIN basic_udirel bu ON bu.id = t1.relId
inv_prein_product_detail t1 LEFT JOIN basic_products bp ON bp.uuid = bu.uuid
LEFT JOIN basic_udirel bu ON bu.id = t1.relId
LEFT JOIN basic_products bp ON bp.uuid = bu.uuid
<where> <where>
<if test="code != null and code != ''"> <if test="code != null and code != ''">
AND t1.code = #{code} AND t1.code = #{code}
and t1.invSpaceCode IS NOT NULL and t1.invSpaceCode IS NOT NULL
and t1.invSpaceCode!='' and t1.invSpaceCode != ''
</if> </if>
<if test="invSpaceCode != null and invSpaceCode != ''"> <if test="invSpaceCode != null and invSpaceCode != ''">
AND t1.invSpaceCode = #{invSpaceCode} AND t1.invSpaceCode = #{invSpaceCode}
</if> </if>
</where> </where>
GROUP BY GROUP BY CODE,
CODE, invSpaceCode
invSpaceCode
</select> </select>
@ -272,22 +269,22 @@
pd.code, pd.code,
pd.relId, pd.relId,
pd.batchNo, pd.batchNo,
pd.produceDate productionDate, pd.produceDate productionDate,
pd.expireDate, pd.expireDate,
bp.ggxh, bp.ggxh,
bp.cpmctymc productName, bp.cpmctymc productName,
bp.zczbhhzbapzbh, bp.zczbhhzbapzbh,
bp.ylqxzcrbarmc, bp.ylqxzcrbarmc,
bp.nameCode, bp.nameCode,
bp.manufactory, bp.manufactory,
pd.invSpaceCode, pd.invSpaceCode,
pd.invCode, pd.invCode,
ad.name deptName, ad.name deptName,
aw.name invName, aw.name invName,
sp.name invSpaceName, sp.name invSpaceName,
sum(pd.inCount) as inCount, ifnull(sum(pd.inCount), 0) as inCount,
sum(pd.outCount) as outCount, ifnull(sum(pd.outCount), 0) as outCount,
sum(pd.reCount) as reCount pd.inCount - pd.outCount as reCount
from inv_prein_product_detail pd from inv_prein_product_detail pd
left join basic_udirel bu on pd.relId = bu.id left join basic_udirel bu on pd.relId = bu.id
left join basic_products bp on bp.uuid = bu.uuid left join basic_products bp on bp.uuid = bu.uuid

@ -223,37 +223,32 @@
</select> </select>
<select id="getInventoryQuantity" resultType="Integer"> <select id="getInventoryQuantity" resultType="Integer">
SELECT ifnull(SUM(inCount), 0) - ifnull(SUM(outCount), 0)
SELECT ifnull(SUM(inCount),0)-ifnull(SUM(outCount),0) FROM inv_pre_product_detail ipd
FROM WHERE CODE = #{code}
inv_pre_product_detail ipd and (invSpaceCode is null or invSpaceCode = '')
WHERE
CODE = #{code}
and (invSpaceCode is null or invSpaceCode = '' )
</select> </select>
<select id="filterSpaceList" resultType="com.glxp.api.res.inv.InvPlaceDetailResponse"> <select id="filterSpaceList" resultType="com.glxp.api.res.inv.InvPlaceDetailResponse">
SELECT SELECT t1.nameCode,
t1.nameCode, t1.relId,
t1.relId, (SELECT NAME FROM auth_dept WHERE auth_dept.`code` = t1.deptCode) AS deptName,
( SELECT NAME FROM auth_dept WHERE auth_dept.`code` = t1.deptCode ) AS deptName, (SELECT NAME FROM auth_warehouse WHERE auth_warehouse.`code` = t1.invCode) AS invName,
( SELECT NAME FROM auth_warehouse WHERE auth_warehouse.`code` = t1.invCode ) AS invName, (SELECT NAME FROM auth_space WHERE auth_space.`code` = t1.invSpaceCode) AS invSpaceName,
( SELECT NAME FROM auth_space WHERE auth_space.`code` = t1.invSpaceCode ) AS invSpaceName, SUM(t1.reCount) as count,
SUM( t1.reCount ) as count, bp.cpmctymc as productName,
bp.cpmctymc as productName, bp.ggxh,
bp.ggxh, t1.batchNo,
t1.batchNo, t1.produceDate as productionDate,
t1.produceDate as productionDate, t1.expireDate,
t1.expireDate, bp.measname,
bp.measname, bp.zczbhhzbapzbh,
bp.zczbhhzbapzbh, bp.ylqxzcrbarmc,
bp.ylqxzcrbarmc, bp.manufactory,
bp.manufactory, (SELECT `name` FROM basic_corp WHERE erpId = t1.supId) supName
( SELECT `name` FROM basic_corp WHERE erpId = t1.supId ) supName FROM inv_pre_product_detail t1
FROM LEFT JOIN basic_udirel bu ON bu.id = t1.relId
inv_pre_product_detail t1 LEFT JOIN basic_products bp ON bp.uuid = bu.uuid
LEFT JOIN basic_udirel bu ON bu.id = t1.relId
LEFT JOIN basic_products bp ON bp.uuid = bu.uuid
<where> <where>
<if test="code != null and code != ''"> <if test="code != null and code != ''">
AND t1.code = #{code} AND t1.code = #{code}
@ -262,40 +257,39 @@
AND t1.invSpaceCode = #{invSpaceCode} AND t1.invSpaceCode = #{invSpaceCode}
</if> </if>
</where> </where>
GROUP BY GROUP BY CODE,
CODE, invSpaceCode
invSpaceCode
</select> </select>
<select id="findByGroupCode" resultType="com.glxp.api.res.inv.InvPlaceDetailResponse"> <select id="findByGroupCode" resultType="com.glxp.api.res.inv.InvPlaceDetailResponse">
select pd.id, select pd.id,
pd.code, pd.code,
pd.relId, pd.relId,
pd.batchNo, pd.batchNo,
pd.produceDate productionDate, pd.produceDate productionDate,
pd.expireDate, pd.expireDate,
bp.ggxh, bp.ggxh,
bp.cpmctymc productName, bp.cpmctymc productName,
bp.zczbhhzbapzbh, bp.zczbhhzbapzbh,
bp.ylqxzcrbarmc, bp.ylqxzcrbarmc,
bp.nameCode, bp.nameCode,
bp.manufactory, bp.manufactory,
pd.invSpaceCode, pd.invSpaceCode,
pd.invCode, pd.invCode,
ad.name deptName, ad.name deptName,
aw.name invName, aw.name invName,
sp.name invSpaceName, sp.name invSpaceName,
sum(pd.inCount) as inCount, ifnull(sum(pd.inCount), 0) as inCount,
sum(pd.outCount) as outCount, ifnull(sum(pd.outCount), 0) as outCount,
sum(pd.reCount) as reCount pd.inCount - pd.outCount as reCount
from inv_pre_product_detail pd from inv_pre_product_detail pd
left join basic_udirel bu on pd.relId = bu.id left join basic_udirel bu on pd.relId = bu.id
left join basic_products bp on bp.uuid = bu.uuid left join basic_products bp on bp.uuid = bu.uuid
left join auth_dept ad on pd.deptCode = ad.code left join auth_dept ad on pd.deptCode = ad.code
left join auth_warehouse aw on pd.invCode = aw.code left join auth_warehouse aw on pd.invCode = aw.code
left join auth_space sp on pd.invSpaceCode = sp.code left join auth_space sp on pd.invSpaceCode = sp.code
and sp.invStorageCode = pd.deptCode and sp.invWarehouseCode = pd.invCode and sp.invStorageCode = pd.deptCode and sp.invWarehouseCode = pd.invCode
<where> <where>
<if test="invCode != null and invCode != ''"> <if test="invCode != null and invCode != ''">
AND pd.invCode = #{invCode} AND pd.invCode = #{invCode}

@ -14,14 +14,14 @@
ipp.expireDate, ipp.expireDate,
bp.ylqxzcrbarmc, bp.ylqxzcrbarmc,
bp.zczbhhzbapzbh, bp.zczbhhzbapzbh,
sum(ipp.inCount) as inCount, ifnull(sum(ipp.inCount), 0) as inCount,
sum(ipp.outCount) as outCount, ifnull(sum(ipp.outCount), 0) as outCount,
sum(ipp.reCount) as reCount, ipp.inCount - ipp.outCount as reCount,
basic_corp.name supName, basic_corp.name supName,
ipp.supId, ipp.supId,
auth_dept.name deptName, auth_dept.name deptName,
auth_warehouse.name invName, auth_warehouse.name invName,
as.name spaceName, as.name spaceName,
ipp.deptCode, ipp.deptCode,
ipp.invCode ipp.invCode
from inv_product_detail ipp from inv_product_detail ipp
@ -345,37 +345,32 @@
</select> </select>
<select id="getInventoryQuantity" resultType="Integer"> <select id="getInventoryQuantity" resultType="Integer">
SELECT ifnull(SUM(inCount), 0) - ifnull(SUM(outCount), 0)
SELECT ifnull(SUM(inCount),0)-ifnull(SUM(outCount),0) FROM inv_product_detail ipd
FROM WHERE CODE = #{code}
inv_product_detail ipd and (invSpaceCode is null or invSpaceCode = '')
WHERE
CODE = #{code}
and (invSpaceCode is null or invSpaceCode = '' )
</select> </select>
<select id="filterSpaceList" resultType="com.glxp.api.res.inv.InvPlaceDetailResponse"> <select id="filterSpaceList" resultType="com.glxp.api.res.inv.InvPlaceDetailResponse">
SELECT SELECT t1.nameCode,
t1.nameCode, t1.relId,
t1.relId, (SELECT NAME FROM auth_dept WHERE auth_dept.`code` = t1.deptCode) AS deptName,
( SELECT NAME FROM auth_dept WHERE auth_dept.`code` = t1.deptCode ) AS deptName, (SELECT NAME FROM auth_warehouse WHERE auth_warehouse.`code` = t1.invCode) AS invName,
( SELECT NAME FROM auth_warehouse WHERE auth_warehouse.`code` = t1.invCode ) AS invName, (SELECT NAME FROM auth_space WHERE auth_space.`code` = t1.invSpaceCode) AS invSpaceName,
( SELECT NAME FROM auth_space WHERE auth_space.`code` = t1.invSpaceCode ) AS invSpaceName, SUM(t1.reCount) as count,
SUM( t1.reCount ) as count, bp.cpmctymc as productName,
bp.cpmctymc as productName, bp.ggxh,
bp.ggxh, t1.batchNo,
t1.batchNo, t1.produceDate as productionDate,
t1.produceDate as productionDate, t1.expireDate,
t1.expireDate, bp.measname,
bp.measname, bp.zczbhhzbapzbh,
bp.zczbhhzbapzbh, bp.ylqxzcrbarmc,
bp.ylqxzcrbarmc, bp.manufactory,
bp.manufactory, (SELECT `name` FROM basic_corp WHERE erpId = t1.supId) supName
( SELECT `name` FROM basic_corp WHERE erpId = t1.supId ) supName FROM inv_product_detail t1
FROM LEFT JOIN basic_udirel bu ON bu.id = t1.relId
inv_product_detail t1 LEFT JOIN basic_products bp ON bp.uuid = bu.uuid
LEFT JOIN basic_udirel bu ON bu.id = t1.relId
LEFT JOIN basic_products bp ON bp.uuid = bu.uuid
<where> <where>
<if test="code != null and code != ''"> <if test="code != null and code != ''">
AND t1.code = #{code} AND t1.code = #{code}
@ -384,8 +379,7 @@
AND t1.invSpaceCode = #{invSpaceCode} AND t1.invSpaceCode = #{invSpaceCode}
</if> </if>
</where> </where>
GROUP BY GROUP BY CODE,
CODE, invSpaceCode
invSpaceCode
</select> </select>
</mapper> </mapper>

Loading…
Cancel
Save