Commit 5753d915 by 江和松

合同选择材料计划改为明细选择

parent 9e0a6706
......@@ -52,7 +52,7 @@ public class HGCG001 extends DaoEPBase {
public static final String FIELD_PUR_QTY = "purQty"; /* 采购数量*/
public static final String FIELD_PUR_UNIT_WEIGHT = "purUnitWeight"; /* 采购单重*/
public static final String FIELD_PUR_WEIGHT = "purWeight"; /* 采购重量*/
public static final String FIELD_STATUS = "status"; /* 状态:0-未审批,1-审核通过,2-审核未通过*/
public static final String FIELD_STATUS = "status"; /* 状态:0-待审核,1-审核中,2-审核通过,3-审核拒绝,4-生成合同,5-部分生成合同*/
public static final String FIELD_AUDIT_TIME = "auditTime"; /* 审核时间*/
public static final String FIELD_AUDIT_USER_ID = "auditUserId"; /* 审核人ID*/
public static final String FIELD_AUDIT_USER_NAME = "auditUserName"; /* 审核人名称*/
......@@ -92,7 +92,7 @@ public class HGCG001 extends DaoEPBase {
public static final String COL_PUR_QTY = "PUR_QTY"; /* 采购数量*/
public static final String COL_PUR_UNIT_WEIGHT = "PUR_UNIT_WEIGHT"; /* 采购单重*/
public static final String COL_PUR_WEIGHT = "PUR_WEIGHT"; /* 采购重量*/
public static final String COL_STATUS = "STATUS"; /* 状态:0-未审批,1-审核通过,2-审核未通过*/
public static final String COL_STATUS = "STATUS"; /* 状态:0-待审核,1-审核中,2-审核通过,3-审核拒绝,4-生成合同,5-部分生成合同*/
public static final String COL_AUDIT_TIME = "AUDIT_TIME"; /* 审核时间*/
public static final String COL_AUDIT_USER_ID = "AUDIT_USER_ID"; /* 审核人ID*/
public static final String COL_AUDIT_USER_NAME = "AUDIT_USER_NAME"; /* 审核人名称*/
......@@ -136,7 +136,7 @@ public class HGCG001 extends DaoEPBase {
private BigDecimal purQty = new BigDecimal(0.000); /* 采购数量*/
private BigDecimal purUnitWeight = new BigDecimal(0.000); /* 采购单重*/
private BigDecimal purWeight = new BigDecimal(0.000); /* 采购重量*/
private Integer status; /* 状态:0-未审批,1-审核通过,2-审核未通过*/
private Integer status; /* 状态:0-待审核,1-审核中,2-审核通过,3-审核拒绝,4-生成合同,5-部分生成合同*/
private String auditTime = " "; /* 审核时间*/
private String auditUserId = " "; /* 审核人ID*/
private String auditUserName = " "; /* 审核人名称*/
......@@ -300,7 +300,7 @@ public class HGCG001 extends DaoEPBase {
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_STATUS);
eiColumn.setDescName("状态:0-未审批,1-审核通过,2-审核未通过");
eiColumn.setDescName("状态:0-待审核,1-审核中,2-审核通过,3-审核拒绝,4-生成合同,5-部分生成合同");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_AUDIT_TIME);
......@@ -820,7 +820,7 @@ public class HGCG001 extends DaoEPBase {
this.purWeight = purWeight;
}
/**
* get the status - 状态:0-未审批,1-审核通过,2-审核未通过.
* get the status - 状态:0-待审核,1-审核中,2-审核通过,3-审核拒绝,4-生成合同,5-部分生成合同.
* @return the status
*/
public Integer getStatus() {
......@@ -828,9 +828,9 @@ public class HGCG001 extends DaoEPBase {
}
/**
* set the status - 状态:0-未审批,1-审核通过,2-审核未通过.
* set the status - 状态:0-待审核,1-审核中,2-审核通过,3-审核拒绝,4-生成合同,5-部分生成合同.
*
* @param status - 状态:0-未审批,1-审核通过,2-审核未通过
* @param status - 状态:0-待审核,1-审核中,2-审核通过,3-审核拒绝,4-生成合同,5-部分生成合同
*/
public void setStatus(Integer status) {
this.status = status;
......
......@@ -54,6 +54,15 @@ public class HGCG001A extends DaoEPBase {
public static final String FIELD_MATERIAL_PLAN_ID = "materialPlanId"; /* 材料计划id*/
public static final String FIELD_INVENT_TYPE_DETAIL = "inventTypeDetail"; /* 存货类型大类*/
public static final String FIELD_PRIMARY_ID = "primaryId"; /* 主表id*/
public static final String FIELD_STATUS = "status"; /* 状态:0-待审核,1-审核中,2-审核通过,3-审核拒绝,4-生成合同,5-部分生成合同*/
//页面展示
public static final String FIELD_SOURCE = "source"; /* 数据来源 根据采购数据来源小代码 目前默认0材料计划,1手工录入*/
public static final String FIELD_PRICE = "price"; /* 单价*/
public static final String FIELD_AMOUNT = "amount"; /* 金额(不含税金额)*/
public static final String FIELD_TAX_INCLUDE_AMOUNT = "taxIncludeAmount"; /* 含税金额*/
public static final String FIELD_TAX_AMOUNT = "taxAmount"; /* 税额*/
public static final String FIELD_TAX_RATE = "taxRate"; /* 税率*/
public static final String COL_ID = "ID";
public static final String COL_ACCOUNT_CODE = "ACCOUNT_CODE"; /* 企业编码*/
......@@ -89,6 +98,7 @@ public class HGCG001A extends DaoEPBase {
public static final String COL_PRIMARY_ID = "PRIMARY_ID"; /* 主表id*/
public static final String QUERY = "HGCG001A.query";
public static final String QUERY_BY_CONTRACT = "HGCG001A.queryByContract";
public static final String COUNT = "HGCG001A.count";
public static final String INSERT = "HGCG001A.insert";
public static final String UPDATE = "HGCG001A.update";
......@@ -126,6 +136,15 @@ public class HGCG001A extends DaoEPBase {
private Long materialPlanId = new Long(0); /* 材料计划id*/
private Integer inventTypeDetail; /* 存货类型大类*/
private Long primaryId = new Long(0); /* 主表id*/
private Integer status; /* 状态:0-待审核,1-审核中,2-审核通过,3-审核拒绝,4-生成合同,5-部分生成合同*/
//选择合同需要信息
private Integer source; /* 数据来源 根据采购数据来源小代码 目前默认0材料计划,1手工录入*/
private BigDecimal price = new BigDecimal("0"); /* 单价*/
private BigDecimal amount = new BigDecimal("0"); /* 金额(不含税金额)*/
private BigDecimal taxIncludeAmount = new BigDecimal("0"); /* 含税金额*/
private BigDecimal taxAmount = new BigDecimal("0"); /* 税额*/
private BigDecimal taxRate = new BigDecimal("0"); /* 税率*/
/**
* initialize the metadata.
......@@ -289,7 +308,48 @@ public class HGCG001A extends DaoEPBase {
eiColumn.setDescName("主表id");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_STATUS);
eiColumn.setDescName("状态:0-待审核,1-审核中,2-审核通过,3-审核拒绝,4-生成合同,5-部分生成合同");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_SOURCE);
eiColumn.setDescName("数据来源");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_PRICE);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(12);
eiColumn.setDescName("单价");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_AMOUNT);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(12);
eiColumn.setDescName("金额(不含税金额)");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_TAX_INCLUDE_AMOUNT);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(12);
eiColumn.setDescName("含税金额");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_TAX_AMOUNT);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(12);
eiColumn.setDescName("税额");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_TAX_RATE);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(12);
eiColumn.setDescName("税率");
eiMetadata.addMeta(eiColumn);
}
/**
......@@ -811,6 +871,63 @@ public class HGCG001A extends DaoEPBase {
public void setPrimaryId(Long primaryId) {
this.primaryId = primaryId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getSource() {
return source;
}
public void setSource(Integer source) {
this.source = source;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public BigDecimal getTaxIncludeAmount() {
return taxIncludeAmount;
}
public void setTaxIncludeAmount(BigDecimal taxIncludeAmount) {
this.taxIncludeAmount = taxIncludeAmount;
}
public BigDecimal getTaxAmount() {
return taxAmount;
}
public void setTaxAmount(BigDecimal taxAmount) {
this.taxAmount = taxAmount;
}
public BigDecimal getTaxRate() {
return taxRate;
}
public void setTaxRate(BigDecimal taxRate) {
this.taxRate = taxRate;
}
/**
* get the value from Map.
*
......@@ -851,6 +968,14 @@ public class HGCG001A extends DaoEPBase {
setMaterialPlanId(NumberUtils.toLong(StringUtils.toString(map.get(FIELD_MATERIAL_PLAN_ID)), materialPlanId));
setInventTypeDetail(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_INVENT_TYPE_DETAIL)), inventTypeDetail));
setPrimaryId(NumberUtils.toLong(StringUtils.toString(map.get(FIELD_PRIMARY_ID)), primaryId));
setStatus(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_STATUS)), status));
setSource(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_SOURCE)), source));
setPrice(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_PRICE)), price));
setAmount(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_AMOUNT)), amount));
setTaxIncludeAmount(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_TAX_INCLUDE_AMOUNT)), taxIncludeAmount));
setTaxAmount(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_TAX_AMOUNT)), taxAmount));
setTaxRate(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_TAX_RATE)), taxRate));
}
/**
......@@ -892,7 +1017,14 @@ public class HGCG001A extends DaoEPBase {
map.put(FIELD_MATERIAL_PLAN_ID, StringUtils.toString(materialPlanId, eiMetadata.getMeta(FIELD_MATERIAL_PLAN_ID)));
map.put(FIELD_INVENT_TYPE_DETAIL, StringUtils.toString(inventTypeDetail, eiMetadata.getMeta(FIELD_INVENT_TYPE_DETAIL)));
map.put(FIELD_PRIMARY_ID, StringUtils.toString(primaryId, eiMetadata.getMeta(FIELD_PRIMARY_ID)));
map.put(FIELD_STATUS, StringUtils.toString(status, eiMetadata.getMeta(FIELD_STATUS)));
map.put(FIELD_SOURCE, StringUtils.toString(source, eiMetadata.getMeta(FIELD_SOURCE)));
map.put(FIELD_PRICE, StringUtils.toString(price, eiMetadata.getMeta(FIELD_PRICE)));
map.put(FIELD_AMOUNT, StringUtils.toString(amount, eiMetadata.getMeta(FIELD_AMOUNT)));
map.put(FIELD_TAX_INCLUDE_AMOUNT, StringUtils.toString(taxIncludeAmount, eiMetadata.getMeta(FIELD_TAX_INCLUDE_AMOUNT)));
map.put(FIELD_TAX_AMOUNT, StringUtils.toString(taxAmount, eiMetadata.getMeta(FIELD_TAX_AMOUNT)));
map.put(FIELD_TAX_RATE, StringUtils.toString(taxRate, eiMetadata.getMeta(FIELD_TAX_RATE)));
return map;
}
}
......@@ -55,6 +55,7 @@ public class HGCG002B extends DaoEPBase {
public static final String FIELD_TAX_RATE = "taxRate"; /* 税率*/
public static final String FIELD_INVENT_TYPE_DETAIL = "inventTypeDetail"; /* 存货类型大类*/
public static final String FIELD_PRIMARY_ID = "primaryId"; /* 主表id*/
public static final String FIELD_PLAN_DETAIL_ID = "planDetailId"; /* 计划明细ID*/
//页面需要展示
public static final String FIELD_BC_RECEIVE_QTY = "bcReceiveQty"; /* 本次收货数量*/
public static final String FIELD_BC_MAX_RECEIVE_QTY = "bcMaxReceiveQty"; /* 本次最大收货数量*/
......@@ -142,6 +143,7 @@ public class HGCG002B extends DaoEPBase {
private BigDecimal taxRate = new BigDecimal("0"); /* 税率*/
private Integer inventTypeDetail; /* 存货类型大类*/
private Long primaryId = new Long(0); /* 主表id*/
private Long planDetailId = new Long(0); /* 合同明细id*/
//页面需要填写、展示字段
private BigDecimal bcReceiveQty = new BigDecimal(0.000); /* 本次收货数量*/
......@@ -333,6 +335,10 @@ public class HGCG002B extends DaoEPBase {
eiColumn.setDescName("主表id");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_PLAN_DETAIL_ID);
eiColumn.setDescName("合同明细id");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_BC_RECEIVE_QTY);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
......@@ -996,6 +1002,14 @@ public class HGCG002B extends DaoEPBase {
this.status = status;
}
public Long getPlanDetailId() {
return planDetailId;
}
public void setPlanDetailId(Long planDetailId) {
this.planDetailId = planDetailId;
}
/**
* get the value from Map.
*
......@@ -1037,6 +1051,7 @@ public class HGCG002B extends DaoEPBase {
setTaxRate(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_TAX_RATE)), taxRate));
setInventTypeDetail(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_INVENT_TYPE_DETAIL)), inventTypeDetail));
setPrimaryId(NumberUtils.toLong(StringUtils.toString(map.get(FIELD_PRIMARY_ID)), primaryId));
setPlanDetailId(NumberUtils.toLong(StringUtils.toString(map.get(FIELD_PLAN_DETAIL_ID)), planDetailId));
setBcReceiveQty(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_BC_RECEIVE_QTY)), bcReceiveQty));
setBcMaxReceiveQty(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_BC_MAX_RECEIVE_QTY)), bcMaxReceiveQty));
......@@ -1090,6 +1105,7 @@ public class HGCG002B extends DaoEPBase {
map.put(FIELD_TAX_RATE, StringUtils.toString(taxRate, eiMetadata.getMeta(FIELD_TAX_RATE)));
map.put(FIELD_INVENT_TYPE_DETAIL, StringUtils.toString(inventTypeDetail, eiMetadata.getMeta(FIELD_INVENT_TYPE_DETAIL)));
map.put(FIELD_PRIMARY_ID, StringUtils.toString(primaryId, eiMetadata.getMeta(FIELD_PRIMARY_ID)));
map.put(FIELD_PLAN_DETAIL_ID, StringUtils.toString(planDetailId, eiMetadata.getMeta(FIELD_PLAN_DETAIL_ID)));
map.put(FIELD_BC_RECEIVE_QTY, StringUtils.toString(bcReceiveQty, eiMetadata.getMeta(FIELD_BC_RECEIVE_QTY)));
map.put(FIELD_BC_MAX_RECEIVE_QTY, StringUtils.toString(bcMaxReceiveQty, eiMetadata.getMeta(FIELD_BC_MAX_RECEIVE_QTY)));
......
......@@ -244,6 +244,8 @@ public class ServiceHGCG001 extends ServiceBase {
fCg001.setAuditUserName(UserSessionUtils.getLoginCName());
fCg001.setAuditReason("");
DaoUtils.update(HGSqlConstant.HgCg001.UPDATE_AUDIT, fCg001);
//子表修改
DaoUtils.update(HGSqlConstant.HgCg001A.UPDATE_STATUS_BY_PLAN_NO, fCg001);
}
}
......
......@@ -5,8 +5,7 @@ import com.baosight.hggp.common.DdynamicEnum;
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.HGCG002A;
import com.baosight.hggp.hg.cg.domain.*;
import com.baosight.hggp.hg.cg.tools.HGCGTools;
import com.baosight.hggp.hg.cg.utils.HGCGUtils;
import com.baosight.hggp.hg.constant.HGConstant;
......@@ -29,6 +28,8 @@ import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author:songx
......@@ -179,6 +180,10 @@ public class ServiceHGCG002 extends ServiceBase {
* @param dbCg002AMap
*/
private void removeData(List<HGCG002> fCg002s, Map<String, HGCG002A> dbCg002AMap) {
//需要改变状态的采购计划主表
List<String> planNos = fCg002s.stream().map(HGCG002::getPlanNo).collect(Collectors.toList());
List<HGCG001> hgcg001List = HGCGTools.HgCg001.list(planNos);
for (HGCG002 fCg002 : fCg002s) {
String contractNo = fCg002.getContractNo();
HGCG002 dbCg002 = dbCg002AMap.get(contractNo);
......@@ -186,7 +191,16 @@ public class ServiceHGCG002 extends ServiceBase {
DaoUtils.update(HGCG002.DELETE, dbCg002);
// 更新计划状态
HGCGTools.HgCg001.updateStatus(dbCg002.getPlanNo(), HGConstant.CgPlanStatus.S_2);
}
List<Long> primaryIds = fCg002s.stream().map(o->o.getId()).collect(Collectors.toList());
List<HGCG002B> queryHgcg002BList = HGCGTools.HgCg002B.listByPrimaryIds(primaryIds);
for(HGCG002B hgcg002B : queryHgcg002BList){
// 更新计划明细状态
HGCGTools.HgCg001A.updateStatus(hgcg002B.getPlanDetailId(), HGConstant.CgPlanStatus.S_2);
}
}
/**
......
......@@ -25,10 +25,12 @@ import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author:songx
......@@ -52,7 +54,7 @@ public class ServiceHGCG002A extends ServiceBase {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.SPEC_NAME_BLOCK_ID));
EiInfoUtils.addBlock(inInfo,"userByCompany", HGXSTools.XsUser.listAll(UserSessionUtils.getAccountCode()), User.class);
EiInfoUtils.addBlock(inInfo,"roleCompany", UserSessionUtils.getRoleCompany(), Company.class);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCG001().eiMetadata);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCG001A().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
......@@ -72,8 +74,8 @@ public class ServiceHGCG002A extends ServiceBase {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
HGCGUtils.HgCg001.setCondition(queryRow);
// 仅审核通过
queryRow.put(HGCG001.FIELD_STATUS, HGConstant.CgPlanStatus.S_2);
inInfo = super.query(inInfo, HGCG001.QUERY, new HGCG001A());
queryRow.put(HGCG001A.FIELD_STATUS, HGConstant.CgPlanStatus.S_2);
inInfo = super.query(inInfo, HGCG001A.QUERY_BY_CONTRACT, new HGCG001A());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
......@@ -90,16 +92,20 @@ public class ServiceHGCG002A extends ServiceBase {
public EiInfo confirm(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<HGCG001> fCg001s = MapUtils.toDaoEPBase(inInfo, HGCG001.class);
List<HGCG001A> fCg001As = MapUtils.toDaoEPBase(inInfo, HGCG001A.class);
// db数据
Map<String, HGCG001> dbCg001Map = this.lockGetData(fCg001s);
Map<Long, HGCG001A> dbCg001Map = this.lockGetData(fCg001As);
//计划主表信息
List<String> planNos = fCg001As.stream().map(HGCG001A::getPlanNo).collect(Collectors.toList());
Map<String, HGCG001> hgcg001Map = HGCGTools.HgCg001.map(planNos);
// 数据校验
this.checkConfirmData(fCg001s, dbCg001Map);
this.checkConfirmData(fCg001As, dbCg001Map,hgcg001Map);
// 保存数据
this.confirmData(resultRows, dbCg001Map);
this.confirmData(fCg001As, dbCg001Map,hgcg001Map);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fCg001s.size() + "]条数据保存成功!");
inInfo.setMsg("操作成功!本次对[" + fCg001As.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
......@@ -108,75 +114,79 @@ public class ServiceHGCG002A extends ServiceBase {
/**
* 数据校验
*
* @param fCg001s
* @param dbCg001Map
* @param fCg001As
* @param dbCg001AMap
* @param hgcg001Map
*/
private void checkConfirmData(List<HGCG001> fCg001s, Map<String, HGCG001> dbCg001Map) {
for (HGCG001 fCg001 : fCg001s) {
String planNo = fCg001.getPlanNo();
HGCG001 dbCg001 = dbCg001Map.get(planNo);
AssertUtils.isNull(dbCg001, String.format("计划[%s]不存在", planNo));
AssertUtils.isNotEquals(HGConstant.CgPlanStatus.S_2, dbCg001.getStatus(),
String.format("计划[%s]状态不是\"审核通过\",不允许操作", planNo));
private void checkConfirmData(List<HGCG001A> fCg001As, Map<Long, HGCG001A> dbCg001AMap, Map<String, HGCG001> hgcg001Map) {
for (HGCG001A fCg001A : fCg001As) {
Long id = fCg001A.getId();
HGCG001A dbCg001A = dbCg001AMap.get(id);
AssertUtils.isNull(dbCg001A, String.format("计划明细[%s]不存在", id));
AssertUtils.isTrue(fCg001A.getTaxRate().compareTo(BigDecimal.ZERO) <= 0, "税率不能小于等于");
AssertUtils.isTrue(fCg001A.getPrice().compareTo(BigDecimal.ZERO) <= 0, "单价不能小于等于");
}
}
/**
* 数据保存
*
* @param resultRows
* @param dbCg001Map
* @param hgcg001Map
*/
private void confirmData(List<Map> resultRows, Map<String, HGCG001> dbCg001Map) {
for (Map resultRow : resultRows) {
String planNo = MapUtils.getString(resultRow, HGCG001.FIELD_PLAN_NO);
HGCG001 dbCg001 = dbCg001Map.get(planNo);
HGCG002 newCg002 = new HGCG002();
BeanUtils.copyProperties(dbCg001, newCg002,"id","createdBy","createdName","createdTime","updatedBy","updatedName","updatedTime");
newCg002.setContractDate(DateUtils.shortDate());
newCg002.setContractNo(SequenceGenerator.getNextSequence(HGConstant.SequenceId.CG_CONTRACT_NO));
newCg002.setSupCode(MapUtils.getString(resultRow, HGCG002.FIELD_SUP_CODE));
newCg002.setSupName(MapUtils.getString(resultRow, HGCG002.FIELD_SUP_NAME));
newCg002.setPurUserName(MapUtils.getString(resultRow, HGCG002.FIELD_PUR_USER_NAME));
newCg002.setStatus(HGConstant.CgContractStatus.S_0);
newCg002.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
newCg002.setSource(HGConstant.CgSource.DEFAULT);
DaoUtils.insert(HGCG002.INSERT, newCg002);
private void confirmData(List<HGCG001A> resultRows, Map<Long, HGCG001A> dbCg001Map, Map<String, HGCG001> hgcg001Map) {
//取一条主表数据,用于拷贝合同主表信息
HGCG001A oneCg001A = resultRows.get(0);
HGCG001 oneCG001 = hgcg001Map.get(oneCg001A.getPlanNo());
HGCG002 newCg002 = new HGCG002();
BeanUtils.copyProperties(oneCG001, newCg002,"id","createdBy","createdName","createdTime","updatedBy","updatedName","updatedTime");
newCg002.setContractDate(DateUtils.shortDate());
newCg002.setContractNo(SequenceGenerator.getNextSequence(HGConstant.SequenceId.CG_CONTRACT_NO));
newCg002.setStatus(HGConstant.CgContractStatus.S_0);
newCg002.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
newCg002.setSource(HGConstant.CgSource.DEFAULT);
DaoUtils.insert(HGCG002.INSERT, newCg002);
for (HGCG001A hgcg001A : resultRows) {
//新增子表信息
insertDetails(dbCg001,newCg002);
insertDetails(hgcg001A,newCg002);
HGCG001 cg001 = hgcg001Map.get(hgcg001A.getPlanNo());
// 更新计划状态
HGCGTools.HgCg001.updateStatus(cg001.getPlanNo(), HGConstant.CgPlanStatus.S_4);
// 更新计划状态
HGCGTools.HgCg001.updateStatus(planNo, HGConstant.CgPlanStatus.S_4);
HGCGTools.HgCg001A.updateStatus(hgcg001A.getId(), HGConstant.CgPlanStatus.S_4);
}
//修改主表信息
HGCGTools.HgCg002.updateCg002Pur(newCg002);
}
private void insertDetails(HGCG001 dbCg001, HGCG002 newCg002) {
private void insertDetails(HGCG001A dbCg001A, HGCG002 newCg002) {
//获取采购计划明细
List<HGCG001A> hgcg001AList = HGCGTools.HgCg001A.listByPrimaryId(dbCg001.getId());
List<HGCG002B> cg002BList = new LinkedList<>();
hgcg001AList.forEach(cg001A->{
HGCG002B cg002B = new HGCG002B();
//拷贝明细信息
BeanUtils.copyProperties(cg001A,cg002B,"id","createdBy","createdName","createdTime","updatedBy","updatedName","updatedTime");
cg002B.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
cg002B.setPrimaryId(newCg002.getId());
cg002BList.add(cg002B);
});
HGCG002B cg002B = new HGCG002B();
//拷贝明细信息
BeanUtils.copyProperties(dbCg001A,cg002B,"id","createdBy","createdName","createdTime","updatedBy","updatedName","updatedTime");
cg002B.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
cg002B.setPrimaryId(newCg002.getId());
cg002B.setPlanDetailId(dbCg001A.getId());
cg002BList.add(cg002B);
DaoUtils.insertBatch(HGCG002B.INSERT,cg002BList);
//修改主表信息
HGCGTools.HgCg002.updateCg002Pur(newCg002);
}
/**
* 锁并且获取数据
*
* @param fCg001s
* @param fCg001As
* @return
*/
private Map<String, HGCG001> lockGetData(List<HGCG001> fCg001s) {
// 计划号
List<String> planNos = ObjectUtils.listEpKey(fCg001s, HGCG001.FIELD_PLAN_NO);
private Map<Long, HGCG001A> lockGetData(List<HGCG001A> fCg001As) {
// ids
List<String> ids = ObjectUtils.listEpKey(fCg001As, HGCG001A.FIELD_ID);
// 锁
HGCGTools.HgCg001.lock(planNos);
HGCGTools.HgCg001A.lock(ids);
// db数据
return HGCGTools.HgCg001.map(planNos);
return HGCGTools.HgCg001A.map(ids);
}
}
......@@ -115,43 +115,16 @@ public class ServiceHGCG002B extends ServiceBase {
* 数据保存
*
* @param fCg002Bs
* @param cg001
* @param cg002
*/
private void saveData(List<HGCG002B> fCg002Bs, HGCG002 cg001) {
private void saveData(List<HGCG002B> fCg002Bs, HGCG002 cg002) {
for (HGCG002B fCg002B : fCg002Bs) {
DaoUtils.update(HGCG002B.UPDATE, fCg002B);
}
//修改主表信息
updateCg002Pur(cg001);
HGCGTools.HgCg002.updateCg002Pur(cg002);
}
private void updateCg002Pur(HGCG002 cg002) {
List<HGCG002B> hgcg002BList = HGCGTools.HgCg002B.listByPrimaryId(cg002.getId());
//修改主表信息
//采购数量
BigDecimal purQtySum = hgcg002BList.stream().map(HGCG002B::getPurQty).reduce(BigDecimal.ZERO,BigDecimal::add);
cg002.setPurQty(purQtySum);
//采购重量
BigDecimal purWeightSum = hgcg002BList.stream().map(HGCG002B::getPurWeight).reduce(BigDecimal.ZERO,BigDecimal::add);
cg002.setPurWeight(purWeightSum);
//收货数量
BigDecimal receiveQtySum = hgcg002BList.stream().map(HGCG002B::getReceiveQty).reduce(BigDecimal.ZERO,BigDecimal::add);
cg002.setReceiveQty(receiveQtySum);
//收货重量
BigDecimal receiveWeightSum = hgcg002BList.stream().map(HGCG002B::getReceiveWeight).reduce(BigDecimal.ZERO,BigDecimal::add);
cg002.setReceiveWeight(receiveWeightSum);
//金额(不含税金额)
BigDecimal amountSum = hgcg002BList.stream().map(HGCG002B::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
cg002.setAmount(amountSum);
//税额
BigDecimal taxAmountSum = hgcg002BList.stream().map(HGCG002B::getTaxAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
cg002.setTaxAmount(taxAmountSum);
//含税金额
BigDecimal taxIncludeAmountSum = hgcg002BList.stream().map(HGCG002B::getTaxIncludeAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
cg002.setTaxIncludeAmount(taxIncludeAmountSum);
DaoUtils.update(HGSqlConstant.HgCg002.UPDATE_PUR, cg002);
}
/**
* 删除操作.
......@@ -201,9 +174,9 @@ public class ServiceHGCG002B extends ServiceBase {
*
* @param fCg002Bs
* @param dbCg002BMap
* @param cg001
* @param cg002
*/
private void removeData(List<HGCG002B> fCg002Bs, Map<Long, HGCG002B> dbCg002BMap,HGCG002 cg001) {
private void removeData(List<HGCG002B> fCg002Bs, Map<Long, HGCG002B> dbCg002BMap,HGCG002 cg002) {
for (HGCG002B fCg002B : fCg002Bs) {
Long id = fCg002B.getId();
HGCG002B dbCg002B = dbCg002BMap.get(id);
......@@ -211,7 +184,7 @@ public class ServiceHGCG002B extends ServiceBase {
DaoUtils.update(HGCG002B.DELETE, dbCg002B);
}
//修改主表信息
updateCg002Pur(cg001);
HGCGTools.HgCg002.updateCg002Pur(cg002);
}
}
......@@ -100,6 +100,9 @@
<isNotEmpty prepend=" AND " property="primaryId">
PRIMARY_ID = #primaryId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="primaryIds">
PRIMARY_ID IN <iterate open="(" close=")" conjunction="," property="primaryIds">#primaryIds[]#</iterate>
</isNotEmpty>
</sql>
<sql id="idCondition">
......@@ -149,12 +152,6 @@
<isNotEmpty prepend=" AND " property="companyName">
a.COMPANY_NAME = #companyName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="planDate">
a.PLAN_DATE = #planDate#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="planNo">
a.PLAN_NO = #planNo#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventType">
a.INVENT_TYPE = #inventType#
</isNotEmpty>
......@@ -215,6 +212,25 @@
<isNotEmpty prepend=" AND " property="ids">
a.ID IN <iterate open="(" close=")" conjunction="," property="ids">#ids[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="status">
a.STATUS = #status#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="source">
b.SOURCE = #source#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="planDate">
b.PLAN_DATE = #planDate#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="planNo">
b.PLAN_NO = #planNo#
</isNotEmpty>
</sql>
<!-- 公共修改字段 -->
<sql id="updateRevise">
UPDATED_BY = #updatedBy#,
UPDATED_NAME = #updatedName#,
UPDATED_TIME = #updatedTime#
</sql>
<select id="query" parameterClass="java.util.HashMap"
......@@ -251,9 +267,11 @@
PUR_WEIGHT as "purWeight", <!-- 采购重量 -->
MATERIAL_PLAN_ID as "materialPlanId", <!-- 材料计划id -->
INVENT_TYPE_DETAIL as "inventTypeDetail", <!-- 存货类型大类 -->
STATUS as "status", <!-- 状态:0-未审批,1-审核通过,2-审核未通过 -->
PRIMARY_ID as "primaryId" <!-- 主表id -->
FROM ${hggpSchema}.HGCG001A WHERE 1=1
<include refid="condition" />
<include refid="idCondition"/>
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
......@@ -285,8 +303,6 @@
a.DELETE_FLAG as "deleteFlag", <!-- 0-未删除,1-已删除 -->
a.COMPANY_CODE as "companyCode", <!-- 公司编码 -->
a.COMPANY_NAME as "companyName", <!-- 公司名称 -->
a.PLAN_DATE as "planDate", <!-- 计划日期 -->
a.PLAN_NO as "planNo", <!-- 计划单号 -->
a.INVENT_TYPE as "inventType", <!-- 存货类型 -->
a.INVENT_CODE as "inventCode", <!-- 存货编码 -->
a.INVENT_NAME as "inventName", <!-- 存货名称 -->
......@@ -304,15 +320,20 @@
a.PUR_WEIGHT as "purWeight", <!-- 采购重量 -->
a.MATERIAL_PLAN_ID as "materialPlanId", <!-- 材料计划id -->
a.INVENT_TYPE_DETAIL as "inventTypeDetail", <!-- 存货类型大类 -->
a.STATUS as "status", <!-- 状态:0-未审批,1-审核通过,2-审核未通过 -->
b.SOURCE as "source", <!-- 数据来源 根据采购数据来源小代码 目前默认0材料计划,1手工录入 -->
b.PLAN_DATE as "planDate", <!-- 计划日期 -->
b.PLAN_NO as "planNo", <!-- 计划单号 -->
a.PRIMARY_ID as "primaryId" <!-- 主表id -->
FROM ${hggpSchema}.HGCG001A a WHERE 1=1
FROM ${hggpSchema}.HGCG001A a LEFT JOIN ${hggpSchema}.HGCG001 b ON a.PRIMARY_ID = b.ID
WHERE 1=1
<include refid="conditionByContract" />
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
ID desc
a.ID desc
</isEmpty>
</dynamic>
......@@ -350,9 +371,10 @@
PUR_WEIGHT, <!-- 采购重量 -->
MATERIAL_PLAN_ID, <!-- 材料计划id -->
INVENT_TYPE_DETAIL, <!-- 存货类型大类 -->
STATUS,
PRIMARY_ID <!-- 主表id -->
)
VALUES (#id#, #accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #updatedTime#, #deleteFlag#, #companyCode#, #companyName#, #planDate#, #planNo#, #inventType#, #inventCode#, #inventName#, #spec#, #material#, #unit#, #length#, #width#, #thick#, #planQty#, #planUnitWeight#, #planWeight#, #purQty#, #purUnitWeight#, #purWeight#, #materialPlanId#, #inventTypeDetail#, #primaryId#)
VALUES (#id#, #accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #updatedTime#, #deleteFlag#, #companyCode#, #companyName#, #planDate#, #planNo#, #inventType#, #inventCode#, #inventName#, #spec#, #material#, #unit#, #length#, #width#, #thick#, #planQty#, #planUnitWeight#, #planWeight#, #purQty#, #purUnitWeight#, #purWeight#, #materialPlanId#, #inventTypeDetail#,#status#, #primaryId#)
</insert>
<delete id="delete">
......@@ -393,6 +415,7 @@
PUR_WEIGHT = #purWeight#, <!-- 采购重量 -->
MATERIAL_PLAN_ID = #materialPlanId#, <!-- 材料计划id -->
INVENT_TYPE_DETAIL = #inventTypeDetail#, <!-- 存货类型大类 -->
STATUS = #status#,
PRIMARY_ID = #primaryId# <!-- 主表id -->
WHERE
ID = #id#
......@@ -406,4 +429,20 @@
<include refid="idCondition"/>
</update>
<!-- 修改状态信息 -->
<update id="updateStatusByPlanNo">
UPDATE ${hggpSchema}.HGCG001A
SET
STATUS = #status#, <!-- 状态:0-未审批,1-审核通过,2-审核未通过 -->
<include refid="updateRevise"/>
WHERE PLAN_NO = #planNo#
</update>
<!-- 修改状态信息 -->
<update id="updateStatusById">
UPDATE ${hggpSchema}.HGCG001A
SET
STATUS = #status#, <!-- 状态:0-未审批,1-审核通过,2-审核未通过 -->
<include refid="updateRevise"/>
WHERE ID = #id#
</update>
</sqlMap>
......@@ -103,6 +103,9 @@
<isNotEmpty prepend=" AND " property="primaryId">
PRIMARY_ID = #primaryId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="planDetailId">
PLAN_DETAIL_ID = #planDetailId#
</isNotEmpty>
</sql>
<!-- 公共修改字段 -->
<sql id="updateRevise">
......@@ -158,7 +161,8 @@
TAX_AMOUNT as "taxAmount", <!-- 税额 -->
TAX_RATE as "taxRate", <!-- 税率 -->
INVENT_TYPE_DETAIL as "inventTypeDetail", <!-- 存货类型大类 -->
PRIMARY_ID as "primaryId" <!-- 主表id -->
PRIMARY_ID as "primaryId", <!-- 主表id -->
PLAN_DETAIL_ID as "planDetailId" <!-- 计划明细id -->
FROM ${hggpSchema}.HGCG002A WHERE 1=1
<include refid="condition" />
<include refid="idCondition"/>
......@@ -210,9 +214,10 @@
TAX_AMOUNT, <!-- 税额 -->
TAX_RATE, <!-- 税率 -->
INVENT_TYPE_DETAIL, <!-- 存货类型大类 -->
PRIMARY_ID <!-- 主表id -->
PRIMARY_ID, <!-- 主表id -->
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#)
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#, #planDetailId#)
</insert>
<delete id="delete">
......@@ -254,7 +259,8 @@
TAX_AMOUNT = #taxAmount#, <!-- 税额 -->
TAX_RATE = #taxRate#, <!-- 税率 -->
INVENT_TYPE_DETAIL = #inventTypeDetail#, <!-- 存货类型大类 -->
PRIMARY_ID = #primaryId# <!-- 主表id -->
PRIMARY_ID = #primaryId#, <!-- 主表id -->
PLAN_DETAIL_ID = #planDetailId# <!-- 计划明细id -->
WHERE
ID = #id#
</update>
......
......@@ -178,7 +178,7 @@ public class HGCGTools {
AssertUtils.isEmpty(ids, "计划明细id不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put("ids", ids);
return DaoBase.getInstance().query(HGCG001A.QUERY, paramMap);
return DaoBase.getInstance().query(HGCG001A.QUERY_BY_CONTRACT, paramMap);
}
/**
......@@ -193,6 +193,33 @@ public class HGCGTools {
paramMap.put("primaryId", primaryId);
return DaoBase.getInstance().query(HGCG001A.QUERY, paramMap);
}
/**
* 查询
*
* @param planNos
* @return
*/
public static List<HGCG001A> listByplanNos(List<String> planNos) {
AssertUtils.isNull(planNos, "计划编号不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put("planNos", planNos);
return DaoBase.getInstance().query(HGCG001A.QUERY, paramMap);
}
/**
* 修改状态
*
* @param id
* @param status
*/
public static void updateStatus(Long id, Integer status) {
AssertUtils.isNull(id, "明细id不能为空!");
AssertUtils.isNull(status, "状态不能为空!");
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("id", id);
paramMap.put("status", status);
DaoUtils.update(HGSqlConstant.HgCg001A.UPDATE_STATUS_BY_ID, paramMap);
}
}
......@@ -334,6 +361,34 @@ public class HGCGTools {
DaoUtils.update(HGSqlConstant.HgCg002.UPDATE_RECEIVE, paramMap);
});
}
public static void updateCg002Pur(HGCG002 cg002) {
List<HGCG002B> hgcg002BList = HGCGTools.HgCg002B.listByPrimaryId(cg002.getId());
//修改主表信息
//采购数量
BigDecimal purQtySum = hgcg002BList.stream().map(HGCG002B::getPurQty).reduce(BigDecimal.ZERO,BigDecimal::add);
cg002.setPurQty(purQtySum);
//采购重量
BigDecimal purWeightSum = hgcg002BList.stream().map(HGCG002B::getPurWeight).reduce(BigDecimal.ZERO,BigDecimal::add);
cg002.setPurWeight(purWeightSum);
//收货数量
BigDecimal receiveQtySum = hgcg002BList.stream().map(HGCG002B::getReceiveQty).reduce(BigDecimal.ZERO,BigDecimal::add);
cg002.setReceiveQty(receiveQtySum);
//收货重量
BigDecimal receiveWeightSum = hgcg002BList.stream().map(HGCG002B::getReceiveWeight).reduce(BigDecimal.ZERO,BigDecimal::add);
cg002.setReceiveWeight(receiveWeightSum);
//金额(不含税金额)
BigDecimal amountSum = hgcg002BList.stream().map(HGCG002B::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
cg002.setAmount(amountSum);
//税额
BigDecimal taxAmountSum = hgcg002BList.stream().map(HGCG002B::getTaxAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
cg002.setTaxAmount(taxAmountSum);
//含税金额
BigDecimal taxIncludeAmountSum = hgcg002BList.stream().map(HGCG002B::getTaxIncludeAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
cg002.setTaxIncludeAmount(taxIncludeAmountSum);
DaoUtils.update(HGSqlConstant.HgCg002.UPDATE_PUR, cg002);
}
}
/**
......
......@@ -151,6 +151,8 @@ public class HGConstant {
public static final Integer S_3 = 3;
// 生成合同
public static final Integer S_4 = 4;
// 生成合同
public static final Integer S_5 = 5;
}
/**
......
......@@ -39,6 +39,10 @@ public class HGSqlConstant {
private static final String MODULE_NAME = "HGCG001A.";
// 锁
public static final String LOCK = MODULE_NAME + "lock";
// 审核修改状态信息
public static final String UPDATE_STATUS_BY_PLAN_NO = MODULE_NAME + "updateStatusByPlanNo";
// 审核修改状态信息
public static final String UPDATE_STATUS_BY_ID = MODULE_NAME + "updateStatusById";
}
/**
......
......@@ -41,6 +41,9 @@
<EF:EFColumn ename="length" cname="长(MM)" enable="false" width="80" align="right" format="{0:N3}"/>
<EF:EFColumn ename="width" cname="宽(MM)" enable="false" width="80" align="right" format="{0:N3}"/>
<EF:EFColumn ename="thick" cname="厚(MM)" enable="false" width="80" align="right" format="{0:N3}"/>
<EF:EFComboColumn ename="status" cname="状态" enable="false" width="80" align="center">
<EF:EFCodeOption codeName="hggp.hgcg.planStatus"/>
</EF:EFComboColumn>
<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']"/>
......
......@@ -42,7 +42,7 @@
<EF:EFColumn ename="contractDate" cname="合同日期" enable="false" width="100" align="center" editType="date"
dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']"/>
<EF:EFColumn ename="contractNo" cname="合同号" enable="false" width="120" align="center"/>
<EF:EFColumn ename="planNo" cname="计划单号" enable="false" width="120" align="center"/>
<%-- <EF:EFColumn ename="planNo" cname="计划单号" enable="false" width="120" align="center"/>--%>
<EF:EFComboColumn ename="status" cname="状态" enable="false" width="80" align="center">
<EF:EFCodeOption codeName="hggp.hgcg.contractStatus" condition="ITEM_CODE IN ('0','2','4','5')"/>
</EF:EFComboColumn>
......
$(function () {
var userByCompany = __eiInfo.getBlock("userByCompany").getMappedRows();
IPLATUI.EFGrid = {
"result": {
pageable:false,
columns: [
{
field: "purUserName",
template: function (dataItem) {
for (let i = 0; i < userByCompany.length; i++) {
let purUserName = dataItem['purUserName'];
if(purUserName){
if (userByCompany[i]['userName'] === purUserName.userName) {
return userByCompany[i]['userName'];
}
}
}
return "";
},
editor: function (container, options) {
let inInfo = new EiInfo();
inInfo.set("inqu_status-0-companyCode", options.model["companyCode"]);
inInfo.set("field", options.field);
EiCommunicator.send("HGSC001", "userByCompanyComboBox", inInfo, {
onSuccess: function (ei) {
userByCompany = ei.getBlock("userByCompany").getMappedRows();
},
onFail: function (ei) {
}
}, {async: false});
var input = $('<input />');
input.attr("name", options.field);
input.attr("id", options.field);
input.appendTo(container);
input.kendoDropDownList({
dataSource: userByCompany,
minLength: 0,
dataTextField: "userName",
dataValueField: "userName",
optionLabelTemplate: "[#:loginName#]#:userName#-#:depName#",
valueTemplate: "[#:loginName#]#:userName#-#:depName#",
template: "[#:loginName#]#:userName#-#:depName#",
filter: "contains"
});
}
}
],
loadComplete: function (grid) {
grid.dataSource.bind("change", function (e) {
supCodeChange(e);
var item = e.items[0];
if (e.field == "price") {
calAmount(item);
}
if (e.field == "taxRate") {
calAmount(item);
}
});
}
}
......@@ -92,16 +57,16 @@ let confirm = function () {
return;
}
for (let i = 0; i < rows.length; i++) {
if (isBlank(rows[i]['supCode'])) {
message("勾选的第" + (i + 1) + "行供应商名称不能为空");
return;
}
if (isBlank(rows[i]['purUserName'])) {
message("勾选的第" + (i + 1) + "行采购员不能为空");
return;
}
let purUserName = rows[i]['purUserName'];
rows[i]['purUserName'] = purUserName.userName;
// if (isBlank(rows[i]['supCode'])) {
// message("勾选的第" + (i + 1) + "行供应商名称不能为空");
// return;
// }
// if (isBlank(rows[i]['purUserName'])) {
// message("勾选的第" + (i + 1) + "行采购员不能为空");
// return;
// }
// let purUserName = rows[i]['purUserName'];
// rows[i]['purUserName'] = purUserName.userName;
}
JSUtils.confirm("确定对勾选的[" + rows.length + "]条数据生成\"采购合同\"吗? ", {
ok: function () {
......@@ -118,21 +83,43 @@ let confirm = function () {
}
/**
* 供应商变更
* 计算金额
* @param item
* @param length
* @param width
* @param thick
* @param coefficient
*/
let supCodeChange = function (e) {
if (e.field != "supCode") {
return;
}
let item = e.items[0];
let supRecordRows = __eiInfo.blocks.sup_record_block_id.rows;
for (let k = 0; k < resultGrid.getCheckedRowsIndex() + 1; k++) {
for (let i = 0; i < supRecordRows.length; i++) {
if (supRecordRows[i][1] === item.supCode) {
let supName = supRecordRows[i][0];
resultGrid.setCellValue(item, 'supName', supName == null ? "" : supName);
return;
}
let calAmount = function (item) {
//原材料
if(item.inventTypeDetail === '3'){
if(item.purWeight && item.price && item.taxRate){
// 重量*单价金额
let totalAmount = item.purWeight * item.price;
//不含税金额
let amount = totalAmount / (1 + item.taxRate / 100);
//税额
let taxAmount = totalAmount - amount;
//含税金额
let taxIncludeAmount = totalAmount;
resultGrid.setCellValue(item, 'taxAmount', taxAmount)
resultGrid.setCellValue(item, 'amount', amount)
resultGrid.setCellValue(item, 'taxIncludeAmount', taxIncludeAmount)
}
}else{
if(item.purQty && item.price && item.taxRate){
// 数量*单价金额
let totalAmount = item.purQty * item.price;
//不含税金额
let amount = totalAmount / (1 + item.taxRate / 100);
//税额
let taxAmount = totalAmount - amount;
//含税金额
let taxIncludeAmount = totalAmount;
resultGrid.setCellValue(item, 'taxAmount', taxAmount)
resultGrid.setCellValue(item, 'amount', amount)
resultGrid.setCellValue(item, 'taxIncludeAmount', taxIncludeAmount)
}
}
}
......@@ -30,14 +30,24 @@
<EF:EFColumn ename="planDate" cname="计划日期" enable="false" width="100" align="center" editType="date"
dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']"/>
<EF:EFColumn ename="planNo" cname="计划单号" enable="false" width="120" align="center"/>
<EF:EFComboColumn ename="supCode" cname="供应商名称" width="120" align="left" defaultValue=""
filter="contains" required="true">
<EF:EFOptions blockId="sup_record_block_id" valueField="valueField" textField="textField"/>
<EF:EFColumn ename="inventCode" cname="存货编码" enable="false" width="100" align="center"/>
<EF:EFColumn ename="inventName" cname="存货名称" enable="false" width="100" align="center"/>
<EF:EFColumn ename="spec" cname="规格" enable="false" width="120" align="center"/>
<EF:EFColumn ename="purQty" cname="采购数量" width="120" align="right" format="{0:N0}" enable="false"/>
<EF:EFColumn ename="purWeight" cname="采购重量" width="120" align="right" format="{0:N3}" enable="false"/>
<EF:EFColumn ename="price" cname="单价" width="80" align="right" format="{0:N3}" required="true"/>
<EF:EFComboColumn ename="taxRate" cname="税率(%)" enable="true" width="80" align="center" required="true">
<EF:EFCodeOption codeName="hggp.cw.taxPoints" />
</EF:EFComboColumn>
<EF:EFColumn ename="supName" cname="供应商名称" enable="false" width="100" align="center" hidden="true"/>
<EF:EFColumn ename="purUserName" cname="采购员" width="120" align="center" maxLength="100" required="true"/>
<EF:EFColumn ename="purQty" cname="采购数量" enable="false" width="120" align="right" format="{0:N0}"/>
<EF:EFColumn ename="purWeight" cname="采购重量" enable="false" width="120" align="right" format="{0:N3}"/>
<EF:EFColumn ename="amount" cname="不含税金额" enable="false" width="80" align="right" format="{0:N3}"/>
<EF:EFColumn ename="taxAmount" cname="税额" enable="false" width="80" align="right" format="{0:N3}"/>
<EF:EFColumn ename="taxIncludeAmount" cname="含税金额" enable="false" width="80" align="right" format="{0:N3}"/>
<EF:EFColumn ename="material" cname="材质" enable="false" width="80" align="center"/>
<EF:EFColumn ename="unit" cname="单位" enable="false" width="80" align="center"/>
<EF:EFColumn ename="length" cname="长(MM)" enable="false" width="80" align="right" format="{0:N3}"/>
<EF:EFColumn ename="width" cname="宽(MM)" enable="false" width="80" align="right" format="{0:N3}"/>
<EF:EFColumn ename="thick" cname="厚(MM)" enable="false" width="80" align="right" format="{0:N3}"/>
<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']"/>
......
......@@ -42,11 +42,11 @@ $(function () {
input.kendoDropDownList({
dataSource: dataSource,
minLength: 0,
dataTextField: "valueField",
dataTextField: "param4Field",
dataValueField: "valueField",
optionLabelTemplate: "[#:valueField#]#:textField#",
valueTemplate: "[#:valueField#]#:textField#",
template: "[#:valueField#]#:textField#",
optionLabelTemplate: "[#:valueField#]#:textField#[#:param4Field#]",
valueTemplate: "[#:valueField#]#:textField#[#:param4Field#]",
template: "[#:valueField#]#:textField#[#:param4Field#]",
filter: "contains"
});
}
......
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