1.基本功能
1、页面上有待配货盘、待配运力及已配载货盘3个表格,这3个表格之间没有关联,待配货盘和待配运力2个表格分别带有查询条件,是单独查询各自的数据,数据查询出来之后选中一笔待配货盘再选中一笔待配运力然后点击配运力按钮,把数据保存到已配载货盘表格里面显示。具体见下图:
2.配置方法
1、因为3张表之间没有关联关系,所以先虚拟一个视图作为主表,然后把这3张表都当做子表创建关系。这样就可以通过经典案例向导快速创建页面,页面生成出来后待配货盘及待配运力上的查询按钮和重置按钮以及配运力按钮通过自定义按钮来实现逻辑。
3.常用扩展
1、平台配置后还需要手工进行扩展,其中查询按钮的代码参考如下:
$scope.queryOpmCapacityWaitStowageNjp = function()
{
var gridVerifyArr = [ { scope:"$scope" ,grid:["opmCapacityWaitStowageNjp"] }, { scope:"$scope" ,grid:["opmCargoHasStowageNjp"] ,loadOneToOneSubBoData:false } ];
_this.gridVerify({boName:"OpmCargoWaiStowageNjp",scope:$scope,settings:gridVerifyArr});
$scope.getOpmCapacityWaitStowageNjpPages();
$scope.opmCapacityWaitStowageNjpGrid.$$currentSelKey = undefined;
if($scope._pageState) $scope._pageState.resetDataState();
};
```30
2、重置按钮的代码参考如下:
</code></pre>
$scope.reset2OpmCapacityWaitStowageNjp = function(){
$scope.search2={};
$scope.search.capacityNo='';
$scope.search2.tradeType='';
//capacityCustomer
$scope.search.capacityCustomerTxt='';
$scope.CapacityCustomerNameOpmCargoWaiStowageNjpSSelectedRow = {};
$scope.search.capacityCustomerNameTxt='';
$scope.search.capacityCustomer='';
$scope.search2.opType='P';
//portFrom
$scope.search2.portFromTxt='';
$scope.PortFromNameOpmCargoWaiStowageNjpSSelectedRow = {};
$scope.search2.portFromNameTxt='';
$scope.search2.portFrom='';
//portTo
$scope.search2.portToTxt='';
$scope.PortToNameOpmCargoWaiStowageNjpSSelectedRow = {};
$scope.search2.portToNameTxt='';
$scope.search2.portTo='';
$scope.search.vesselCode='';
$scope.search.vesselCodeTxt='';
$scope.VesselNameOpmCargoWaiStowageNjpSSelectedRow = {};
$scope.search.vesselNameTxt='';
$scope.search.voyageNo='';
$scope.search2.est = {};
//$scope.search.est.type = "T";
$scope.search2.est.start='';
$scope.search2.est.end='';
$scope.search.vesselCodeTxt='';
$scope.VesselNameOpmCargoWaiStowageNjpSSelectedRow = {};
<pre><code> }
</code></pre>
<pre><code>3、配运力按钮前台代码参考如下:
</code></pre>
$scope.stowageOpmCargoWaiStowageNjp = function () {
var flag2 = 0;
var capacityCustomer = "";
angular.forEach($scope.opmCargoWaiStowageNjpGrid.getCheckedRows(), function (data, index) {
if(data.capacityCustomer){
if(capacityCustomer&&capacityCustomer!=data.capacityCustomer){
flag2 = 1;
}else{
capacityCustomer= data.capacityCustomer;
}
<pre><code> }
});
if(flag2==1){
GillionMsg.alert("提示", "勾选记录中存在不一样的指定运力商");
return;
}
GillionMsg.confirm('提示', '是否需要配载勾选的数据?', function (btn) {
if (btn) {
var checkCargoWait = $scope.opmCargoWaiStowageNjpCheckedRows;
var checkCapacity = $scope.opmCapacityWaitStowageNjpCheckedRows;
var checkCargoHas = $scope.opmCargoHasStowageNjpCheckedRows;
var cargoIds = Arrays.extract(checkCargoWait, 'cargoInfoId').join(',');
var capacityIds = Arrays.extract(checkCapacity, 'opmCapacityId').join(',');
var shipCargoIds = Arrays.extract(checkCargoHas, 'cargoInfoId').join(',');
var resultIds = "";
if (cargoIds.length > 0) {
resultIds = cargoIds + "," + shipCargoIds;
} else {
resultIds = shipCargoIds;
}
if (resultIds.length > 0 && resultIds.length < 50) {
resultIds = resultIds.substring(0, resultIds.length - 1);
}
if (!cargoIds || cargoIds.length == 0) {
GillionMsg.alert("提示", "请至少勾选一条货盘记录");
return;
}
if (!capacityIds || capacityIds.length == 0 || capacityIds.length > 40) {
GillionMsg.alert("提示", "有且只能勾选一条运力记录");
return;
}
var checkOpmCapacity = checkCapacity[0];
var flag = 0;
var cargoTeu = 0;
var cargoWeight = 0;
var capacityTeu = 0;
var capacityWeight = 0;
var capCustomer = checkOpmCapacity.capacityCustomer;
var capacityNo = checkOpmCapacity.capacityNo;
var capacityTradeType = checkOpmCapacity.tradeType;//待配运力内外贸属性
var capacityPortFromName = checkOpmCapacity.portFrom;//起运港/码头名称
var capacityPortToName = checkOpmCapacity.portTo;//目的港/码头名称
var capacityEst = checkOpmCapacity.est;//干线船最早开航时间
capacityTeu = checkOpmCapacity.teu ? checkOpmCapacity.teu : 0;
capacityWeight = checkOpmCapacity.totalWeight ? checkOpmCapacity.totalWeight : 0;
//如果有指定运营商则必须与勾选的运力商符合
var k=0;
var tempPortFrom ="";
var tempPortTo ="";
angular.forEach(checkCargoWait, function (data, index) {
cargoTeu = Number(cargoTeu) + Number(data.teu ? data.teu : "0");
cargoWeight = Number(cargoWeight) + Number(data.totalWeight ? data.totalWeight : "0");
if (data.dangerTeu || data.reeferTeu || data.oogTeu) {
flag = 1;
}
var carCustomer = data.capacityCustomer;
if (carCustomer && carCustomer != capCustomer) {
flag = 2;
}
var cargoTradeType = data.tradeType;
if(capacityTradeType!='W'&&cargoTradeType!='W'){
if(cargoTradeType&&capacityTradeType&&cargoTradeType!=capacityTradeType){
flag = 3;
}
}
var cargoPortFromName = data.portFrom;//起运港/码头名称
var cargoPortToName = data.portTo;//目的港/码头名称
if(capacityPortFromName&&cargoPortFromName){
if(capacityPortFromName!=cargoPortFromName){
flag = 4;
}
}
var cargoEst=data.est;//预计抵达目的港时间
if(capacityEst&&cargoEst){
if(capacityEst>cargoEst){
flag = 5;
}
}
if(k==0){
tempPortFrom = cargoPortFromName;
tempPortTo = cargoPortToName;
}else{
if(tempPortFrom != cargoPortFromName){
flag = 6;
}
if(tempPortTo != cargoPortToName){
flag = 7;
}
}
k=1;
});
if (flag == 2) {
GillionMsg.alert("提示", "勾选的货盘的指定运力商和运力的运力商不符合");
return;
}
if (flag == 3) {
GillionMsg.alert("提示", "待配货盘内外贸属性与待配运力的内外贸属性一致才能配载");
return;
}
if (flag == 4) {
GillionMsg.alert("提示", "待配货盘的起运港/码头名称或目的港/码头名称与待配运力的起运港/码头名称或目的港/码头名称一致才能配载");
return;
}
if (flag == 5) {
GillionMsg.alert("提示", "待配货盘的前程预计抵港时间要早于待配运力的预计开航时间");
return;
}
if (flag2 == 6) {
GillionMsg.alert("提示", "勾选的待配货盘的起运港/码头需要一致");
return;
}
if (flag2 == 7) {
GillionMsg.alert("提示", "勾选的待配货盘的目的港/码头需要一致");
return;
}
if (capacityTeu < cargoTeu) {
GillionMsg.alert("提示", "剩余舱位数不足");
return;
}
if (capacityWeight < cargoWeight) {
GillionMsg.alert("提示", "剩余总重量不足");
return;
}
var param = {};
param.cargoIds = cargoIds;
param.capacityIds = capacityIds;
param.capacityCustomer = capCustomer;
var opmCargoInfoCargonStowageAllcotes = $scope.opmCargoHasStowageNjps;
var pushDate = [];
angular.forEach($scope.opmCargoWaiStowageNjps, function (data, index) {
var id = data.cargoInfoId;
if (cargoIds.indexOf(id) == -1) {
pushDate.push(data);
} else {
data.capacityNo = capacityNo;
data.cargoStatus = "3";
opmCargoInfoCargonStowageAllcotes.push(data);
}
});
if (flag == 1) {
GillionMsg.confirm(null, '货盘中存在特种箱,请与选择承运的运力方确认是否可承运特种箱?', function (btn) {
if (btn) {
var tip = layer.load(0, {shade: false});
$http.post($config.ctx + '/opmCargoWaiStowageNjp/shipping', param).success(function (data) {
layer.close(tip);
if (data.success != undefined && data.success == true) {
if (data.resultMap) {
if (data.resultMap.flag == 1) {
$scope.opmCapacityWaitStowageNjpGrid.loadData([]);//推荐运力
$scope.opmCargoWaiStowageNjpGrid.loadData(pushDate);//待配货盘
$scope.opmCargoHasStowageNjpGrid.loadData(opmCargoInfoCargonStowageAllcotes);//已配货盘
$scope.opmCargoHasStowageNjps = opmCargoInfoCargonStowageAllcotes;
GillionMsg.alert("提示", data.resultMap.msg);
return;
}
if (data.resultMap.flag == 0) {
GillionMsg.alert("提示", data.resultMap.msg);
return;
}
}
}
});
}
});
} else {
var tip = layer.load(0, {shade: false});
$http.post($config.ctx + '/opmCargoWaiStowageNjp/shipping', param).success(function (data) {
layer.close(tip);
if (data.success != undefined && data.success == true) {
if (data.resultMap) {
if (data.resultMap.flag == 1) {
$scope.opmCapacityWaitStowageNjpGrid.loadData([]);//推荐运力
$scope.opmCargoWaiStowageNjpGrid.loadData(pushDate);//待配货盘
$scope.opmCargoHasStowageNjpGrid.loadData(opmCargoInfoCargonStowageAllcotes);//已配货盘
$scope.opmCargoHasStowageNjps = opmCargoInfoCargonStowageAllcotes;
}
if (data.resultMap.flag == 0) {
GillionMsg.alert("提示", data.resultMap.msg);
return;
}
}
}
});
}
}
}
);
}
</code></pre>
<pre><code>4、配运力按钮后台代码参考如下:
1)扩展控制器代码OpmCargoWaiStowageNjpExtController.java
</code></pre>
/**
* 匹配运力
*
* @param params
* @param response
* @throws Exception
*/
@RequestMapping(value="opmCargoWaiStowageNjp/shipping")
public void shipping(@RequestBody String params, HttpServletResponse response) throws Exception
{
//
Map<String, String> resultMap = opmCargoWaiStowageNjpExtService.shipping(params);
ResponseUtils.flushSuccess(response, "传值成功!", "resultMap", resultMap);
}
<pre><code>2)扩展接口类代码OpmCargoWaiStowageNjpExtService.java
</code></pre>
/**
* 匹配运力
*
* @param params
* @return
*/
public Map<String, String> shipping(String params) throws SQLException;
<pre><code>3)扩展实现类代码OpmCargoWaiStowageNjpExtServiceImpl.java
</code></pre>
/**
*
* @param params
* @return
*/
@Transactional
@Override
public Map<String, String> shipping(String params) throws SQLException {
JSONObject jsonObject = JSONObject.fromObject(params);
String cargoIds = jsonObject.getString("cargoIds");//待配载ids
String capacityIds = jsonObject.getString("capacityIds");//推荐运力ids
Map<String, String> resultMap = new HashMap<String, String>();
<pre><code> List<String> parList = new ArrayList<String>();
parList.add(cargoIds);
parList.add(capacityIds);
parList.add(GuiUtil.getCurrentUserCode());
parList.add("P");//平台配载传入P
List<Map<String, Object>> resultList = GuiUtil.queryProcedure("SP_OPM_ALLOCATE_SHIP", parList);
if (resultList.size() > 0) {
Map<String, Object> res = resultList.get(0);
resultMap.put("flag", GuiUtil.null2Str(res.get("FLAG")));
resultMap.put("msg", GuiUtil.null2Str(res.get("MSG")));
resultMap.put("ids", cargoIds);
if ("1".equals(res.get("FLAG"))) {
//将运力消息插入代办消息
msgBusinessStatusExtService.addMsgBusinessStatus("10", "CAPACITY", capacityIds, "");
}
}
return resultMap;
}
</code></pre>
```
3.常用扩展
4.版本更新