|
|
@@ -16,6 +16,7 @@ import com.actionsoft.sdk.local.SDK;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.awspaas.user.apps.donenow_ivt.cache.formStatusCache;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
@@ -44,8 +45,7 @@ public class ivtOrderController {
|
|
|
}
|
|
|
sql += " ) and CLOSED=0";
|
|
|
List<RowMap> list = DBSql.getMaps(sql, new Object[]{vendorAccountId});
|
|
|
- if (list.isEmpty())
|
|
|
- return ResponseObject.newErrResponse("无数据");
|
|
|
+ if (list.isEmpty()) return ResponseObject.newErrResponse("无数据");
|
|
|
|
|
|
List<JSONObject> warehouseProductIdsMap = new ArrayList<>();
|
|
|
if (warehouseProductIds != null && !warehouseProductIds.isEmpty() && !warehouseProductIds.equals("[]")) {
|
|
|
@@ -58,8 +58,7 @@ public class ivtOrderController {
|
|
|
int cnt = 0;
|
|
|
for (RowMap map : list) {
|
|
|
List<RowMap> lctList = DBSql.getMaps("select id,warehouse_id,product_id,quantity,quantity_minimum,quantity_maximum,(select name from bo_eu_dnivt_warehouse where id=warehouse_id) as bin from bo_eu_dnivt_warehouse_product where product_id=? ", new Object[]{map.getString("ID")});
|
|
|
- if (lctList == null || lctList.isEmpty())
|
|
|
- continue;
|
|
|
+ if (lctList == null || lctList.isEmpty()) continue;
|
|
|
boolean isExist = false;
|
|
|
if (!warehouseProductIdsMap.isEmpty()) {
|
|
|
for (int j = 0; j < warehouseProductIdsMap.size(); ++j) {
|
|
|
@@ -69,8 +68,7 @@ public class ivtOrderController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (isExist)
|
|
|
- continue;
|
|
|
+ if (isExist) continue;
|
|
|
|
|
|
for (RowMap rowMap : lctList) {
|
|
|
cnt++;
|
|
|
@@ -87,8 +85,7 @@ public class ivtOrderController {
|
|
|
SDK.getBOAPI().createDataBO("BO_EU_DNIVT_ORDER_PRODUCT", bo, uc);
|
|
|
}
|
|
|
}
|
|
|
- if (cnt == 0)
|
|
|
- return ResponseObject.newErrResponse("无数据");
|
|
|
+ if (cnt == 0) return ResponseObject.newErrResponse("无数据");
|
|
|
|
|
|
return ResponseObject.newOkResponse();
|
|
|
}
|
|
|
@@ -106,8 +103,7 @@ public class ivtOrderController {
|
|
|
String sql = "select * from bo_eu_dnivt_product where id=?";
|
|
|
|
|
|
RowMap map = DBSql.getMap(sql, new Object[]{productId});
|
|
|
- if (map == null)
|
|
|
- return ResponseObject.newErrResponse("无数据");
|
|
|
+ if (map == null) return ResponseObject.newErrResponse("无数据");
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
result.put("NAME", map.getString("NAME"));
|
|
|
@@ -132,8 +128,7 @@ public class ivtOrderController {
|
|
|
String sql = "select OID,NAME,EXT1 from bo_eu_dnd_general where is_active=1 and closed=0 and general_table_id=44 and orgid=? and oid=?";
|
|
|
|
|
|
RowMap map = DBSql.getMap(sql, new Object[]{uc.getCompanyModel().getId(), taxId});
|
|
|
- if (map == null)
|
|
|
- return ResponseObject.newErrResponse("无数据");
|
|
|
+ if (map == null) return ResponseObject.newErrResponse("无数据");
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
result.put("taxId", map.getString("OID"));
|
|
|
@@ -155,12 +150,10 @@ public class ivtOrderController {
|
|
|
*/
|
|
|
@Mapping(value = "com.awspaas.user.apps.donenow_ivt.purchaseShip")
|
|
|
public ResponseObject purchaseShip(UserContext uc, String costPdtIds) throws SQLException {
|
|
|
- if (StringUtils.isBlank(costPdtIds))
|
|
|
- return ResponseObject.newErrResponse("无数据");
|
|
|
+ if (StringUtils.isBlank(costPdtIds)) return ResponseObject.newErrResponse("无数据");
|
|
|
|
|
|
List<RowMap> pdtList = DBSql.getMaps("select ID,STATUS_ID from bo_eu_dnctt_contract_cost_product where id in(?)", new Object[]{costPdtIds});
|
|
|
- if (pdtList.isEmpty())
|
|
|
- return ResponseObject.newErrResponse("无数据");
|
|
|
+ if (pdtList.isEmpty()) return ResponseObject.newErrResponse("无数据");
|
|
|
for (RowMap pdtMap : pdtList) {
|
|
|
if (pdtMap.getString("STATUS_ID").equals("2158") == false)//待配送
|
|
|
{
|
|
|
@@ -242,8 +235,7 @@ public class ivtOrderController {
|
|
|
} catch (SQLException e) {
|
|
|
conn.rollback();
|
|
|
} finally {
|
|
|
- if (conn != null)
|
|
|
- conn.close();
|
|
|
+ if (conn != null) conn.close();
|
|
|
}
|
|
|
return ResponseObject.newOkResponse();
|
|
|
}
|
|
|
@@ -253,13 +245,11 @@ public class ivtOrderController {
|
|
|
*/
|
|
|
@Mapping(value = "com.awspaas.user.apps.donenow_ivt.purchaseUnShip")
|
|
|
public ResponseObject purchaseUnShip(UserContext uc, String costPdtIds) throws SQLException {
|
|
|
- if (StringUtils.isBlank(costPdtIds))
|
|
|
- return ResponseObject.newErrResponse("无数据");
|
|
|
+ if (StringUtils.isBlank(costPdtIds)) return ResponseObject.newErrResponse("无数据");
|
|
|
|
|
|
List<RowMap> pdtList = DBSql.getMaps("select ID,STATUS_ID,CONTRACT_COST_ID,QUANTITY,WAREHOUSE_ID,SN,SHIPPING_CONTRACT_COST_ID from bo_eu_dnctt_contract_cost_product where FIND_IN_SET(ID,?)", new Object[]{costPdtIds});
|
|
|
|
|
|
- if (pdtList.isEmpty())
|
|
|
- return ResponseObject.newErrResponse("无数据");
|
|
|
+ if (pdtList.isEmpty()) return ResponseObject.newErrResponse("无数据");
|
|
|
|
|
|
Connection conn = null;
|
|
|
try {
|
|
|
@@ -313,18 +303,15 @@ public class ivtOrderController {
|
|
|
lctPdtLotBO.set("QUANTITY", Integer.parseInt(lctPdtLotBO.getString("QUANTITY")) + 1);
|
|
|
|
|
|
String lostSN = lctPdtLotBO.getString("SN");
|
|
|
- if (StringUtils.isNotBlank(lostSN))
|
|
|
- lctPdtLotBO.set("SN", lostSN + "," + sn);
|
|
|
- else
|
|
|
- lctPdtLotBO.set("SN", sn);
|
|
|
+ if (StringUtils.isNotBlank(lostSN)) lctPdtLotBO.set("SN", lostSN + "," + sn);
|
|
|
+ else lctPdtLotBO.set("SN", sn);
|
|
|
|
|
|
String lostShippedSN = lctPdtLotBO.getString("SHIPPED_SN");//移除sn
|
|
|
|
|
|
String[] lostShippedSNs = lostShippedSN.split(",");
|
|
|
List<String> lostShippedSNsList = new ArrayList<String>();
|
|
|
for (String lostShippedSNsItem : lostShippedSNs) {
|
|
|
- if (!lostShippedSNsItem.equals(sn))
|
|
|
- lostShippedSNsList.add(lostShippedSNsItem);
|
|
|
+ if (!lostShippedSNsItem.equals(sn)) lostShippedSNsList.add(lostShippedSNsItem);
|
|
|
}
|
|
|
lostShippedSN = StringUtils.join(lostShippedSNsList.toArray(), ",");
|
|
|
lctPdtLotBO.set("SHIPPED_SN", lostShippedSN);
|
|
|
@@ -346,7 +333,7 @@ public class ivtOrderController {
|
|
|
//删除
|
|
|
if (StringUtils.isNotBlank(pdtMap.getString("SHIPPING_CONTRACT_COST_ID")))
|
|
|
DBSql.update(conn, "update BO_EU_DNCTT_CONTRACT_COST_PRODUCT set CLOSED=1 where ID=?", new Object[]{pdtMap.getString("SHIPPING_CONTRACT_COST_ID")});
|
|
|
- // DBSql.update(conn, "update BO_EU_DNCTT_CONTRACT_COST_PRODUCT set SHIPPING_CONTRACT_COST_ID=NULL where ID=?", new Object[]{pdtMap.getString("ID")});
|
|
|
+ // DBSql.update(conn, "update BO_EU_DNCTT_CONTRACT_COST_PRODUCT set SHIPPING_CONTRACT_COST_ID=NULL where ID=?", new Object[]{pdtMap.getString("ID")});
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -354,8 +341,7 @@ public class ivtOrderController {
|
|
|
} catch (SQLException e) {
|
|
|
conn.rollback();
|
|
|
} finally {
|
|
|
- if (conn != null)
|
|
|
- conn.close();
|
|
|
+ if (conn != null) conn.close();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -636,9 +622,35 @@ public class ivtOrderController {
|
|
|
purchaseOrder.setBindId(processInstance.getId());
|
|
|
purchaseOrder.set("SUBMIT_TIME", getCurrentDateTime());//提交时间
|
|
|
purchaseOrder.set("SUBMITTED_RESOURCE_ID", uc.getUID());//提交人
|
|
|
- //采购客户
|
|
|
- String PURCHASE_ACCOUNT_ID = costList.get(0).getString("ACCOUNT_ID");
|
|
|
- purchaseOrder.set("PURCHASE_ACCOUNT_ID", PURCHASE_ACCOUNT_ID);
|
|
|
+
|
|
|
+ Set<String> PURCHASE_ACCOUNT_ID = new HashSet<>(); //采购客户
|
|
|
+ Set<String> VENDOR_ACCOUNT_ID = new HashSet<>(); // 供应商
|
|
|
+
|
|
|
+ for (RowMap cost : costList) {
|
|
|
+ String account_id = cost.getString("ACCOUNT_ID");
|
|
|
+ if (StringUtils.isNotBlank(account_id)) {
|
|
|
+ PURCHASE_ACCOUNT_ID.add(account_id);
|
|
|
+ } else {
|
|
|
+ account_id = DBSql.getString("select ACCOUNT_ID from BO_EU_DNCTT_CONTRACT where ID=?", new Object[]{cost.getString("CONTRACT_ID")});
|
|
|
+ if (StringUtils.isNotBlank(account_id)) {
|
|
|
+ DBSql.update("UPDATE BO_EU_DNCTT_CONTRACT_COST SET ACCOUNT_ID=? WHERE ID=?", new Object[]{account_id, cost.getString("ID")});
|
|
|
+ PURCHASE_ACCOUNT_ID.add(account_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String PRODUCT_ID = cost.getString("PRODUCT_ID");
|
|
|
+ String vendor_id = DBSql.getString("select VENDOR_ACCOUNT_ID from BO_EU_DNIVT_PRODUCT_VENDOR where PRODUCT_ID=? or PRODUCT_ID in (select BINDID FROM BO_EU_DNIVT_PRODUCT WHERE ID=?)", new Object[]{PRODUCT_ID, PRODUCT_ID});
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(vendor_id)) {
|
|
|
+ VENDOR_ACCOUNT_ID.add(vendor_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (PURCHASE_ACCOUNT_ID.size() == 1)
|
|
|
+ purchaseOrder.set("PURCHASE_ACCOUNT_ID", PURCHASE_ACCOUNT_ID.stream().findFirst());
|
|
|
+ if (VENDOR_ACCOUNT_ID.size() == 1)
|
|
|
+ purchaseOrder.set("VENDOR_ACCOUNT_ID", VENDOR_ACCOUNT_ID.stream().findFirst());
|
|
|
+
|
|
|
|
|
|
SDK.getBOAPI().createDataBO("BO_EU_DNIVT_ORDER", purchaseOrder, uc, conn);
|
|
|
//采购产品
|
|
|
@@ -648,6 +660,8 @@ public class ivtOrderController {
|
|
|
|
|
|
//采购数量需要扣除拣货数量
|
|
|
int purchase_quantity = cost.getInt("QUANTITY") - DBSql.getInt("select sum(QUANTITY) AS QU from BO_EU_DNCTT_CONTRACT_COST_PRODUCT where CONTRACT_COST_ID=? and CLOSED=0", new Object[]{cost.getString("ID")});
|
|
|
+ if (purchase_quantity <= 0)
|
|
|
+ continue;
|
|
|
|
|
|
purchaseOrderProduct.set("PURCHASE_ACCOUNT_ID", cost.getString("ACCOUNT_ID"));
|
|
|
purchaseOrderProduct.set("NAME", cost.getString("NAME"));
|
|
|
@@ -698,4 +712,18 @@ public class ivtOrderController {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_FORMAT);
|
|
|
return sdf.format(new Date());
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改采购订单状态
|
|
|
+ * @param uc
|
|
|
+ * @param orderId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Mapping("com.awspaas.user.apps.donenow_ivt.updateOrderStatus")
|
|
|
+ public ResponseObject updateOrderStatus(UserContext uc, String orderId) {
|
|
|
+ formStatusCache cache = formStatusCache.getInstance();
|
|
|
+ cache.put(orderId, new Date());
|
|
|
+ return ResponseObject.newOkResponse();
|
|
|
+ }
|
|
|
+
|
|
|
}
|