Commit 27b0d4f7 by liuyang

Merge branch 'dev' of http://git.pseer.com:8800/platform/hg-smart into dev-ly

parents f7b9e29c cae6dab8
......@@ -67,9 +67,12 @@ public class DaoUtils {
*/
public static void batchInsert(String sql, List rows) {
// 创建人部门
List<String> orgIds = UserSessionUtils.getOrgId();
AssertUtils.isEmpty(orgIds, "当前用户未绑定部门,无法操作数据,请联系管理员!");
String depCode = orgIds.get(0);
String depCode = "";
if (StringUtils.isBlank(depCode) && !"admin".equals(UserSessionUtils.getLoginName())) {
List<String> orgIds = UserSessionUtils.getOrgId();
AssertUtils.isEmpty(orgIds, "当前用户未绑定部门,无法操作数据,请联系管理员!");
depCode = orgIds.get(0);
}
for (Object row : rows) {
if (row instanceof DaoEPBase) {
DaoEPBase daoEPBase = (DaoEPBase) row;
......@@ -189,7 +192,7 @@ public class DaoUtils {
// 创建人组织机构
try {
String depCode = BeanUtils.getProperty(bean, "depCode");
if (StringUtils.isBlank(depCode)) {
if (StringUtils.isBlank(depCode) && !"admin".equals(userId)) {
List<String> orgIds = UserSessionUtils.getOrgId();
AssertUtils.isEmpty(orgIds, "当前用户未绑定部门,无法操作数据,请联系管理员!");
depCode = orgIds.get(0);
......@@ -257,7 +260,7 @@ public class DaoUtils {
// 创建人部门编码
try {
String depCode = MapUtils.getString(map, "depCode");
if (ObjectUtils.isNullBlank(depCode)) {
if (ObjectUtils.isNullBlank(depCode) && !"admin".equals(userId)) {
List<String> orgIds = UserSessionUtils.getOrgId();
AssertUtils.isEmpty(orgIds, "当前用户未绑定部门,无法操作数据,请联系管理员!");
depCode = orgIds.get(0);
......
......@@ -58,6 +58,7 @@ public class HGKC008A extends DaoEPBase {
public static final String FIELD_AMOUNT = "amount"; /* 金额*/
public static final String FIELD_INVENT_TYPE_DETAIL = "inventTypeDetail"; /* 存货类型大类*/
public static final String FIELD_QUALITY_NO = "qualityNo"; /* 质检单号*/
public static final String FIELD_INV_ID = "invId"; /* 库存ID*/
public static final String COL_ID = "ID"; /* 主键id*/
public static final String COL_ACCOUNT_CODE = "ACCOUNT_CODE"; /* 账套*/
......@@ -95,6 +96,7 @@ public class HGKC008A extends DaoEPBase {
public static final String COL_AMOUNT = "AMOUNT"; /* 金额*/
public static final String COL_INVENT_TYPE_DETAIL = "INVENT_TYPE_DETAIL"; /* 存货类型大类*/
public static final String COL_QUALITY_NO = "QUALITY_NO"; /* 质检单号*/
public static final String COL_INV_ID = "INV_ID"; /* 库存ID*/
public static final String QUERY = "HGKC008A.query";
public static final String COUNT = "HGKC008A.count";
......@@ -138,6 +140,7 @@ public class HGKC008A extends DaoEPBase {
private BigDecimal amount = new BigDecimal("0"); /* 金额*/
private Integer inventTypeDetail; /* 存货类型大类*/
private String qualityNo = " "; /* 质检单号*/
private Long invId = new Long(0); /* 库存ID*/
/**
* initialize the metadata.
......@@ -314,6 +317,10 @@ public class HGKC008A extends DaoEPBase {
eiColumn.setDescName("质检单号");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_INV_ID);
eiColumn.setDescName("库存ID");
eiMetadata.addMeta(eiColumn);
}
/**
......@@ -892,6 +899,14 @@ public class HGKC008A extends DaoEPBase {
this.qualityNo = qualityNo;
}
public Long getInvId() {
return invId;
}
public void setInvId(Long invId) {
this.invId = invId;
}
/**
* get the value from Map.
*
......@@ -936,6 +951,7 @@ public class HGKC008A extends DaoEPBase {
setAmount(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_AMOUNT)), amount));
setInventTypeDetail(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_INVENT_TYPE_DETAIL)), inventTypeDetail));
setQualityNo(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_QUALITY_NO)), qualityNo));
setInvId(NumberUtils.toLong(StringUtils.toString(map.get(FIELD_INV_ID)), invId));
}
/**
......@@ -981,6 +997,7 @@ public class HGKC008A extends DaoEPBase {
map.put(FIELD_AMOUNT, StringUtils.toString(amount, eiMetadata.getMeta(FIELD_AMOUNT)));
map.put(FIELD_INVENT_TYPE_DETAIL, StringUtils.toString(inventTypeDetail, eiMetadata.getMeta(FIELD_INVENT_TYPE_DETAIL)));
map.put(FIELD_QUALITY_NO, StringUtils.toString(qualityNo, eiMetadata.getMeta(FIELD_QUALITY_NO)));
map.put(FIELD_INV_ID, StringUtils.toString(invId, eiMetadata.getMeta(FIELD_INV_ID)));
return map;
}
......
......@@ -3,15 +3,18 @@ package com.baosight.hggp.hg.kc.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.common.InventTypeDetailEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.DeleteFlagEnum;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.constant.HGSqlConstant;
import com.baosight.hggp.hg.kc.constant.HgKcConst;
import com.baosight.hggp.hg.kc.domain.HGKC008;
import com.baosight.hggp.hg.kc.domain.HGKC008A;
import com.baosight.hggp.hg.kc.domain.HGKC010;
import com.baosight.hggp.hg.kc.domain.HGKC010B;
import com.baosight.hggp.hg.kc.tools.HGKCTools;
import com.baosight.hggp.hg.kc.utils.HGKCUtils;
import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.util.AssertUtils;
......@@ -26,6 +29,8 @@ import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.CollectionUtils;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
......@@ -74,6 +79,7 @@ public class ServiceHGKC008B extends ServiceBase {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
// inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, "inventTypeDetails", InventTypeDetailEnum.getInentTypeTwo());
queryRow.put("isInvQty", CommonConstant.YesNo.YES_1);
inInfo = super.query(inInfo, HGSqlConstant.HgKc010.QUERY_LY, new HGKC010());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
......@@ -132,6 +138,7 @@ public class ServiceHGKC008B extends ServiceBase {
newKc008A.setCompanyCode(dbKc008.getCompanyCode());
newKc008A.setCompanyName(dbKc008.getCompanyName());
newKc008A.setReceiveId(dbKc008.getId());
newKc008A.setInvId(dbKc010.getId());
newKc008A.setInvQty(fKc010B.getApplyQty());
newKc008A.setInvWeight(fKc010B.getApplyQty().multiply(dbKc010.getInvUnitWeight()));
newKc008A.setInvWidth(dbKc010.getWidth());
......@@ -160,6 +167,17 @@ public class ServiceHGKC008B extends ServiceBase {
for (HGKC010B fKc010B : fKc010Bs) {
AssertUtils.isGe(BigDecimal.ZERO, fKc010B.getApplyQty(), String.format("库存【%s】申请数量必须大于0",
fKc010B.getInventCode()));
// 查询已申请未提交的领料数量
List<HGKC008A> qtyKc008As = HGKCTools.HgKc008A.listByInv(fKc010B.getCompanyCode(), fKc010B.getWhCode(),
fKc010B.getInventCode());
BigDecimal applyQtySum = CollectionUtils.isEmpty(qtyKc008As) ? BigDecimal.ZERO
: qtyKc008As.stream().filter(item -> HgKcConst.HgKc008.Status.S0.equals(item.getStatus()))
.map(HGKC008A::getInvQty).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal totalApplyQty = applyQtySum.add(fKc010B.getApplyQty());
HGKC010 dbKc010 = dbKc010Map.get(fKc010B.getId());
AssertUtils.isGt(totalApplyQty, dbKc010.getInvQty(), String.format("存货【%s(%s)】累计申请数量【%s】超过库存数量【%s】",
fKc010B.getInventCode(), fKc010B.getInventName(),
totalApplyQty.stripTrailingZeros().toPlainString(), dbKc010.getInvQty()));
}
for (HGKC008A dbKc008A : dbKc008As) {
for (Map.Entry<Long, HGKC010> dbKc010MapEntry : dbKc010Map.entrySet()) {
......
......@@ -38,38 +38,26 @@
PRICE as "price", <!-- 单价 -->
AMOUNT as "amount", <!-- 金额 -->
INVENT_TYPE_DETAIL as "inventTypeDetail", <!-- 存货类型大类 -->
QUALITY_NO as "qualityNo" <!-- 质检单号 -->
QUALITY_NO as "qualityNo", <!-- 质检单号 -->
INV_ID as "invId" <!-- 库存ID -->
</sql>
<sql id="condition">
AND DELETE_FLAG = 0
<include refid="idCondition"/>
<include refid="customCondition"/>
<include refid="HGXSDataAuth.authCondition"/>
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depCode">
DEP_CODE = #depCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdBy">
CREATED_BY = #createdBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdName">
CREATED_NAME = #createdName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTime">
CREATED_TIME = #createdTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedBy">
UPDATED_BY = #updatedBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedName">
UPDATED_NAME = #updatedName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedTime">
UPDATED_TIME = #updatedTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="receiveId">
RECEIVE_ID = #receiveId#
</isNotEmpty>
......@@ -91,11 +79,8 @@
<isNotEmpty prepend=" AND " property="inventType">
INVENT_TYPE = #inventType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventCode">
INVENT_CODE like CONCAT('%',#inventCode#,'%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME like CONCAT('%',#inventName#,'%')
INVENT_NAME LIKE CONCAT('%',#inventName#,'%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="invSpecId">
INV_SPEC_ID = #invSpecId#
......@@ -136,18 +121,15 @@
<isNotEmpty prepend=" AND " property="notIds">
id NOT IN <iterate close=")" open="(" conjunction="," property="notIds">#notIds[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventTypeDetail">
INVENT_TYPE_DETAIL = #inventTypeDetail#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventTypeDetails">
INVENT_TYPE_DETAIL IN <iterate close=")" open="(" conjunction="," property="inventTypeDetails">#inventTypeDetails[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="status">
STATUS = #status#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="applyCode">
APPLY_CODE = #applyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="invId">
INV_ID = #invId#
</isNotEmpty>
</sql>
<sql id="idCondition">
......@@ -166,17 +148,48 @@
</sql>
<sql id="customCondition">
<include refid="condition"/>
<isNotEmpty prepend=" AND " property="inventCode">
INVENT_CODE LIKE CONCAT('%', #inventCode#, '%')
</isNotEmpty>
<isEqual prepend=" AND " property="isInvQty" compareValue="1">
INV_QTY > 0
</isEqual>
<isNotEmpty prepend=" AND " property="inventTypeDetail">
INVENT_TYPE_DETAIL = #inventTypeDetail#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventTypeDetails">
INVENT_TYPE_DETAIL IN <iterate close=")" open="(" conjunction="," property="inventTypeDetails">#inventTypeDetails[]#</iterate>
</isNotEmpty>
</sql>
<sql id="getCondition">
<include refid="condition"/>
<isNotEmpty prepend=" AND " property="inventCode">
INVENT_CODE = #inventCode#
</isNotEmpty>
</sql>
<!-- 查询 -->
<select id="get" resultClass="com.baosight.hggp.hg.kc.domain.HGKC008A">
SELECT
<include refid="column"/>
FROM ${hggpSchema}.HGKC008A
WHERE 1=1
<include refid="getCondition"/>
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
</dynamic>
</select>
<!-- 查询 -->
<select id="query" resultClass="com.baosight.hggp.hg.kc.domain.HGKC008A">
SELECT
<include refid="column"/>
FROM ${hggpSchema}.HGKC008A WHERE 1=1
<include refid="condition"/>
<include refid="customCondition"/>
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
......@@ -186,7 +199,7 @@
<select id="count" resultClass="int">
SELECT COUNT(*) FROM ${hggpSchema}.HGKC008A WHERE 1=1
<include refid="condition"/>
<include refid="customCondition"/>
</select>
<insert id="insert">
......@@ -222,12 +235,13 @@
PRICE, <!-- 单价 -->
AMOUNT, <!-- 金额 -->
INVENT_TYPE_DETAIL,
QUALITY_NO
QUALITY_NO,
INV_ID
) VALUES (#accountCode#,#projCode#, #projName#, #depCode#, #createdBy#, #createdName#, #createdTime#,
#deleteFlag#, #status#, #applyLineCode#, #applyCode#, #receiveId#, #companyCode#, #companyName#, #whCode#,
#whName#, #inventRecordId#, #inventType#, #inventCode#, #inventName#, #invSpecId#,#invSpec#, #invLength#,
#invWidth#, #invThick#, #invQty#, #invUnitWeight#, #invWeight#, #price#, #amount#, #inventTypeDetail#,
#qualityNo#)
#qualityNo#, #invId#)
</insert>
<delete id="delete">
......
......@@ -150,6 +150,9 @@
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME LIKE CONCAT('%', #inventName#, '%')
</isNotEmpty>
<isEqual prepend=" AND " property="isInvQty" compareValue="1">
INV_QTY > 0
</isEqual>
</sql>
<sql id="orderBy">
......
......@@ -1211,6 +1211,25 @@ public class HGKCTools {
return results.stream().collect(Collectors.toMap(HGKC008A::getApplyLineCode, item -> item));
}
/**
* 查询
*
* @param companyCode
* @param whCode
* @param inventCode
* @return
*/
public static List<HGKC008A> listByInv(String companyCode, String whCode, String inventCode) {
if (StringUtils.isBlank(companyCode) || StringUtils.isBlank(whCode) || StringUtils.isBlank(inventCode)) {
return null;
}
Map<String, Object> paramMap = new HashMap();
paramMap.put(HGKC008A.FIELD_COMPANY_CODE, companyCode);
paramMap.put(HGKC008A.FIELD_WH_CODE, whCode);
paramMap.put(HGKC008A.FIELD_INVENT_CODE, inventCode);
return DaoBase.getInstance().query(HGKC008A.QUERY, paramMap);
}
public static List<HGKC008A> getHgkc008aList(Long receiveId) {
Map paramMap = new HashMap();
paramMap.put("receiveId", receiveId);
......
......@@ -41,10 +41,15 @@ let confirm = function () {
}
for (let i = 0; i < rows.length; i++) {
let applyQty = rows[i]['applyQty'];
let invQty = rows[i]['invQty'];
if (!isPositiveNumber(applyQty)) {
message("勾选的第" + (i + 1) + "行申请数量必须大于0");
return;
}
if (parseFloat(invQty) < parseFloat(applyQty)) {
message("勾选的第" + (i + 1) + "行申请数量不能大于库存数量");
return;
}
}
JSUtils.confirm("确定对勾选的[" + rows.length + "]条数据进行\"生产领料\"操作吗? ", {
ok: function () {
......
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