Commit fa49d08c by 宋祥

1.修复质检单完成时,合同成收货完成的问题

parent 5e8d1c85
......@@ -67,6 +67,7 @@ public class HGCG002B extends DaoEPBase {
public static final String FIELD_BC_MAX_RECEIVE_WEIGHT = "bcMaxReceiveWeight"; /* 本次最大收货重量*/
public static final String FIELD_CONTRACT_DATE = "contractDate"; /* 合同日期*/
public static final String FIELD_CONTRACT_NO = "contractNo"; /* 合同号*/
public static final String FIELD_CONTRACT_LINE_NO = "contractLineNo"; /* 合同行号*/
public static final String FIELD_PLAN_NO = "planNo"; /* 计划单号*/
public static final String FIELD_SUP_CODE = "supCode"; /* 供应商编码*/
public static final String FIELD_SUP_NAME = "supName"; /* 供应商名称*/
......@@ -161,6 +162,7 @@ public class HGCG002B extends DaoEPBase {
private BigDecimal bcMaxReceiveWeight = new BigDecimal(0.000); /* 本次最大收货重量*/
private String contractDate = " "; /* 合同日期*/
private String contractNo = " "; /* 合同号*/
private String contractLineNo = " "; /* 合同行号*/
private String planNo = " "; /* 计划单号*/
private String supCode = " "; /* 供应商编码*/
private String supName = " "; /* 供应商名称*/
......@@ -386,7 +388,11 @@ public class HGCG002B extends DaoEPBase {
eiColumn = new EiColumn(FIELD_CONTRACT_NO);
eiColumn.setDescName("合同号");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_CONTRACT_LINE_NO);
eiColumn.setDescName("合同行号");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_PLAN_NO);
eiColumn.setDescName("计划单号");
eiMetadata.addMeta(eiColumn);
......@@ -1087,7 +1093,15 @@ public class HGCG002B extends DaoEPBase {
public void setCalculationMethod(Integer calculationMethod) {
this.calculationMethod = calculationMethod;
}
public String getContractLineNo() {
return contractLineNo;
}
public void setContractLineNo(String contractLineNo) {
this.contractLineNo = contractLineNo;
}
/**
* get the value from Map.
*
......@@ -1140,6 +1154,7 @@ public class HGCG002B extends DaoEPBase {
setBcMaxReceiveWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_BC_MAX_RECEIVE_WEIGHT)), bcMaxReceiveWeight));
setContractDate(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_CONTRACT_DATE)), contractDate));
setContractNo(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_CONTRACT_NO)), contractNo));
setContractLineNo(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_CONTRACT_LINE_NO)), contractLineNo));
setPlanNo(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PLAN_NO)), planNo));
setSupCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_SUP_CODE)), supCode));
setSupName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_SUP_NAME)), supName));
......@@ -1199,6 +1214,7 @@ public class HGCG002B extends DaoEPBase {
map.put(FIELD_BC_MAX_RECEIVE_WEIGHT, StringUtils.toString(bcMaxReceiveWeight, eiMetadata.getMeta(FIELD_BC_MAX_RECEIVE_WEIGHT)));
map.put(FIELD_CONTRACT_DATE, StringUtils.toString(contractDate, eiMetadata.getMeta(FIELD_CONTRACT_DATE)));
map.put(FIELD_CONTRACT_NO, StringUtils.toString(contractNo, eiMetadata.getMeta(FIELD_CONTRACT_NO)));
map.put(FIELD_CONTRACT_LINE_NO, StringUtils.toString(contractLineNo, eiMetadata.getMeta(FIELD_CONTRACT_LINE_NO)));
map.put(FIELD_PLAN_NO, StringUtils.toString(planNo, eiMetadata.getMeta(FIELD_PLAN_NO)));
map.put(FIELD_SUP_CODE, StringUtils.toString(supCode, eiMetadata.getMeta(FIELD_SUP_CODE)));
map.put(FIELD_SUP_NAME, StringUtils.toString(supName, eiMetadata.getMeta(FIELD_SUP_NAME)));
......
......@@ -170,6 +170,9 @@ public class ServiceHGCG002A extends ServiceBase {
*/
private void insertDetails(HGCG001A fCg001A, HGCG002 newCg002) {
HGCG002B cg002B = BeanUtils.copy(fCg001A, HGCG002B.class);
cg002B.setContractNo(newCg002.getContractNo());
cg002B.setContractLineNo(SequenceGenerator.getNextSequence(HGConstant.SequenceId.CG_CONTRACT_LINE_NO,
new String[]{newCg002.getContractNo()}));
cg002B.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
cg002B.setPrimaryId(newCg002.getId());
cg002B.setPlanDetailId(fCg001A.getId());
......
......@@ -145,9 +145,7 @@ public class ServiceHGCG003 extends ServiceBase {
* @param dbCg003Map
*/
private void checkEditData(List<HGCG003> fCg003s, Map<String, HGCG003> dbCg003Map) {
// 查询合同信息
List<String> contractNos = ObjectUtils.listEpKey(dbCg003Map.values(), HGCG003.FIELD_CONTRACT_NO);
Map<String, HGCG002A> dbCg002AMap = HGCGTools.HgCg002.map(contractNos);
for (HGCG003 fCg003 : fCg003s) {
String receiveNo = fCg003.getReceiveNo();
HGCG003 dbCg003 = dbCg003Map.get(receiveNo);
......@@ -156,14 +154,6 @@ public class ServiceHGCG003 extends ServiceBase {
String.format("收货单[%s]状态不是\"待确认\",不允许操作", receiveNo));
AssertUtils.isGt(BigDecimal.ZERO, fCg003.getReceiveQty(),
String.format("收货单[%s]的\"收货数量(%s)\"必须大于0", receiveNo, fCg003.getReceiveQty()));
// 校验合同数量
BigDecimal diffQty = fCg003.getReceiveQty().subtract(dbCg003.getReceiveQty());
if (diffQty.compareTo(BigDecimal.ZERO) == 1) {
HGCG002A dbCg002A = dbCg002AMap.get(dbCg003.getContractNo());
AssertUtils.isGt(diffQty, dbCg002A.getBcMaxReceiveQty(),
String.format("收货单【%s】的累计\"收货数量(%s)\"不能大于合同的\"采购数量(%s)\"", receiveNo,
fCg003.getReceiveQty(), dbCg002A.getPurQty()));
}
}
}
......@@ -202,12 +192,12 @@ public class ServiceHGCG003 extends ServiceBase {
// 采购收货DB数据
Map<String, HGCG003> dbCg003Map = HGCGUtils.HgCg003.lockGetDataEp(fCg003s);
// 采购合同DB数据
Map<String, HGCG002A> dbCg002AMap = HGCGUtils.HgCg002.lockGetData(
Map<String, HGCG002A> dbCg002Map = HGCGUtils.HgCg002.lockGetData(
ObjectUtils.listEpKey(fCg003s, HGCG003.FIELD_CONTRACT_NO));
// 数据校验
this.checkRemoveData(fCg003s, dbCg003Map);
// 保存数据
this.removeData(fCg003s, dbCg003Map, dbCg002AMap);
this.removeData(fCg003s, dbCg003Map, dbCg002Map);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fCg003s.size() + "]条数据删除成功!");
......
......@@ -185,18 +185,18 @@ public class ServiceHGCG003A extends ServiceBase {
*
* @param fCg002Bs
* @param dbCg002BMap
* @param cg002
* @param dbCg002
*/
private void confirmData(List<HGCG002B> fCg002Bs, Map<Long, HGCG002B> dbCg002BMap, HGCG002 cg002) {
private void confirmData(List<HGCG002B> fCg002Bs, Map<Long, HGCG002B> dbCg002BMap, HGCG002 dbCg002) {
// 写入主信息
HGCG003 newCg003 = insertMain(fCg002Bs, cg002);
HGCG003 newCg003 = insertMain(fCg002Bs, dbCg002);
// 写入明细数据
for (HGCG002B fCg002B : fCg002Bs) {
insertDetails(fCg002B, dbCg002BMap, newCg003);
}
// 修改合同信息
List<HGCG002> cg002s = new LinkedList<>();
cg002s.add(cg002);
cg002s.add(dbCg002);
HGCGTools.HgCg002.updateContractPrimary(cg002s);
}
......
......@@ -40,7 +40,9 @@
PROJ_NAME as "projName", <!-- 项目名称 -->
CALCULATION_METHOD as "calculationMethod", <!-- 计算方式 0-数量乘单价 1-重量乘单价 -->
PLAN_DETAIL_ID as "planDetailId", <!-- 计划明细id -->
STATUS as "status"
STATUS as "status",
CONTRACT_NO as "contractNo",
CONTRACT_LINE_NO as "contractLineNo"
</sql>
<sql id="condition">
......@@ -199,47 +201,51 @@
<include refid="condition"/>
</select>
<insert id="insert">
INSERT INTO ${hggpSchema}.HGCG002A (ID,
ACCOUNT_CODE, <!-- 企业编码 -->
DEP_CODE, <!-- 部门编码 -->
CREATED_BY, <!-- 记录创建者 -->
CREATED_NAME, <!-- 记录创建名称 -->
CREATED_TIME, <!-- 记录创建时间 -->
UPDATED_BY, <!-- 记录修改者 -->
UPDATED_NAME, <!-- 记录修改名称 -->
UPDATED_TIME, <!-- 记录修改时间 -->
DELETE_FLAG, <!-- 0-未删除,1-已删除 -->
COMPANY_CODE, <!-- 公司编码 -->
COMPANY_NAME, <!-- 公司名称 -->
INVENT_TYPE, <!-- 存货类型 -->
INVENT_CODE, <!-- 存货编码 -->
INVENT_NAME, <!-- 存货名称 -->
SPEC, <!-- 规格 -->
MATERIAL, <!-- 材质 -->
UNIT, <!-- 单位 -->
LENGTH, <!-- 长度 -->
WIDTH, <!-- 宽度 -->
THICK, <!-- 厚度 -->
PUR_QTY, <!-- 采购数量 -->
PUR_UNIT_WEIGHT, <!-- 采购单重 -->
PUR_WEIGHT, <!-- 采购重量 -->
RECEIVE_QTY, <!-- 收货数量 -->
RECEIVE_WEIGHT, <!-- 收货重量 -->
PRICE, <!-- 单价 -->
AMOUNT, <!-- 金额(不含税金额) -->
TAX_INCLUDE_AMOUNT, <!-- 含税金额 -->
TAX_AMOUNT, <!-- 税额 -->
TAX_RATE, <!-- 税率 -->
INVENT_TYPE_DETAIL, <!-- 存货类型大类 -->
PRIMARY_ID, <!-- 主表id -->
PROJ_CODE, <!-- 项目编码 -->
PROJ_NAME, <!-- 项目名称 -->
CALCULATION_METHOD,
PLAN_DETAIL_ID
)
VALUES (#id#, #accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #updatedTime#, #deleteFlag#, #companyCode#, #companyName#, #inventType#, #inventCode#, #inventName#, #spec#, #material#, #unit#, #length#, #width#, #thick#, #purQty#, #purUnitWeight#, #purWeight#, #receiveQty#, #receiveWeight#, #price#, #amount#, #taxIncludeAmount#, #taxAmount#, #taxRate#, #inventTypeDetail#, #primaryId#,#projCode#,#projName#,#calculationMethod#, #planDetailId#)
</insert>
<insert id="insert">
INSERT INTO ${hggpSchema}.HGCG002A (
ACCOUNT_CODE, <!-- 企业编码 -->
DEP_CODE, <!-- 部门编码 -->
CREATED_BY, <!-- 记录创建者 -->
CREATED_NAME, <!-- 记录创建名称 -->
CREATED_TIME, <!-- 记录创建时间 -->
DELETE_FLAG, <!-- 0-未删除,1-已删除 -->
COMPANY_CODE, <!-- 公司编码 -->
COMPANY_NAME, <!-- 公司名称 -->
INVENT_TYPE, <!-- 存货类型 -->
INVENT_CODE, <!-- 存货编码 -->
INVENT_NAME, <!-- 存货名称 -->
SPEC, <!-- 规格 -->
MATERIAL, <!-- 材质 -->
UNIT, <!-- 单位 -->
LENGTH, <!-- 长度 -->
WIDTH, <!-- 宽度 -->
THICK, <!-- 厚度 -->
PUR_QTY, <!-- 采购数量 -->
PUR_UNIT_WEIGHT, <!-- 采购单重 -->
PUR_WEIGHT, <!-- 采购重量 -->
RECEIVE_QTY, <!-- 收货数量 -->
RECEIVE_WEIGHT, <!-- 收货重量 -->
PRICE, <!-- 单价 -->
AMOUNT, <!-- 金额(不含税金额) -->
TAX_INCLUDE_AMOUNT, <!-- 含税金额 -->
TAX_AMOUNT, <!-- 税额 -->
TAX_RATE, <!-- 税率 -->
INVENT_TYPE_DETAIL, <!-- 存货类型大类 -->
PRIMARY_ID, <!-- 主表id -->
PROJ_CODE, <!-- 项目编码 -->
PROJ_NAME, <!-- 项目名称 -->
CALCULATION_METHOD,
PLAN_DETAIL_ID,
CONTRACT_NO,
CONTRACT_LINE_NO
) VALUES (
#accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#,
#deleteFlag#, #companyCode#, #companyName#, #inventType#, #inventCode#, #inventName#, #spec#,
#material#, #unit#, #length#, #width#, #thick#, #purQty#, #purUnitWeight#, #purWeight#, #receiveQty#,
#receiveWeight#, #price#, #amount#, #taxIncludeAmount#, #taxAmount#, #taxRate#, #inventTypeDetail#,
#primaryId#,#projCode#,#projName#,#calculationMethod#, #planDetailId#, #contractNo#, #contractLineNo#
)
</insert>
<delete id="delete">
DELETE FROM ${hggpSchema}.HGCG002A WHERE
......
......@@ -140,6 +140,9 @@
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="ids">
ID IN <iterate open="(" close=")" conjunction="," property="ids">#ids[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="receiveNo">
RECEIVE_NO = #receiveNo#
</isNotEmpty>
......
......@@ -312,33 +312,44 @@ public class HGCGTools {
paramMap.put(HGCG002.FIELD_RECEIVE_WEIGHT, newReceiveWeight);
DaoUtils.update(HGSqlConstant.HgCg002.UPDATE_RECEIVE, paramMap);
}
/**
* 查询
*
* @param contractNos
* @param ids
* @return
*/
public static List<HGCG002A> list(List<String> contractNos) {
AssertUtils.isEmpty(contractNos, "合同号不能为空");
public static List<HGCG002> listByIds(List<Long> ids) {
AssertUtils.isEmpty(ids, "合同号不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put("contractNos", contractNos);
paramMap.put("ids", ids);
return DaoBase.getInstance().query(HGCG002.QUERY, paramMap);
}
/**
* 查询
*
* @param ids
* @return
*/
public static List<HGCG002> listByIds(List<Long> ids) {
AssertUtils.isEmpty(ids, "合同号不能为空");
public static Map<Long, HGCG002> mapByIds(List<Long> ids) {
List<HGCG002> results = listByIds(ids);
return results.stream().collect(Collectors.toMap(HGCG002::getId, item -> item));
}
/**
* 查询
*
* @param contractNos
* @return
*/
public static List<HGCG002A> list(List<String> contractNos) {
AssertUtils.isEmpty(contractNos, "合同号不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put("ids", ids);
paramMap.put("contractNos", contractNos);
return DaoBase.getInstance().query(HGCG002.QUERY, paramMap);
}
/**
* 查询
*
......@@ -347,7 +358,7 @@ public class HGCGTools {
*/
public static Map<String, HGCG002A> map(List<String> contractNos) {
List<HGCG002A> results = list(contractNos);
return results.stream().collect(Collectors.toMap(HGCG002A::getContractNo, item -> item));
return results.stream().collect(Collectors.toMap(HGCG002::getContractNo, item -> item));
}
/**
......@@ -430,39 +441,7 @@ public class HGCGTools {
DaoUtils.update(HGSqlConstant.HgCg002.UPDATE_PUR, cg002);
}
public static void updateChecks(List<HGZL001> fZl001s) {
//获取收货明细数据
List<Long> receiveDetailIds = fZl001s.stream().map(HGZL001::getReceiveDetailId).collect(Collectors.toList());
List<HGCG003B> hgcg003BList = HGCGTools.HgCg003B.list(receiveDetailIds);
//获取合同明细
List<Long> contractDetailIds = hgcg003BList.stream().map(HGCG003B::getContractDetailId).collect(Collectors.toList());
List<HGCG002B> hgcg002BList = HGCGTools.HgCg002B.list(contractDetailIds);
//合同主表信息
List<Long> contractIds = hgcg002BList.stream().map(o->o.getPrimaryId()).collect(Collectors.toList());
List<HGCG002> queryHgcg002List = HGCGTools.HgCg002.listByIds(contractIds);
fZl001s.forEach(hgzl001 ->{
//关联获取到收货明细
HGCG003B hgcg003B = hgcg003BList.stream().filter(o -> o.getId().compareTo(hgzl001.getReceiveDetailId()) == 0).findAny().orElse(null);
if(Objects.nonNull(hgcg003B)){
//关联获取到合同明细
HGCG002B hgcg002B = hgcg002BList.stream().filter(o->o.getId().compareTo(hgcg003B.getContractDetailId()) == 0).findAny().orElse(null);
if(Objects.nonNull(hgcg002B)){
BigDecimal unqualifyQty = hgzl001.getUnqualifyQty();
Integer status = unqualifyQty.compareTo(BigDecimal.ZERO) == 0 ? HGConstant.CgContractStatus.S_5
: HGConstant.CgContractStatus.S_4;
hgcg002B.setStatus(status);
HGCGTools.HgCg002B.updateCheck(hgcg002B,unqualifyQty.negate());
//修改主表信息
HGCG002 hgcg002 = queryHgcg002List.stream().filter(o->o.getId().compareTo(hgcg002B.getPrimaryId()) == 0).findAny().orElse(null);
hgcg002.setStatus(status);
HGCGTools.HgCg002.updateCheck(hgcg002,unqualifyQty.negate());
}
}
});
}
/**
* 修改状态
*
......@@ -611,24 +590,6 @@ public class HGCGTools {
/**
* 修改状态
*
* @param dbCg002B
* @param receiveQty
*/
public static void updateCheck(HGCG002B dbCg002B, BigDecimal receiveQty) {
AssertUtils.isNull(dbCg002B, "合同明细不能为空!");
AssertUtils.isNull(receiveQty, "收货数量不能为空!");
BigDecimal newReceiveQty = receiveQty.add(dbCg002B.getReceiveQty());
Map<String, Object> paramMap = new HashMap<>();
paramMap.put(HGCG002.FIELD_ID, dbCg002B.getId());
paramMap.put(HGCG002.FIELD_RECEIVE_QTY, newReceiveQty);
paramMap.put(HGCG002.FIELD_RECEIVE_WEIGHT, newReceiveQty.multiply(dbCg002B.getPurUnitWeight()));
paramMap.put(HGCG002.FIELD_STATUS, dbCg002B.getStatus());
DaoUtils.update(HGSqlConstant.HgCg002B.UPDATE_CHECK, paramMap);
}
/**
* 修改状态
*
* @param primaryId
* @param status
*/
......@@ -664,6 +625,7 @@ public class HGCGTools {
AssertUtils.isEmpty(results, String.format("采购收货单[%s]不存在", id));
return results.get(0);
}
/**
* 锁
*
......@@ -678,7 +640,20 @@ public class HGCGTools {
paramMap.put("receiveNos", receiveNos);
DaoBase.getInstance().update(HGSqlConstant.HgCg003.LOCK, paramMap);
}
/**
* 查询
*
* @param ids
* @return
*/
public static List<HGCG003> listById(List<Long> ids) {
AssertUtils.isEmpty(ids, "合同号不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put("ids", ids);
return DaoBase.getInstance().query(HGCG003.QUERY, paramMap);
}
/**
* 查询
*
......@@ -760,50 +735,6 @@ public class HGCGTools {
*
* @param zl001s
*/
public static void updateChecks(List<HGZL001> zl001s) {
zl001s.forEach(zl001->{
Map<String, Object> paramDetailMap = new HashMap<>();
paramDetailMap.put(HGCG003B.FIELD_ID, zl001.getReceiveDetailId());
paramDetailMap.put(HGCG003B.FIELD_STATUS, HGConstant.CgReceiveStatus.S_4);
paramDetailMap.put(HGCG003B.FIELD_DELIVER_QTY, zl001.getUnqualifyQty());
paramDetailMap.put(HGCG003B.FIELD_DEPOSIT_QTY, zl001.getQualifyQty());
DaoUtils.update(HGSqlConstant.HgCg003B.UPDATE_CONFIRM, paramDetailMap);
//采购入库
HGKCTools.HgKc001.putInStorageData(zl001.getReceiveDetailId());
});
//获取质检通过的收货单信息
List<String> receiveNos = zl001s.stream().map(o->o.getReceiveNo()).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(receiveNos)){
//主表信息
List<HGCG003> hgcg003List = HGCGTools.HgCg003.list(receiveNos);
//子表信息
List<HGCG003B> hgcg003BList = HGCGTools.HgCg003B.listByPrimaryIds(hgcg003List.stream().map(o->o.getId()).collect(Collectors.toList()));
hgcg003List.forEach(cg003->{
List<HGCG003B> hgcg003BFilterList = hgcg003BList.stream().filter(o->o.getPrimaryId().compareTo(cg003.getId()) == 0
&& o.getStatus().intValue() == HGConstant.CgReceiveStatus.S_3).collect(Collectors.toList());
//如果不存在质检中的收货明细了,则主表为质检完成
if(CollectionUtils.isEmpty(hgcg003BFilterList)){
Map<String, Object> paramDetailMap = new HashMap<>();
paramDetailMap.put(HGCG003.FIELD_RECEIVE_NO, cg003.getReceiveNo());
paramDetailMap.put(HGCG003.FIELD_STATUS, HGConstant.CgReceiveStatus.S_4);
BigDecimal depositQtySum = hgcg003BList.stream().map(HGCG003B::getDepositQty).reduce(BigDecimal.ZERO,BigDecimal::add);
paramDetailMap.put(HGCG003.FIELD_DEPOSIT_QTY, depositQtySum);
BigDecimal deliverQtySum = hgcg003BList.stream().map(HGCG003B::getDeliverQty).reduce(BigDecimal.ZERO,BigDecimal::add);
paramDetailMap.put(HGCG003.FIELD_DELIVER_QTY, deliverQtySum);
DaoUtils.update(HGSqlConstant.HgCg003.UPDATE_CONFIRM, paramDetailMap);
}
});
}
}
/**
* 修改状态
*
* @param zl001s
*/
public static void deleteChecks(List<HGZL001> zl001s) {
zl001s.forEach(zl001->{
Map<String, Object> paramDetailMap = new HashMap<>();
......@@ -877,7 +808,7 @@ public class HGCGTools {
paramMap.put("primaryId", primaryId);
return DaoBase.getInstance().query(HGCG003B.QUERY, paramMap);
}
/**
* 查询
*
......@@ -890,7 +821,36 @@ public class HGCGTools {
paramMap.put("primaryIds", primaryIds);
return DaoBase.getInstance().query(HGCG003B.QUERY, paramMap);
}
/**
* 查询
*
* @param primaryIds
* @return
*/
public static Map<Long, List<HGCG003B>> mapByPrimaryIds(List<Long> primaryIds) {
List<HGCG003B> results = listByPrimaryIds(primaryIds);
if (CollectionUtils.isEmpty(results)) {
return null;
}
return results.stream().collect(Collectors.groupingBy(HGCG003B::getPrimaryId));
}
/**
* 锁
*
* @param id
* @return
*/
public static void lock(Long id) {
if (id == null) {
return;
}
Map paramMap = new HashMap();
paramMap.put("id", id);
DaoBase.getInstance().update(HGSqlConstant.HgCg003B.LOCK, paramMap);
}
/**
* 锁
*
......@@ -945,7 +905,6 @@ public class HGCGTools {
DaoUtils.update(HGSqlConstant.HgCg003B.UPDATE_STATUS, paramMap);
}
}
}
......@@ -178,7 +178,20 @@ public class HGCGUtils {
* @date:2024/5/9,16:58
*/
public static class HgCg003B {
/**
* 锁并且获取数据
*
* @param id
* @return
*/
public static HGCG003B lockGetData(Long id) {
// 锁
HGCGTools.HgCg003B.lock(id);
// db数据
return HGCGTools.HgCg003B.get(id);
}
/**
* 锁并且获取数据
*
......
......@@ -101,6 +101,8 @@ public class HGConstant {
public static final String CG_PLAN_NO = "CG_PLAN_NO";
// 采购合同号
public static final String CG_CONTRACT_NO = "CG_CONTRACT_NO";
// 采购合同行号
public static final String CG_CONTRACT_LINE_NO = "CG_CONTRACT_LINE_NO";
// 采购收货号
public static final String CG_RECEIVE_NO = "CG_RECEIVE_NO";
// 采购入库号
......
......@@ -8,6 +8,7 @@ import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.DeleteFlagEnum;
import com.baosight.hggp.hg.cg.domain.HGCG003B;
import com.baosight.hggp.hg.cg.tools.HGCGTools;
import com.baosight.hggp.hg.cg.utils.HGCGUtils;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.constant.HGSqlConstant;
......@@ -107,16 +108,11 @@ public class HGKCTools {
/**
* 生产入库(入库质检单)
* @param receiveId
*
* @param dbCg003B
*/
public static void putInStorageData(Long receiveId) {
List<Long> receiveIDsList = new LinkedList<>();
receiveIDsList.add(receiveId);
// db数据
Map<Long, HGCG003B> dbCg003BMap = HGCGUtils.HgCg003B.lockGetData(receiveIDsList);
HGCG003B dbCg003B = dbCg003BMap.get(receiveId);
HGKC001 newKc001 = new HGKC001();
BeanUtils.copyProperties(dbCg003B, newKc001,"id","createdBy","createdName","createdTime","updatedBy","updatedName","updatedTime");
public static void putInStorageData(HGCG003B dbCg003B) {
HGKC001 newKc001 = BeanUtils.copy(dbCg003B, HGKC001.class);
newKc001.setDepositDate(DateUtils.shortDate());
newKc001.setDepositNo(SequenceGenerator.getNextSequence(HGConstant.SequenceId.CG_DEPOSIT_NO));
newKc001.setDepositQty(dbCg003B.getDepositQty());
......
......@@ -6,7 +6,13 @@ 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.cg.domain.HGCG002;
import com.baosight.hggp.hg.cg.domain.HGCG002B;
import com.baosight.hggp.hg.cg.domain.HGCG003;
import com.baosight.hggp.hg.cg.domain.HGCG003B;
import com.baosight.hggp.hg.cg.tools.HGCGTools;
import com.baosight.hggp.hg.cg.utils.HGCGUtils;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.constant.HGSqlConstant;
import com.baosight.hggp.hg.kc.tools.HGKCTools;
import com.baosight.hggp.hg.xs.domain.Company;
......@@ -21,10 +27,15 @@ import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import org.apache.commons.collections.CollectionUtils;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author ZJH
......@@ -194,10 +205,14 @@ public class ServiceHGZL001 extends ServiceBase {
try {
List<HGZL001> fZl001s = MapUtils.toDaoEPBases(inInfo, HGZL001.class);
Map<String, HGZL001> dbZl001Map = HGZLUtils.HgZl001.lockGetDataEp(fZl001s);
// 获取收货明细数据
List<Long> receiveDetailIds = fZl001s.stream().map(HGZL001::getReceiveDetailId)
.collect(Collectors.toList());
Map<Long, HGCG003B> dbCg003BMap = HGCGUtils.HgCg003B.lockGetData(receiveDetailIds);
// 数据校验
this.checkProcessData(fZl001s, dbZl001Map);
this.checkProcessData(fZl001s, dbZl001Map, dbCg003BMap);
// 保存数据
this.saveProcessData(fZl001s, dbZl001Map);
this.saveProcessData(fZl001s, dbZl001Map, dbCg003BMap);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fZl001s.size() + "]条数据处理成功!");
......@@ -206,50 +221,145 @@ public class ServiceHGZL001 extends ServiceBase {
}
return inInfo;
}
/**
* 校验数据
*
* @param fZl001s
* @param dbZl001Map
* @param dbCg003BMap
*/
private void checkProcessData(List<HGZL001> fZl001s, Map<String, HGZL001> dbZl001Map) {
private void checkProcessData(List<HGZL001> fZl001s, Map<String, HGZL001> dbZl001Map,
Map<Long, HGCG003B> dbCg003BMap) {
for (HGZL001 fZl001 : fZl001s) {
String checkNo = fZl001.getCheckNo();
HGZL001 dbZl003 = dbZl001Map.get(checkNo);
AssertUtils.isNotEquals(CommonConstant.YesNo.NO_0, dbZl003.getStatus(),
String.format("质检单[%s]状态不是\"未处理\",不允许操作", checkNo));
AssertUtils.isTrue(fZl001.getQualifyQty().compareTo(BigDecimal.ZERO) < 0 ,String.format("质检单[%s]的合格数量不能为负数", checkNo));
AssertUtils.isTrue(fZl001.getUnqualifyQty().compareTo(BigDecimal.ZERO) < 0 ,String.format("质检单[%s]的不合格数量不能为负数", checkNo));
AssertUtils.isTrue(fZl001.getQualifyQty().compareTo(BigDecimal.ZERO) < 0,
String.format("质检单[%s]的合格数量不能为负数", checkNo));
AssertUtils.isTrue(fZl001.getUnqualifyQty().compareTo(BigDecimal.ZERO) < 0,
String.format("质检单[%s]的不合格数量不能为负数", checkNo));
AssertUtils.isNotEquals(fZl001.getQualifyQty().add(fZl001.getUnqualifyQty()), dbZl003.getReceiveQty(),
String.format("质检单[%s]的合格数量加不合格数量必须等于收货数量", checkNo));
AssertUtils.isNull(dbCg003BMap.get(fZl001.getReceiveDetailId()),
String.format("质检单[%s]的关联的收货信息不存在", checkNo));
}
}
/**
* 保存数据
*
* @param fZl001s
* @param dbZl001Map
* @param dbCg003BMap
*/
private void saveProcessData(List<HGZL001> fZl001s, Map<String, HGZL001> dbZl001Map) {
private void saveProcessData(List<HGZL001> fZl001s, Map<String, HGZL001> dbZl001Map,
Map<Long, HGCG003B> dbCg003BMap) {
for (HGZL001 fZl001 : fZl001s) {
// 更新质检单状态
String checkNo = fZl001.getCheckNo();
HGZL001 dbZl001 = dbZl001Map.get(checkNo);
dbZl001.setQualifyQty(fZl001.getQualifyQty());
dbZl001.setUnqualifyQty(fZl001.getUnqualifyQty());
dbZl001.setStatus(CommonConstant.YesNo.YES_1);
DaoUtils.update(HGSqlConstant.HgZl001.PROCESS, dbZl001);
// // 更新收货单状态
// HGCGTools.HgCg003.updateCheck(dbZl001);
//生成采购入库单
//HGKCTools.HgKc001.putInStorageData(dbZl001.getReceiveDetailId());
// 更新收货单明细
this.updateReceiveDetail(fZl001, dbCg003BMap);
}
// 更新收货单状态
HGCGTools.HgCg003.updateChecks(fZl001s);
// 更新收货单主表信息
this.updateReceiveMain(fZl001s);
// 质检修改合同状态
HGCGTools.HgCg002.updateChecks(fZl001s);
this.updateContract(fZl001s, dbCg003BMap);
}
/**
* 更新收货单明细
*
* @param fZl001
* @param dbCg003BMap
*/
private void updateReceiveDetail(HGZL001 fZl001, Map<Long, HGCG003B> dbCg003BMap) {
Long receiveDetailId = fZl001.getReceiveDetailId();
// 更新采购收货明细的入库数量
Map<String, Object> paramDetailMap = new HashMap<>();
paramDetailMap.put(HGCG003B.FIELD_ID, receiveDetailId);
paramDetailMap.put(HGCG003B.FIELD_STATUS, HGConstant.CgReceiveStatus.S_4);
paramDetailMap.put(HGCG003B.FIELD_DELIVER_QTY, fZl001.getUnqualifyQty());
paramDetailMap.put(HGCG003B.FIELD_DEPOSIT_QTY, fZl001.getQualifyQty());
DaoUtils.update(HGSqlConstant.HgCg003B.UPDATE_CONFIRM, paramDetailMap);
// 生成采购入库单
HGKCTools.HgKc001.putInStorageData(dbCg003BMap.get(receiveDetailId));
}
/**
* 更新收货单状态
*
* @param fZl001s
*/
public void updateReceiveMain(List<HGZL001> fZl001s) {
// 收货单号去重
List<String> receiveNos = fZl001s.stream().map(item -> item.getReceiveNo()).distinct()
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(receiveNos)) {
return;
}
// 收货单主表信息
List<HGCG003> dbCg003s = HGCGTools.HgCg003.list(receiveNos);
// 收货单子表信息
List<Long> primaryIds = dbCg003s.stream().map(item -> item.getId()).collect(Collectors.toList());
Map<Long, List<HGCG003B>> dbCg003BMap = HGCGTools.HgCg003B.mapByPrimaryIds(primaryIds);
for (HGCG003 dbCg003 : dbCg003s) {
List<HGCG003B> dbCg003Bs = dbCg003BMap == null ? null : dbCg003BMap.get(dbCg003.getId());
AssertUtils.isEmpty(dbCg003Bs, String.format("采购收货单【%s】无明细数据,请检查", dbCg003.getReceiveNo()));
// 过滤出质检中的收货单
boolean bool = dbCg003Bs.stream().anyMatch(dbCg003B
-> HGConstant.CgReceiveStatus.S_3.equals(dbCg003B.getStatus()));
// 如果不存在质检中的收货明细了,则主表为质检完成
if (!bool) {
Map<String, Object> paramDetailMap = new HashMap<>();
paramDetailMap.put(HGCG003.FIELD_RECEIVE_NO, dbCg003.getReceiveNo());
paramDetailMap.put(HGCG003.FIELD_STATUS, HGConstant.CgReceiveStatus.S_4);
BigDecimal depositQtySum = dbCg003Bs.stream().map(HGCG003B::getDepositQty)
.reduce(BigDecimal.ZERO, BigDecimal::add);
paramDetailMap.put(HGCG003.FIELD_DEPOSIT_QTY, depositQtySum);
BigDecimal deliverQtySum = dbCg003Bs.stream().map(HGCG003B::getDeliverQty)
.reduce(BigDecimal.ZERO, BigDecimal::add);
paramDetailMap.put(HGCG003.FIELD_DELIVER_QTY, deliverQtySum);
DaoUtils.update(HGSqlConstant.HgCg003.UPDATE_CONFIRM, paramDetailMap);
}
}
}
/**
* 修改合同状态
*
* @param fZl001s
* @param dbCg003BMap
*/
public void updateContract(List<HGZL001> fZl001s, Map<Long, HGCG003B> dbCg003BMap) {
// 获取收货明细数据
List<HGCG003B> dbCg003Bs = dbCg003BMap.values().stream().collect(Collectors.toList());
// 获取合同明细
List<Long> contractDetailIds = dbCg003Bs.stream().map(HGCG003B::getContractDetailId).distinct()
.collect(Collectors.toList());
Map<Long, HGCG002B> dbCg002BMap = HGCGTools.HgCg002B.map(contractDetailIds);
// 合同主表信息
List<Long> contractIds = dbCg002BMap.values().stream().map(item -> item.getPrimaryId())
.collect(Collectors.toList());
Map<Long, HGCG002> dbCg002Map = HGCGTools.HgCg002.mapByIds(contractIds);
for (HGZL001 fZl001 : fZl001s) {
// 关联获取到收货明细
HGCG003B dbCg003B = dbCg003BMap.get(fZl001.getReceiveDetailId());
BigDecimal unqualifyQty = fZl001.getUnqualifyQty().negate();
BigDecimal unqualifyWeight = unqualifyQty.multiply(dbCg003B.getReceiveUnitWeight());
// 关联获取到合同明细
HGCG002B dbCg002B = dbCg002BMap.get(dbCg003B.getContractDetailId());
HGCGTools.HgCg002B.updateReceive(dbCg002B, unqualifyQty, unqualifyWeight);
// 修改主表信息
HGCG002 dbCg002 = dbCg002Map.get(dbCg002B.getPrimaryId());
HGCGTools.HgCg002.updateReceive(dbCg002, unqualifyQty, unqualifyWeight);
}
}
}
......@@ -88,7 +88,6 @@
sumType="page"/>
<EF:EFColumn ename="taxIncludeAmount" cname="含税金额" enable="false" width="120" align="right"
format="{0:C3}" sumType="page"/>
<EF:EFColumn ename="planNo" cname="计划单号" enable="false" width="120" align="center"/>
<EF:EFColumn ename="createdName" cname="创建人" enable="false" width="100" align="center"/>
<EF:EFColumn ename="createdTime" cname="创建时间" enable="false" width="140" align="center"
......
......@@ -68,6 +68,7 @@
<EF:EFComboColumn ename="status" cname="状态" enable="false" width="80" align="center">
<EF:EFCodeOption codeName="hggp.hgcg.receiveStatus"/>
</EF:EFComboColumn>
<EF:EFColumn ename="contractNo" cname="合同号" enable="false" width="120" align="center"/>
<EF:EFColumn ename="createdName" cname="创建人" enable="false" width="100" align="center"/>
<EF:EFColumn ename="createdTime" cname="创建时间" enable="false" width="140" align="center"
editType="datetime" parseFormats="['yyyyMMddHHmmss']"/>
......
......@@ -29,11 +29,12 @@
<EF:EFOption label="已处理" value="1"></EF:EFOption>
<EF:EFOption label="未处理" value="0"></EF:EFOption>
</EF:EFSelect>
<EF:EFInput cname="收货单号" ename="receiveNo" blockId="inqu_status" row="0" colWidth="3"/>
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="明细信息">
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true" checkMode="row">
<EF:EFRegion id="result" title="明细信息" fitHeight="true">
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true" checkMode="row" height="68vh">
<EF:EFColumn ename="id" cname="内码" hidden="true"/>
<EF:EFColumn ename="problemPhoto" cname="问题照片" locked="true" enable="false" width="100" align="center"
required="true"/>
......
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