库存货位查询

pro
anthonywj 2 years ago
parent e1c80c5360
commit be5f16b38d

@ -87,6 +87,7 @@ public class IdcServiceImpl implements IdcService {
private ScheduledDao scheduledDao;
private String imagePath = FileConstant.COMMON_FILE_PATH;
/*获取拉取任务列表*/
@Override
public BaseResponse taskList(HttpServletRequest request, Map<String, Object> params) {
@ -206,11 +207,11 @@ public class IdcServiceImpl implements IdcService {
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");
List<Map<String,Object>> list = dbDao.list(map);
for(int i=0;i<list.size();i++) {
signleDownloadFile(host,list.get(i).get("filePath").toString());
List<Map<String, Object>> list = dbDao.list(map);
for (int i = 0; i < list.size(); i++) {
signleDownloadFile(host, list.get(i).get("filePath").toString());
}
}
@ -230,7 +231,7 @@ public class IdcServiceImpl implements IdcService {
String[] syncTables = TableUtils.syncTables();
for (int i = 0; i < syncTables.length; i++) {
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"));
saveIdcLog("---", "", map.get(tnames[0]) + syncTables[i], 0, 0);
if (sync) {
@ -245,21 +246,20 @@ public class IdcServiceImpl implements IdcService {
/*上传失败重新上传*/
private void asyncFailTask(String host) {
try
{
try {
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";
Map<String,Object> map = new HashMap<String,Object>();
Map<String, Object> map = new HashMap<String, Object>();
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<>();
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());
JSONObject object = JSONObject.parseObject(json);
List<Map> dataList = JSONObject.parseArray(JSON.toJSONString(object.get("data")), Map.class);
for (int m = 0; m < dataList.size(); m++) {
if(object.get("filePathColumn")!=null&&!StringUtils.isEmpty(object.get("filePathColumn").toString())&&
dataList.get(m).get(object.get("filePathColumn").toString()) !=null ) {
if (object.get("filePathColumn") != null && !StringUtils.isEmpty(object.get("filePathColumn").toString()) &&
dataList.get(m).get(object.get("filePathColumn").toString()) != null) {
String fileNames = dataList.get(m).get(object.get("filePathColumn").toString()).toString();
String[] str = fileNames.split(",");
for (int r = 0; r < str.length; r++) {
@ -267,14 +267,14 @@ public class IdcServiceImpl implements IdcService {
files.add(filePath + filePathSlash + imagePath + str[r]);
}
}
for(int k=0;k<30;k++) {
if(dataList.get(k).get("tableName"+k) == null)
for (int k = 0; k < 30; k++) {
if (dataList.get(k).get("tableName" + k) == null)
break;
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);
for(int x =0 ;x <childList.size();x++) {
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(",");
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);
for (int x = 0; x < childList.size(); x++) {
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(",");
for (int s = 0; s < str.length; s++) {
if (!StringUtils.isEmpty(str[s]) && FileUtils.isFileExist(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)) {
JSONObject res = JSON.parseObject(result);
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);
} else {
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 lastUpdateTime = getUpdateTime(tnames[2] + "." + tnames[0]+"."+tnames[1]+".delete");
String lastUpdateTime = getUpdateTime(tnames[2] + "." + tnames[0] + "." + tnames[1] + ".delete");
Date nowUpdateTime = new Date();
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)";
Map<String,Object> count = new HashMap<String,Object>();
count.put("sql", "select count(*) from idc_delete where "+where);
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)";
Map<String, Object> count = new HashMap<String, Object>();
count.put("sql", "select count(*) from idc_delete where " + where);
int total = dbDao.count(count);
int limit = 50;
if (total > 0) {
boolean success = true;
for (int i = 0; i < Math.ceil(total / limit) + 1; i++) {
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("sqlWhere", where);
map.put("limit", limit);
map.put("page", i * limit);
List<Map<String,Object>> list = dbDao.list(map);
if(list!=null&&map.size()>0) {
List<Map<String,Object>> data = new ArrayList<>();
for(int k=0;i<list.size();k++) {
List<Map<String, Object>> list = dbDao.list(map);
if (list != null && map.size() > 0) {
List<Map<String, Object>> data = new ArrayList<>();
for (int k = 0; i < list.size(); k++) {
String line = list.get(k).get("uniqueValue").toString();
JSONObject obj = JSON.parseObject(line);
String uniqueColumn = "";
for(String key : obj.keySet()){
uniqueColumn += uniqueColumn.length()>0 ? ","+key : key;
for (String key : obj.keySet()) {
uniqueColumn += uniqueColumn.length() > 0 ? "," + key : key;
}
obj.put("uniqueColumn", uniqueColumn);
obj.put("operateMode", "D");
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("messageType", tnames[9]+"(删除)");
msg.put("messageType", tnames[9] + "(删除)");
msg.put("apiCode", "common");
msg.put("tableName", DBAUtils.tableAliasName(tnames[2]));
msg.put("sendTime", new Date());
@ -374,7 +374,7 @@ public class IdcServiceImpl implements IdcService {
} else {
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 {
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();
// if (!StringUtils.isEmpty(tnames[0])) {
@ -425,7 +425,7 @@ public class IdcServiceImpl implements IdcService {
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))";
} else {
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) {
result = syncMasterData(map, isUpload, syncIp);
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 {
success = false;
}
syncAddTaskStatus(json.getJSONObject("data"), 3, true, startTime, true,success);
syncAddTaskStatus(json.getJSONObject("data"), 3, true, startTime, true, success);
} else {
if (json.get("code") != null && json.get("data") != null) {
//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);
}
}
@ -553,7 +553,7 @@ public class IdcServiceImpl implements IdcService {
IDCUtils.createDirectory(filePath + filePathSlash + datePath + "/");
if (!FileUtils.makeDirectory(backFilePath + backFileSlash + datePath))
IDCUtils.createDirectory(filePath + backFileSlash + datePath + "/");
if(!FileUtils.makeDirectory(filePath + filePathSlash + imagePath))
if (!FileUtils.makeDirectory(filePath + filePathSlash + imagePath))
IDCUtils.createDirectory(filePath + filePathSlash + imagePath);
FileUtils.SaveFileAs(content, fileName);
FileUtils.SaveFileAs(content, backFileName);
@ -585,7 +585,7 @@ public class IdcServiceImpl implements IdcService {
boolean success = false;
if (isLastLevel()) {
success = analyMiddle("", json, files, true, true);
syncAddTaskStatus(json, 3, true, startTime, true,success);
syncAddTaskStatus(json, 3, true, startTime, true, success);
if (!success) {
return ResultVOUtils.error(9000, "解析失败");
@ -596,11 +596,11 @@ public class IdcServiceImpl implements IdcService {
String host = getNextHost();
String result = relay(request.getHeader("reqNo"), content, saveFiles, host);
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);
return object;
} else {
syncAddTaskStatus(json, 2, true, startTime, false,false);
syncAddTaskStatus(json, 2, true, startTime, false, false);
return ResultVOUtils.error(9000, "转发失败");
}
@ -630,7 +630,7 @@ public class IdcServiceImpl implements IdcService {
public void downloadFile(String fileName, HttpServletResponse response) {
OutputStream os;
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 {
if (FileUtils.isFileExist(sourceFileName)) {
byte[] bytes = FileUtils.readFileByBytes(sourceFileName);
@ -639,7 +639,7 @@ public class IdcServiceImpl implements IdcService {
os.flush();
os.close();
} else {
logger.error("file not exists:"+sourceFileName);
logger.error("file not exists:" + sourceFileName);
}
} catch (IOException e) {
// TODO Auto-generated catch block
@ -718,7 +718,7 @@ public class IdcServiceImpl implements IdcService {
Map<String, Object> whereParams = new HashMap<String, Object>();
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>();
String where = DBAUtils.convertWhere(column, whereParams, dataWhere);
sql += !StringUtils.isEmpty(where) ? " where " + where : "";
@ -827,7 +827,7 @@ public class IdcServiceImpl implements IdcService {
}
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,
boolean isEnd,boolean isReceive) {
boolean isEnd, boolean isReceive) {
try {
String content = JSON.toJSONString(json);
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("receiveStatus", isReceive ? "1" : "0");
map.put("startTime", startTime != null ? startTime : new Date());
if(isReceive)
if (isReceive)
map.put("endTime", new Date());
map.put("updateTime", new Date());
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++) {
if (!StringUtils.isEmpty(filePathColumn)) {
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++) {
if (list.get(i).get("data" + z) != null) {
@ -960,7 +960,7 @@ public class IdcServiceImpl implements IdcService {
String[] keyColumn = new String[30];
String[] keyDataType = new String[30];
List<Map<String, String>> columnList = dbDao.listColumnsMysql(tName);
Map<String,Object> column = getColumn(tName);
Map<String, Object> column = getColumn(tName);
boolean result = false;
int key = 0;
int col = 0;
@ -968,7 +968,7 @@ public class IdcServiceImpl implements IdcService {
if (col > 0)
sql += ",";
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++;
if (uniqueColumn != null && columnList.get(i).get("columnKey") != null && ("," + uniqueColumn + ",").contains("," + columnList.get(i).get("columnName") + ",")) {
keyColumn[key] = columnList.get(i).get("columnName").toString();
@ -998,13 +998,13 @@ public class IdcServiceImpl implements IdcService {
}
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(",");
for(String str:ucs) {
Map<String,Object> map = (Map<String, Object>) column.get(str);
for (String str : ucs) {
Map<String, Object> map = (Map<String, Object>) column.get(str);
String dataType = map.get("dataType").toString();
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 {
for (int z = 0; z < keyColumn.length; z++) {
@ -1166,7 +1166,7 @@ public class IdcServiceImpl implements IdcService {
@Override
public boolean signleDownloadFile(String syncIp, String fileName) {
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);
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
@ -1183,13 +1183,13 @@ public class IdcServiceImpl implements IdcService {
int total = 0;
try {
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()) {
FileOutputStream outputStream = new FileOutputStream(filePath + filePathSlash + imagePath+fileName);
FileOutputStream outputStream = new FileOutputStream(filePath + filePathSlash + imagePath + fileName);
byte b[] = new byte[1024];
@ -1202,18 +1202,17 @@ public class IdcServiceImpl implements IdcService {
outputStream.flush();
outputStream.close();
if(!(total>0)) {
new File(filePath + filePathSlash + imagePath+fileName).delete();
executeSql("delete from idc_file where filePath='"+fileName+"'");
if (!(total > 0)) {
new File(filePath + filePathSlash + imagePath + fileName).delete();
executeSql("delete from idc_file where filePath='" + fileName + "'");
}
} catch (Exception e) {
e.printStackTrace();
}
}
if(!(total>0)) {
String sql = "replace idc_file (filePath,createTime,msg) values ('"+fileName+"',now(),'"+msg+"')";
if (!(total > 0)) {
String sql = "replace idc_file (filePath,createTime,msg) values ('" + fileName + "',now(),'" + msg + "')";
executeSql(sql);
}
@ -1221,7 +1220,7 @@ public class IdcServiceImpl implements IdcService {
// TODO Auto-generated catch block
e.printStackTrace();
}
return (total>0);
return (total > 0);
}
// @Override
// public boolean signleDownloadFile(String syncIp, String fileName) {
@ -1357,8 +1356,6 @@ public class IdcServiceImpl implements IdcService {
}
/*把列数据转Map*/
private Map<String, Object> getColumn(String tableName) {
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 {
File targetFile = new File(filePath);
if (!targetFile.exists()) {

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

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

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

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

Loading…
Cancel
Save