Commit 6970df8f by 宋祥

1.修改采购收货信息

parent c095c529
...@@ -183,6 +183,26 @@ public class ServiceHGCG003A extends ServiceBase { ...@@ -183,6 +183,26 @@ public class ServiceHGCG003A extends ServiceBase {
* @param cg002 * @param cg002
*/ */
private void confirmData(List<HGCG002B> fCg002Bs, Map<Long, HGCG002B> dbCg002BMap, HGCG002 cg002) { private void confirmData(List<HGCG002B> fCg002Bs, Map<Long, HGCG002B> dbCg002BMap, HGCG002 cg002) {
// 写入主信息
HGCG003 newCg003 = insertMain(fCg002Bs, cg002);
// 写入明细数据
for (HGCG002B fCg002B : fCg002Bs) {
Long id = fCg002B.getId();
insertDetails(fCg002B, dbCg002BMap.get(id), newCg003);
}
// 修改合同信息
List<HGCG002> cg002s = new LinkedList<>();
cg002s.add(cg002);
HGCGTools.HgCg002.updateContractPrimary(cg002s);
}
/**
* 新增主信息
*
* @param fCg002Bs
* @param cg002
*/
private HGCG003 insertMain(List<HGCG002B> fCg002Bs, HGCG002 cg002) {
HGCG002B firstCg002B = fCg002Bs.get(0); HGCG002B firstCg002B = fCg002Bs.get(0);
HGCG003 newCg003 = BeanUtils.copy(firstCg002B, HGCG003.class); HGCG003 newCg003 = BeanUtils.copy(firstCg002B, HGCG003.class);
newCg003.setReceiveDate(DateUtils.shortDate()); newCg003.setReceiveDate(DateUtils.shortDate());
...@@ -207,15 +227,7 @@ public class ServiceHGCG003A extends ServiceBase { ...@@ -207,15 +227,7 @@ public class ServiceHGCG003A extends ServiceBase {
newCg003.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode()); newCg003.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
newCg003.setSource(HGConstant.CgSource.DEFAULT); newCg003.setSource(HGConstant.CgSource.DEFAULT);
DaoUtils.insert(HGCG003.INSERT, newCg003); DaoUtils.insert(HGCG003.INSERT, newCg003);
// 写入明细数据 return newCg003;
for (HGCG002B fCg002B : fCg002Bs) {
Long id = fCg002B.getId();
HGCG002B dbCg002b = dbCg002BMap.get(id);
insertDetails(fCg002B, dbCg002b, newCg003);
}
List<HGCG002> hgcg002List = new LinkedList<>();
hgcg002List.add(cg002);
HGCGTools.HgCg002.updateContractPrimary(hgcg002List);
} }
/** /**
...@@ -226,22 +238,19 @@ public class ServiceHGCG003A extends ServiceBase { ...@@ -226,22 +238,19 @@ public class ServiceHGCG003A extends ServiceBase {
* @param newCg003 * @param newCg003
*/ */
private void insertDetails(HGCG002B fCg002B, HGCG002B dbCg002b, HGCG003 newCg003) { private void insertDetails(HGCG002B fCg002B, HGCG002B dbCg002b, HGCG003 newCg003) {
HGCG003B cg003B = new HGCG003B(); HGCG003B cg003B = BeanUtils.copy(dbCg002b, HGCG003B.class);
//拷贝主表明细信息 cg003B.setReceiveDate(newCg003.getReceiveDate()); // 收货日期
BeanUtils.copyProperties(newCg003, cg003B, "id"); cg003B.setReceiveNo(newCg003.getReceiveNo()); // 收货号
System.out.println("cg003B -> " + JSON.toJSONString(cg003B)); cg003B.setPlanNo(newCg003.getPlanNo()); // 计划号
//拷贝明细信息 cg003B.setContractNo(newCg003.getContractNo()); // 合同号
BeanUtils.copyProperties(fCg002B, cg003B, "id", "createdBy", "createdName", "createdTime", "updatedBy",
"updatedName", "updatedTime", "contractNo", "planNo", "supCode", "supName", "purUserId",
"purUserName", "status");
System.out.println("cg003B -> " + JSON.toJSONString(cg003B));
cg003B.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
cg003B.setPrimaryId(newCg003.getId()); cg003B.setPrimaryId(newCg003.getId());
cg003B.setReceiveUnitWeight(fCg002B.getPurUnitWeight()); cg003B.setReceiveUnitWeight(fCg002B.getPurUnitWeight());
cg003B.setReceiveQty(fCg002B.getBcReceiveQty()); cg003B.setReceiveQty(fCg002B.getBcReceiveQty());
cg003B.setReceiveWeight(fCg002B.getReceiveWeight()); cg003B.setReceiveWeight(fCg002B.getReceiveWeight());
cg003B.setContractDetailId(fCg002B.getId()); cg003B.setContractDetailId(fCg002B.getId());
cg003B.setUnCancelAmount(fCg002B.getTaxIncludeAmount()); cg003B.setUnCancelAmount(fCg002B.getTaxIncludeAmount());
cg003B.setStatus(HGConstant.CgReceiveStatus.S_0);
cg003B.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
DaoUtils.insert(HGCG003B.INSERT, cg003B); DaoUtils.insert(HGCG003B.INSERT, cg003B);
// 更新合同状态 // 更新合同状态
HGCGTools.HgCg002B.updateReceive(dbCg002b, cg003B.getReceiveQty(), cg003B.getReceiveWeight()); HGCGTools.HgCg002B.updateReceive(dbCg002b, cg003B.getReceiveQty(), cg003B.getReceiveWeight());
......
...@@ -349,38 +349,43 @@ public class HGCGTools { ...@@ -349,38 +349,43 @@ public class HGCGTools {
/** /**
* 更新合同信息 * 更新合同信息
* *
* @param hgcg002List * @param cg002s
*/ */
public static void updateContractPrimary(List<HGCG002> hgcg002List) { public static void updateContractPrimary(List<HGCG002> cg002s) {
List<Long> primaryIds = hgcg002List.stream().map(o->o.getId()).collect(Collectors.toList()); List<Long> primaryIds = cg002s.stream().map(o -> o.getId()).collect(Collectors.toList());
List<HGCG002B> queryHgcg002BList = HGCGTools.HgCg002B.listByPrimaryIds(primaryIds); Map<Long, List<HGCG002B>> dbCg002BMap = HGCGTools.HgCg002B.mapByPrimaryId(primaryIds);
hgcg002List.forEach(cg002 ->{ cg002s.forEach(cg002 -> {
List<HGCG002B> hgcg002BList = queryHgcg002BList.stream().filter(o->o.getPrimaryId().compareTo(cg002.getId()) == 0).collect(Collectors.toList()); List<HGCG002B> dbCg002Bs = dbCg002BMap.get(cg002.getId());
//修改主表信息 //修改主表信息
//采购数量 //采购数量
BigDecimal purQtySum = hgcg002BList.stream().map(HGCG002B::getPurQty).reduce(BigDecimal.ZERO,BigDecimal::add); BigDecimal purQtySum = dbCg002Bs.stream().map(HGCG002B::getPurQty)
.reduce(BigDecimal.ZERO, BigDecimal::add);
cg002.setPurQty(purQtySum); cg002.setPurQty(purQtySum);
//采购重量 //采购重量
BigDecimal purWeightSum = hgcg002BList.stream().map(HGCG002B::getPurWeight).reduce(BigDecimal.ZERO,BigDecimal::add); BigDecimal purWeightSum = dbCg002Bs.stream().map(HGCG002B::getPurWeight)
.reduce(BigDecimal.ZERO, BigDecimal::add);
cg002.setPurWeight(purWeightSum); cg002.setPurWeight(purWeightSum);
//收货数量 //收货数量
BigDecimal receiveQtySum = hgcg002BList.stream().map(HGCG002B::getReceiveQty).reduce(BigDecimal.ZERO,BigDecimal::add); BigDecimal receiveQtySum = dbCg002Bs.stream().map(HGCG002B::getReceiveQty)
.reduce(BigDecimal.ZERO, BigDecimal::add);
cg002.setReceiveQty(receiveQtySum); cg002.setReceiveQty(receiveQtySum);
//收货重量 //收货重量
BigDecimal receiveWeightSum = hgcg002BList.stream().map(HGCG002B::getReceiveWeight).reduce(BigDecimal.ZERO,BigDecimal::add); BigDecimal receiveWeightSum = dbCg002Bs.stream().map(HGCG002B::getReceiveWeight)
.reduce(BigDecimal.ZERO, BigDecimal::add);
cg002.setReceiveWeight(receiveWeightSum); cg002.setReceiveWeight(receiveWeightSum);
//金额(不含税金额) //金额(不含税金额)
BigDecimal amountSum = hgcg002BList.stream().map(HGCG002B::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add); BigDecimal amountSum = dbCg002Bs.stream().map(HGCG002B::getAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
cg002.setAmount(amountSum); cg002.setAmount(amountSum);
//税额 //税额
BigDecimal taxAmountSum = hgcg002BList.stream().map(HGCG002B::getTaxAmount).reduce(BigDecimal.ZERO,BigDecimal::add); BigDecimal taxAmountSum = dbCg002Bs.stream().map(HGCG002B::getTaxAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
cg002.setTaxAmount(taxAmountSum); cg002.setTaxAmount(taxAmountSum);
//含税金额 //含税金额
BigDecimal taxIncludeAmountSum = hgcg002BList.stream().map(HGCG002B::getTaxIncludeAmount).reduce(BigDecimal.ZERO,BigDecimal::add); BigDecimal taxIncludeAmountSum = dbCg002Bs.stream().map(HGCG002B::getTaxIncludeAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
cg002.setTaxIncludeAmount(taxIncludeAmountSum); cg002.setTaxIncludeAmount(taxIncludeAmountSum);
DaoUtils.update(HGSqlConstant.HgCg002.UPDATE_PUR, cg002); DaoUtils.update(HGSqlConstant.HgCg002.UPDATE_PUR, cg002);
AssertUtils.isNull(cg002, "合同号不能为空!");
AssertUtils.isNull(receiveQtySum, "收货数量不能为空!"); AssertUtils.isNull(receiveQtySum, "收货数量不能为空!");
BigDecimal diffQty = cg002.getPurQty().subtract(receiveQtySum); BigDecimal diffQty = cg002.getPurQty().subtract(receiveQtySum);
Integer status = diffQty.compareTo(BigDecimal.ZERO) == 0 ? HGConstant.CgContractStatus.S_5 Integer status = diffQty.compareTo(BigDecimal.ZERO) == 0 ? HGConstant.CgContractStatus.S_5
...@@ -507,7 +512,7 @@ public class HGCGTools { ...@@ -507,7 +512,7 @@ public class HGCGTools {
paramMap.put("primaryId", primaryId); paramMap.put("primaryId", primaryId);
return DaoBase.getInstance().query(HGCG002B.QUERY, paramMap); return DaoBase.getInstance().query(HGCG002B.QUERY, paramMap);
} }
/** /**
* 查询 * 查询
* *
...@@ -520,7 +525,21 @@ public class HGCGTools { ...@@ -520,7 +525,21 @@ public class HGCGTools {
paramMap.put("primaryIds", primaryIds); paramMap.put("primaryIds", primaryIds);
return DaoBase.getInstance().query(HGCG002B.QUERY, paramMap); return DaoBase.getInstance().query(HGCG002B.QUERY, paramMap);
} }
/**
* 查询
*
* @param primaryIds
* @return
*/
public static Map<Long, List<HGCG002B>> mapByPrimaryId(List<Long> primaryIds) {
List<HGCG002B> results = listByPrimaryIds(primaryIds);
if (CollectionUtils.isEmpty(results)) {
return null;
}
return results.stream().collect(Collectors.groupingBy(HGCG002B::getPrimaryId));
}
/** /**
* 锁 * 锁
* *
......
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