Commit 4c9eef38 by liuyang

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

parents 05a6d7dd c34d5bc5
# Intellij IDEA Files
.idea/
*.iws
*.iml
# Spring Boot specific files
target/
# Log file
*.log
# JRebel Files
.jrebel/
......@@ -158,22 +158,22 @@ public class ServiceHGCG002A extends ServiceBase {
// 更新计划状态
HGCGTools.HgCg001A.updateStatus(fCg001A.getId(), HGConstant.CgPlanStatus.S_4);
}
//修改主表信息
// 修改主表信息
HGCGTools.HgCg002.updateCg002Pur(newCg002);
}
/**
* //获取采购计划明细
*
* @param fCg001A
* @param newCg002
*/
private void insertDetails(HGCG001A fCg001A, HGCG002 newCg002) {
//获取采购计划明细
List<HGCG002B> cg002BList = new LinkedList<>();
HGCG002B cg002B = new HGCG002B();
//拷贝明细信息
BeanUtils.copyProperties(fCg001A, cg002B, "id", "createdBy", "createdName", "createdTime", "updatedBy",
"updatedName", "updatedTime");
HGCG002B cg002B = BeanUtils.copy(fCg001A, HGCG002B.class);
cg002B.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
cg002B.setPrimaryId(newCg002.getId());
cg002B.setPlanDetailId(fCg001A.getId());
cg002BList.add(cg002B);
DaoUtils.insertBatch(HGCG002B.INSERT, cg002BList);
DaoUtils.insert(HGCG002B.INSERT, cg002B);
}
/**
......
......@@ -266,7 +266,8 @@ public class ServiceHGCG003 extends ServiceBase {
// 数据来源为合同的才需要更新合同状态
if (Objects.nonNull(hgcg003) && hgcg003.getSource().intValue() == HGConstant.CgSource.DEFAULT) {
HGCG002B dbCg002b = dbCg002BMap.get(fCg003B.getContractDetailId());
HGCGTools.HgCg002B.updateReceive(dbCg002b, fCg003B.getReceiveQty().negate());
HGCGTools.HgCg002B.updateReceive(dbCg002b, fCg003B.getReceiveQty().negate(),
fCg003B.getReceiveWeight().negate());
}
}
}
......
package com.baosight.hggp.hg.cg.service;
import com.alibaba.fastjson.JSON;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.dao.DaoUtils;
......@@ -125,9 +126,9 @@ public class ServiceHGCG003A extends ServiceBase {
AssertUtils.isGt(fCg002B.getBcReceiveQty(), fCg002B.getBcMaxReceiveQty(),
String.format("合同[%s]本次收货数量(%s)不能大于本次最大收货数量(%s)", cg001.getContractNo(),
fCg002B.getBcReceiveQty(), fCg002B.getBcMaxReceiveQty()));
AssertUtils.isGt(fCg002B.getBcReceiveWeight(), fCg002B.getBcMaxReceiveWeight(),
String.format("合同[%s]本次收货重量(%s)不能大于本次最大收货重量(%s)", cg001.getContractNo(),
fCg002B.getBcReceiveWeight(), fCg002B.getBcMaxReceiveWeight()));
// AssertUtils.isGt(fCg002B.getBcReceiveWeight(), fCg002B.getBcMaxReceiveWeight(),
// String.format("合同[%s]本次收货重量(%s)不能大于本次最大收货重量(%s)", cg001.getContractNo(),
// fCg002B.getBcReceiveWeight(), fCg002B.getBcMaxReceiveWeight()));
}
}
......@@ -182,10 +183,28 @@ public class ServiceHGCG003A extends ServiceBase {
* @param cg002
*/
private void confirmData(List<HGCG002B> fCg002Bs, Map<Long, HGCG002B> dbCg002BMap, HGCG002 cg002) {
HGCG002B hgcg002B = fCg002Bs.get(0);
HGCG003 newCg003 = new HGCG003();
BeanUtils.copyProperties(hgcg002B, newCg003, "id", "createdBy", "createdName", "createdTime", "updatedBy",
"updatedName", "updatedTime");
// 写入主信息
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);
HGCG003 newCg003 = BeanUtils.copy(firstCg002B, HGCG003.class);
newCg003.setReceiveDate(DateUtils.shortDate());
newCg003.setReceiveNo(SequenceGenerator.getNextSequence(HGConstant.SequenceId.CG_RECEIVE_NO));
// 计算收获总数量
......@@ -208,15 +227,7 @@ public class ServiceHGCG003A extends ServiceBase {
newCg003.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
newCg003.setSource(HGConstant.CgSource.DEFAULT);
DaoUtils.insert(HGCG003.INSERT, 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);
return newCg003;
}
/**
......@@ -227,23 +238,22 @@ public class ServiceHGCG003A extends ServiceBase {
* @param newCg003
*/
private void insertDetails(HGCG002B fCg002B, HGCG002B dbCg002b, HGCG003 newCg003) {
HGCG003B cg003B = new HGCG003B();
//拷贝主表明细信息
BeanUtils.copyProperties(newCg003, cg003B, "id");
//拷贝明细信息
BeanUtils.copyProperties(fCg002B, cg003B, "id", "createdBy", "createdName", "createdTime", "updatedBy",
"updatedName", "updatedTime", "contractNo", "planNo", "supCode", "supName", "purUserId",
"purUserName", "status");
cg003B.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
HGCG003B cg003B = BeanUtils.copy(dbCg002b, HGCG003B.class);
cg003B.setReceiveDate(newCg003.getReceiveDate()); // 收货日期
cg003B.setReceiveNo(newCg003.getReceiveNo()); // 收货号
cg003B.setPlanNo(newCg003.getPlanNo()); // 计划号
cg003B.setContractNo(newCg003.getContractNo()); // 合同号
cg003B.setPrimaryId(newCg003.getId());
cg003B.setReceiveUnitWeight(fCg002B.getPurUnitWeight());
cg003B.setReceiveQty(fCg002B.getBcReceiveQty());
cg003B.setReceiveWeight(fCg002B.getReceiveWeight());
cg003B.setContractDetailId(fCg002B.getId());
cg003B.setUnCancelAmount(fCg002B.getTaxIncludeAmount());
cg003B.setStatus(HGConstant.CgReceiveStatus.S_0);
cg003B.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
DaoUtils.insert(HGCG003B.INSERT, cg003B);
// 更新合同状态
HGCGTools.HgCg002B.updateReceive(dbCg002b, cg003B.getReceiveQty());
HGCGTools.HgCg002B.updateReceive(dbCg002b, cg003B.getReceiveQty(), cg003B.getReceiveWeight());
}
}
......@@ -176,7 +176,8 @@ public class ServiceHGCG003B extends ServiceBase {
// 计算差异数量,更新合同状态
HGCG003B dbCg003B = dbCg003BMap.get(fCg003B.getId());
BigDecimal diffQty = fCg003B.getReceiveQty().subtract(dbCg003B.getReceiveQty());
HGCGTools.HgCg002B.updateReceive(dbCg002BMap.get(fCg003B.getContractDetailId()), diffQty);
BigDecimal diffWeight = fCg003B.getReceiveWeight().subtract(dbCg003B.getReceiveWeight());
HGCGTools.HgCg002B.updateReceive(dbCg002BMap.get(fCg003B.getContractDetailId()), diffQty, diffWeight);
}
List<HGCG002> hgcg002List = new LinkedList<>();
dbCg002AMap.forEach((k, v) -> {
......@@ -292,7 +293,7 @@ public class ServiceHGCG003B extends ServiceBase {
*/
private void removeData(List<HGCG003B> fCg003Bs, Map<Long, HGCG003B> dbCg003bMap, Map<String, HGCG002A> dbCg002AMap,
HGCG003 cg003, Map<Long, HGCG002B> dbCg002BMap) {
//数据来源为合同的
// 数据来源为合同的
if (cg003.getSource().intValue() == HGConstant.CgSource.DEFAULT) {
for (HGCG003B fCg003B : fCg003Bs) {
HGCG003B dbCg003B = dbCg003bMap.get(fCg003B.getId());
......@@ -300,7 +301,7 @@ public class ServiceHGCG003B extends ServiceBase {
DaoUtils.update(HGCG003B.DELETE, dbCg003B);
// 更新合同状态
HGCGTools.HgCg002B.updateReceive(dbCg002BMap.get(fCg003B.getContractDetailId()),
dbCg003B.getReceiveQty().negate());
dbCg003B.getReceiveQty().negate(), dbCg003B.getReceiveWeight().negate());
}
List<HGCG002> hgcg002List = new LinkedList<>();
dbCg002AMap.forEach((k, v) -> {
......
......@@ -350,38 +350,43 @@ public class HGCGTools {
/**
* 更新合同信息
*
* @param hgcg002List
* @param cg002s
*/
public static void updateContractPrimary(List<HGCG002> hgcg002List) {
List<Long> primaryIds = hgcg002List.stream().map(o->o.getId()).collect(Collectors.toList());
List<HGCG002B> queryHgcg002BList = HGCGTools.HgCg002B.listByPrimaryIds(primaryIds);
hgcg002List.forEach(cg002 ->{
List<HGCG002B> hgcg002BList = queryHgcg002BList.stream().filter(o->o.getPrimaryId().compareTo(cg002.getId()) == 0).collect(Collectors.toList());
public static void updateContractPrimary(List<HGCG002> cg002s) {
List<Long> primaryIds = cg002s.stream().map(o -> o.getId()).collect(Collectors.toList());
Map<Long, List<HGCG002B>> dbCg002BMap = HGCGTools.HgCg002B.mapByPrimaryId(primaryIds);
cg002s.forEach(cg002 -> {
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);
//采购重量
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);
//收货数量
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);
//收货重量
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);
//金额(不含税金额)
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);
//税额
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);
//含税金额
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);
DaoUtils.update(HGSqlConstant.HgCg002.UPDATE_PUR, cg002);
AssertUtils.isNull(cg002, "合同号不能为空!");
AssertUtils.isNull(receiveQtySum, "收货数量不能为空!");
BigDecimal diffQty = cg002.getPurQty().subtract(receiveQtySum);
Integer status = diffQty.compareTo(BigDecimal.ZERO) == 0 ? HGConstant.CgContractStatus.S_5
......@@ -508,7 +513,7 @@ public class HGCGTools {
paramMap.put("primaryId", primaryId);
return DaoBase.getInstance().query(HGCG002B.QUERY, paramMap);
}
/**
* 查询
*
......@@ -521,7 +526,21 @@ public class HGCGTools {
paramMap.put("primaryIds", primaryIds);
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));
}
/**
* 锁
*
......@@ -567,14 +586,15 @@ public class HGCGTools {
* @param dbCg002B
* @param receiveQty
*/
public static void updateReceive(HGCG002B dbCg002B, BigDecimal receiveQty) {
public static void updateReceive(HGCG002B dbCg002B, BigDecimal receiveQty, BigDecimal receiveWeight) {
AssertUtils.isNull(dbCg002B, "合同明细不能为空!");
AssertUtils.isNull(receiveQty, "收货数量不能为空!");
BigDecimal newReceiveQty = receiveQty.add(dbCg002B.getReceiveQty());
BigDecimal newReceiveWeight = receiveWeight.add(dbCg002B.getReceiveWeight());
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_RECEIVE_WEIGHT, newReceiveWeight);
if (newReceiveQty.compareTo(BigDecimal.ZERO) == 0) {
paramMap.put(HGCG002.FIELD_STATUS, HGConstant.CgContractStatus.S_2);
} else if (dbCg002B.getPurQty().compareTo(newReceiveQty) == 0) {
......
......@@ -116,10 +116,10 @@ let confirm = function () {
message("勾选的第" + (i + 1) + "行本次收货数量不能大于本次最大收货数量");
return;
}
if (!isBlank(bcReceiveWeight) && parseFloat(bcReceiveWeight) > parseFloat(bcMaxReceiveWeight)) {
message("勾选的第" + (i + 1) + "行本次收货重量不能大于本次最大收货重量");
return;
}
// if (!isBlank(bcReceiveWeight) && parseFloat(bcReceiveWeight) > parseFloat(bcMaxReceiveWeight)) {
// message("勾选的第" + (i + 1) + "行本次收货重量不能大于本次最大收货重量");
// return;
// }
}
JSUtils.confirm("确定对勾选的[" + rows.length + "]条数据生成\"采购收货\"吗? ", {
ok: function () {
......
......@@ -108,6 +108,11 @@ function add(docId, leafType, docType) {
message("文件类型或ID不能为空");
return;
}
// 第一级目录
if (leafType === "C") {
otherDownload(true, null);
return;
}
let inInfo = new EiInfo();
inInfo.set("result-0-fileId", $("#inqu_status-0-fileId").val());
inInfo.set("result-0-docId", docId);
......@@ -143,7 +148,7 @@ function preview(docId, docType) {
} else if (isFrame(docType)) {
previewFrame(docId);
} else {
otherDownload(docId);
otherDownload(false, docId);
}
}
......@@ -224,10 +229,15 @@ function previewFrame(docId) {
/**
* 其他下载
*
* @param isRoot
* @param docId
*/
function otherDownload(docId) {
function otherDownload(isRoot, docId) {
$("#descDiv").css('display', '');
$("#descSpan").html("该文件暂不支持预览,点击<a href='" + downloadHref(docId, false)
+ "' target='_blank'>下载</a>");
if (isRoot) {
$("#descSpan").html("文件预览区域...");
} else {
$("#descSpan").html("该文件暂不支持预览,点击<a href='" + downloadHref(docId, false)
+ "' target='_blank'>下载</a>");
}
}
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