Commit bfe647e6 by 宋祥

1.采购合同、采购收货

parent 79ec23d8
package com.baosight.hggp.hg.cg.domain; package com.baosight.hggp.hg.cg.domain;
import com.baosight.iplat4j.core.data.DaoEPBase;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.util.NumberUtils; import com.baosight.iplat4j.core.util.NumberUtils;
import com.baosight.iplat4j.core.util.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.data.DaoEPBase;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.baosight.iplat4j.core.util.StringUtils;
/** /**
* Project: <br> * Project: <br>
...@@ -17,7 +16,7 @@ import java.util.Map; ...@@ -17,7 +16,7 @@ import java.util.Map;
* Copyrigth:Baosight Software LTD.co Copyright (c) 2019. <br> * Copyrigth:Baosight Software LTD.co Copyright (c) 2019. <br>
* *
* @version 1.0 * @version 1.0
* @history 2024-05-09 15:41:54 create * @history 2024-05-10 15:20:01 create
*/ */
public class HGCG002 extends DaoEPBase { public class HGCG002 extends DaoEPBase {
...@@ -49,6 +48,7 @@ public class HGCG002 extends DaoEPBase { ...@@ -49,6 +48,7 @@ public class HGCG002 extends DaoEPBase {
public static final String FIELD_LENGTH = "length"; /* 长度*/ public static final String FIELD_LENGTH = "length"; /* 长度*/
public static final String FIELD_PUR_QTY = "purQty"; /* 采购数量*/ public static final String FIELD_PUR_QTY = "purQty"; /* 采购数量*/
public static final String FIELD_PUR_WEIGHT = "purWeight"; /* 采购重量*/ public static final String FIELD_PUR_WEIGHT = "purWeight"; /* 采购重量*/
public static final String FIELD_RECEIVE_QTY = "receiveQty"; /* 收货数量*/
public static final String FIELD_STATUS = "status"; /* 状态:0-未审批,1-审核通过,2-审核未通过*/ public static final String FIELD_STATUS = "status"; /* 状态:0-未审批,1-审核通过,2-审核未通过*/
public static final String FIELD_AUDIT_TIME = "auditTime"; /* 审核时间*/ 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_ID = "auditUserId"; /* 审核人ID*/
...@@ -81,6 +81,7 @@ public class HGCG002 extends DaoEPBase { ...@@ -81,6 +81,7 @@ public class HGCG002 extends DaoEPBase {
public static final String COL_LENGTH = "LENGTH"; /* 长度*/ public static final String COL_LENGTH = "LENGTH"; /* 长度*/
public static final String COL_PUR_QTY = "PUR_QTY"; /* 采购数量*/ public static final String COL_PUR_QTY = "PUR_QTY"; /* 采购数量*/
public static final String COL_PUR_WEIGHT = "PUR_WEIGHT"; /* 采购重量*/ public static final String COL_PUR_WEIGHT = "PUR_WEIGHT"; /* 采购重量*/
public static final String COL_RECEIVE_QTY = "RECEIVE_QTY"; /* 收货数量*/
public static final String COL_STATUS = "STATUS"; /* 状态:0-未审批,1-审核通过,2-审核未通过*/ public static final String COL_STATUS = "STATUS"; /* 状态:0-未审批,1-审核通过,2-审核未通过*/
public static final String COL_AUDIT_TIME = "AUDIT_TIME"; /* 审核时间*/ 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_ID = "AUDIT_USER_ID"; /* 审核人ID*/
...@@ -102,7 +103,7 @@ public class HGCG002 extends DaoEPBase { ...@@ -102,7 +103,7 @@ public class HGCG002 extends DaoEPBase {
private String updatedBy = " "; /* 记录修改者*/ private String updatedBy = " "; /* 记录修改者*/
private String updatedName = " "; /* 记录修改名称*/ private String updatedName = " "; /* 记录修改名称*/
private String updatedTime = " "; /* 记录修改时间*/ private String updatedTime = " "; /* 记录修改时间*/
private Integer deleteFlag = 0; /* 0-未删除,1-已删除*/ private Integer deleteFlag; /* 0-未删除,1-已删除*/
private String companyCode = " "; /* 公司编码*/ private String companyCode = " "; /* 公司编码*/
private String companyName = " "; /* 公司名称*/ private String companyName = " "; /* 公司名称*/
private String contractDate = " "; /* 合同日期*/ private String contractDate = " "; /* 合同日期*/
...@@ -119,7 +120,8 @@ public class HGCG002 extends DaoEPBase { ...@@ -119,7 +120,8 @@ public class HGCG002 extends DaoEPBase {
private BigDecimal length = new BigDecimal(0.000); /* 长度*/ private BigDecimal length = new BigDecimal(0.000); /* 长度*/
private BigDecimal purQty = new BigDecimal(0.000); /* 采购数量*/ private BigDecimal purQty = new BigDecimal(0.000); /* 采购数量*/
private BigDecimal purWeight = new BigDecimal(0.000); /* 采购重量*/ private BigDecimal purWeight = new BigDecimal(0.000); /* 采购重量*/
private Integer status = 0; /* 状态:0-未审批,1-审核通过,2-审核未通过*/ private BigDecimal receiveQty = new BigDecimal(0.000); /* 收货数量*/
private Integer status; /* 状态:0-未审批,1-审核通过,2-审核未通过*/
private String auditTime = " "; /* 审核时间*/ private String auditTime = " "; /* 审核时间*/
private String auditUserId = " "; /* 审核人ID*/ private String auditUserId = " "; /* 审核人ID*/
private String auditUserName = " "; /* 审核人名称*/ private String auditUserName = " "; /* 审核人名称*/
...@@ -245,6 +247,13 @@ public class HGCG002 extends DaoEPBase { ...@@ -245,6 +247,13 @@ public class HGCG002 extends DaoEPBase {
eiColumn.setDescName("采购重量"); eiColumn.setDescName("采购重量");
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_RECEIVE_QTY);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(20);
eiColumn.setDescName("收货数量");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_STATUS); eiColumn = new EiColumn(FIELD_STATUS);
eiColumn.setDescName("状态:0-未审批,1-审核通过,2-审核未通过"); eiColumn.setDescName("状态:0-未审批,1-审核通过,2-审核未通过");
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
...@@ -692,6 +701,22 @@ public class HGCG002 extends DaoEPBase { ...@@ -692,6 +701,22 @@ public class HGCG002 extends DaoEPBase {
this.purWeight = purWeight; this.purWeight = purWeight;
} }
/** /**
* get the receiveQty - 收货数量.
* @return the receiveQty
*/
public BigDecimal getReceiveQty() {
return this.receiveQty;
}
/**
* set the receiveQty - 收货数量.
*
* @param receiveQty - 收货数量
*/
public void setReceiveQty(BigDecimal receiveQty) {
this.receiveQty = receiveQty;
}
/**
* get the status - 状态:0-未审批,1-审核通过,2-审核未通过. * get the status - 状态:0-未审批,1-审核通过,2-审核未通过.
* @return the status * @return the status
*/ */
...@@ -805,6 +830,7 @@ public class HGCG002 extends DaoEPBase { ...@@ -805,6 +830,7 @@ public class HGCG002 extends DaoEPBase {
setLength(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_LENGTH)), length)); setLength(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_LENGTH)), length));
setPurQty(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_PUR_QTY)), purQty)); setPurQty(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_PUR_QTY)), purQty));
setPurWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_PUR_WEIGHT)), purWeight)); setPurWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_PUR_WEIGHT)), purWeight));
setReceiveQty(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_RECEIVE_QTY)), receiveQty));
setStatus(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_STATUS)), status)); setStatus(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_STATUS)), status));
setAuditTime(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_AUDIT_TIME)), auditTime)); setAuditTime(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_AUDIT_TIME)), auditTime));
setAuditUserId(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_AUDIT_USER_ID)), auditUserId)); setAuditUserId(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_AUDIT_USER_ID)), auditUserId));
...@@ -845,6 +871,7 @@ public class HGCG002 extends DaoEPBase { ...@@ -845,6 +871,7 @@ public class HGCG002 extends DaoEPBase {
map.put(FIELD_LENGTH, StringUtils.toString(length, eiMetadata.getMeta(FIELD_LENGTH))); map.put(FIELD_LENGTH, StringUtils.toString(length, eiMetadata.getMeta(FIELD_LENGTH)));
map.put(FIELD_PUR_QTY, StringUtils.toString(purQty, eiMetadata.getMeta(FIELD_PUR_QTY))); map.put(FIELD_PUR_QTY, StringUtils.toString(purQty, eiMetadata.getMeta(FIELD_PUR_QTY)));
map.put(FIELD_PUR_WEIGHT, StringUtils.toString(purWeight, eiMetadata.getMeta(FIELD_PUR_WEIGHT))); map.put(FIELD_PUR_WEIGHT, StringUtils.toString(purWeight, eiMetadata.getMeta(FIELD_PUR_WEIGHT)));
map.put(FIELD_RECEIVE_QTY, StringUtils.toString(receiveQty, eiMetadata.getMeta(FIELD_RECEIVE_QTY)));
map.put(FIELD_STATUS, StringUtils.toString(status, eiMetadata.getMeta(FIELD_STATUS))); map.put(FIELD_STATUS, StringUtils.toString(status, eiMetadata.getMeta(FIELD_STATUS)));
map.put(FIELD_AUDIT_TIME, StringUtils.toString(auditTime, eiMetadata.getMeta(FIELD_AUDIT_TIME))); map.put(FIELD_AUDIT_TIME, StringUtils.toString(auditTime, eiMetadata.getMeta(FIELD_AUDIT_TIME)));
map.put(FIELD_AUDIT_USER_ID, StringUtils.toString(auditUserId, eiMetadata.getMeta(FIELD_AUDIT_USER_ID))); map.put(FIELD_AUDIT_USER_ID, StringUtils.toString(auditUserId, eiMetadata.getMeta(FIELD_AUDIT_USER_ID)));
......
package com.baosight.hggp.hg.cg.domain;
import com.baosight.iplat4j.core.data.DaoEPBase;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.util.NumberUtils;
import com.baosight.iplat4j.core.util.StringUtils;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
/**
* Project: <br>
* Title:Hgcg002.java <br>
* Description: <br>
*
* Copyrigth:Baosight Software LTD.co Copyright (c) 2019. <br>
*
* @version 1.0
* @history 2024-05-09 15:41:54 create
*/
public class HGCG002A extends HGCG002 {
public static final String FIELD_BC_RECEIVE_QTY = "bcReceiveQty"; /* 本次收货数量*/
public static final String FIELD_BC_MAX_RECEIVE_QTY = "bcMaxReceiveQty"; /* 本次最大收货数量*/
private BigDecimal bcReceiveQty = new BigDecimal(0.000); /* 本次收货数量*/
private BigDecimal bcMaxReceiveQty = new BigDecimal(0.000); /* 本次最大收货数量*/
/**
* initialize the metadata.
*/
public void initMetaData() {
EiColumn eiColumn;
eiColumn = new EiColumn(FIELD_BC_RECEIVE_QTY);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(20);
eiColumn.setDescName("本次收货数量");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_BC_MAX_RECEIVE_QTY);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(20);
eiColumn.setDescName("本次最大收货数量");
eiMetadata.addMeta(eiColumn);
}
/**
* the constructor.
*/
public HGCG002A() {
super.initMetaData();
initMetaData();
}
public BigDecimal getBcReceiveQty() {
return bcReceiveQty;
}
public void setBcReceiveQty(BigDecimal bcReceiveQty) {
this.bcReceiveQty = bcReceiveQty;
}
public BigDecimal getBcMaxReceiveQty() {
return bcMaxReceiveQty;
}
public void setBcMaxReceiveQty(BigDecimal bcMaxReceiveQty) {
this.bcMaxReceiveQty = bcMaxReceiveQty;
}
/**
* get the value from Map.
*
* @param map - source data map
*/
@Override
public void fromMap(Map map) {
super.fromMap(map);
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));
}
/**
* set the value to Map.
*/
@Override
public Map toMap() {
Map map = super.toMap();
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)));
return map;
}
}
...@@ -106,7 +106,7 @@ public class ServiceHGCG001 extends ServiceBase { ...@@ -106,7 +106,7 @@ public class ServiceHGCG001 extends ServiceBase {
String planNo = fCg001.getPlanNo(); String planNo = fCg001.getPlanNo();
HGCG001 dbCg001 = dbCg001Map.get(planNo); HGCG001 dbCg001 = dbCg001Map.get(planNo);
AssertUtils.isNull(dbCg001, String.format("计划[%s]不存在", planNo)); AssertUtils.isNull(dbCg001, String.format("计划[%s]不存在", planNo));
AssertUtils.isNotEquals(HGConstant.planStatus.S_0, dbCg001.getStatus(), AssertUtils.isNotEquals(HGConstant.CgPlanStatus.S_0, dbCg001.getStatus(),
String.format("计划[%s]状态不是\"待审核\",不允许操作", planNo)); String.format("计划[%s]状态不是\"待审核\",不允许操作", planNo));
AssertUtils.isGe(BigDecimal.ZERO, fCg001.getPurQty(), String.format("计划[%s]采购数量必须大于0", planNo)); AssertUtils.isGe(BigDecimal.ZERO, fCg001.getPurQty(), String.format("计划[%s]采购数量必须大于0", planNo));
AssertUtils.isGe(BigDecimal.ZERO, fCg001.getPurWeight(), String.format("计划[%s]采购重量必须大于0", planNo)); AssertUtils.isGe(BigDecimal.ZERO, fCg001.getPurWeight(), String.format("计划[%s]采购重量必须大于0", planNo));
...@@ -142,9 +142,9 @@ public class ServiceHGCG001 extends ServiceBase { ...@@ -142,9 +142,9 @@ public class ServiceHGCG001 extends ServiceBase {
this.removeData(fCg001s); this.removeData(fCg001s);
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fCg001s.size() + "]条数据保存成功!"); inInfo.setMsg("操作成功!本次对[" + fCg001s.size() + "]条数据删除成功!");
} catch (Exception e) { } catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败"); LogUtils.setDetailMsg(inInfo, e, "删除失败");
} }
return inInfo; return inInfo;
} }
...@@ -160,7 +160,7 @@ public class ServiceHGCG001 extends ServiceBase { ...@@ -160,7 +160,7 @@ public class ServiceHGCG001 extends ServiceBase {
String planNo = fCg001.getPlanNo(); String planNo = fCg001.getPlanNo();
HGCG001 dbCg001 = dbCg001Map.get(planNo); HGCG001 dbCg001 = dbCg001Map.get(planNo);
AssertUtils.isNull(dbCg001, String.format("计划[%s]不存在", planNo)); AssertUtils.isNull(dbCg001, String.format("计划[%s]不存在", planNo));
AssertUtils.isNotEquals(HGConstant.planStatus.S_0, dbCg001.getStatus(), AssertUtils.isNotEquals(HGConstant.CgPlanStatus.S_0, dbCg001.getStatus(),
String.format("计划[%s]状态不是\"待审核\",不允许操作", planNo)); String.format("计划[%s]状态不是\"待审核\",不允许操作", planNo));
} }
} }
...@@ -195,9 +195,9 @@ public class ServiceHGCG001 extends ServiceBase { ...@@ -195,9 +195,9 @@ public class ServiceHGCG001 extends ServiceBase {
this.submitData(fCg001s); this.submitData(fCg001s);
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fCg001s.size() + "]条数据提交成功!"); inInfo.setMsg("操作成功!本次对[" + fCg001s.size() + "]条数据审核成功!");
} catch (Exception e) { } catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败"); LogUtils.setDetailMsg(inInfo, e, "审核失败");
} }
return inInfo; return inInfo;
} }
...@@ -213,7 +213,7 @@ public class ServiceHGCG001 extends ServiceBase { ...@@ -213,7 +213,7 @@ public class ServiceHGCG001 extends ServiceBase {
String planNo = fCg001.getPlanNo(); String planNo = fCg001.getPlanNo();
HGCG001 dbCg001 = dbCg001Map.get(planNo); HGCG001 dbCg001 = dbCg001Map.get(planNo);
AssertUtils.isNull(dbCg001, String.format("计划[%s]不存在", planNo)); AssertUtils.isNull(dbCg001, String.format("计划[%s]不存在", planNo));
AssertUtils.isNotEquals(HGConstant.planStatus.S_0, dbCg001.getStatus(), AssertUtils.isNotEquals(HGConstant.CgPlanStatus.S_0, dbCg001.getStatus(),
String.format("计划[%s]状态不是\"待审核\",不允许操作", planNo)); String.format("计划[%s]状态不是\"待审核\",不允许操作", planNo));
AssertUtils.isGe(BigDecimal.ZERO, dbCg001.getPurQty(), String.format("计划[%s]采购数量必须大于0", planNo)); AssertUtils.isGe(BigDecimal.ZERO, dbCg001.getPurQty(), String.format("计划[%s]采购数量必须大于0", planNo));
AssertUtils.isGe(BigDecimal.ZERO, dbCg001.getPurWeight(), String.format("计划[%s]采购重量必须大于0", planNo)); AssertUtils.isGe(BigDecimal.ZERO, dbCg001.getPurWeight(), String.format("计划[%s]采购重量必须大于0", planNo));
...@@ -228,7 +228,7 @@ public class ServiceHGCG001 extends ServiceBase { ...@@ -228,7 +228,7 @@ public class ServiceHGCG001 extends ServiceBase {
*/ */
private void submitData(List<HGCG001> fCg001s) { private void submitData(List<HGCG001> fCg001s) {
for (HGCG001 fCg001 : fCg001s) { for (HGCG001 fCg001 : fCg001s) {
fCg001.setStatus(HGConstant.planStatus.S_1); fCg001.setStatus(HGConstant.CgPlanStatus.S_1);
fCg001.setAuditTime(DateUtils.shortDateTime()); fCg001.setAuditTime(DateUtils.shortDateTime());
fCg001.setAuditUserId(UserSessionUtils.getLoginName()); fCg001.setAuditUserId(UserSessionUtils.getLoginName());
fCg001.setAuditUserName(UserSessionUtils.getLoginCName()); fCg001.setAuditUserName(UserSessionUtils.getLoginCName());
......
...@@ -6,6 +6,7 @@ import com.baosight.hggp.core.dao.DaoUtils; ...@@ -6,6 +6,7 @@ import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.DeleteFlagEnum; import com.baosight.hggp.core.enums.DeleteFlagEnum;
import com.baosight.hggp.core.security.UserSessionUtils; import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.cg.domain.HGCG002; import com.baosight.hggp.hg.cg.domain.HGCG002;
import com.baosight.hggp.hg.cg.domain.HGCG002A;
import com.baosight.hggp.hg.cg.tools.HGCGTools; import com.baosight.hggp.hg.cg.tools.HGCGTools;
import com.baosight.hggp.hg.cg.utils.HgCgUtils; import com.baosight.hggp.hg.cg.utils.HgCgUtils;
import com.baosight.hggp.hg.constant.HGConstant; import com.baosight.hggp.hg.constant.HGConstant;
...@@ -43,6 +44,7 @@ public class ServiceHGCG002 extends ServiceBase { ...@@ -43,6 +44,7 @@ public class ServiceHGCG002 extends ServiceBase {
public EiInfo initLoad(EiInfo inInfo) { public EiInfo initLoad(EiInfo inInfo) {
try { try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.COMPANY_CODE_BLOCK_ID)); CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.COMPANY_CODE_BLOCK_ID));
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.SUP_RECORD_BLOCK_ID));
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCG002().eiMetadata); inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCG002().eiMetadata);
} catch (PlatException e) { } catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败"); LogUtils.setDetailMsg(inInfo, e, "初始化失败");
...@@ -80,9 +82,9 @@ public class ServiceHGCG002 extends ServiceBase { ...@@ -80,9 +82,9 @@ public class ServiceHGCG002 extends ServiceBase {
try { try {
List<HGCG002> fCg002s = MapUtils.toDaoEPBase(inInfo, HGCG002.class); List<HGCG002> fCg002s = MapUtils.toDaoEPBase(inInfo, HGCG002.class);
// db数据 // db数据
Map<String, HGCG002> dbCg002Map = this.lockGetData(fCg002s); Map<String, HGCG002A> dbCg002AMap = HgCgUtils.HgCg002.lockGetDataEp(fCg002s);
// 数据校验 // 数据校验
this.checkSaveData(fCg002s, dbCg002Map); this.checkSaveData(fCg002s, dbCg002AMap);
// 保存数据 // 保存数据
this.saveData(fCg002s); this.saveData(fCg002s);
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
...@@ -98,14 +100,14 @@ public class ServiceHGCG002 extends ServiceBase { ...@@ -98,14 +100,14 @@ public class ServiceHGCG002 extends ServiceBase {
* 数据校验 * 数据校验
* *
* @param fCg002s * @param fCg002s
* @param dbCg002Map * @param dbCg002AMap
*/ */
private void checkSaveData(List<HGCG002> fCg002s, Map<String, HGCG002> dbCg002Map) { private void checkSaveData(List<HGCG002> fCg002s, Map<String, HGCG002A> dbCg002AMap) {
for (HGCG002 fCg002 : fCg002s) { for (HGCG002 fCg002 : fCg002s) {
String contractNo = fCg002.getContractNo(); String contractNo = fCg002.getContractNo();
HGCG002 dbCg002 = dbCg002Map.get(contractNo); HGCG002 dbCg002 = dbCg002AMap.get(contractNo);
AssertUtils.isNull(dbCg002, String.format("合同[%s]不存在", contractNo)); AssertUtils.isNull(dbCg002, String.format("合同[%s]不存在", contractNo));
AssertUtils.isNotEquals(HGConstant.planStatus.S_0, fCg002.getStatus(), AssertUtils.isNotEquals(HGConstant.CgPlanStatus.S_0, dbCg002.getStatus(),
String.format("合同[%s]状态不是\"待审核\",不允许操作", contractNo)); String.format("合同[%s]状态不是\"待审核\",不允许操作", contractNo));
} }
} }
...@@ -132,16 +134,16 @@ public class ServiceHGCG002 extends ServiceBase { ...@@ -132,16 +134,16 @@ public class ServiceHGCG002 extends ServiceBase {
try { try {
List<HGCG002> fCg002s = MapUtils.toDaoEPBase(inInfo, HGCG002.class); List<HGCG002> fCg002s = MapUtils.toDaoEPBase(inInfo, HGCG002.class);
// db数据 // db数据
Map<String, HGCG002> dbCg002Map = this.lockGetData(fCg002s); Map<String, HGCG002A> dbCg002AMap = HgCgUtils.HgCg002.lockGetDataEp(fCg002s);
// 数据校验 // 数据校验
this.checkRemoveData(fCg002s, dbCg002Map); this.checkRemoveData(fCg002s, dbCg002AMap);
// 保存数据 // 保存数据
this.removeData(fCg002s); this.removeData(fCg002s, dbCg002AMap);
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fCg002s.size() + "]条数据保存成功!"); inInfo.setMsg("操作成功!本次对[" + fCg002s.size() + "]条数据删除成功!");
} catch (Exception e) { } catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败"); LogUtils.setDetailMsg(inInfo, e, "删除失败");
} }
return inInfo; return inInfo;
} }
...@@ -150,14 +152,14 @@ public class ServiceHGCG002 extends ServiceBase { ...@@ -150,14 +152,14 @@ public class ServiceHGCG002 extends ServiceBase {
* 数据校验 * 数据校验
* *
* @param fCg002s * @param fCg002s
* @param dbCg002Map * @param dbCg002AMap
*/ */
private void checkRemoveData(List<HGCG002> fCg002s, Map<String, HGCG002> dbCg002Map) { private void checkRemoveData(List<HGCG002> fCg002s, Map<String, HGCG002A> dbCg002AMap) {
for (HGCG002 fCg002 : fCg002s) { for (HGCG002 fCg002 : fCg002s) {
String contractNo = fCg002.getContractNo(); String contractNo = fCg002.getContractNo();
HGCG002 dbCg002 = dbCg002Map.get(contractNo); HGCG002 dbCg002 = dbCg002AMap.get(contractNo);
AssertUtils.isNull(dbCg002, String.format("合同[%s]不存在", contractNo)); AssertUtils.isNull(dbCg002, String.format("合同[%s]不存在", contractNo));
AssertUtils.isNotEquals(HGConstant.contractStatus.S_0, fCg002.getStatus(), AssertUtils.isNotEquals(HGConstant.CgContractStatus.S_0, dbCg002.getStatus(),
String.format("合同[%s]状态不是\"待审核\",不允许操作", contractNo)); String.format("合同[%s]状态不是\"待审核\",不允许操作", contractNo));
} }
} }
...@@ -166,11 +168,16 @@ public class ServiceHGCG002 extends ServiceBase { ...@@ -166,11 +168,16 @@ public class ServiceHGCG002 extends ServiceBase {
* 数据保存 * 数据保存
* *
* @param fCg002s * @param fCg002s
* @param dbCg002AMap
*/ */
private void removeData(List<HGCG002> fCg002s) { private void removeData(List<HGCG002> fCg002s, Map<String, HGCG002A> dbCg002AMap) {
for (HGCG002 fCg002 : fCg002s) { for (HGCG002 fCg002 : fCg002s) {
fCg002.setDeleteFlag(DeleteFlagEnum.REMOVE.getCode()); String contractNo = fCg002.getContractNo();
DaoUtils.update(HGCG002.DELETE, fCg002); HGCG002 dbCg002 = dbCg002AMap.get(contractNo);
dbCg002.setDeleteFlag(DeleteFlagEnum.REMOVE.getCode());
DaoUtils.update(HGCG002.DELETE, dbCg002);
// 更新计划状态
HGCGTools.HgCg001.updateStatus(dbCg002.getPlanNo(), HGConstant.CgPlanStatus.S_1);
} }
} }
...@@ -185,16 +192,16 @@ public class ServiceHGCG002 extends ServiceBase { ...@@ -185,16 +192,16 @@ public class ServiceHGCG002 extends ServiceBase {
try { try {
List<HGCG002> fCg002s = MapUtils.toDaoEPBase(inInfo, HGCG002.class); List<HGCG002> fCg002s = MapUtils.toDaoEPBase(inInfo, HGCG002.class);
// db数据 // db数据
Map<String, HGCG002> dbCg002Map = this.lockGetData(fCg002s); Map<String, HGCG002A> dbCg002AMap = HgCgUtils.HgCg002.lockGetDataEp(fCg002s);
// 数据校验 // 数据校验
this.checkSubmitData(fCg002s, dbCg002Map); this.checkSubmitData(fCg002s, dbCg002AMap);
// 提交数据 // 提交数据
this.submitData(fCg002s); this.submitData(fCg002s);
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fCg002s.size() + "]条数据提交成功!"); inInfo.setMsg("操作成功!本次对[" + fCg002s.size() + "]条数据审核成功!");
} catch (Exception e) { } catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败"); LogUtils.setDetailMsg(inInfo, e, "审核失败");
} }
return inInfo; return inInfo;
} }
...@@ -203,14 +210,14 @@ public class ServiceHGCG002 extends ServiceBase { ...@@ -203,14 +210,14 @@ public class ServiceHGCG002 extends ServiceBase {
* 数据校验 * 数据校验
* *
* @param fCg002s * @param fCg002s
* @param dbCg002Map * @param dbCg002AMap
*/ */
private void checkSubmitData(List<HGCG002> fCg002s, Map<String, HGCG002> dbCg002Map) { private void checkSubmitData(List<HGCG002> fCg002s, Map<String, HGCG002A> dbCg002AMap) {
for (HGCG002 fCg002 : fCg002s) { for (HGCG002 fCg002 : fCg002s) {
String contractNo = fCg002.getContractNo(); String contractNo = fCg002.getContractNo();
HGCG002 dbCg002 = dbCg002Map.get(contractNo); HGCG002 dbCg002 = dbCg002AMap.get(contractNo);
AssertUtils.isNull(dbCg002, String.format("合同[%s]不存在", contractNo)); AssertUtils.isNull(dbCg002, String.format("合同[%s]不存在", contractNo));
AssertUtils.isNotEquals(HGConstant.contractStatus.S_0, dbCg002.getStatus(), AssertUtils.isNotEquals(HGConstant.CgContractStatus.S_0, dbCg002.getStatus(),
String.format("合同[%s]状态不是\"待审核\",不允许操作", contractNo)); String.format("合同[%s]状态不是\"待审核\",不允许操作", contractNo));
} }
} }
...@@ -223,7 +230,7 @@ public class ServiceHGCG002 extends ServiceBase { ...@@ -223,7 +230,7 @@ public class ServiceHGCG002 extends ServiceBase {
*/ */
private void submitData(List<HGCG002> fCg002s) { private void submitData(List<HGCG002> fCg002s) {
for (HGCG002 fCg002 : fCg002s) { for (HGCG002 fCg002 : fCg002s) {
fCg002.setStatus(HGConstant.contractStatus.S_1); fCg002.setStatus(HGConstant.CgContractStatus.S_1);
fCg002.setAuditTime(DateUtils.shortDateTime()); fCg002.setAuditTime(DateUtils.shortDateTime());
fCg002.setAuditUserId(UserSessionUtils.getLoginName()); fCg002.setAuditUserId(UserSessionUtils.getLoginName());
fCg002.setAuditUserName(UserSessionUtils.getLoginCName()); fCg002.setAuditUserName(UserSessionUtils.getLoginCName());
...@@ -232,18 +239,4 @@ public class ServiceHGCG002 extends ServiceBase { ...@@ -232,18 +239,4 @@ public class ServiceHGCG002 extends ServiceBase {
} }
} }
/**
* 锁并且获取数据
*
* @param fCg002s
* @return
*/
private Map<String, HGCG002> lockGetData(List<HGCG002> fCg002s) {
// 合同号
List<String> contractNos = ObjectUtils.listEpKey(fCg002s, HGCG002.FIELD_CONTRACT_NO);
// 锁
HGCGTools.HgCg002.lock(contractNos);
// db数据
return HGCGTools.HgCg002.map(contractNos);
}
} }
...@@ -12,6 +12,7 @@ import com.baosight.hggp.hg.constant.HGConstant; ...@@ -12,6 +12,7 @@ import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.util.AssertUtils; import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.BeanUtils; import com.baosight.hggp.util.BeanUtils;
import com.baosight.hggp.util.CommonMethod; import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.EiInfoUtils; import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils; import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils; import com.baosight.hggp.util.MapUtils;
...@@ -20,6 +21,7 @@ import com.baosight.iplat4j.core.ei.EiConstant; ...@@ -20,6 +21,7 @@ import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException; import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase; import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
...@@ -42,6 +44,7 @@ public class ServiceHGCG002A extends ServiceBase { ...@@ -42,6 +44,7 @@ public class ServiceHGCG002A extends ServiceBase {
public EiInfo initLoad(EiInfo inInfo) { public EiInfo initLoad(EiInfo inInfo) {
try { try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.COMPANY_CODE_BLOCK_ID)); CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.COMPANY_CODE_BLOCK_ID));
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.SUP_RECORD_BLOCK_ID));
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCG001().eiMetadata); inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCG001().eiMetadata);
} catch (PlatException e) { } catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败"); LogUtils.setDetailMsg(inInfo, e, "初始化失败");
...@@ -62,7 +65,7 @@ public class ServiceHGCG002A extends ServiceBase { ...@@ -62,7 +65,7 @@ public class ServiceHGCG002A extends ServiceBase {
Map queryRow = EiInfoUtils.getFirstRow(inInfo); Map queryRow = EiInfoUtils.getFirstRow(inInfo);
HgCgUtils.HgCg001.setCondition(queryRow); HgCgUtils.HgCg001.setCondition(queryRow);
// 仅审核通过 // 仅审核通过
queryRow.put(HGCG001.FIELD_STATUS, HGConstant.planStatus.S_1); queryRow.put(HGCG001.FIELD_STATUS, HGConstant.CgPlanStatus.S_1);
inInfo = super.query(inInfo, HGCG001.QUERY, new HGCG001()); inInfo = super.query(inInfo, HGCG001.QUERY, new HGCG001());
} catch (Exception e) { } catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败"); LogUtils.setDetailMsg(inInfo, e, "查询失败");
...@@ -84,7 +87,7 @@ public class ServiceHGCG002A extends ServiceBase { ...@@ -84,7 +87,7 @@ public class ServiceHGCG002A extends ServiceBase {
// db数据 // db数据
Map<String, HGCG001> dbCg001Map = this.lockGetData(fCg001s); Map<String, HGCG001> dbCg001Map = this.lockGetData(fCg001s);
// 数据校验 // 数据校验
this.checkSaveData(fCg001s, dbCg001Map); this.checkConfirmData(fCg001s, dbCg001Map);
// 保存数据 // 保存数据
this.confirmData(resultRows, dbCg001Map); this.confirmData(resultRows, dbCg001Map);
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
...@@ -102,12 +105,12 @@ public class ServiceHGCG002A extends ServiceBase { ...@@ -102,12 +105,12 @@ public class ServiceHGCG002A extends ServiceBase {
* @param fCg001s * @param fCg001s
* @param dbCg001Map * @param dbCg001Map
*/ */
private void checkSaveData(List<HGCG001> fCg001s, Map<String, HGCG001> dbCg001Map) { private void checkConfirmData(List<HGCG001> fCg001s, Map<String, HGCG001> dbCg001Map) {
for (HGCG001 fCg001 : fCg001s) { for (HGCG001 fCg001 : fCg001s) {
String planNo = fCg001.getPlanNo(); String planNo = fCg001.getPlanNo();
HGCG001 dbCg001 = dbCg001Map.get(planNo); HGCG001 dbCg001 = dbCg001Map.get(planNo);
AssertUtils.isNull(dbCg001, String.format("计划[%s]不存在", planNo)); AssertUtils.isNull(dbCg001, String.format("计划[%s]不存在", planNo));
AssertUtils.isNotEquals(HGConstant.planStatus.S_1, dbCg001.getStatus(), AssertUtils.isNotEquals(HGConstant.CgPlanStatus.S_1, dbCg001.getStatus(),
String.format("计划[%s]状态不是\"审核通过\",不允许操作", planNo)); String.format("计划[%s]状态不是\"审核通过\",不允许操作", planNo));
} }
} }
...@@ -121,16 +124,17 @@ public class ServiceHGCG002A extends ServiceBase { ...@@ -121,16 +124,17 @@ public class ServiceHGCG002A extends ServiceBase {
private void confirmData(List<Map> resultRows, Map<String, HGCG001> dbCg001Map) { private void confirmData(List<Map> resultRows, Map<String, HGCG001> dbCg001Map) {
for (Map resultRow : resultRows) { for (Map resultRow : resultRows) {
String planNo = MapUtils.getString(resultRow, HGCG001.FIELD_PLAN_NO); String planNo = MapUtils.getString(resultRow, HGCG001.FIELD_PLAN_NO);
String supCode = MapUtils.getString(resultRow, HGCG002.FIELD_SUP_CODE);
String supName = MapUtils.getString(resultRow, HGCG002.FIELD_SUP_NAME);
String purUserName = MapUtils.getString(resultRow, HGCG002.FIELD_PUR_USER_NAME);
HGCG002 newCg002 = BeanUtils.copy(dbCg001Map.get(planNo), HGCG002.class); HGCG002 newCg002 = BeanUtils.copy(dbCg001Map.get(planNo), HGCG002.class);
newCg002.setSupCode(supCode); newCg002.setContractDate(DateUtils.shortDate());
newCg002.setSupName(supName); newCg002.setContractNo(SequenceGenerator.getNextSequence(HGConstant.SequenceId.CG_CONTRACT_NO));
newCg002.setPurUserName(purUserName); newCg002.setSupCode(MapUtils.getString(resultRow, HGCG002.FIELD_SUP_CODE));
newCg002.setStatus(HGConstant.contractStatus.S_0); 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.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
DaoUtils.insert(HGCG002.INSERT, newCg002); DaoUtils.insert(HGCG002.INSERT, newCg002);
// 更新计划状态
HGCGTools.HgCg001.updateStatus(planNo, HGConstant.CgPlanStatus.S_3);
} }
} }
......
package com.baosight.hggp.hg.cg.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.DeleteFlagEnum;
import com.baosight.hggp.hg.cg.domain.HGCG002;
import com.baosight.hggp.hg.cg.domain.HGCG002A;
import com.baosight.hggp.hg.cg.domain.HGCG003;
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.util.AssertUtils;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.ObjectUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @author:songx
* @date:2024/5/9,11:04
*/
public class ServiceHGCG003 extends ServiceBase {
/**
* 画面初始化
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "采购收货", operType = "查询", operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.COMPANY_CODE_BLOCK_ID));
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.SUP_RECORD_BLOCK_ID));
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCG003().eiMetadata);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询操作
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "采购合同", operType = "查询", operDesc = "查询")
public EiInfo query(EiInfo inInfo) {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
HgCgUtils.HgCg003.setCondition(queryRow);
inInfo = super.query(inInfo, HGCG003.QUERY, new HGCG003());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 保存操作.
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "采购收货", operType = "修改", operDesc = "保存")
public EiInfo save(EiInfo inInfo) {
try {
List<HGCG003> fCg003s = MapUtils.toDaoEPBase(inInfo, HGCG003.class);
// 采购收货DB数据
Map<String, HGCG003> dbCg003Map = HgCgUtils.HgCg003.lockGetDataEp(fCg003s);
// 采购合同DB数据
Map<String, HGCG002A> dbCg002AMap = HgCgUtils.HgCg002.lockGetData(
ObjectUtils.listEpKey(fCg003s, HGCG003.FIELD_CONTRACT_NO));
// 数据校验
this.checkSaveData(fCg003s, dbCg003Map);
// 保存数据
this.saveData(fCg003s, dbCg003Map, dbCg002AMap);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fCg003s.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 数据校验
*
* @param fCg003s
* @param dbCg003Map
*/
private void checkSaveData(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);
AssertUtils.isNull(dbCg003, String.format("收货单[%s]不存在", receiveNo));
AssertUtils.isNotEquals(HGConstant.CgReceiveStatus.S_0, dbCg003.getStatus(),
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()));
}
}
}
/**
* 数据保存
*
* @param fCg003s
* @param dbCg003Map
* @param dbCg002AMap
*/
private void saveData(List<HGCG003> fCg003s, Map<String, HGCG003> dbCg003Map, Map<String, HGCG002A> dbCg002AMap) {
for (HGCG003 fCg003 : fCg003s) {
String receiveNo = fCg003.getReceiveNo();
String contractNo = fCg003.getContractNo();
DaoUtils.update(HGSqlConstant.HgCg003.UPDATE_QTY, fCg003);
// 计算差异数量,更新合同状态
HGCG003 dbCg003 = dbCg003Map.get(receiveNo);
BigDecimal diffQty = fCg003.getReceiveQty().subtract(dbCg003.getReceiveQty());
HGCGTools.HgCg002.updateReceive(dbCg002AMap.get(contractNo), diffQty);
}
}
/**
* 删除操作.
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "采购收货", operType = "修改", operDesc = "删除")
public EiInfo remove(EiInfo inInfo) {
try {
List<HGCG003> fCg003s = MapUtils.toDaoEPBase(inInfo, HGCG003.class);
// 采购收货DB数据
Map<String, HGCG003> dbCg003Map = HgCgUtils.HgCg003.lockGetDataEp(fCg003s);
// 采购合同DB数据
Map<String, HGCG002A> dbCg002AMap = HgCgUtils.HgCg002.lockGetData(
ObjectUtils.listEpKey(fCg003s, HGCG003.FIELD_CONTRACT_NO));
// 数据校验
this.checkRemoveData(fCg003s, dbCg003Map);
// 保存数据
this.removeData(fCg003s, dbCg003Map, dbCg002AMap);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fCg003s.size() + "]条数据删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
/**
* 数据校验
*
* @param fCg003s
* @param dbCg003Map
*/
private void checkRemoveData(List<HGCG003> fCg003s, Map<String, HGCG003> dbCg003Map) {
for (HGCG003 fCg003 : fCg003s) {
String receiveNo = fCg003.getReceiveNo();
HGCG003 dbCg003 = dbCg003Map.get(receiveNo);
AssertUtils.isNull(dbCg003, String.format("收货单[%s]不存在", receiveNo));
AssertUtils.isNotEquals(HGConstant.CgReceiveStatus.S_0, dbCg003.getStatus(),
String.format("收货单[%s]状态不是\"待确认\",不允许操作", receiveNo));
}
}
/**
* 数据保存
*
* @param fCg003s
* @param dbCg003Map
* @param dbCg002AMap
*/
private void removeData(List<HGCG003> fCg003s, Map<String, HGCG003> dbCg003Map, Map<String, HGCG002A> dbCg002AMap) {
for (HGCG003 fCg003 : fCg003s) {
String receiveNo = fCg003.getReceiveNo();
String contractNo = fCg003.getContractNo();
HGCG003 dbCg003 = dbCg003Map.get(receiveNo);
dbCg003.setDeleteFlag(DeleteFlagEnum.REMOVE.getCode());
DaoUtils.update(HGCG003.DELETE, dbCg003);
// 更新合同状态
HGCGTools.HgCg002.updateReceive(dbCg002AMap.get(contractNo), dbCg003.getReceiveQty().negate());
}
}
/**
* 确认操作.
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "采购收货", operType = "修改", operDesc = "确认")
public EiInfo confirm(EiInfo inInfo) {
try {
List<HGCG003> fCg003s = MapUtils.toDaoEPBase(inInfo, HGCG003.class);
// db数据
Map<String, HGCG003> dbCg003Map = HgCgUtils.HgCg003.lockGetDataEp(fCg003s);
// 数据校验
this.checkConfirmData(fCg003s, dbCg003Map);
// 提交数据
this.confirmData(fCg003s);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fCg003s.size() + "]条数据审核成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "审核失败");
}
return inInfo;
}
/**
* 数据校验
*
* @param fCg003s
* @param dbCg003Map
*/
private void checkConfirmData(List<HGCG003> fCg003s, Map<String, HGCG003> dbCg003Map) {
for (HGCG003 fCg003 : fCg003s) {
String receiveNo = fCg003.getReceiveNo();
HGCG003 dbCg003 = dbCg003Map.get(receiveNo);
AssertUtils.isNull(dbCg003, String.format("收货单[%s]不存在", receiveNo));
AssertUtils.isNotEquals(HGConstant.CgReceiveStatus.S_0, dbCg003.getStatus(),
String.format("收货单[%s]状态不是\"待确认\",不允许操作", receiveNo));
}
}
/**
* 确认数据
*
* @param fCg003s
*/
private void confirmData(List<HGCG003> fCg003s) {
for (HGCG003 fCg003 : fCg003s) {
fCg003.setStatus(HGConstant.CgReceiveStatus.S_1);
DaoUtils.update(HGSqlConstant.HgCg003.UPDATE_STATUS, fCg003);
}
}
}
package com.baosight.hggp.hg.cg.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.DeleteFlagEnum;
import com.baosight.hggp.hg.cg.domain.HGCG002;
import com.baosight.hggp.hg.cg.domain.HGCG002A;
import com.baosight.hggp.hg.cg.domain.HGCG003;
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.util.AssertUtils;
import com.baosight.hggp.util.BeanUtils;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.ObjectUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
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.List;
import java.util.Map;
/**
* @author:songx
* @date:2024/5/9,11:04
*/
public class ServiceHGCG003A extends ServiceBase {
/**
* 画面初始化
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "采购合同", operType = "查询", operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.COMPANY_CODE_BLOCK_ID));
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.SUP_RECORD_BLOCK_ID));
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCG002A().eiMetadata);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询操作
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "采购合同", operType = "查询", operDesc = "查询")
public EiInfo query(EiInfo inInfo) {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
HgCgUtils.HgCg001.setCondition(queryRow);
// 仅审核通过和收货中
queryRow.put("statuses", new Integer[]{HGConstant.CgContractStatus.S_1, HGConstant.CgContractStatus.S_3});
inInfo = super.query(inInfo, HGCG002.QUERY, new HGCG002A());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 确认操作.
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "采购合同", operType = "修改", operDesc = "确认")
public EiInfo confirm(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<HGCG002A> fCg002As = MapUtils.toDaoEPBase(inInfo, HGCG002A.class);
// db数据
Map<String, HGCG002A> dbCg002AMap = this.lockGetData(fCg002As);
// 数据校验
this.checkConfirmData(fCg002As, dbCg002AMap);
// 保存数据
this.confirmData(fCg002As, dbCg002AMap);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fCg002As.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 数据校验
*
* @param fCg002As
* @param dbCg002AMap
*/
private void checkConfirmData(List<HGCG002A> fCg002As, Map<String, HGCG002A> dbCg002AMap) {
for (HGCG002A fCg002A : fCg002As) {
String contractNo = fCg002A.getContractNo();
HGCG002A dbCg002A = dbCg002AMap.get(contractNo);
AssertUtils.isNull(dbCg002A, String.format("合同[%s]不存在", contractNo));
AssertUtils.isTrue(!(HGConstant.CgContractStatus.S_1.equals(dbCg002A.getStatus())
|| HGConstant.CgContractStatus.S_3.equals(dbCg002A.getStatus())),
String.format("合同[%s]状态不是\"审核通过\"或\"收货中\",不允许操作", contractNo));
AssertUtils.isGt(fCg002A.getBcReceiveQty(), dbCg002A.getBcMaxReceiveQty(),
String.format("合同[%s]本次收货数量(%s)不能大于本次最大收货数量(%s)", contractNo,
fCg002A.getBcReceiveQty(), dbCg002A.getBcMaxReceiveQty()));
}
}
/**
* 数据保存
*
* @param fCg002As
* @param dbCg002AMap
*/
private void confirmData(List<HGCG002A> fCg002As, Map<String, HGCG002A> dbCg002AMap) {
for (HGCG002A fCg002A : fCg002As) {
String contractNo = fCg002A.getContractNo();
HGCG002A dbCg002A = dbCg002AMap.get(contractNo);
HGCG003 newCg003 = BeanUtils.copy(dbCg002AMap.get(contractNo), HGCG003.class);
newCg003.setReceiveDate(DateUtils.shortDate());
newCg003.setReceiveNo(SequenceGenerator.getNextSequence(HGConstant.SequenceId.CG_RECEIVE_NO));
newCg003.setReceiveQty(fCg002A.getBcReceiveQty());
newCg003.setStatus(HGConstant.CgReceiveStatus.S_0);
newCg003.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
DaoUtils.insert(HGCG003.INSERT, newCg003);
// 更新合同状态
HGCGTools.HgCg002.updateReceive(dbCg002A, fCg002A.getBcReceiveQty());
}
}
/**
* 锁并且获取数据
*
* @param fCg002As
* @return
*/
private Map<String, HGCG002A> lockGetData(List<HGCG002A> fCg002As) {
// 合同号
List<String> contractNos = ObjectUtils.listEpKey(fCg002As, HGCG002.FIELD_CONTRACT_NO);
// 锁
HGCGTools.HgCg002.lock(contractNos);
// db数据
return HGCGTools.HgCg002.map(contractNos);
}
}
...@@ -223,4 +223,13 @@ ...@@ -223,4 +223,13 @@
WHERE PLAN_NO = #planNo# WHERE PLAN_NO = #planNo#
</update> </update>
<!-- 修改状态 -->
<update id="updateStatus">
UPDATE ${hggpSchema}.HGCG001
SET
STATUS = #status#, <!-- 状态:0-未审批,1-审核通过,2-审核未通过 -->
<include refid="updateRevise"/>
WHERE PLAN_NO = #planNo#
</update>
</sqlMap> </sqlMap>
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
LENGTH as "length", <!-- 长度 --> LENGTH as "length", <!-- 长度 -->
PUR_QTY as "purQty", <!-- 采购数量 --> PUR_QTY as "purQty", <!-- 采购数量 -->
PUR_WEIGHT as "purWeight", <!-- 采购重量 --> PUR_WEIGHT as "purWeight", <!-- 采购重量 -->
RECEIVE_QTY as "receiveQty", <!-- 收货数量 -->
STATUS as "status", <!-- 状态:0-未审批,1-审核通过,2-审核未通过 --> STATUS as "status", <!-- 状态:0-未审批,1-审核通过,2-审核未通过 -->
AUDIT_TIME as "auditTime", <!-- 审核时间 --> AUDIT_TIME as "auditTime", <!-- 审核时间 -->
AUDIT_USER_ID as "auditUserId", <!-- 审核人ID --> AUDIT_USER_ID as "auditUserId", <!-- 审核人ID -->
...@@ -36,6 +37,10 @@ ...@@ -36,6 +37,10 @@
AUDIT_REASON as "auditReason" <!-- 审核原因 --> AUDIT_REASON as "auditReason" <!-- 审核原因 -->
</sql> </sql>
<sql id="qtyColumn">
(PUR_QTY - RECEIVE_QTY) as "bcMaxReceiveQty"
</sql>
<sql id="condition"> <sql id="condition">
AND DELETE_FLAG = 0 AND DELETE_FLAG = 0
<include refid="idCondition"/> <include refid="idCondition"/>
...@@ -165,9 +170,10 @@ ...@@ -165,9 +170,10 @@
</dynamic> </dynamic>
</sql> </sql>
<select id="query" resultClass="com.baosight.hggp.hg.cg.domain.HGCG002"> <select id="query" resultClass="com.baosight.hggp.hg.cg.domain.HGCG002A">
SELECT SELECT
<include refid="column"/> <include refid="column"/>,
<include refid="qtyColumn"/>
FROM ${hggpSchema}.HGCG002 WHERE 1=1 FROM ${hggpSchema}.HGCG002 WHERE 1=1
<include refid="condition"/> <include refid="condition"/>
<include refid="orderBy"/> <include refid="orderBy"/>
...@@ -223,6 +229,18 @@ ...@@ -223,6 +229,18 @@
<include refid="idCondition"/> <include refid="idCondition"/>
</update> </update>
<!-- 修改采购信息 -->
<update id="updatePur">
UPDATE ${hggpSchema}.HGCG002
SET
SUP_CODE = #supCode#, <!-- 供应商编码 -->
SUP_NAME = #supName#, <!-- 供应商名称 -->
PUR_USER_ID = #purUserId#, <!-- 采购员 -->
PUR_USER_NAME = #purUserName#, <!-- 采购员名称 -->
<include refid="updateRevise"/>
WHERE CONTRACT_NO = #contractNo#
</update>
<!-- 修改审核信息 --> <!-- 修改审核信息 -->
<update id="updateAudit"> <update id="updateAudit">
UPDATE ${hggpSchema}.HGCG002 UPDATE ${hggpSchema}.HGCG002
...@@ -236,4 +254,23 @@ ...@@ -236,4 +254,23 @@
WHERE CONTRACT_NO = #contractNo# WHERE CONTRACT_NO = #contractNo#
</update> </update>
<!-- 修改状态 -->
<update id="updateStatus">
UPDATE ${hggpSchema}.HGCG002
SET
STATUS = #status#,
<include refid="updateRevise"/>
WHERE CONTRACT_NO = #contractNo#
</update>
<!-- 修改收货 -->
<update id="updateReceive">
UPDATE ${hggpSchema}.HGCG002
SET
STATUS = #status#,
RECEIVE_QTY = #receiveQty#,
<include refid="updateRevise"/>
WHERE CONTRACT_NO = #contractNo#
</update>
</sqlMap> </sqlMap>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="HGCG003">
<sql id="column">
ID as "id",
ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
DEP_CODE as "depCode", <!-- 部门编码 -->
CREATED_BY as "createdBy", <!-- 记录创建者 -->
CREATED_NAME as "createdName", <!-- 记录创建名称 -->
CREATED_TIME as "createdTime", <!-- 记录创建时间 -->
UPDATED_BY as "updatedBy", <!-- 记录修改者 -->
UPDATED_NAME as "updatedName", <!-- 记录修改名称 -->
UPDATED_TIME as "updatedTime", <!-- 记录修改时间 -->
DELETE_FLAG as "deleteFlag", <!-- 0-未删除,1-已删除 -->
COMPANY_CODE as "companyCode", <!-- 公司编码 -->
COMPANY_NAME as "companyName", <!-- 公司名称 -->
RECEIVE_DATE as "receiveDate", <!-- 收货日期 -->
RECEIVE_NO as "receiveNo", <!-- 收货单号 -->
PLAN_NO as "planNo", <!-- 计划单号 -->
CONTRACT_NO as "contractNo", <!-- 合同号 -->
SUP_CODE as "supCode", <!-- 供应商编码 -->
SUP_NAME as "supName", <!-- 供应商名称 -->
PUR_USER_ID as "purUserId", <!-- 采购员 -->
PUR_USER_NAME as "purUserName", <!-- 采购员名称 -->
INVENT_CODE as "inventCode", <!-- 存货编码 -->
INVENT_NAME as "inventName", <!-- 存货名称 -->
SPEC as "spec", <!-- 规格 -->
MATERIAL as "material", <!-- 材质 -->
LENGTH as "length", <!-- 长度 -->
RECEIVE_QTY as "receiveQty", <!-- 收货数量 -->
DELIVER_QTY as "deliverQty", <!-- 退货数量 -->
DEPOSIT_QTY as "depositQty", <!-- 入库数量 -->
RECEIVE_WEIGHT as "receiveWeight", <!-- 收货重量 -->
STATUS as "status" <!-- 状态:0-已收货,1-已入库,2-部分入库,3-退货 -->
</sql>
<sql id="condition">
AND DELETE_FLAG = 0
<include refid="idCondition"/>
<include refid="customCondition"/>
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depCode">
DEP_CODE = #depCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdBy">
CREATED_BY = #createdBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdName">
CREATED_NAME = #createdName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTime">
CREATED_TIME = #createdTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedBy">
UPDATED_BY = #updatedBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedName">
UPDATED_NAME = #updatedName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedTime">
UPDATED_TIME = #updatedTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="deleteFlag">
DELETE_FLAG = #deleteFlag#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyName">
COMPANY_NAME = #companyName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="receiveDate">
RECEIVE_DATE = #receiveDate#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="planNo">
PLAN_NO = #planNo#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="contractNo">
CONTRACT_NO = #contractNo#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="supCode">
SUP_CODE = #supCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="supName">
SUP_NAME = #supName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="purUserId">
PUR_USER_ID = #purUserId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="purUserName">
PUR_USER_NAME = #purUserName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventCode">
INVENT_CODE = #inventCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME = #inventName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="spec">
SPEC = #spec#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="material">
MATERIAL = #material#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="length">
LENGTH = #length#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="receiveQty">
RECEIVE_QTY = #receiveQty#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="deliverQty">
DELIVER_QTY = #deliverQty#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depositQty">
DEPOSIT_QTY = #depositQty#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="receiveWeight">
RECEIVE_WEIGHT = #receiveWeight#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="status">
STATUS = #status#
</isNotEmpty>
</sql>
<sql id="idCondition">
<isNotEmpty prepend=" AND " property="receiveNo">
RECEIVE_NO = #receiveNo#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="receiveNos">
RECEIVE_NO IN <iterate open="(" close=")" conjunction="," property="receiveNos">#receiveNos[]#</iterate>
</isNotEmpty>
</sql>
<sql id="customCondition">
<isNotEmpty prepend=" AND " property="createdTimeFrom">
CREATED_TIME &gt;= #createdTimeFrom#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTimeTo">
CREATED_TIME &lt;= #createdTimeTo#
</isNotEmpty>
</sql>
<!-- 公共修改字段 -->
<sql id="updateRevise">
UPDATED_BY = #updatedBy#,
UPDATED_NAME = #updatedName#,
UPDATED_TIME = #updatedTime#
</sql>
<sql id="orderBy">
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
ID DESC
</isEmpty>
</dynamic>
</sql>
<select id="query" resultClass="com.baosight.hggp.hg.cg.domain.HGCG003">
SELECT
<include refid="column"/>
FROM ${hggpSchema}.HGCG003 WHERE 1=1
<include refid="condition"/>
<include refid="orderBy"/>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*) FROM ${hggpSchema}.HGCG003 WHERE 1=1
<include refid="condition"/>
</select>
<insert id="insert">
INSERT INTO ${hggpSchema}.HGCG003 (
ACCOUNT_CODE, <!-- 企业编码 -->
DEP_CODE, <!-- 部门编码 -->
CREATED_BY, <!-- 记录创建者 -->
CREATED_NAME, <!-- 记录创建名称 -->
CREATED_TIME, <!-- 记录创建时间 -->
DELETE_FLAG, <!-- 0-未删除,1-已删除 -->
COMPANY_CODE, <!-- 公司编码 -->
COMPANY_NAME, <!-- 公司名称 -->
RECEIVE_DATE, <!-- 收货日期 -->
RECEIVE_NO, <!-- 收货单号 -->
PLAN_NO, <!-- 计划单号 -->
CONTRACT_NO, <!-- 合同号 -->
SUP_CODE, <!-- 供应商编码 -->
SUP_NAME, <!-- 供应商名称 -->
PUR_USER_ID, <!-- 采购员 -->
PUR_USER_NAME, <!-- 采购员名称 -->
INVENT_CODE, <!-- 存货编码 -->
INVENT_NAME, <!-- 存货名称 -->
SPEC, <!-- 规格 -->
MATERIAL, <!-- 材质 -->
LENGTH, <!-- 长度 -->
RECEIVE_QTY, <!-- 收货数量 -->
RECEIVE_WEIGHT, <!-- 收货重量 -->
STATUS <!-- 状态:0-已收货,1-已入库,2-部分入库,3-退货 -->
) VALUES (
#accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#,
#deleteFlag#, #companyCode#, #companyName#, #receiveDate#, #receiveNo#,
#planNo#, #contractNo#, #supCode#, #supName#, #purUserId#, #purUserName#,
#inventCode#, #inventName#, #spec#, #material#, #length#,
#receiveQty#, #receiveWeight#, #status#
)
</insert>
<delete id="delete">
UPDATE ${hggpSchema}.HGCG003
SET
DELETE_FLAG = #deleteFlag#,
<include refid="updateRevise"/>
WHERE RECEIVE_NO = #receiveNo#
</delete>
<!-- 行锁 -->
<update id="lock">
UPDATE ${hggpSchema}.HGCG003
SET CREATED_TIME = CREATED_TIME
WHERE 1=1
<include refid="idCondition"/>
</update>
<!-- 修改状态 -->
<update id="updateStatus">
UPDATE ${hggpSchema}.HGCG003
SET
STATUS = #status#,
<include refid="updateRevise"/>
WHERE RECEIVE_NO = #receiveNo#
</update>
<!-- 修改数量 -->
<update id="updateQty">
UPDATE ${hggpSchema}.HGCG003
SET
RECEIVE_QTY = #receiveQty#, <!-- 收货数量 -->
<include refid="updateRevise"/>
WHERE RECEIVE_NO = #receiveNo#
</update>
</sqlMap>
package com.baosight.hggp.hg.cg.tools; package com.baosight.hggp.hg.cg.tools;
import com.baosight.hggp.core.dao.DaoBase; import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.cg.domain.HGCG001; import com.baosight.hggp.hg.cg.domain.HGCG001;
import com.baosight.hggp.hg.cg.domain.HGCG002; import com.baosight.hggp.hg.cg.domain.HGCG002;
import com.baosight.hggp.hg.cg.domain.HGCG002A;
import com.baosight.hggp.hg.cg.domain.HGCG003;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.constant.HGSqlConstant; import com.baosight.hggp.hg.constant.HGSqlConstant;
import com.baosight.hggp.util.AssertUtils; import com.baosight.hggp.util.AssertUtils;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import java.math.BigDecimal;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -65,6 +70,21 @@ public class HGCGTools { ...@@ -65,6 +70,21 @@ public class HGCGTools {
return results.stream().collect(Collectors.toMap(HGCG001::getPlanNo, item -> item)); return results.stream().collect(Collectors.toMap(HGCG001::getPlanNo, item -> item));
} }
/**
* 修改状态
*
* @param planNo
* @param status
*/
public static void updateStatus(String planNo, Integer status) {
AssertUtils.isEmpty(planNo, "计划号不能为空!");
AssertUtils.isNull(status, "状态不能为空!");
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("planNo", planNo);
paramMap.put("status", status);
DaoUtils.update(HGSqlConstant.HgCg001.UPDATE_STATUS, paramMap);
}
} }
/** /**
...@@ -91,13 +111,47 @@ public class HGCGTools { ...@@ -91,13 +111,47 @@ public class HGCGTools {
} }
/** /**
* 修改状态
*
* @param contractNo
* @param status
*/
public static void updateStatus(String contractNo, Integer status) {
AssertUtils.isEmpty(contractNo, "合同号不能为空!");
AssertUtils.isNull(status, "状态不能为空!");
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("contractNo", contractNo);
paramMap.put("status", status);
DaoUtils.update(HGSqlConstant.HgCg002.UPDATE_STATUS, paramMap);
}
/**
* 修改状态
*
* @param dbCg002
* @param receiveQty
*/
public static void updateReceive(HGCG002 dbCg002, BigDecimal receiveQty) {
AssertUtils.isNull(dbCg002, "合同号不能为空!");
AssertUtils.isNull(receiveQty, "收货数量不能为空!");
BigDecimal diffQty = dbCg002.getPurQty().subtract(receiveQty.add(dbCg002.getReceiveQty()));
Integer status = diffQty.compareTo(BigDecimal.ZERO) == 0 ? HGConstant.CgContractStatus.S_4
: HGConstant.CgContractStatus.S_3;
Map<String, Object> paramMap = new HashMap<>();
paramMap.put(HGCG002.FIELD_CONTRACT_NO, dbCg002.getContractNo());
paramMap.put(HGCG002.FIELD_STATUS, status);
paramMap.put(HGCG002.FIELD_RECEIVE_QTY, receiveQty.add(dbCg002.getReceiveQty()));
DaoUtils.update(HGSqlConstant.HgCg002.UPDATE_RECEIVE, paramMap);
}
/**
* 查询 * 查询
* *
* @param contractNos * @param contractNos
* @return * @return
*/ */
public static List<HGCG002> list(List<String> contractNos) { public static List<HGCG002A> list(List<String> contractNos) {
AssertUtils.isEmpty(contractNos, "计划号不能为空"); AssertUtils.isEmpty(contractNos, "合同号不能为空");
Map<String, Object> paramMap = new HashMap(); Map<String, Object> paramMap = new HashMap();
paramMap.put("contractNos", contractNos); paramMap.put("contractNos", contractNos);
return DaoBase.getInstance().query(HGCG002.QUERY, paramMap); return DaoBase.getInstance().query(HGCG002.QUERY, paramMap);
...@@ -109,9 +163,58 @@ public class HGCGTools { ...@@ -109,9 +163,58 @@ public class HGCGTools {
* @param contractNos * @param contractNos
* @return * @return
*/ */
public static Map<String, HGCG002> map(List<String> contractNos) { public static Map<String, HGCG002A> map(List<String> contractNos) {
List<HGCG002> results = list(contractNos); List<HGCG002A> results = list(contractNos);
return results.stream().collect(Collectors.toMap(HGCG002::getContractNo, item -> item)); return results.stream().collect(Collectors.toMap(HGCG002A::getContractNo, item -> item));
}
}
/**
* HGCG003 工具类
*
* @author:songx
* @date:2024/5/9,14:33
*/
public static class HgCg003 {
/**
* 锁
*
* @param receiveNos
* @return
*/
public static void lock(List<String> receiveNos) {
if (CollectionUtils.isEmpty(receiveNos)) {
return;
}
Map paramMap = new HashMap();
paramMap.put("receiveNos", receiveNos);
DaoBase.getInstance().update(HGSqlConstant.HgCg003.LOCK, paramMap);
}
/**
* 查询
*
* @param receiveNos
* @return
*/
public static List<HGCG003> list(List<String> receiveNos) {
AssertUtils.isEmpty(receiveNos, "合同号不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put("receiveNos", receiveNos);
return DaoBase.getInstance().query(HGCG003.QUERY, paramMap);
}
/**
* 查询
*
* @param receiveNos
* @return
*/
public static Map<String, HGCG003> map(List<String> receiveNos) {
List<HGCG003> results = list(receiveNos);
return results.stream().collect(Collectors.toMap(HGCG003::getReceiveNo, item -> item));
} }
} }
......
...@@ -2,10 +2,15 @@ package com.baosight.hggp.hg.cg.utils; ...@@ -2,10 +2,15 @@ package com.baosight.hggp.hg.cg.utils;
import com.baosight.hggp.hg.cg.domain.HGCG001; import com.baosight.hggp.hg.cg.domain.HGCG001;
import com.baosight.hggp.hg.cg.domain.HGCG002; import com.baosight.hggp.hg.cg.domain.HGCG002;
import com.baosight.hggp.hg.cg.domain.HGCG002A;
import com.baosight.hggp.hg.cg.domain.HGCG003;
import com.baosight.hggp.hg.cg.tools.HGCGTools;
import com.baosight.hggp.util.DateUtils; import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.MapUtils; import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.ObjectUtils;
import com.baosight.hggp.util.StringUtils; import com.baosight.hggp.util.StringUtils;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -79,6 +84,77 @@ public class HgCgUtils { ...@@ -79,6 +84,77 @@ public class HgCgUtils {
} }
} }
/**
* 锁并且获取数据
*
* @param fCg002s
* @return
*/
public static Map<String, HGCG002A> lockGetDataEp(List<HGCG002> fCg002s) {
return lockGetData(ObjectUtils.listEpKey(fCg002s, HGCG002.FIELD_CONTRACT_NO));
}
/**
* 锁并且获取数据
*
* @param contractNos
* @return
*/
public static Map<String, HGCG002A> lockGetData(List<String> contractNos) {
// 锁
HGCGTools.HgCg002.lock(contractNos);
// db数据
return HGCGTools.HgCg002.map(contractNos);
}
}
/**
* HGCG003 工具类
*
* @author:songx
* @date:2024/5/9,16:58
*/
public static class HgCg003 {
/**
* 设置查询条件
*
* @param queryRow 集合
* @return
*/
public static void setCondition(Map queryRow) {
HgCgUtils.setCondition(queryRow);
// 收货日期
String receiveDate = MapUtils.getString(queryRow, HGCG003.FIELD_RECEIVE_DATE);
if (StringUtils.isNotBlank(receiveDate)) {
queryRow.put(HGCG003.FIELD_RECEIVE_DATE, DateUtils.formatShort(receiveDate));
}
}
/**
* 锁并且获取数据
*
* @param fCg003s
* @return
*/
public static Map<String, HGCG003> lockGetDataEp(List<HGCG003> fCg003s) {
return lockGetData(ObjectUtils.listEpKey(fCg003s, HGCG003.FIELD_RECEIVE_NO));
}
/**
* 锁并且获取数据
*
* @param receiveNos
* @return
*/
public static Map<String, HGCG003> lockGetData(List<String> receiveNos) {
// 锁
HGCGTools.HgCg003.lock(receiveNos);
// db数据
return HGCGTools.HgCg003.map(receiveNos);
}
} }
} }
...@@ -85,17 +85,21 @@ public class HGConstant { ...@@ -85,17 +85,21 @@ public class HGConstant {
public static final String DEVICE_CODE = "DEVICE_CODE"; public static final String DEVICE_CODE = "DEVICE_CODE";
//计划单号 //计划单号
public static final String PLAN_CODE = "PLAN_CODE"; public static final String PLAN_CODE = "PLAN_CODE";
// 计划号 // 采购计划号
public static final String PLAN_NO = "PLAN_NO"; 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_RECEIVE_NO = "CG_RECEIVE_NO";
} }
/** /**
* 计划状态 * 采购计划状态
* *
* @author:songx * @author:songx
* @date:2024/2/22,13:57 * @date:2024/2/22,13:57
*/ */
public static class planStatus { public static class CgPlanStatus {
// 待审核 // 待审核
public static final Integer S_0 = 0; public static final Integer S_0 = 0;
...@@ -103,15 +107,17 @@ public class HGConstant { ...@@ -103,15 +107,17 @@ public class HGConstant {
public static final Integer S_1 = 1; public static final Integer S_1 = 1;
// 审核拒绝 // 审核拒绝
public static final Integer S_2 = 2; public static final Integer S_2 = 2;
// 生成合同
public static final Integer S_3 = 3;
} }
/** /**
* 合同状态 * 采购合同状态
* *
* @author:songx * @author:songx
* @date:2024/2/22,13:57 * @date:2024/2/22,13:57
*/ */
public static class contractStatus { public static class CgContractStatus {
// 待审核 // 待审核
public static final Integer S_0 = 0; public static final Integer S_0 = 0;
...@@ -119,6 +125,30 @@ public class HGConstant { ...@@ -119,6 +125,30 @@ public class HGConstant {
public static final Integer S_1 = 1; public static final Integer S_1 = 1;
// 审核拒绝 // 审核拒绝
public static final Integer S_2 = 2; public static final Integer S_2 = 2;
// 收货中
public static final Integer S_3 = 3;
// 收货完成
public static final Integer S_4 = 4;
}
/**
* 收货状态
*
* @author:songx
* @date:2024/2/22,13:57
*/
public static class CgReceiveStatus {
// 待确认
public static final Integer S_0 = 0;
// 已收货
public static final Integer S_1 = 1;
// 质检中
public static final Integer S_2 = 2;
// 质检完成
public static final Integer S_3 = 3;
// 已入库
public static final Integer S_4 = 4;
} }
/** /**
......
...@@ -22,6 +22,8 @@ public class HGSqlConstant { ...@@ -22,6 +22,8 @@ public class HGSqlConstant {
public static final String UPDATE_PUR = MODULE_NAME + "updatePur"; public static final String UPDATE_PUR = MODULE_NAME + "updatePur";
// 修改审核信息 // 修改审核信息
public static final String UPDATE_AUDIT = MODULE_NAME + "updateAudit"; public static final String UPDATE_AUDIT = MODULE_NAME + "updateAudit";
// 修改状态
public static final String UPDATE_STATUS = MODULE_NAME + "updateStatus";
} }
/** /**
...@@ -40,6 +42,28 @@ public class HGSqlConstant { ...@@ -40,6 +42,28 @@ public class HGSqlConstant {
public static final String UPDATE_PUR = MODULE_NAME + "updatePur"; public static final String UPDATE_PUR = MODULE_NAME + "updatePur";
// 修改审核信息 // 修改审核信息
public static final String UPDATE_AUDIT = MODULE_NAME + "updateAudit"; public static final String UPDATE_AUDIT = MODULE_NAME + "updateAudit";
// 修改状态
public static final String UPDATE_STATUS = MODULE_NAME + "updateStatus";
// 修改收货数量
public static final String UPDATE_RECEIVE = MODULE_NAME + "updateReceive";
}
/**
* HGCG003 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HgCg003 {
// 模块名称
private static final String MODULE_NAME = "HGCG003.";
// 锁
public static final String LOCK = MODULE_NAME + "lock";
// 修改状态
public static final String UPDATE_STATUS = MODULE_NAME + "updateStatus";
// 修改数量
public static final String UPDATE_QTY = MODULE_NAME + "updateQty";
} }
/** /**
......
...@@ -150,6 +150,32 @@ public class AssertUtils { ...@@ -150,6 +150,32 @@ public class AssertUtils {
} }
/** /**
* A等于B
*
* @param a
* @param b
* @param message
*/
public static void isEqual(BigDecimal a, BigDecimal b, String message) {
if (a.compareTo(b) == 0) {
throw new PlatException(message);
}
}
/**
* A不等于B
*
* @param a
* @param b
* @param message
*/
public static void isNotEqual(BigDecimal a, BigDecimal b, String message) {
if (a.compareTo(b) != 0) {
throw new PlatException(message);
}
}
/**
* A大于B * A大于B
* *
* @param a * @param a
......
...@@ -7,12 +7,7 @@ $(function () { ...@@ -7,12 +7,7 @@ $(function () {
pageSize: 20, pageSize: 20,
pageSizes: [20, 50, 70, 100], pageSizes: [20, 50, 70, 100],
}, },
columns: [{ columns: [],
field: "length",
template: function (options) {
return options.length == 0 ? "-" : options.length;
}
}],
loadComplete: function (grid) { loadComplete: function (grid) {
// 提交 // 提交
$(document.body).on("click", "#SUBMIT", submit); $(document.body).on("click", "#SUBMIT", submit);
...@@ -64,18 +59,18 @@ let save = function () { ...@@ -64,18 +59,18 @@ let save = function () {
return; return;
} }
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
if (!isPositiveNumber(rows[i]['purQty'])) { if (isBlank(rows[i]['supCode'])) {
message("勾选的第" + (i + 1) + "行采购数量必须是大于0的数字"); message("勾选的第" + (i + 1) + "行供应商名称不能为空");
return; return;
} }
if (!isPositiveNumber(rows[i]['purWeight'])) { if (isBlank(rows[i]['purUserName'])) {
message("勾选的第" + (i + 1) + "行采购重量必须是大于0的数字"); message("勾选的第" + (i + 1) + "行采购员不能为空");
return; return;
} }
} }
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", { JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () { ok: function () {
JSUtils.submitGridsData("result", "HGCG001", "save", true); JSUtils.submitGridsData("result", "HGCG002", "save", true);
} }
}); });
} }
...@@ -91,7 +86,7 @@ let remove = function () { ...@@ -91,7 +86,7 @@ let remove = function () {
} }
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"删除\"操作? ", { JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"删除\"操作? ", {
ok: function () { ok: function () {
JSUtils.submitGridsData("result", "HGCG001", "remove", true); JSUtils.submitGridsData("result", "HGCG002", "remove", true);
} }
}); });
} }
...@@ -107,7 +102,7 @@ let submit = function () { ...@@ -107,7 +102,7 @@ let submit = function () {
} }
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"提交\"操作? ", { JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"提交\"操作? ", {
ok: function () { ok: function () {
JSUtils.submitGridsData("result", "HGCG001", "submit", true); JSUtils.submitGridsData("result", "HGCG002", "submit", true);
} }
}); });
} }
...@@ -120,7 +115,7 @@ let selectPlan = function () { ...@@ -120,7 +115,7 @@ let selectPlan = function () {
href: "HGCG002A?methodName=initLoad", href: "HGCG002A?methodName=initLoad",
title: "<div style='text-align: center;'>计划查询</div>", title: "<div style='text-align: center;'>计划查询</div>",
width: "80%", width: "80%",
height: "70%", height: "80%",
callbackName: selectPlanCallback callbackName: selectPlanCallback
}); });
} }
......
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
<EF:EFPage title="采购合同"> <EF:EFPage title="采购合同">
<EF:EFRegion id="inqu" title="查询条件"> <EF:EFRegion id="inqu" title="查询条件">
<div class="row"> <div class="row">
<EF:EFDatePicker cname="计划日期" blockId="inqu_status" ename="contractDate" row="0" colWidth="3" <EF:EFDatePicker cname="合同日期" blockId="inqu_status" ename="contractDate" row="0" colWidth="3"
role="date" format="yyyy-MM-dd" readonly="true"/> role="date" format="yyyy-MM-dd" readonly="true"/>
<EF:EFInput cname="合同号" blockId="inqu_status" ename="contractNo" row="0" colWidth="3"/> <EF:EFInput cname="合同号" blockId="inqu_status" ename="contractNo" row="0" colWidth="3"/>
<EF:EFInput cname="计划单号" blockId="inqu_status" ename="planNo" row="0" colWidth="3"/> <EF:EFInput cname="计划单号" blockId="inqu_status" ename="planNo" row="0" colWidth="3"/>
<EF:EFSelect cname="状态" blockId="inqu_status" ename="status" row="0" colWidth="3" optionLabel="全部" <EF:EFSelect cname="状态" blockId="inqu_status" ename="status" row="0" colWidth="3" optionLabel="全部"
defultValue=""> defultValue="">
<EF:EFCodeOption codeName="hggp.hgcg.planStatus"/> <EF:EFCodeOption codeName="hggp.hgcg.contractStatus"/>
</EF:EFSelect> </EF:EFSelect>
</div> </div>
<div class="row"> <div class="row">
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</EF:EFSelect> </EF:EFSelect>
<EF:EFSelect cname="供应商名称" blockId="inqu_status" ename="supCode" row="0" colWidth="3" <EF:EFSelect cname="供应商名称" blockId="inqu_status" ename="supCode" row="0" colWidth="3"
filter="contains" optionLabel="全部" defultValue=""> filter="contains" optionLabel="全部" defultValue="">
<EF:EFOptions blockId="company_code_block_id" textField="textField" valueField="valueField"/> <EF:EFOptions blockId="sup_record_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect> </EF:EFSelect>
<EF:EFSelect cname="存货名称" blockId="inqu_status" ename="inventCode" row="0" colWidth="3" <EF:EFSelect cname="存货名称" blockId="inqu_status" ename="inventCode" row="0" colWidth="3"
filter="contains" optionLabel="全部" defultValue=""> filter="contains" optionLabel="全部" defultValue="">
...@@ -53,11 +53,11 @@ ...@@ -53,11 +53,11 @@
<EF:EFColumn ename="contractNo" cname="合同号" enable="false" width="120" align="center"/> <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:EFComboColumn ename="status" cname="状态" enable="false" width="80" align="center">
<EF:EFCodeOption codeName="hggp.hgcg.planStatus"/> <EF:EFCodeOption codeName="hggp.hgcg.contractStatus"/>
</EF:EFComboColumn> </EF:EFComboColumn>
<EF:EFComboColumn ename="supCode" cname="供应商名称" width="120" align="left" defaultValue="" <EF:EFComboColumn ename="supCode" cname="供应商名称" width="120" align="left" defaultValue=""
filter="contains" required="true"> filter="contains" required="true">
<EF:EFOptions blockId="factory_record_block_id" valueField="valueField" textField="textField"/> <EF:EFOptions blockId="sup_record_block_id" valueField="valueField" textField="textField"/>
</EF:EFComboColumn> </EF:EFComboColumn>
<EF:EFColumn ename="purUserName" cname="采购员" width="100" align="center" required="true"/> <EF:EFColumn ename="purUserName" cname="采购员" width="100" align="center" required="true"/>
<EF:EFColumn ename="inventCode" cname="存货编码" enable="false" width="100" align="center"/> <EF:EFColumn ename="inventCode" cname="存货编码" enable="false" width="100" align="center"/>
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
<EF:EFColumn ename="material" cname="材质" enable="false" width="80" align="center"/> <EF:EFColumn ename="material" cname="材质" enable="false" width="80" align="center"/>
<EF:EFColumn ename="purQty" cname="采购数量" width="120" align="right" format="{0:N3}"/> <EF:EFColumn ename="purQty" cname="采购数量" width="120" align="right" format="{0:N3}"/>
<EF:EFColumn ename="purWeight" cname="采购重量" width="120" align="right" format="{0:N3}"/> <EF:EFColumn ename="purWeight" cname="采购重量" width="120" align="right" format="{0:N3}"/>
<EF:EFColumn ename="receiveQty" cname="已收货数量" width="120" align="right" format="{0:N3}"/>
<EF:EFColumn ename="createdName" cname="创建人" enable="false" width="100" align="center"/> <EF:EFColumn ename="createdName" cname="创建人" enable="false" width="100" align="center"/>
<EF:EFColumn ename="createdTime" cname="创建时间" enable="false" width="140" align="center" <EF:EFColumn ename="createdTime" cname="创建时间" enable="false" width="140" align="center"
editType="datetime" parseFormats="['yyyyMMddHHmmss']"/> editType="datetime" parseFormats="['yyyyMMddHHmmss']"/>
......
$(function () { $(function () {
IPLATUI.EFGrid = { IPLATUI.EFGrid = {
"result": { "result": {
columns: [] columns: [],
loadComplete: function (grid) {
grid.dataSource.bind("change", function (e) {
supCodeChange(e);
});
}
} }
} }
...@@ -41,6 +46,14 @@ let confirm = function () { ...@@ -41,6 +46,14 @@ let confirm = function () {
return; return;
} }
for (let i = 0; i < rows.length; i++) { 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;
}
} }
JSUtils.confirm("确定对勾选的[" + rows.length + "]条数据生成\"采购合同\"吗? ", { JSUtils.confirm("确定对勾选的[" + rows.length + "]条数据生成\"采购合同\"吗? ", {
ok: function () { ok: function () {
...@@ -56,3 +69,22 @@ let confirm = function () { ...@@ -56,3 +69,22 @@ let confirm = function () {
}); });
} }
/**
* 供应商变更
*/
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;
}
}
}
}
...@@ -40,6 +40,12 @@ ...@@ -40,6 +40,12 @@
<EF:EFColumn ename="planDate" cname="计划日期" enable="false" width="100" align="center" editType="date" <EF:EFColumn ename="planDate" cname="计划日期" enable="false" width="100" align="center" editType="date"
dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']"/> dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']"/>
<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="supCode" cname="供应商名称" width="120" align="left" defaultValue=""
filter="contains" required="true">
<EF:EFOptions blockId="sup_record_block_id" valueField="valueField" textField="textField"/>
</EF:EFComboColumn>
<EF:EFColumn ename="supName" cname="供应商名称" enable="false" width="100" align="center" hidden="true"/>
<EF:EFColumn ename="purUserName" cname="采购员" width="100" align="center" maxLength="100" required="true"/>
<EF:EFColumn ename="inventCode" cname="存货编码" enable="false" width="100" align="center"/> <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="inventName" cname="存货名称" enable="false" width="100" align="center"/>
<EF:EFColumn ename="inventRecordId" cname="规格ID" enable="false" width="120" align="center" <EF:EFColumn ename="inventRecordId" cname="规格ID" enable="false" width="120" align="center"
......
$(function () {
IPLATUI.EFGrid = {
"result": {
exportGrid: false, // 隐藏右侧自定义导出按钮
pageable: {
pageSize: 20,
pageSizes: [20, 50, 70, 100],
},
columns: [],
loadComplete: function (grid) {
// 确认
$("#CONFIRM").on("click", confirm);
},
onSave: function (e) {
// 阻止后台请求,使用自定义
e.preventDefault();
save();
},
onDelete: function (e) {
// 阻止后台请求,使用自定义
e.preventDefault();
remove();
}
}
}
// 查询
$("#QUERY").on("click", query);
// 选择合同
$("#SELECT_CONTRACT").on("click", selectContract);
downKeyUp();
});
/**
* 页面加载时执行
*/
$(window).load(function () {
// 查询
query();
});
/**
* 查询
*/
let query = function () {
resultGrid.dataSource.page(1);
}
/**
* 保存
*/
let save = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
for (let i = 0; i < rows.length; i++) {
if (!isPositiveNumber(rows[i]['receiveQty'])) {
message("勾选的第" + (i + 1) + "行收货数量必须大于0");
return;
}
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGCG003", "save", true);
}
});
}
/**
* 删除
*/
let remove = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"删除\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGCG003", "remove", true);
}
});
}
/**
* 确认
*/
let confirm = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"确认\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGCG003", "confirm", true);
}
});
}
/**
* 选择
*/
let selectContract = function () {
JSColorbox.open({
href: "HGCG003A?methodName=initLoad",
title: "<div style='text-align: center;'>合同查询</div>",
width: "80%",
height: "80%",
callbackName: selectContractCallback
});
}
/**
* 选择回调
*/
let selectContractCallback = function () {
// 刷新页面
query();
// 关闭弹窗
JSColorbox.close();
}
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<EF:EFPage title="采购收货">
<EF:EFRegion id="inqu" title="查询条件">
<div class="row">
<EF:EFDatePicker cname="收货日期" blockId="inqu_status" ename="receiveDate" row="0" colWidth="3"
role="date" format="yyyy-MM-dd" readonly="true"/>
<EF:EFInput cname="收货单号" blockId="inqu_status" ename="receiveNo" row="0" colWidth="3"/>
<EF:EFInput cname="合同号" blockId="inqu_status" ename="contractNo" row="0" colWidth="3"/>
<EF:EFSelect cname="状态" blockId="inqu_status" ename="status" row="0" colWidth="3" optionLabel="全部"
defultValue="">
<EF:EFCodeOption codeName="hggp.hgcg.receiveStatus"/>
</EF:EFSelect>
</div>
<div class="row">
<EF:EFSelect cname="公司名称" blockId="inqu_status" ename="companyCode" row="0" colWidth="3"
filter="contains" optionLabel="全部" defultValue="">
<EF:EFOptions blockId="company_code_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
<EF:EFSelect cname="供应商名称" blockId="inqu_status" ename="supCode" row="0" colWidth="3"
filter="contains" optionLabel="全部" defultValue="">
<EF:EFOptions blockId="sup_record_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
<EF:EFSelect cname="存货名称" blockId="inqu_status" ename="inventCode" row="0" colWidth="3"
filter="contains" optionLabel="全部" defultValue="">
<EF:EFOptions blockId="invent_name_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
<EF:EFSelect cname="规格" ename="inqu_status-0-spec" colWidth="3" filter="contains" optionLabel="全部"
defultValue="">
<EF:EFOptions blockId="spec_name_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
</div>
<div class="row">
<EF:EFDateSpan startCname="创建时间(从)" endCname="至" blockId="inqu_status"
startName="createdTimeFrom" endName="createdTimeTo" row="0" role="datetime"
format="yyyy-MM-dd HH:mm:ss" ratio="3:3" satrtRatio="4:8" endRatio="4:8" readonly="true">
</EF:EFDateSpan>
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="明细信息">
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true" checkMode="row">
<EF:EFColumn ename="id" cname="内码" hidden="true"/>
<EF:EFColumn ename="companyCode" cname="公司编码" enable="false" width="100" align="center" hidden="true"/>
<EF:EFColumn ename="companyName" cname="公司名称" enable="false" width="130" align="center"/>
<EF:EFColumn ename="receiveDate" cname="收货日期" enable="false" width="100" align="center" editType="date"
dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']"/>
<EF:EFColumn ename="receiveNo" cname="收货单号" enable="false" width="120" align="center"/>
<EF:EFColumn ename="contractNo" cname="合同号" enable="false" width="120" align="center"/>
<EF:EFComboColumn ename="status" cname="状态" enable="false" width="80" align="center">
<EF:EFCodeOption codeName="hggp.hgcg.receiveStatus"/>
</EF:EFComboColumn>
<EF:EFComboColumn ename="supCode" cname="供应商名称" enable="false" width="120" align="left">
<EF:EFOptions blockId="sup_record_block_id" valueField="valueField" textField="textField"/>
</EF:EFComboColumn>
<EF:EFColumn ename="purUserName" cname="采购员" enable="false" width="100" align="center"/>
<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="inventRecordId" cname="规格ID" enable="false" width="120" align="center" hidden="true"/>
<EF:EFColumn ename="spec" cname="规格" enable="false" width="120" align="center"/>
<EF:EFColumn ename="material" cname="材质" enable="false" width="80" align="center"/>
<EF:EFColumn ename="receiveQty" cname="收货数量" width="120" align="right" format="{0:N3}" required="true"/>
<EF:EFColumn ename="deliverQty" cname="退货数量" enable="false" width="120" align="right" format="{0:N3}"/>
<EF:EFColumn ename="depositQty" cname="入库数量" enable="false" width="120" align="right" format="{0:N3}"/>
<EF:EFColumn ename="receiveWeight" cname="收货重量" enable="false" width="120" align="right" format="{0:N3}"/>
<EF:EFColumn ename="length" cname="长(M)" 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']"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
$(function () {
IPLATUI.EFGrid = {
"result": {
columns: [],
loadComplete: function (grid) {
}
}
}
$("#ef_form_head").hide();
// 查询
$("#QUERY").on("click", query);
// 确认
$("#CONFIRM").on("click", confirm);
downKeyUp();
});
/**
* 页面加载时执行
*/
$(window).load(function () {
// 勾选事件
resultCheckClick();
// 初始化查询
query();
});
/**
* 勾选事件
*/
let resultCheckClick = function (){
resultGrid.element.on("click", "input.check-one,input.check-all", function (e) {
let action = $(this).prop("checked");
if (action != true) {
return;
}
let checkRows = resultGrid.getCheckedRows();
let checkRowIndexs = resultGrid.getCheckedRowsIndex();
for (let rowNo = 0; rowNo < checkRowIndexs.length; rowNo++) {
let index = checkRowIndexs[rowNo];
let bcReceiveQty = checkRows[rowNo]["bcReceiveQty"];
let bcMaxReceiveQty = checkRows[rowNo]["bcMaxReceiveQty"];
if (isBlank(bcReceiveQty) || bcReceiveQty == 0) {
resultGrid.setCellValue(index, "bcReceiveQty", bcMaxReceiveQty);
}
}
});
}
/**
* 查询
*/
var query = function (e) {
resultGrid.dataSource.page(1);
};
/**
* 选择
*/
let confirm = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据")
return;
}
for (let i = 0; i < rows.length; i++) {
let bcReceiveQty = rows[i]['bcReceiveQty'];
let bcMaxReceiveQty = rows[i]['bcMaxReceiveQty'];
if (!isPositiveNumber(bcReceiveQty)) {
message("勾选的第" + (i + 1) + "行本次收货数量必须大于0");
return;
}
if (parseFloat(bcReceiveQty) > parseFloat(bcMaxReceiveQty)) {
message("勾选的第" + (i + 1) + "行本次收货数量不能大于本次最大收货数量");
return;
}
}
JSUtils.confirm("确定对勾选的[" + rows.length + "]条数据生成\"采购收货\"吗? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGCG003A", "confirm",
true, function (e) {
var status = e.getStatus();
if (status !== -1) {
parent.JSColorbox.setValueCallback();
}
}
);
}
});
}
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<EF:EFPage title="合同查询">
<EF:EFRegion id="inqu" title="查询区域" type="query">
<div class="row">
<EF:EFDatePicker cname="合同日期" blockId="inqu_status" ename="contractDate" row="0" colWidth="3"
role="date" format="yyyy-MM-dd" readonly="true"/>
<EF:EFInput cname="合同号" blockId="inqu_status" ename="contractNo" row="0" colWidth="3"/>
<EF:EFInput cname="计划单号" blockId="inqu_status" ename="planNo" row="0" colWidth="3"/>
<EF:EFSelect cname="状态" blockId="inqu_status" ename="status" row="0" colWidth="3" optionLabel="全部"
defultValue="">
<EF:EFCodeOption codeName="hggp.hgcg.contractStatus" condition="ITEM_CODE IN ('1', '3')"/>
</EF:EFSelect>
</div>
<div class="row">
<EF:EFSelect cname="公司名称" blockId="inqu_status" ename="companyCode" row="0" colWidth="3"
filter="contains" optionLabel="全部" defultValue="">
<EF:EFOptions blockId="company_code_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
<EF:EFSelect cname="供应商名称" blockId="inqu_status" ename="supCode" row="0" colWidth="3"
filter="contains" optionLabel="全部" defultValue="">
<EF:EFOptions blockId="sup_record_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
<EF:EFSelect cname="存货名称" blockId="inqu_status" ename="inventCode" row="0" colWidth="3"
filter="contains" optionLabel="全部" defultValue="">
<EF:EFOptions blockId="invent_name_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
<EF:EFSelect cname="规格" ename="inqu_status-0-spec" colWidth="3" filter="contains" optionLabel="全部"
defultValue="">
<EF:EFOptions blockId="spec_name_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
</div>
<div class="row">
<EF:EFDateSpan startCname="创建时间(从)" endCname="至" blockId="inqu_status"
startName="createdTimeFrom" endName="createdTimeTo" row="0" role="datetime"
format="yyyy-MM-dd HH:mm:ss" ratio="3:3" satrtRatio="4:8" endRatio="4:8" readonly="true">
</EF:EFDateSpan>
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="记录集">
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true" checkMode="row">
<EF:EFColumn ename="id" cname="内码" hidden="true"/>
<EF:EFColumn ename="companyCode" cname="公司编码" enable="false" width="100" align="center" hidden="true"/>
<EF:EFColumn ename="companyName" cname="公司名称" enable="false" width="130" align="center"/>
<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:EFComboColumn ename="status" cname="状态" enable="false" width="80" align="center">
<EF:EFCodeOption codeName="hggp.hgcg.contractStatus"/>
</EF:EFComboColumn>
<EF:EFColumn ename="bcReceiveQty" cname="本次</br>收货数量" width="100" align="right" format="{0:N3}"
required="true"/>
<EF:EFColumn ename="bcMaxReceiveQty" cname="本次最大</br>收货数量" enable="false" width="100" align="right"
format="{0:N3}"/>
<EF:EFColumn ename="receiveQty" cname="已收货数量" enable="false" width="100" align="right" format="{0:N3}"/>
<EF:EFColumn ename="purQty" cname="采购数量" enable="false" width="100" align="right" format="{0:N3}"/>
<EF:EFColumn ename="purWeight" cname="采购重量" enable="false" width="100" align="right" format="{0:N3}"/>
<EF:EFComboColumn ename="supCode" cname="供应商名称" enable="false" width="120" align="left" defaultValue=""
filter="contains">
<EF:EFOptions blockId="sup_record_block_id" valueField="valueField" textField="textField"/>
</EF:EFComboColumn>
<EF:EFColumn ename="purUserName" cname="采购员" enable="false" width="100" align="center" required="true"/>
<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="inventRecordId" cname="规格ID" enable="false" width="120" align="center" hidden="true"/>
<EF:EFColumn ename="spec" cname="规格" enable="false" width="120" align="center"/>
<EF:EFColumn ename="material" cname="材质" enable="false" width="80" 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']"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
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