|
@@ -20,8 +20,180 @@ import java.util.*
|
|
|
*/
|
|
*/
|
|
|
object ContractAdapter {
|
|
object ContractAdapter {
|
|
|
|
|
|
|
|
|
|
+ /**(重点提醒 这里属于服务端接口,仅用于审核等操作,,,)
|
|
|
|
|
+ * 获取新增采购合同报文
|
|
|
|
|
+ * @param contractInfo SpotContractInfo 新增合同信息
|
|
|
|
|
+ * @param OperateType String 操作类型-1:保存草稿2:提交申请3:审核通过4:审核拒绝5:撤回6:正常完结7:异常终止
|
|
|
|
|
+ * @param Remark String 备注
|
|
|
|
|
+ * @param SpotContractID String 现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)
|
|
|
|
|
+ * @return Packet50 采购合同报文
|
|
|
|
|
+ */
|
|
|
|
|
+ fun getOneContractReqInfo(
|
|
|
|
|
+ contractInfo: SpotContractInfo = SpotContractInfo(),
|
|
|
|
|
+ OperateType: String,
|
|
|
|
|
+ Remark: String = "",
|
|
|
|
|
+ SpotContractID: String = ""
|
|
|
|
|
+ ): Packet50 {
|
|
|
|
|
+ val builder = ErmcpMI1.SpotContractOperateReq.newBuilder()
|
|
|
|
|
+ val contractInfobuilder = ErmcpMI1.SpotContractInfo.newBuilder()
|
|
|
|
|
+ contractInfo.let {
|
|
|
|
|
+ if (it.ContractNo.isNotEmpty()) {
|
|
|
|
|
+ contractInfobuilder.contractNo = it.ContractNo
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.Amount != 0.0) {
|
|
|
|
|
+ contractInfobuilder.amount = it.Amount
|
|
|
|
|
+ }
|
|
|
|
|
+// if (it.BrandID.isNotEmpty()) {
|
|
|
|
|
+// contractInfobuilder.spotGoodsBrandID = it.BrandID
|
|
|
|
|
+// }
|
|
|
|
|
+ if (it.BuyUserID.toString() != "0") {
|
|
|
|
|
+ contractInfobuilder.buyUserID = it.BuyUserID.toInt()
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.SellUserID.toString() != "0") {
|
|
|
|
|
+ contractInfobuilder.sellUserID = it.SellUserID.toInt()
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.UserID.toString() != "0") {
|
|
|
|
|
+ contractInfobuilder.userID = it.UserID.toInt()
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.ContractAttachment.isNotEmpty()) {
|
|
|
|
|
+ contractInfobuilder.contractAttachment =
|
|
|
|
|
+ ByteString.copyFrom(it.ContractAttachment.toByteArray())
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.WrStandardID.toString() != "0") {
|
|
|
|
|
+ contractInfobuilder.wrStandardID = it.WrStandardID.toInt()
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.ContractMargin != 0.0) {
|
|
|
|
|
+ contractInfobuilder.contractMargin = it.ContractMargin
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.ContractType != 0) {
|
|
|
|
|
+ contractInfobuilder.contractType = it.ContractType
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.SpotGoodsDesc.isNotEmpty()) {
|
|
|
|
|
+ contractInfobuilder.spotGoodsDescBytes =
|
|
|
|
|
+ ByteString.copyFrom(it.SpotGoodsDesc.toByteArray())
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.ConvertFactor != 0.0) {
|
|
|
|
|
+ contractInfobuilder.convertFactor = it.ConvertFactor
|
|
|
|
|
+ }
|
|
|
|
|
+// if (it.BizType.toString() != "0"){
|
|
|
|
|
+// contractInfobuilder.bizType = it.BizType
|
|
|
|
|
+// }
|
|
|
|
|
+// if (it.SaleUserID.toString() != "0"){
|
|
|
|
|
+// contractInfobuilder.saleUserID = it.SaleUserID
|
|
|
|
|
+// }
|
|
|
|
|
+ if (it.DeliveryDesc.isNotEmpty()) {
|
|
|
|
|
+ contractInfobuilder.deliveryDesc = it.DeliveryDesc
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.DeliveryEndDate.isNotEmpty()) {
|
|
|
|
|
+ contractInfobuilder.deliveryEndDate = it.DeliveryEndDate
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.DeliveryGoodsID.toString() != "0") {
|
|
|
|
|
+ contractInfobuilder.deliveryGoodsID = it.DeliveryGoodsID.toInt()
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.DeliveryStartDate.isNotEmpty()) {
|
|
|
|
|
+ contractInfobuilder.deliveryStartDate = it.DeliveryStartDate
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.StartDate.isNotEmpty()){
|
|
|
|
|
+ contractInfobuilder.startDate = it.StartDate
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.EndDate.isNotEmpty()) {
|
|
|
|
|
+ contractInfobuilder.endDate = it.EndDate
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.GoodsID.toString() != "0") {
|
|
|
|
|
+ contractInfobuilder.goodsID = it.GoodsID.toInt()
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.MerUserID.toString() != "0") {
|
|
|
|
|
+ contractInfobuilder.merUserID = it.MerUserID.toInt()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (it.PointDesc.isNotEmpty()) {
|
|
|
|
|
+ contractInfobuilder.pointDesc = it.PointDesc
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.Price != 0.0) {
|
|
|
|
|
+ contractInfobuilder.price = it.Price
|
|
|
|
|
+ }
|
|
|
|
|
+// if (it.AccountID.toString() != "0"){
|
|
|
|
|
+// contractInfobuilder.accountID = it.AccountID
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ if (it.SpotGoodsBrandID.toString() != "0"){
|
|
|
|
|
+ contractInfobuilder.spotGoodsBrandID = it.SpotGoodsBrandID.toInt()
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.PriceMove != 0.0) {
|
|
|
|
|
+ contractInfobuilder.priceMove = it.PriceMove
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.PriceType != 0) {
|
|
|
|
|
+ contractInfobuilder.priceType = it.PriceType
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.PricedAmount != 0.0) {
|
|
|
|
|
+ contractInfobuilder.pricedAmount = it.PricedAmount
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.PricedQty != 0.0) {
|
|
|
|
|
+ contractInfobuilder.pricedQty = it.PricedQty
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.ProductType != 0) {
|
|
|
|
|
+ contractInfobuilder.productType = it.ProductType
|
|
|
|
|
+ }
|
|
|
|
|
+ if (it.Qty != 0.0) {
|
|
|
|
|
+ contractInfobuilder.qty = it.Qty
|
|
|
|
|
+ }
|
|
|
|
|
+// contractInfobuilder.tradeDate = TimeUtils.getNowString(SimpleDateFormat("yyyyMMdd"))
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ val loginInfo = GlobalDataCollection.instance?.loginRsp!!
|
|
|
|
|
+ // FIXME: - 250000000005
|
|
|
|
|
+ builder.setHeader(
|
|
|
|
|
+ MessageHeadModel.getHead(
|
|
|
|
|
+ FunCode.SpotContractOperateReq,
|
|
|
|
|
+ loginInfo.userID,
|
|
|
|
|
+ GlobalDataCollection.instance?.accountId ?: 0,
|
|
|
|
|
+ 0,
|
|
|
|
|
+ 18
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ builder.setClientTicket(UUID.randomUUID().toString().replace("-", ""))
|
|
|
|
|
+ builder.operateType = OperateType.toInt()
|
|
|
|
|
+ if (OperateType == "1" || OperateType == "2") {
|
|
|
|
|
+ builder.info = contractInfobuilder.build()
|
|
|
|
|
+ }
|
|
|
|
|
+ builder.userID = loginInfo.loginID
|
|
|
|
|
+ builder.remark = Remark
|
|
|
|
|
+ builder.operateSrc = 2
|
|
|
|
|
+ if (SpotContractID.isNotEmpty()) {
|
|
|
|
|
+ builder.spotContractID = SpotContractID.toLong()
|
|
|
|
|
+ }
|
|
|
|
|
+ val arrayOutputStream = ByteArrayOutputStream();
|
|
|
|
|
+ builder.build().writeTo(arrayOutputStream)
|
|
|
|
|
+ return Packet50(FunCode.SpotContractOperateReq, arrayOutputStream.toByteArray())
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 新增采购合同报文解析
|
|
|
|
|
+ * @param packet50 Packet50
|
|
|
|
|
+ * @return Triple<Boolean, Error?, ErmcpMI1.SpotContractOperateRsp?>
|
|
|
|
|
+ */
|
|
|
|
|
+ fun analysisOneContractRsq(packet50: Packet50): Triple<Boolean, Error?, ErmcpMI1.SpotContractOperateRsp?> {
|
|
|
|
|
+ return try {
|
|
|
|
|
+ val resultRsp = ErmcpMI1.SpotContractOperateRsp.parseFrom(packet50.content)
|
|
|
|
|
+ if (resultRsp.retCode == 0) {
|
|
|
|
|
+ // 操作成功
|
|
|
|
|
+ Triple(true, null, resultRsp)
|
|
|
|
|
+ }else if (resultRsp.retCode == -1){
|
|
|
|
|
+ // 操作失败
|
|
|
|
|
+ Triple(false, Error(resultRsp.retDesc), null)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 操作失败
|
|
|
|
|
+ Triple(false, Error(ErrorMessageUtils.getErrorString(resultRsp.retCode)), null)
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e: Exception) {
|
|
|
|
|
+ // 操作失败
|
|
|
|
|
+ Triple(false, Error("装箱失败"), null)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**(重点提醒 这里属于管理端接口,仅用于新增)
|
|
|
* 获取新增采购合同报文
|
|
* 获取新增采购合同报文
|
|
|
* @param contractInfo SpotContractInfo 新增合同信息
|
|
* @param contractInfo SpotContractInfo 新增合同信息
|
|
|
* @param OperateType String 操作类型-1:保存草稿2:提交申请3:审核通过4:审核拒绝5:撤回6:正常完结7:异常终止
|
|
* @param OperateType String 操作类型-1:保存草稿2:提交申请3:审核通过4:审核拒绝5:撤回6:正常完结7:异常终止
|
|
@@ -86,19 +258,19 @@ object ContractAdapter {
|
|
|
contractInfobuilder.deliveryDesc = it.DeliveryDesc
|
|
contractInfobuilder.deliveryDesc = it.DeliveryDesc
|
|
|
}
|
|
}
|
|
|
if (it.DeliveryEndDate.isNotEmpty()) {
|
|
if (it.DeliveryEndDate.isNotEmpty()) {
|
|
|
- contractInfobuilder.deliveryEndDate = it.DeliveryEndDate
|
|
|
|
|
|
|
+ contractInfobuilder.deliveryEndDate = it.DeliveryEndDate + " 00:00:00"
|
|
|
}
|
|
}
|
|
|
if (it.DeliveryGoodsID.toString() != "0") {
|
|
if (it.DeliveryGoodsID.toString() != "0") {
|
|
|
contractInfobuilder.deliveryGoodsID = it.DeliveryGoodsID
|
|
contractInfobuilder.deliveryGoodsID = it.DeliveryGoodsID
|
|
|
}
|
|
}
|
|
|
if (it.DeliveryStartDate.isNotEmpty()) {
|
|
if (it.DeliveryStartDate.isNotEmpty()) {
|
|
|
- contractInfobuilder.deliveryStartDate = it.DeliveryStartDate
|
|
|
|
|
|
|
+ contractInfobuilder.deliveryStartDate = it.DeliveryStartDate + " 00:00:00"
|
|
|
}
|
|
}
|
|
|
if (it.StartDate.isNotEmpty()){
|
|
if (it.StartDate.isNotEmpty()){
|
|
|
- contractInfobuilder.startDate = it.StartDate
|
|
|
|
|
|
|
+ contractInfobuilder.startDate = it.StartDate + " 00:00:00"
|
|
|
}
|
|
}
|
|
|
if (it.EndDate.isNotEmpty()) {
|
|
if (it.EndDate.isNotEmpty()) {
|
|
|
- contractInfobuilder.endDate = it.EndDate
|
|
|
|
|
|
|
+ contractInfobuilder.endDate = it.EndDate + " 00:00:00"
|
|
|
}
|
|
}
|
|
|
if (it.GoodsID.toString() != "0") {
|
|
if (it.GoodsID.toString() != "0") {
|
|
|
contractInfobuilder.goodsID = it.GoodsID
|
|
contractInfobuilder.goodsID = it.GoodsID
|
|
@@ -174,9 +346,9 @@ object ContractAdapter {
|
|
|
* @param packet50 Packet50
|
|
* @param packet50 Packet50
|
|
|
* @return Triple<Boolean, Error?, ErmcpMI1.SpotContractOperateRsp?>
|
|
* @return Triple<Boolean, Error?, ErmcpMI1.SpotContractOperateRsp?>
|
|
|
*/
|
|
*/
|
|
|
- fun analysisContractRsq(packet50: Packet50): Triple<Boolean, Error?, ErmcpMI1.SpotContractOperateRsp?> {
|
|
|
|
|
|
|
+ fun analysisContractRsq(packet50: Packet50): Triple<Boolean, Error?, ManageServiceMI2.GldErmcpSpotContractOperateRsp?> {
|
|
|
return try {
|
|
return try {
|
|
|
- val resultRsp = ErmcpMI1.SpotContractOperateRsp.parseFrom(packet50.content)
|
|
|
|
|
|
|
+ val resultRsp = ManageServiceMI2.GldErmcpSpotContractOperateRsp.parseFrom(packet50.content)
|
|
|
if (resultRsp.retCode == 0) {
|
|
if (resultRsp.retCode == 0) {
|
|
|
// 操作成功
|
|
// 操作成功
|
|
|
Triple(true, null, resultRsp)
|
|
Triple(true, null, resultRsp)
|
|
@@ -202,16 +374,16 @@ object ContractAdapter {
|
|
|
* @return Packet50
|
|
* @return Packet50
|
|
|
*/
|
|
*/
|
|
|
fun getPerationContractReqInfo(
|
|
fun getPerationContractReqInfo(
|
|
|
- info: ManageServiceMI2.ContractOperateApplyInfo,
|
|
|
|
|
|
|
+ info: ErmcpMI1.ContractOperateApplyInfo,
|
|
|
operateType: Int = 0,
|
|
operateType: Int = 0,
|
|
|
remark: String = "",
|
|
remark: String = "",
|
|
|
operateApplyID: Long = 0
|
|
operateApplyID: Long = 0
|
|
|
): Packet50 {
|
|
): Packet50 {
|
|
|
- val builder = ManageServiceMI2.ErmcpContractOperateApplyReq.newBuilder()
|
|
|
|
|
|
|
+ val builder = ErmcpMI1.ContractOperateApplyReq.newBuilder()
|
|
|
val loginInfo = GlobalDataCollection.instance?.loginRsp!!
|
|
val loginInfo = GlobalDataCollection.instance?.loginRsp!!
|
|
|
builder.setHeader(
|
|
builder.setHeader(
|
|
|
MessageHeadModel.getHead(
|
|
MessageHeadModel.getHead(
|
|
|
- FunCode.ErmcpContractOperateApplyReq,
|
|
|
|
|
|
|
+ FunCode.ContractOperateApplyReq,
|
|
|
loginInfo.userID,
|
|
loginInfo.userID,
|
|
|
GlobalDataCollection.instance?.accountId ?: 0,
|
|
GlobalDataCollection.instance?.accountId ?: 0,
|
|
|
0,
|
|
0,
|
|
@@ -227,7 +399,7 @@ object ContractAdapter {
|
|
|
builder.info = info
|
|
builder.info = info
|
|
|
val arrayOutputStream = ByteArrayOutputStream()
|
|
val arrayOutputStream = ByteArrayOutputStream()
|
|
|
builder.build().writeTo(arrayOutputStream)
|
|
builder.build().writeTo(arrayOutputStream)
|
|
|
- return Packet50(FunCode.ErmcpContractOperateApplyReq, arrayOutputStream.toByteArray())
|
|
|
|
|
|
|
+ return Packet50(FunCode.ContractOperateApplyReq, arrayOutputStream.toByteArray())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -236,13 +408,16 @@ object ContractAdapter {
|
|
|
* @param packet50 Packet50
|
|
* @param packet50 Packet50
|
|
|
* @return Triple<Boolean, Error?, ErmcpMI1.ContractOperateApplyRsp?>
|
|
* @return Triple<Boolean, Error?, ErmcpMI1.ContractOperateApplyRsp?>
|
|
|
*/
|
|
*/
|
|
|
- fun analysisPerationContractRsq(packet50: Packet50) : Triple<Boolean, Error?, ManageServiceMI2.ErmcpContractOperateApplyRsp?> {
|
|
|
|
|
|
|
+ fun analysisPerationContractRsq(packet50: Packet50) : Triple<Boolean, Error?, ErmcpMI1.ContractOperateApplyRsp?> {
|
|
|
|
|
|
|
|
return try {
|
|
return try {
|
|
|
- val loginRsp = ManageServiceMI2.ErmcpContractOperateApplyRsp.parseFrom(packet50.content)
|
|
|
|
|
|
|
+ val loginRsp = ErmcpMI1.ContractOperateApplyRsp.parseFrom(packet50.content)
|
|
|
if (loginRsp.retCode == 0) {
|
|
if (loginRsp.retCode == 0) {
|
|
|
// 操作成功
|
|
// 操作成功
|
|
|
Triple(true, null, loginRsp)
|
|
Triple(true, null, loginRsp)
|
|
|
|
|
+ }else if (loginRsp.retCode == -1){
|
|
|
|
|
+ // 操作失败
|
|
|
|
|
+ Triple(false, Error(loginRsp.retDesc), null)
|
|
|
} else {
|
|
} else {
|
|
|
// 操作失败
|
|
// 操作失败
|
|
|
Triple(false, Error(ErrorMessageUtils.getErrorString(loginRsp.retCode)), null)
|
|
Triple(false, Error(ErrorMessageUtils.getErrorString(loginRsp.retCode)), null)
|