| 
					
				 | 
			
			
				@@ -1,18 +1,29 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.platform.yijia.controller; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.google.gson.Gson; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.platform.yijia.param.request.LoginBody; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.platform.yijia.pojo.PayOrder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.platform.yijia.pojo.StationClassStructure; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.platform.yijia.pojo.StationClassesSummary; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.platform.yijia.pojo.SysUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.platform.yijia.service.IStationClassStructureService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.platform.yijia.service.IStationClassesSummaryService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.platform.yijia.service.PayOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.platform.yijia.service.PosMachineService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.platform.yijia.utils.CodeMsg; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.platform.yijia.utils.ResultData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Controller; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.web.bind.annotation.RequestBody; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.web.bind.annotation.RequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.web.bind.annotation.RequestMethod; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.web.bind.annotation.ResponseBody; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.web.bind.annotation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.text.DateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.text.ParseException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * <Title> PosMachineController </Title> 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -27,6 +38,15 @@ public class PosMachineController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private PosMachineService posMachineService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private IStationClassStructureService stationClassStructureService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private IStationClassesSummaryService stationClassesSummaryService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private PayOrderService payOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     //POS机端用户登录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @RequestMapping(value = "/loginPosMachine", method = RequestMethod.POST) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ResponseBody 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -36,15 +56,15 @@ public class PosMachineController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Gson gson =new Gson(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //返回结果集 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ResultData resultData = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if(loginBody.getUsername() !=null && loginBody.getPassword() !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            SysUser sysUser = posMachineService.selectUserByUserName(loginBody.getUsername()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(loginBody.getUserName() !=null && loginBody.getPassword() !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            SysUser sysUser = posMachineService.selectUserByUserName(loginBody.getUserName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if(sysUser !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 String password = sysUser.getPassword(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //密码加密判断已加密密码是否与真实密码相同 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 boolean matches = bCryptPasswordEncoder.matches(loginBody.getPassword(), password); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if(matches){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    resultData = ResultData.success(CodeMsg.SUCCESS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    resultData = ResultData.success(sysUser); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     resultData = ResultData.error(CodeMsg.PASSWORD_ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -54,4 +74,326 @@ public class PosMachineController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return gson.toJson(resultData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * pos机班结 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param stationClassStructure 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @throws ParseException 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @RequestMapping (value = "/posClassStructure", method = RequestMethod.POST) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Map posClassStructure (@RequestBody StationClassStructure stationClassStructure) throws ParseException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map map = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //获取当前班结油站 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Integer stationId=stationClassStructure.getStationId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //String stationName=stationClassStructure.getStationName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String username = stationClassStructure.getClassStructureMan(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //根据油站查询出油站是否班结过,班结过就需要查询上次班结的时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StationClassStructure classes =new StationClassStructure(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        classes.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //查询出上次班结,最后一条数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StationClassStructure sss =stationClassStructureService.selectStationClassStructureMax(classes); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String beginTime=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //当前时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Date date= new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StationClassStructure classesStructure =new StationClassStructure(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        classesStructure.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DateFormat dFormat = new SimpleDateFormat("yyyyMMdd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String no=dFormat.format(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        classesStructure.setLikeClassStructureNo(no); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //查询班结信息中本日班结次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StationClassStructure structure =stationClassStructureService.selectDistnctClassStructure(classesStructure); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(structure!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(structure.getNum()==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                no = no + "0"+1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                int num  = structure.getNum()+1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(num>0 && num<10){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    no = no + "0"+num; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    no = no +""+ num; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int i=0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(sss!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //获取上次班结时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            PayOrder order=new PayOrder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            order.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            order.setStatus("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            beginTime= dateFormat.format(sss.getClassStructureDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            order.setBeginTime(beginTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            order.setEndTime( dateFormat.format(date)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<PayOrder> list = payOrderService.selectPayOrderList(order); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for(PayOrder payOrder:list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                StationClassStructure stationclass =new StationClassStructure(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setStationId(payOrder.getStationId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setStationName(payOrder.getStationName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setClassStartDate(dateFormat.parse(beginTime)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setClassStructureMan(username); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setClassStructureNo(no); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setClassStructureDate(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setOrderNo(payOrder.getOrderNo()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setOilGun(payOrder.getOilGun()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setOilName(payOrder.getOilName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setConsumerId(payOrder.getConsumerId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setConsumer(payOrder.getConsumer()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setAmt(new BigDecimal(payOrder.getAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getReceivableAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setReceivableAmt(new BigDecimal(payOrder.getReceivableAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setReceivableAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getReceivedAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setReceivedAmt(new BigDecimal(payOrder.getReceivedAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setReceivedAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getDiscountAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDiscountAmt(new BigDecimal(payOrder.getDiscountAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDiscountAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getDiscountCouponAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDiscountCouponAmt(new BigDecimal(payOrder.getDiscountCouponAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDiscountCouponAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getWxAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setWxAmt(new BigDecimal(payOrder.getWxAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setWxAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getZfbAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setZfbAmt(new BigDecimal(payOrder.getZfbAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setZfbAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getPosAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setPosAmt(new BigDecimal(payOrder.getPosAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setPosAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getXjAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setXjAmt(new BigDecimal(payOrder.getXjAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setXjAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getDidiAppAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDidiAppAmt(new BigDecimal(payOrder.getDidiAppAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDidiAppAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getTyAppAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDidiAppAmt(new BigDecimal(payOrder.getTyAppAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDidiAppAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getOtherAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setOtherAmt(new BigDecimal(payOrder.getOtherAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setOtherAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getDzkAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDzkAmt(new BigDecimal(payOrder.getDzkAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDzkAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getMemberAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setMemberAmt(new BigDecimal(payOrder.getMemberAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setMemberAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setOrderLiters(new BigDecimal(payOrder.getOrderLiters())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setPayWay(payOrder.getPayWay()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setPayType(payOrder.getPayType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setPayDate(payOrder.getPayDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setOilPersonnel(payOrder.getOilPersonnel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setOrderType(payOrder.getOrderType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getPrintCount()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setPrintNum(payOrder.getPrintCount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setPrintNum(Integer.valueOf("0")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                i= stationClassStructureService.insertStationClassStructure(stationclass); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //初次班结 班结时间默认为当前时间,班结人username 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //根据班结时间查询订单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            PayOrder order=new PayOrder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            order.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            order.setEndTime(dateFormat.format(date)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<PayOrder> list = payOrderService.selectPayOrderList(order); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for(PayOrder payOrder:list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                StationClassStructure stationclass =new StationClassStructure(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setStationId(payOrder.getStationId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setStationName(payOrder.getStationName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setClassStructureMan(username); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setClassStructureDate(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setClassStructureNo(no); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setOrderNo(payOrder.getOrderNo()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setOilGun(payOrder.getOilGun()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setOilName(payOrder.getOilName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setConsumerId(payOrder.getConsumerId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setConsumer(payOrder.getConsumer()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setAmt(new BigDecimal(payOrder.getAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getReceivableAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setReceivableAmt(new BigDecimal(payOrder.getReceivableAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setReceivableAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getReceivedAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setReceivedAmt(new BigDecimal(payOrder.getReceivedAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setReceivedAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getDiscountAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDiscountAmt(new BigDecimal(payOrder.getDiscountAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDiscountAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getDiscountCouponAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDiscountCouponAmt(new BigDecimal(payOrder.getDiscountCouponAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDiscountCouponAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getWxAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setWxAmt(new BigDecimal(payOrder.getWxAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setWxAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getZfbAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setZfbAmt(new BigDecimal(payOrder.getZfbAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setZfbAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getPosAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setPosAmt(new BigDecimal(payOrder.getPosAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setPosAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getXjAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setXjAmt(new BigDecimal(payOrder.getXjAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setXjAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getDidiAppAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDidiAppAmt(new BigDecimal(payOrder.getDidiAppAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDidiAppAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getTyAppAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDidiAppAmt(new BigDecimal(payOrder.getTyAppAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDidiAppAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getOtherAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setOtherAmt(new BigDecimal(payOrder.getOtherAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setOtherAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getDzkAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDzkAmt(new BigDecimal(payOrder.getDzkAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setDzkAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getMemberAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setMemberAmt(new BigDecimal(payOrder.getMemberAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setMemberAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getOrderLiters() !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setOrderLiters(new BigDecimal(payOrder.getOrderLiters())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setOrderLiters(new BigDecimal(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setPayWay(payOrder.getPayWay()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setPayType(payOrder.getPayType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setPayDate(payOrder.getPayDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setOilPersonnel(payOrder.getOilPersonnel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationclass.setOrderType(payOrder.getOrderType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(payOrder.getPrintCount()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setPrintNum(payOrder.getPrintCount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    stationclass.setPrintNum(Integer.valueOf("0")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                i= stationClassStructureService.insertStationClassStructure(stationclass); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StationClassStructure scs =new StationClassStructure(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        scs.setClassStructureNo(no); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //汇总班结数据将汇总的数据插入到汇总数据中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StationClassStructure stationclass = stationClassStructureService.selectSummyClassStructure(scs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(stationclass!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            StationClassesSummary stationClassesSummary =new StationClassesSummary(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            stationClassesSummary.setClassesNo(stationclass.getClassStructureNo()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationclass.getClassStartDate()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationClassesSummary.setStartDate(stationclass.getClassStartDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationclass.getClassStructureDate()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationClassesSummary.setEndDate(stationclass.getClassStructureDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            stationClassesSummary.setStationName(stationclass.getStationName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationclass.getStationId()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationClassesSummary.setStationId(stationclass.getStationId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationclass.getNum()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationClassesSummary.setOrderNum(Integer.valueOf(stationclass.getNum())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationclass.getPrintNum()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationClassesSummary.setPrintNum(stationclass.getPrintNum()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationclass.getOrderLiters()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationClassesSummary.setSaleLiters(stationclass.getOrderLiters()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationclass.getAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationClassesSummary.setSaleAmt(stationclass.getAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationclass.getDzkAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationClassesSummary.setDzkAmt(stationclass.getDzkAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationClassesSummary.setDzkAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationclass.getZfbAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationClassesSummary.setZfbAmt(stationclass.getZfbAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationClassesSummary.setZfbAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationclass.getWxAmt()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationClassesSummary.setWxAmt(stationclass.getWxAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationClassesSummary.setWxAmt(BigDecimal.valueOf(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            stationClassesSummary.setClassesMan(stationclass.getClassStructureMan()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            i=stationClassesSummaryService.insertStationClassesSummary(stationClassesSummary); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(i==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //查询班结小票数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                StationClassStructure classStructure= new StationClassStructure(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                classStructure.setClassStructureNo(no); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                classStructure.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //根据油品汇总数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                List<StationClassStructure> list= stationClassStructureService.listOilStructure(classStructure); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(list!=null && list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    map.put("code","200"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    map.put("msg","班结成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    map.put("oilList",list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    map.put("code","500"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    map.put("msg","班结失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            map.put("code","500"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            map.put("msg","班结失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |