更新GPS牌照存入合同ID
This commit is contained in:
parent
3dbe907db3
commit
d15e517cbb
@ -12,7 +12,7 @@
|
||||
dwTemp.genHTMLObjectWindow("");
|
||||
String sButtons[][] = {
|
||||
{"true","All","Button","新增","新增","newRecord()","","","",""},
|
||||
{"true","All","Button","ÏêÇé","ÏêÇé","viewAndEdit()","","","",""},
|
||||
{"true","All","Button","ÐÞ¸Ä","ÐÞ¸Ä","viewAndEdit()","","","","btn_icon_edit"},
|
||||
{"true","","Button","删除","删除","if(confirm('确实要删除吗?'))as_delete(0)","","","","btn_icon_delete",""},
|
||||
{"true","All","Button","导入Excel","导入Excel","importExcel()","","","","btn_icon_import"},
|
||||
{"true","","Button","牌照模版下载","牌照模版下载","LicensePlateDownload()","","","","btn_icon_down",""},
|
||||
|
||||
@ -7,6 +7,10 @@
|
||||
*/
|
||||
String sPrevUrl = CurPage.getParameter("ID");
|
||||
//if(sPrevUrl == null) sPrevUrl = "";
|
||||
String inputuserid = CurUser.getUserID();
|
||||
String inputusername = CurUser.getUserName();
|
||||
String inputorgid = CurOrg.getOrgID();
|
||||
String inputorgname = CurOrg.getOrgName();
|
||||
|
||||
String sTempletNo = "LB_CAR_LICENSE_PLATE_INFO_Info";//--Ä£°åºÅ--
|
||||
ASObjectModel doTemp = new ASObjectModel(sTempletNo);
|
||||
@ -23,6 +27,39 @@
|
||||
/* sButtonPosition = "south"; */
|
||||
%><%@ include file="/Frame/resources/include/ui/include_info.jspf"%>
|
||||
<script type="text/javascript">
|
||||
|
||||
window.onload=function(){
|
||||
setItemValue(0,getRow(),"INPUTUSERID","<%=inputusername%>");
|
||||
setItemValue(0,getRow(),"UPDATEUSERID","<%=inputusername%>");
|
||||
setItemValue(0,getRow(),"INPUTORGID","<%=inputorgname%>");
|
||||
setItemValue(0,getRow(),"UPDATEORGID","<%=inputorgname%>");
|
||||
var date = new Date();
|
||||
var updatetime = date.toJSON().substring(0,10).replace(/-/g,"/")+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
|
||||
var inputtime = date.toJSON().substring(0,10).replace(/-/g,"/")+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
|
||||
var inputtimes = getItemValue(0,getRow(),"INPUTTIME");
|
||||
if(inputtimes==null||inputtimes==""){
|
||||
setItemValue(0,getRow(),"INPUTTIME",inputtime);
|
||||
}
|
||||
setItemValue(0,getRow(),"UPDATETIME",updatetime);
|
||||
}
|
||||
//请选择合同编号
|
||||
function selectContractNo(){
|
||||
AsDialog.OpenSelector("SelectContractNo","","dialogWidth=" + parseInt(window.screen.width * 0.6) + "px dialogHeight=" + parseInt(window.screen.height * 0.6) + "px",function(sReturn){
|
||||
if(!sReturn||sReturn=="_CANCEL_"){
|
||||
alert(getHtmlMessage('1'));//请选择一条信息!
|
||||
return;
|
||||
}
|
||||
|
||||
sReturn = sReturn.split("@");//"@"表示了向页面添加数据时的连续性
|
||||
|
||||
setItemValue(0,getRow(),"CONTRACT_ID",sReturn[0]);//向页面的框中添加数据
|
||||
setItemValue(0,getRow(),"contract_no",sReturn[1]);
|
||||
setItemValue(0,getRow(),"FRAME_NUMBER",sReturn[2]);
|
||||
setItemValue(0,getRow(),"PLATE_NUMBER",sReturn[3]);
|
||||
setItemValue(0,getRow(),"PLATETIME",sReturn[4]);
|
||||
},"请选择合同编号");
|
||||
}
|
||||
|
||||
function save(){
|
||||
as_save("myiframe0","returnList()");
|
||||
}
|
||||
|
||||
@ -18,6 +18,22 @@
|
||||
};
|
||||
%><%@include file="/Frame/resources/include/ui/include_info.jspf"%>
|
||||
<script type="text/javascript">
|
||||
//请选择合同编号
|
||||
function SelectContractGps(){
|
||||
AsDialog.OpenSelector("SelectContractGps","","dialogWidth=" + parseInt(window.screen.width * 0.5) + "px dialogHeight=" + parseInt(window.screen.height * 0.6) + "px",function(sReturn){
|
||||
if(!sReturn||sReturn=="_CANCEL_"){
|
||||
alert(getHtmlMessage('1'));//请选择一条信息!
|
||||
return;
|
||||
}
|
||||
|
||||
sReturn = sReturn.split("@");//"@"表示了向页面添加数据时的连续性
|
||||
|
||||
setItemValue(0,getRow(),"CONTRACT_ID",sReturn[0]);//向页面的框中添加数据
|
||||
setItemValue(0,getRow(),"contract_no",sReturn[1]);
|
||||
setItemValue(0,getRow(),"FRAME_NUMBER",sReturn[3]);
|
||||
setItemValue(0,getRow(),"PLATE_NUMBER",sReturn[4]);
|
||||
},"请选择合同编号");
|
||||
}
|
||||
function saveRecord(){
|
||||
as_save("myiframe0");
|
||||
}
|
||||
|
||||
@ -22,25 +22,25 @@ public class LBCarLicenseCallback extends BaseImportExcelCallBack{
|
||||
Map<String, String> model, Integer rowIndex, JBOTransaction tx,
|
||||
Transaction Sqlca) throws Exception {
|
||||
//获取Excel表中的合同编号(excel表中的字段为contract_id,实际输入的内容为合同编号)
|
||||
String contractNumber = importObject.getAttribute("contract_id").getString();
|
||||
String contractNo = importObject.getAttribute("contract_no").getString();
|
||||
|
||||
//jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO
|
||||
//根据合同编号获取该合同信息
|
||||
BizObject contractInfo=JBOFactory.createBizObjectQuery(LB_CONTRACT_INFO.CLASS_NAME,"contract_number=:contractNumber").setParameter("contractNumber", contractNumber).getSingleResult(false);
|
||||
BizObject contractInfo=JBOFactory.createBizObjectQuery(LB_CONTRACT_INFO.CLASS_NAME,"contract_no=:contractNo").setParameter("contractNo", contractNo).getSingleResult(false);
|
||||
if(contractInfo != null){
|
||||
//获取该合同信息的合同id
|
||||
String contractId = contractInfo.getAttribute("ID").toString();
|
||||
//判断该车辆信息表中是否已经存在该合同,如果不存在则可以新增
|
||||
BizObject carLicenseInfo=JBOFactory.createBizObjectQuery(LB_CAR_LICENSE_PLATE_INFO.CLASS_NAME,"CONTRACT_ID=:contractId").setParameter("contractId", contractId).getSingleResult(false);
|
||||
BizObject carLicenseInfo=JBOFactory.createBizObjectQuery(LB_CAR_LICENSE_PLATE_INFO.CLASS_NAME,"CONTRACT_ID=:contractId").setParameter("contractId", contractId).getSingleResult(true);
|
||||
if(carLicenseInfo==null){
|
||||
BizObjectManager carLicenseManager =JBOFactory.getBizObjectManager(LB_CAR_LICENSE_PLATE_INFO.CLASS_NAME);
|
||||
importObject.setAttributeValue("contract_id",contractId);
|
||||
/*BizObjectManager carLicenseManager =JBOFactory.getBizObjectManager(LB_CAR_LICENSE_PLATE_INFO.CLASS_NAME);
|
||||
BizObject carLicensePlate=carLicenseManager.newObject();
|
||||
carLicensePlate.setAttributeValue("CONTRACT_ID", contractId);
|
||||
carLicensePlate.setAttributeValue("PLATE_STATUS", importObject.getAttribute("plate_status").getString());
|
||||
carLicensePlate.setAttributeValue("FRAME_NUMBER", importObject.getAttribute("frame_number").getString());
|
||||
carLicensePlate.setAttributeValue("PLATE_NUMBER", importObject.getAttribute("plate_number").getString());
|
||||
carLicensePlate.setAttributeValue("PLATETIME", importObject.getAttribute("platetime").getString());
|
||||
carLicenseManager.saveObject(carLicensePlate);
|
||||
carLicenseManager.saveObject(carLicensePlate);*/
|
||||
}else{
|
||||
throw new BusinessException("该合同编号已拥有车辆");
|
||||
}
|
||||
|
||||
@ -3,16 +3,173 @@ package com.tenwa.officetempalte.importcallback.impl;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO;
|
||||
import jbo.com.tenwa.lease.comm.LB_REGISTER_GPS_INFO;
|
||||
|
||||
import com.amarsoft.are.jbo.BizObject;
|
||||
import com.amarsoft.are.jbo.JBOFactory;
|
||||
import com.amarsoft.are.jbo.JBOTransaction;
|
||||
import com.amarsoft.awe.util.Transaction;
|
||||
import com.amarsoft.context.ASUser;
|
||||
import com.tenwa.comm.exception.BusinessException;
|
||||
|
||||
public class LBRegisterGpsCallBack extends BaseImportExcelCallBack{
|
||||
@Override
|
||||
public void run(ASUser CurUser, BizObject importObject,
|
||||
Map<String, String> model, Integer rowIndex, JBOTransaction tx,
|
||||
Transaction Sqlca) throws Exception {
|
||||
|
||||
//获取Excel表中的合同编号(excel表中的字段为contract_id,实际输入的内容为合同编号)
|
||||
String contractNo = importObject.getAttribute("contract_no").getString();
|
||||
|
||||
//jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO
|
||||
//根据合同编号获取该合同信息
|
||||
BizObject contractInfo=JBOFactory.createBizObjectQuery(LB_CONTRACT_INFO.CLASS_NAME,"contract_no=:contractNo").setParameter("contractNo", contractNo).getSingleResult(false);
|
||||
if(contractInfo != null){
|
||||
//获取该合同信息的合同id
|
||||
String contractId = contractInfo.getAttribute("ID").toString();
|
||||
//判断该车辆信息表中是否已经存在该合同,如果不存在则可以新增
|
||||
BizObject carLicenseInfo=JBOFactory.createBizObjectQuery(LB_REGISTER_GPS_INFO.CLASS_NAME,"CONTRACT_ID=:contractId").setParameter("contractId", contractId).getSingleResult(true);
|
||||
if(carLicenseInfo==null){
|
||||
importObject.setAttributeValue("contract_id",contractId);
|
||||
}else{
|
||||
throw new BusinessException("该合同编号已拥有车辆");
|
||||
}
|
||||
|
||||
}else{
|
||||
throw new BusinessException("不存在该合同编号");
|
||||
}
|
||||
|
||||
//将yyyy-mm-dd这种日期格式改为yyyy/mm/dd
|
||||
String stores_day=importObject.getAttribute("stores_day").toString();
|
||||
// 如果是8位 20000101
|
||||
if(stores_day.indexOf("/") != -1){
|
||||
String[] date = stores_day.split("/");
|
||||
stores_day = "";
|
||||
for(String d:date){
|
||||
if(d.length() == 1){
|
||||
d = "0"+d;
|
||||
}
|
||||
stores_day += d+"/";
|
||||
}
|
||||
stores_day = stores_day.substring(0,stores_day.length()-1);
|
||||
}else if(stores_day.length()==8){
|
||||
StringBuffer sb1=new StringBuffer(stores_day);
|
||||
// 在3位置插入"/"
|
||||
String s1=sb1.insert(4,"/").toString(); // 2000/0101
|
||||
StringBuffer sb2=new StringBuffer(s1);
|
||||
stores_day=sb2.insert(7,"/").toString(); // 2000/01/01
|
||||
}else if(stores_day.contains("-")){
|
||||
stores_day=stores_day.replaceAll("-", "/");
|
||||
}else if(stores_day.contains("年")&&stores_day.contains("月")&&stores_day.contains("日")){
|
||||
stores_day=stores_day.replaceAll("年", "/").replaceAll("月","/").replaceAll("日","");
|
||||
}
|
||||
String[] checkDate = stores_day.split("/");
|
||||
try{
|
||||
int year = Integer.parseInt(checkDate[0]);
|
||||
int month = Integer.parseInt(checkDate[1]);
|
||||
int day = Integer.parseInt(checkDate[2]);
|
||||
int num = 28;
|
||||
if(day <= 0){
|
||||
throw new RuntimeException("第"+(rowIndex+1)+"行日期不正确,不存在'"+day+"'这样的日期!");
|
||||
}
|
||||
String mes = "平年";
|
||||
if((year%4 == 0 && year%100 != 0) || year%400 == 0){
|
||||
num = 29;
|
||||
mes = "闰年";
|
||||
}
|
||||
switch(month){
|
||||
case 1:case 3:case 5:case 7:case 8:case 10:case 12:
|
||||
if(day > 31 || day <= 0){
|
||||
throw new RuntimeException("第"+(rowIndex+1)+"行日期不正确,"+month+"月份没有"+day+"天!");
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(day > num || day <=0){
|
||||
throw new RuntimeException("第"+(rowIndex+1)+"行日期不正确,"+mes+month+"月份没有"+day+"天!");
|
||||
}
|
||||
break;
|
||||
case 4:case 6:case 9:case 11:
|
||||
if(day > 30 || day <=0){
|
||||
throw new RuntimeException("第"+(rowIndex+1)+"行日期不正确,"+month+"月份没有"+day+"天!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("第"+(rowIndex+1)+"行月份错误,没有'"+month+"'月份!");
|
||||
}
|
||||
}catch(NumberFormatException e){
|
||||
throw new BusinessException("第"+(rowIndex+1)+"行日期格式不正确!");
|
||||
}catch(RuntimeException e){
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
|
||||
importObject.setAttributeValue("stores_day", stores_day);
|
||||
|
||||
//将yyyy-mm-dd这种日期格式改为yyyy/mm/dd
|
||||
String exception_day=importObject.getAttribute("exception_day").toString();
|
||||
// 如果是8位 20000101
|
||||
if(exception_day.indexOf("/") != -1){
|
||||
String[] date = exception_day.split("/");
|
||||
exception_day = "";
|
||||
for(String d:date){
|
||||
if(d.length() == 1){
|
||||
d = "0"+d;
|
||||
}
|
||||
exception_day += d+"/";
|
||||
}
|
||||
exception_day = exception_day.substring(0,exception_day.length()-1);
|
||||
}else if(exception_day.length()==8){
|
||||
StringBuffer sb1=new StringBuffer(exception_day);
|
||||
// 在3位置插入"/"
|
||||
String s1=sb1.insert(4,"/").toString(); // 2000/0101
|
||||
StringBuffer sb2=new StringBuffer(s1);
|
||||
exception_day=sb2.insert(7,"/").toString(); // 2000/01/01
|
||||
}else if(exception_day.contains("-")){
|
||||
exception_day=exception_day.replaceAll("-", "/");
|
||||
}else if(exception_day.contains("年")&&exception_day.contains("月")&&exception_day.contains("日")){
|
||||
exception_day=exception_day.replaceAll("年", "/").replaceAll("月","/").replaceAll("日","");
|
||||
}
|
||||
String[] checkDates = stores_day.split("/");
|
||||
try{
|
||||
int year = Integer.parseInt(checkDates[0]);
|
||||
int month = Integer.parseInt(checkDates[1]);
|
||||
int day = Integer.parseInt(checkDates[2]);
|
||||
int num = 28;
|
||||
if(day <= 0){
|
||||
throw new RuntimeException("第"+(rowIndex+1)+"行日期不正确,不存在'"+day+"'这样的日期!");
|
||||
}
|
||||
String mes = "平年";
|
||||
if((year%4 == 0 && year%100 != 0) || year%400 == 0){
|
||||
num = 29;
|
||||
mes = "闰年";
|
||||
}
|
||||
switch(month){
|
||||
case 1:case 3:case 5:case 7:case 8:case 10:case 12:
|
||||
if(day > 31 || day <= 0){
|
||||
throw new RuntimeException("第"+(rowIndex+1)+"行日期不正确,"+month+"月份没有"+day+"天!");
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(day > num || day <=0){
|
||||
throw new RuntimeException("第"+(rowIndex+1)+"行日期不正确,"+mes+month+"月份没有"+day+"天!");
|
||||
}
|
||||
break;
|
||||
case 4:case 6:case 9:case 11:
|
||||
if(day > 30 || day <=0){
|
||||
throw new RuntimeException("第"+(rowIndex+1)+"行日期不正确,"+month+"月份没有"+day+"天!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("第"+(rowIndex+1)+"行月份错误,没有'"+month+"'月份!");
|
||||
}
|
||||
}catch(NumberFormatException e){
|
||||
throw new BusinessException("第"+(rowIndex+1)+"行日期格式不正确!");
|
||||
}catch(RuntimeException e){
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
|
||||
importObject.setAttributeValue("exception_day", exception_day);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user