InoviceController.groovy
上传用户:steveyhw
上传日期:2019-05-13
资源大小:307k
文件大小:8k
- import java.text.SimpleDateFormat
- class InoviceController {
-
- def index = { redirect(action:list,params:params) }
- // the delete, save and update actions only accept POST requests
- def allowedMethods = [delete:'POST', save:'POST', update:'POST']
- def list = {
- def df = new SimpleDateFormat('yyyy-MM-dd')
- if(!params.max) params.max = '2'
- if(!params.sort)params.sort = 'id'
- if(!params.offset)params.offset = '0'
- if(!params.order)params.order = 'asc'
- if(!params._inoBuyname)params._inoBuyname = ''
- if(!params._inoBuycompany)params._inoBuycompany = ''
- if(!params._inoCargoname)params._inoCargoname = ''
-
- java.util.Date _inoLastchangefrom =null
- java.util.Date _inoLastchangeto =null
- if(!params._inoLastchangefrom){
- _inoLastchangefrom = df.parse('1970-01-01')
- }else{_inoLastchangefrom = df.parse(params._inoLastchangefrom)}
- if(!params._inoLastchangeto){
- _inoLastchangeto = new Date()
- }else{_inoLastchangeto = df.parse(params._inoLastchangeto)}
- if(!params._inoDel)params._inoDel = null
- println '_inoDel :'+params._inoDel
- def _inoDelState = '0'
- if(params._inoDel == 'on'){
- _inoDelState = ''
- } else if(params._inoDel == null){ _inoDelState = '0' }
- println '_inoDelState :'+_inoDelState
- println params
- def results=null
- println 'between '+_inoLastchangefrom+' and '+_inoLastchangeto
- results = Inovice.findAll("from Inovice i where str(i.inoBuyname) like :_inoBuyname and i.inoBuycompany like :_inoBuycompany and i.inoCargoname like :_inoCargoname and i.inoLastchange between :_inoLastchangefrom and :_inoLastchangeto and i.inoDel like :_inoDelState order by ${params.sort} ${params.order} ",
- [_inoBuyname:'%'+params._inoBuyname+'%',_inoBuycompany:'%'+params._inoBuycompany+'%',_inoCargoname:'%'+params._inoCargoname+'%',_inoLastchangefrom:_inoLastchangefrom,_inoLastchangeto:_inoLastchangeto,_inoDelState:'%'+_inoDelState+'%'],[max:Integer.parseInt(params.max),offset:Integer.parseInt(params.offset)])
- params.count=Inovice.findAll("from Inovice i where str(i.inoBuyname) like :_inoBuyname and i.inoBuycompany like :_inoBuycompany and i.inoCargoname like :_inoCargoname and i.inoLastchange between :_inoLastchangefrom and :_inoLastchangeto and i.inoDel like :_inoDelState order by ${params.sort} ${params.order} ",
- [_inoBuyname:'%'+params._inoBuyname+'%',_inoBuycompany:'%'+params._inoBuycompany+'%',_inoCargoname:'%'+params._inoCargoname+'%',_inoLastchangefrom:_inoLastchangefrom,_inoLastchangeto:_inoLastchangeto,_inoDelState:'%'+_inoDelState+'%']).size()
- println 'params._inoDel '+params._inoDel
- render(view:'list',model:[inoviceList:results])
- }
- def show = {
- def inovice = Inovice.get( params.id )
- if(!inovice) {
- flash.message = "inovice.not.found"
- flash.args = [params.id]
- flash.defaultMessage = "Inovice not found with id ${params.id}"
- redirect(action:list,params:[_inoBuyname:params._inoBuyname,_inoBuycompany:params._inoBuycompany,_inoCargoname:params._inoCargoname,_inoLastchangefrom:params._inoLastchangefrom,_inoLastchangeto:params._inoLastchangeto,_inoDel:params._inoDel,max:params.max,sort:params.sort,offset:params.offset,order:params.order])
- }
- else { return [ inovice : inovice ] }
- }
- def delete = {
- def inovice = Inovice.get( params.id )
- if(inovice) {
- //inovice.delete()
- inovice.inoDel = '1'
- inovice.inoLastchange = new Date()
- inovice.inoLastchanger = 'session'
- inovice.save()
- flash.message = "inovice.deleted"
- flash.args = [params.id]
- flash.defaultMessage = "Inovice ${params.id} deleted"
- redirect(action:list,params:[_inoBuyname:params._inoBuyname,_inoBuycompany:params._inoBuycompany,_inoCargoname:params._inoCargoname,_inoLastchangefrom:params._inoLastchangefrom,_inoLastchangeto:params._inoLastchangeto,_inoDel:params._inoDel,max:params.max,sort:params.sort,offset:params.offset,order:params.order])
- }
- else {
- flash.message = "inovice.not.found"
- flash.args = [params.id]
- flash.defaultMessage = "Inovice not found with id ${params.id}"
- redirect(action:list,params:[_inoBuyname:params._inoBuyname,_inoBuycompany:params._inoBuycompany,_inoCargoname:params._inoCargoname,_inoLastchangefrom:params._inoLastchangefrom,_inoLastchangeto:params._inoLastchangeto,_inoDel:params._inoDel,max:params.max,sort:params.sort,offset:params.offset,order:params.order])
- }
- }
- def edit = {
- def inovice = Inovice.get( params.id )
- if(!inovice) {
- flash.message = "inovice.not.found"
- flash.args = [params.id]
- flash.defaultMessage = "Inovice not found with id ${params.id}"
- redirect(action:list,params:[_inoBuyname:params._inoBuyname,_inoBuycompany:params._inoBuycompany,_inoCargoname:params._inoCargoname,_inoLastchangefrom:params._inoLastchangefrom,_inoLastchangeto:params._inoLastchangeto,_inoDel:params._inoDel,max:params.max,sort:params.sort,offset:params.offset,order:params.order])
- }
- else {
- return [ inovice : inovice ]
- }
- }
- def update = {
- def inovice = Inovice.get( params.id )
- if(inovice) {
- inovice.properties = params
- //�趨ɾ��״̬ �����˴���ʱ�� �����˸���ʱ��
- inovice.inoDel = '0'
- inovice.inoLastchanger = 'session'
- inovice.inoLastchange = new Date()
-
- if(!inovice.hasErrors() && inovice.save()) {
- flash.message = "inovice.updated"
- flash.args = [params.id]
- flash.defaultMessage = "Inovice ${params.id} updated"
- redirect(action:show,id:inovice.id,params:[_inoBuyname:params._inoBuyname,_inoBuycompany:params._inoBuycompany,_inoCargoname:params._inoCargoname,_inoLastchangefrom:params._inoLastchangefrom,_inoLastchangeto:params._inoLastchangeto,_inoDel:params._inoDel,max:params.max,sort:params.sort,offset:params.offset,order:params.order])
- }
- else {
- render(view:'edit',model:[inovice:inovice])
- }
- }
- else {
- flash.message = "inovice.not.found"
- flash.args = [params.id]
- flash.defaultMessage = "Inovice not found with id ${params.id}"
- redirect(action:edit,id:params.id,params:[_inoBuyname:params._inoBuyname,_inoBuycompany:params._inoBuycompany,_inoCargoname:params._inoCargoname,_inoLastchangefrom:params._inoLastchangefrom,_inoLastchangeto:params._inoLastchangeto,_inoDel:params._inoDel,max:params.max,sort:params.sort,offset:params.offset,order:params.order])
- }
- }
- def create = {
- def inovice = new Inovice()
- inovice.properties = params
- inovice.inoSellman = 'session'
- return ['inovice':inovice]
- }
- def save = {
- String inoid=Inovice.executeQuery("select max(i.inoId) from Inovice i ")[0]
- println inoid
- if(inoid=="null"||inoid==null){
- inoid = 'INO100000000'
- }else { inoid='INO'+(Integer.parseInt(inoid.substring(3,12))+1)}
- //def inotation = new inotation(params)
- def inovice = new Inovice(params)
- inovice.inoId = inoid //���ñ��
- //�趨ɾ��״̬ �����˴���ʱ�� �����˸���ʱ��
- inovice.inoDel = '0'
- inovice.inoCreater = 'session'
- inovice.inoCreatetime = new Date()
- inovice.inoLastchanger = 'session'
- inovice.inoLastchange = new Date()
-
- if(!inovice.hasErrors() && inovice.save()) {
- flash.message = "inovice.created"
- flash.args = ["${inovice.id}"]
- flash.defaultMessage = "Inovice ${inovice.id} created"
- redirect(action:show,id:inovice.id,params:[_inoBuyname:params._inoBuyname,_inoBuycompany:params._inoBuycompany,_inoCargoname:params._inoCargoname,_inoLastchangefrom:params._inoLastchangefrom,_inoLastchangeto:params._inoLastchangeto,_inoDel:params._inoDel,max:params.max,sort:params.sort,offset:params.offset,order:params.order])
- }
- else {
- render(view:'create',model:[inovice:inovice])
- }
- }
- }