Commit 49bca2e0 by 宋祥

1.库存收发存BUG修复

parent dd20e6f8
...@@ -24,6 +24,7 @@ import com.baosight.hpjx.util.CommonMethod; ...@@ -24,6 +24,7 @@ import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.DateUtils; import com.baosight.hpjx.util.DateUtils;
import com.baosight.hpjx.util.EiInfoUtils; import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils; import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.ObjectUtils;
import com.baosight.hpjx.util.StringUtil; import com.baosight.hpjx.util.StringUtil;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; import com.baosight.iplat4j.core.ei.EiInfo;
...@@ -32,6 +33,7 @@ import com.baosight.iplat4j.core.service.impl.ServiceBase; ...@@ -32,6 +33,7 @@ import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.web.threadlocal.UserSession; import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
...@@ -122,7 +124,7 @@ public class ServiceHPKC009 extends ServiceBase { ...@@ -122,7 +124,7 @@ public class ServiceHPKC009 extends ServiceBase {
inInfo.setStatus(EiConstant.STATUS_SUCCESS); inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("按天统计成功"); inInfo.setMsg("按天统计成功");
} catch (Exception e) { } catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "按天统计失败"); LogUtils.setMsg(inInfo, e, "按天统计失败");
} }
return inInfo; return inInfo;
} }
...@@ -158,7 +160,7 @@ public class ServiceHPKC009 extends ServiceBase { ...@@ -158,7 +160,7 @@ public class ServiceHPKC009 extends ServiceBase {
inInfo.setStatus(EiConstant.STATUS_SUCCESS); inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("按月统计成功"); inInfo.setMsg("按月统计成功");
} catch (Exception e) { } catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "按月统计失败"); LogUtils.setMsg(inInfo, e, "按月统计失败");
} }
return inInfo; return inInfo;
} }
...@@ -172,61 +174,54 @@ public class ServiceHPKC009 extends ServiceBase { ...@@ -172,61 +174,54 @@ public class ServiceHPKC009 extends ServiceBase {
List<HPKC009> newKc009s = new ArrayList<>(); List<HPKC009> newKc009s = new ArrayList<>();
// 1.1、期末库存 // 1.1、期末库存
queryMap.put("dateProc", queryMap.get("yesterTo")); queryMap.put("dateProc", queryMap.get("yesterTo"));
List<HPKC010> endKcs = dao.query(HPKC010A.QUERY, queryMap); List<HPKC010A> endKcs = dao.query(HPKC010A.QUERY, queryMap);
// 1.2、采购入库 // 1.2、采购入库
queryMap.put("createdTimeFrom", queryMap.get("yesterFrom") + "000000"); queryMap.put("createdTimeFrom", queryMap.get("yesterFrom") + "000000");
queryMap.put("createdTimeTo", queryMap.get("yesterTo") + "235959"); queryMap.put("createdTimeTo", queryMap.get("yesterTo") + "235959");
List<HPKC001> cgRks = dao.query(HPSqlConstant.HPKC001.STAT_DATE, queryMap); List<HPKC001> cgRks = dao.query(HPSqlConstant.HPKC001.STAT_DATE, queryMap);
Map<String, HPKC001> cgRkMap = cgRks.stream().collect(Collectors.toMap(item -> Map<String, HPKC001> cgRkMap = cgRks.stream().collect(Collectors.toMap(item ->
item.getCompanyCode() + "#" + item.getDepCode() + "#" + item.getWhCode() + "#" buildKey(item.getCompanyCode(), item.getDepCode(), item.getInventType(), item.getInventCode(),
+ item.getInventType() + "#" + item.getInventCode() + "#" item.getWhCode(), item.getInventRecordId()), item -> item));
+ item.getInventRecordId(), item -> item));
// 1.3、生产入库 // 1.3、生产入库
List<HPKC003> scRks = dao.query(HPSqlConstant.HPKC003.STAT_DATE, queryMap); List<HPKC003> scRks = dao.query(HPSqlConstant.HPKC003.STAT_DATE, queryMap);
Map<String, HPKC003> scRkMap = scRks.stream().collect(Collectors.toMap(item -> Map<String, HPKC003> scRkMap = scRks.stream().collect(Collectors.toMap(item ->
item.getCompanyCode() + "#" + item.getDepCode() + "#" + item.getWhCode() + "#" buildKey(item.getCompanyCode(), item.getDepCode(), item.getInventType(), item.getInventCode(),
+ item.getInventType() + "#" + item.getInventCode(), item -> item)); item.getWhCode(), item.getInventRecordId()), item -> item));
// 1.4、其他入库 // 1.4、其他入库
List<HPKC006> qtRks = dao.query(HPSqlConstant.HPKC006.STAT_DATE, queryMap); List<HPKC006> qtRks = dao.query(HPSqlConstant.HPKC006.STAT_DATE, queryMap);
Map<String, HPKC006> qtRkMap = qtRks.stream().collect(Collectors.toMap(item -> Map<String, HPKC006> qtRkMap = qtRks.stream().collect(Collectors.toMap(item ->
item.getCompanyCode() + "#" + item.getDepCode() + "#" + item.getWhCode() + "#" buildKey(item.getCompanyCode(), item.getDepCode(), item.getInventType(), item.getInventCode(),
+ item.getInventType() + "#" + item.getInventCode() + "#" item.getWhCode(), item.getInventRecordId()), item -> item));
+ item.getInventRecordId(), item -> item));
// 1.5、生产领料 // 1.5、生产领料
List<HPKC002> scCks = dao.query(HPSqlConstant.HPKC002.STAT_DATE, queryMap); List<HPKC002> scCks = dao.query(HPSqlConstant.HPKC002.STAT_DATE, queryMap);
Map<String, HPKC002> scCkMap = scCks.stream().collect(Collectors.toMap(item -> Map<String, HPKC002> scCkMap = scCks.stream().collect(Collectors.toMap(item ->
item.getCompanyCode() + "#" + item.getDepCode() + "#" + item.getWhCode() + "#" buildKey(item.getCompanyCode(), item.getDepCode(), item.getInventType(), item.getInventCode(),
+ item.getInventType() + "#" + item.getInventCode() + "#" item.getWhCode(), item.getInventRecordId()), item -> item));
+ item.getInventRecordId(), item -> item));
// 1.6、销售出库 // 1.6、销售出库
List<HPKC004> xsCks = dao.query(HPSqlConstant.HPKC004.STAT_DATE, queryMap); List<HPKC004> xsCks = dao.query(HPSqlConstant.HPKC004.STAT_DATE, queryMap);
Map<String, HPKC004> xsCkMap = xsCks.stream().collect(Collectors.toMap(item -> Map<String, HPKC004> xsCkMap = xsCks.stream().collect(Collectors.toMap(item ->
item.getCompanyCode() + "#" + item.getDepCode() + "#" + item.getWhCode() + "#" buildKey(item.getCompanyCode(), item.getDepCode(), item.getInventType(), item.getInventCode(),
+ item.getInventType() + "#" + item.getInventCode(), item -> item)); item.getWhCode(), item.getInventRecordId()), item -> item));
// 1.7、其它出库 // 1.7、其它出库
List<HPKC007> qtCks = dao.query(HPSqlConstant.HPKC007.STAT_DATE, queryMap); List<HPKC007> qtCks = dao.query(HPSqlConstant.HPKC007.STAT_DATE, queryMap);
Map<String, HPKC007> qtCkMap = qtCks.stream().collect(Collectors.toMap(item -> Map<String, HPKC007> qtCkMap = qtCks.stream().collect(Collectors.toMap(item ->
item.getCompanyCode() + "#" + item.getDepCode() + "#" + item.getWhCode() + "#" buildKey(item.getCompanyCode(), item.getDepCode(), item.getInventType(), item.getInventCode(),
+ item.getInventType() + "#" + item.getInventCode() + "#" item.getWhCode(), item.getInventRecordId()), item -> item));
+ item.getInventRecordId(), item -> item));
// 1.8、盘点差异数量 // 1.8、盘点差异数量
List<HPKC005> pdDiffs = dao.query(HPSqlConstant.HPKC005.STAT_DATE, queryMap); List<HPKC005> pdDiffs = dao.query(HPSqlConstant.HPKC005.STAT_DATE, queryMap);
Map<String, HPKC005> pdDiffMap = pdDiffs.stream().collect(Collectors.toMap(item -> Map<String, HPKC005> pdDiffMap = pdDiffs.stream().collect(Collectors.toMap(item ->
item.getCompanyCode() + "#" + item.getDepCode() + "#" + item.getWhCode() + "#" buildKey(item.getCompanyCode(), item.getDepCode(), item.getInventType(), item.getInventCode(),
+ item.getInventType() + "#" + item.getInventCode() + "#" item.getWhCode(), item.getInventRecordId()), item -> item));
+ item.getInventRecordId(), item -> item));
// 1.9、期初库存 // 1.9、期初库存
queryMap.put("dateProc", queryMap.get("beforeDate")); queryMap.put("dateProc", queryMap.get("beforeDate"));
List<HPKC009> initKcs = dao.query(HPKC009.QUERY, new HashMap<>()); List<HPKC009> initKcs = dao.query(HPKC009.QUERY, new HashMap<>());
Map<String, HPKC009> initKcMap = initKcs.stream().collect(Collectors.toMap(item -> Map<String, HPKC009> initKcMap = initKcs.stream().collect(Collectors.toMap(item ->
item.getCompanyCode() + "#" + item.getDepCode() + "#" + item.getWhCode() + "#" buildKey(item.getCompanyCode(), item.getDepCode(), item.getInventType(), item.getInventCode(),
+ item.getInventType() + "#" + item.getInventCode() + "#" item.getWhCode(), item.getInventRecordId()), item -> item));
+ item.getInventRecordId(), item -> item));
// 根据期末库存生成收发存对象 // 根据期末库存生成收发存对象
for (HPKC010 endKc : endKcs) { for (HPKC010A endKc : endKcs) {
String key = endKc.getCompanyCode() + "#" + endKc.getDepCode() + "#" String key = buildKey(endKc.getCompanyCode(), endKc.getDepCode(), endKc.getInventType(),
+ endKc.getWhCode() + "#" + endKc.getInventType() + "#" endKc.getInventCode(), endKc.getWhCode(), endKc.getInventRecordId());
+ endKc.getInventCode() + "#" + endKc.getInventRecordId();
HPKC009 kc009 = BeanUtils.copy(endKc, HPKC009.class); HPKC009 kc009 = BeanUtils.copy(endKc, HPKC009.class);
kc009.setDateType(queryMap.get("dateType").toString()); kc009.setDateType(queryMap.get("dateType").toString());
kc009.setDateProc(queryMap.get("yesterDate").toString()); kc009.setDateProc(queryMap.get("yesterDate").toString());
...@@ -519,4 +514,24 @@ public class ServiceHPKC009 extends ServiceBase { ...@@ -519,4 +514,24 @@ public class ServiceHPKC009 extends ServiceBase {
} }
} }
/**
* 构建KEY
*
* @param companyCode
* @param depCode
* @param inventType
* @param inventCode
* @param whCode
* @param inventRecordId
* @return
*/
private String buildKey(Object companyCode, Object depCode, Object inventType, Object inventCode,
Object whCode, Object inventRecordId) {
return ObjectUtils.trimToEmpty(companyCode) + "#"
+ ObjectUtils.trimToEmpty(depCode) + "#"
+ ObjectUtils.trimToEmpty(inventType) + "#"
+ ObjectUtils.trimToEmpty(inventCode) + "#"
+ ObjectUtils.trimToEmpty(whCode) + "#"
+ ObjectUtils.trimToEmpty(inventRecordId);
}
} }
...@@ -191,7 +191,7 @@ ...@@ -191,7 +191,7 @@
WH_CODE AS "whCode", WH_CODE AS "whCode",
INVENT_TYPE AS "inventType", INVENT_TYPE AS "inventType",
INVENT_CODE AS "inventCode", INVENT_CODE AS "inventCode",
INVENT_RECORD_ID AS "inventRecordId"; INVENT_RECORD_ID AS "inventRecordId",
COALESCE(SUM(AMOUNT), 0) AS "amount", COALESCE(SUM(AMOUNT), 0) AS "amount",
COALESCE(SUM(WEIGHT), 0) AS "weight" COALESCE(SUM(WEIGHT), 0) AS "weight"
FROM ${hpjxSchema}.T_HPKC004 FROM ${hpjxSchema}.T_HPKC004
......
...@@ -33,20 +33,18 @@ public class LogUtils { ...@@ -33,20 +33,18 @@ public class LogUtils {
if (inInfo == null) { if (inInfo == null) {
return; return;
} }
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg(title); inInfo.setMsg(title);
if (e == null) { if (e == null) {
inInfo.setStatus(EiConstant.STATUS_FAILURE); inInfo.setDetailMsg("");
inInfo.setDetailMsg("未知");
return; return;
} }
// 由于平台调用链不支持查看detailMsg的消息内容,因此这里修改成往Msg中写错误信息 // 由于平台调用链不支持查看detailMsg的消息内容,因此这里修改成往Msg中写错误信息
inInfo.setDetailMsg(e.getMessage()); inInfo.setDetailMsg(e.getMessage());
if (e instanceof PlatException) { if (e instanceof PlatException) {
inInfo.setMsg(inInfo.getMsg().concat(",原因:").concat(e.getMessage())); inInfo.setMsg(inInfo.getMsg().concat(",原因:").concat(e.getMessage()));
inInfo.setStatus(EiConstant.STATUS_FAILURE);
} else { } else {
inInfo.setMsg(inInfo.getMsg().concat(",原因参见详细错误描述!")); inInfo.setMsg(inInfo.getMsg().concat(",原因参见详细错误描述!"));
inInfo.setStatus(EiConstant.STATUS_FAILURE);
} }
} }
...@@ -66,18 +64,13 @@ public class LogUtils { ...@@ -66,18 +64,13 @@ public class LogUtils {
if (inInfo == null) { if (inInfo == null) {
return; return;
} }
inInfo.setStatus(EiConstant.STATUS_FAILURE);
String msg = title.concat(",原因:"); String msg = title.concat(",原因:");
if (e == null) { if (e == null) {
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg(msg.concat("未知")); inInfo.setMsg(msg.concat("未知"));
return; return;
} }
inInfo.setMsg(msg.concat(e.getMessage())); inInfo.setMsg(msg.concat(e.getMessage()));
if (e instanceof PlatException) {
inInfo.setStatus(EiConstant.STATUS_FAILURE);
} else {
inInfo.setStatus(EiConstant.STATUS_FAILURE);
}
} }
/** /**
......
...@@ -46,8 +46,8 @@ public class ObjectUtils extends org.apache.commons.lang.ObjectUtils { ...@@ -46,8 +46,8 @@ public class ObjectUtils extends org.apache.commons.lang.ObjectUtils {
/** /**
* Gets the toString of an Object returning an null if null input. * Gets the toString of an Object returning an null if null input.
* ObjectUtils.toString(null) = " " * ObjectUtils.toString(null) = ""
* ObjectUtils.toString("") = " " * ObjectUtils.toString("") = ""
* ObjectUtils.toString("bat") = "bat" * ObjectUtils.toString("bat") = "bat"
* ObjectUtils.toString(Boolean.TRUE) = "true" * ObjectUtils.toString(Boolean.TRUE) = "true"
* *
...@@ -55,13 +55,17 @@ public class ObjectUtils extends org.apache.commons.lang.ObjectUtils { ...@@ -55,13 +55,17 @@ public class ObjectUtils extends org.apache.commons.lang.ObjectUtils {
* @return * @return
*/ */
public static String toEmptyString(Object obj) { public static String toEmptyString(Object obj) {
if (obj == null || "".equals(obj)) { return obj == null ? "" : obj.toString();
return " ";
} else {
return obj.toString();
}
//return obj == null ? " " : obj.toString();
} }
/**
*
* @param obj
* @return
*/
public static String trimToEmpty(Object obj) {
return obj == null ? "" : obj.toString().trim();
}
/** /**
* 检查object是empty或null * 检查object是empty或null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment