|
@@ -12,6 +12,7 @@ import com.actionsoft.bpms.server.UserContext;
|
|
|
import com.actionsoft.bpms.server.bind.annotation.Controller;
|
|
import com.actionsoft.bpms.server.bind.annotation.Controller;
|
|
|
import com.actionsoft.bpms.server.bind.annotation.Mapping;
|
|
import com.actionsoft.bpms.server.bind.annotation.Mapping;
|
|
|
import com.actionsoft.bpms.util.DBSql;
|
|
import com.actionsoft.bpms.util.DBSql;
|
|
|
|
|
+import com.actionsoft.bpms.util.TypeUtil;
|
|
|
import com.actionsoft.sdk.local.SDK;
|
|
import com.actionsoft.sdk.local.SDK;
|
|
|
import com.actionsoft.sdk.local.api.Logger;
|
|
import com.actionsoft.sdk.local.api.Logger;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -27,12 +28,16 @@ import java.math.RoundingMode;
|
|
|
import java.sql.Connection;
|
|
import java.sql.Connection;
|
|
|
import java.sql.SQLException;
|
|
import java.sql.SQLException;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
+import static com.awspaas.user.apps.donenow_ivt.service.PaymentPlanService.toBigDecimal;
|
|
|
|
|
+
|
|
|
@Controller
|
|
@Controller
|
|
|
public class ivtOrderController {
|
|
public class ivtOrderController {
|
|
|
private static final Logger ivtLogger = SDK.getLogAPI().getLogger(ivtOrderController.class);//记录日志
|
|
private static final Logger ivtLogger = SDK.getLogAPI().getLogger(ivtOrderController.class);//记录日志
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 添加供应商产品
|
|
* 添加供应商产品
|
|
|
* @param uc
|
|
* @param uc
|
|
@@ -621,8 +626,7 @@ public class ivtOrderController {
|
|
|
sql = sql.substring(0, sql.length() - 1) + ")";
|
|
sql = sql.substring(0, sql.length() - 1) + ")";
|
|
|
List<RowMap> costList = DBSql.getMaps(sql, Arrays.stream(serviceArr).toArray());
|
|
List<RowMap> costList = DBSql.getMaps(sql, Arrays.stream(serviceArr).toArray());
|
|
|
|
|
|
|
|
- if (costList.isEmpty())
|
|
|
|
|
- return ResponseObject.newErrResponse("没有找到对应的合同产品");
|
|
|
|
|
|
|
+ if (costList.isEmpty()) return ResponseObject.newErrResponse("没有找到对应的合同产品");
|
|
|
|
|
|
|
|
|
|
|
|
|
String costIds = costList.stream().map(cost -> cost.getString("ID")).collect(Collectors.joining(","));
|
|
String costIds = costList.stream().map(cost -> cost.getString("ID")).collect(Collectors.joining(","));
|
|
@@ -657,6 +661,7 @@ public class ivtOrderController {
|
|
|
ivtLogger.info("接收到的costIds参数: " + costIds);
|
|
ivtLogger.info("接收到的costIds参数: " + costIds);
|
|
|
|
|
|
|
|
// ========== 新增:初始化TAX_CATEGORY_ID与税率的映射关系 ==========
|
|
// ========== 新增:初始化TAX_CATEGORY_ID与税率的映射关系 ==========
|
|
|
|
|
+ /*
|
|
|
Map<String, BigDecimal> taxRateMap = new HashMap<>();
|
|
Map<String, BigDecimal> taxRateMap = new HashMap<>();
|
|
|
taxRateMap.put("597", new BigDecimal("0.00")); // 增值税-0
|
|
taxRateMap.put("597", new BigDecimal("0.00")); // 增值税-0
|
|
|
taxRateMap.put("598", new BigDecimal("0.01")); // 增值税-1
|
|
taxRateMap.put("598", new BigDecimal("0.01")); // 增值税-1
|
|
@@ -666,6 +671,13 @@ public class ivtOrderController {
|
|
|
taxRateMap.put("10097", new BigDecimal("0.09")); // 增值税-9
|
|
taxRateMap.put("10097", new BigDecimal("0.09")); // 增值税-9
|
|
|
taxRateMap.put("14138", new BigDecimal("0.13")); // 增值税-13
|
|
taxRateMap.put("14138", new BigDecimal("0.13")); // 增值税-13
|
|
|
|
|
|
|
|
|
|
+ */
|
|
|
|
|
+ List<RowMap> taxCateList = DBSql.getMaps("SELECT OID,NAME,ORGID,GENERAL_TABLE_ID,EXT1,CLOSED,IS_ACTIVE FROM BO_EU_DND_GENERAL WHERE GENERAL_TABLE_ID=44 AND ORGID=? ", new Object[]{uc.getCompanyModel().getId()});
|
|
|
|
|
+ Map<String, BigDecimal> taxRateMap = new HashMap<>();
|
|
|
|
|
+ for (RowMap taxCate : taxCateList) {
|
|
|
|
|
+ taxRateMap.put(taxCate.getString("OID"), toBigDecimal(taxCate.getDouble("EXT1")));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
String[] costIdArr = costIds.split(",");
|
|
String[] costIdArr = costIds.split(",");
|
|
|
String sql = "SELECT * FROM BO_EU_DNCTT_CONTRACT_COST WHERE ID IN(";
|
|
String sql = "SELECT * FROM BO_EU_DNCTT_CONTRACT_COST WHERE ID IN(";
|
|
|
for (int i = 0; i < costIdArr.length; i++) {
|
|
for (int i = 0; i < costIdArr.length; i++) {
|
|
@@ -780,14 +792,9 @@ public class ivtOrderController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
BigDecimal unitCost = new BigDecimal(unitCostStr);
|
|
BigDecimal unitCost = new BigDecimal(unitCostStr);
|
|
|
- BigDecimal unitCostNotax = unitCost.divide(
|
|
|
|
|
- BigDecimal.ONE.add(taxRate),
|
|
|
|
|
- 2,
|
|
|
|
|
- RoundingMode.HALF_UP
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- BigDecimal costTotalNotax = unitCostNotax.multiply(new BigDecimal(purchaseQuantity))
|
|
|
|
|
- .setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
|
|
+ BigDecimal unitCostNotax = unitCost.divide(BigDecimal.ONE.add(taxRate), 2, RoundingMode.HALF_UP);
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal costTotalNotax = unitCostNotax.multiply(new BigDecimal(purchaseQuantity)).setScale(2, RoundingMode.HALF_UP);
|
|
|
purchaseOrderProduct.set("PURCHASE_ACCOUNT_ID", cost.getString("ACCOUNT_ID"));
|
|
purchaseOrderProduct.set("PURCHASE_ACCOUNT_ID", cost.getString("ACCOUNT_ID"));
|
|
|
purchaseOrderProduct.set("NAME", cost.getString("NAME"));
|
|
purchaseOrderProduct.set("NAME", cost.getString("NAME"));
|
|
|
purchaseOrderProduct.set("PRODUCT_ID", cost.getString("PRODUCT_ID"));
|
|
purchaseOrderProduct.set("PRODUCT_ID", cost.getString("PRODUCT_ID"));
|
|
@@ -910,11 +917,9 @@ public class ivtOrderController {
|
|
|
|
|
|
|
|
List<BO> orderProducts = SDK.getBOAPI().query("BO_EU_DNIVT_ORDER_PRODUCT").addQuery("BINDID =", bindId).list();
|
|
List<BO> orderProducts = SDK.getBOAPI().query("BO_EU_DNIVT_ORDER_PRODUCT").addQuery("BINDID =", bindId).list();
|
|
|
|
|
|
|
|
- if (order.isEnd())
|
|
|
|
|
- return ResponseObject.newErrResponse("采购订单已结束,不能删除");
|
|
|
|
|
|
|
+ if (order.isEnd()) return ResponseObject.newErrResponse("采购订单已结束,不能删除");
|
|
|
|
|
|
|
|
- if (order.getString("ISEND").equals("1"))
|
|
|
|
|
- return ResponseObject.newErrResponse("采购订单已结束,不能删除");
|
|
|
|
|
|
|
+ if (order.getString("ISEND").equals("1")) return ResponseObject.newErrResponse("采购订单已结束,不能删除");
|
|
|
|
|
|
|
|
SDK.getProcessAPI().deleteById(bindId, uc.getUID());
|
|
SDK.getProcessAPI().deleteById(bindId, uc.getUID());
|
|
|
|
|
|
|
@@ -940,12 +945,62 @@ public class ivtOrderController {
|
|
|
@Mapping("com.awspaas.user.apps.donenow_ivt.createPaymentPlan")
|
|
@Mapping("com.awspaas.user.apps.donenow_ivt.createPaymentPlan")
|
|
|
public ResponseObject createPaymentPlan(UserContext uc, String orderId) {
|
|
public ResponseObject createPaymentPlan(UserContext uc, String orderId) {
|
|
|
|
|
|
|
|
|
|
+ //校验
|
|
|
|
|
+ BO purchaseOrder = SDK.getBOAPI().get("BO_EU_DNIVT_ORDER", orderId);
|
|
|
|
|
+ List<BO> orderProducts = SDK.getBOAPI().query("BO_EU_DNIVT_ORDER_PRODUCT").bindId(purchaseOrder.getBindId()).list();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ for (BO orderProduct : orderProducts) {
|
|
|
|
|
+ if (StringUtils.isNotBlank(orderProduct.getString("CONTRACT_COST_ID"))) {
|
|
|
|
|
+ String SERVICE_ID = DBSql.getString("select SERVICE_ID from BO_EU_DNCTT_CONTRACT_COST where ID=?", new Object[]{orderProduct.getString("CONTRACT_COST_ID")});
|
|
|
|
|
+ //关联服务
|
|
|
|
|
+ if (StringUtils.isNotBlank(SERVICE_ID)) {
|
|
|
|
|
+
|
|
|
|
|
+ BO service = SDK.getBOAPI().get("BO_EU_DNCTT_CONTRACT_SERVICE", SERVICE_ID);
|
|
|
|
|
+
|
|
|
|
|
+ String RULE_CATE = service.getString("PURCHASE_PERIOD_TYPE");//采购周期
|
|
|
|
|
+
|
|
|
|
|
+ //PERIOD_TYPE_ONCE = "609"; // 一次性收费
|
|
|
|
|
+ if (RULE_CATE.equals("609") == false) {
|
|
|
|
|
+
|
|
|
|
|
+ LocalDate PERIOD_BEGIN_DATE = service.get("PURCHASE_START_DATE", LocalDate.class);
|
|
|
|
|
+
|
|
|
|
|
+ LocalDate START_DATE = TypeUtil.convert(DBSql.getString("select START_DATE from BO_EU_DNCTT_CONTRACT where ID=?", new Object[]{service.getString("CONTRACT_ID")}).substring(0, 10), LocalDate.class);
|
|
|
|
|
+
|
|
|
|
|
+ LocalDate PERIOD_END_DATE = TypeUtil.convert(DBSql.getString("select END_DATE from BO_EU_DNCTT_CONTRACT where ID=?", new Object[]{service.getString("CONTRACT_ID")}).substring(0, 10), LocalDate.class);
|
|
|
|
|
+
|
|
|
|
|
+ //采购单开始日期
|
|
|
|
|
+ if (service.get("PURCHASE_START_DATE") != null) {
|
|
|
|
|
+ START_DATE = TypeUtil.convert(service.get("PURCHASE_START_DATE").toString().substring(0, 10), LocalDate.class);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String PURCHASE_CALC_METHOD_1STPERIOD = service.getString("PURCHASE_CALC_METHOD_1STPERIOD");
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isBlank(RULE_CATE) || StringUtils.isBlank(PURCHASE_CALC_METHOD_1STPERIOD)) {
|
|
|
|
|
+ return ResponseObject.newErrResponse("采购周期规则或采购计划计算方式未设置");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (PERIOD_BEGIN_DATE == null || PERIOD_END_DATE == null || START_DATE == null || PERIOD_BEGIN_DATE.isAfter(PERIOD_END_DATE) || START_DATE.isAfter(PERIOD_END_DATE)) {
|
|
|
|
|
+ return ResponseObject.newErrResponse("采购周期开始日期或结束日期未设置");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (DBSql.getInt("select count(1) as cnt from BO_EU_DNIVT_ORDER_PAYMENT_PLAN where ORDER_ID = ? and CONTRACT_COST_ID=? and CONTRACT_SERVICE_ID=? AND PAY_AMOUNT is NOT null AND PAY_AMOUNT<>0", new Object[]{orderId, orderProduct.getString("CONTRACT_COST_ID"), SERVICE_ID}) > 0) {
|
|
|
|
|
+ return ResponseObject.newErrResponse("付款计划已经开始付款,不能重新生成");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
PaymentPlanService.getInstance().createPaymentPlan(uc, orderId);
|
|
PaymentPlanService.getInstance().createPaymentPlan(uc, orderId);
|
|
|
|
|
|
|
|
|
|
+ //检查 是否创建成功
|
|
|
|
|
+ if (DBSql.getInt("select count(1) CNT from BO_EU_DNIVT_ORDER_PAYMENT_PLAN where ORDER_ID=?", new Object[]{orderId}) == 0)
|
|
|
|
|
+ return ResponseObject.newErrResponse("创建付款计划失败");
|
|
|
|
|
+
|
|
|
return ResponseObject.newOkResponse();
|
|
return ResponseObject.newOkResponse();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|