Example #1
0
	/*
	 * 修改时删除子项
	 */
	public String delete(HttpServletRequest request,HttpServletResponse response) throws Exception {
        Map map = dataBaseControl.getOneResultSet("select * from fi_payfor_item t where t.id = ? ", new Object[]{request.getParameter("id")});
        Map payformap = dataBaseControl.getOneResultSet("select t.* from fi_payfor t where t.id = ?", new Object[]{map.get("f_id")});
        
        String type = ""+payformap.get("type");
        
        if(!type.equals("1"))
        {
        	Map map1 = dataBaseControl.getOneResultSet("select * from gm_purchase_item t where t.id = ?", new Object[]{map.get("purchase_item_id")});

            Gm_purchase_item gm_purchase_item =new Gm_purchase_item();

            BeanUtils.populate(gm_purchase_item, map1);
            
            int hasnum = gm_purchase_item.getYfsl() - Integer.parseInt(map.get("num").toString());

            gm_purchase_item.setYfsl(hasnum);
            
            dataBaseControl.updateByBean(gm_purchase_item);
            
            Map map2 = dataBaseControl.getOneResultSet("select * from gm_materiel_inout t where t.id = ?", new Object[]{map.get("inout_id")});
            Gm_materiel_inout gm_materiel_inout = new Gm_materiel_inout();
            BeanUtils.populate(gm_materiel_inout, map2);
            gm_materiel_inout.setIspay("0");
            dataBaseControl.updateByBean(gm_materiel_inout);
        }
        
        
		dataBaseControl.executeSql("DELETE FROM fi_payfor_item WHERE ID in (?)", new Object[]{request.getParameter("id")});
		
		List list= dataBaseControl.getOutResultSet("select * from fi_payfor_item t where t.f_id = ? ", new Object[]{map.get("f_id")});
		String flag = "0";
		
		
		if(list == null || list.isEmpty())
		{
			dataBaseControl.executeSql("DELETE FROM fi_payfor WHERE ID in (?)", new Object[]{map.get("f_id")});
			flag = "1";
		}
		else
		{
			
		}
		
		
		return "/fi/fi_payfor/Fi_payfor!edit.do?id="+map.get("f_id")+"&flag="+flag+"&type="+request.getParameter("type");
	
	}
Example #2
0
	/*
	 * 提交修改后的款项支付
	 */
	public String sub1(HttpServletRequest request, HttpServletResponse response)	throws Exception {
		Map user = (Map)request.getSession().getAttribute("user");
		Map map = dataBaseControl.getOneResultSet("select * from fi_payfor t where t.id = ?", new Object[]{request.getParameter("payforid")});
		
		List itemlist = (List)dataBaseControl.getOutResultSet("select * from fi_payfor_item t where t.f_id = ? order by t.id", new Object[]{request.getParameter("payforid")});
		
		Object[] checkbox = request.getParameterValues("checkbox");
		
		Fi_payfor fi_payfor = new Fi_payfor();
		BeanUtils.populate(fi_payfor, map);
		
		if(checkbox.length!=0)
		{
			dataBaseControl.beginTransaction();
			float total = 0 ;
			
			for(int j = 0 ; j < itemlist.size();j++)
			{
				boolean flag = false;
				Map tmap = (Map)itemlist.get(j);
				
				String id = tmap.get("id").toString();
				
				
				for(int i = 0 ; i < checkbox.length;i++)
				{
					String nid = checkbox[i].toString();
					if(id.equals(nid))  //分配付款时仍然保留
					{
						flag = true;
					}
				}
				
				if(flag)//分配付款保留的
				{
					float money = 0;
					Map map1 = dataBaseControl.getOneResultSet("select * from fi_payfor_item t where t.id = ?", new Object[]{id});
					Fi_payfor_item fi_payfor_item = new Fi_payfor_item();
					BeanUtils.populate(fi_payfor_item, map1);
					
					fi_payfor_item.setOdate(new java.sql.Date((new java.util.Date()).getTime()));
					//fi_payfor_item.setNum(new Integer(request.getParameter("num"+checkbox[i].toString()).equals("")?"0":request.getParameter("num"+checkbox[i].toString())));
					money = Float.valueOf(fi_payfor_item.getMoney()+"") ;
					total = total + money;
					fi_payfor_item.setPerson(new Integer(user.get("base_info_id").toString()));
					dataBaseControl.updateByBean(fi_payfor_item);
				}
				
				else//此次分配付款未勾选的,删除记录,并将其设置为"未付状态"
				{
					Map map1 = dataBaseControl.getOneResultSet("select * from gm_purchase_item t where t.id = ?", new Object[]{tmap.get("purchase_item_id")});

		            Gm_purchase_item gm_purchase_item =new Gm_purchase_item();

		            BeanUtils.populate(gm_purchase_item, map1);
		            
		            int hasnum = gm_purchase_item.getYfsl() - Integer.parseInt(tmap.get("num").toString());

		            gm_purchase_item.setYfsl(hasnum);
		            
		            dataBaseControl.updateByBean(gm_purchase_item);
		            
		            Map map2 = dataBaseControl.getOneResultSet("select * from gm_materiel_inout t where t.id = ?", new Object[]{tmap.get("inout_id")});
		            Gm_materiel_inout gm_materiel_inout = new Gm_materiel_inout();
		            BeanUtils.populate(gm_materiel_inout, map2);
		            gm_materiel_inout.setIspay("0");
		            dataBaseControl.updateByBean(gm_materiel_inout);
		            
		            dataBaseControl.executeSql("DELETE FROM fi_payfor_item WHERE ID in (?)", new Object[]{tmap.get("id")});
		    		
				}
				
			}
			
			
			
			fi_payfor.setOdate(new java.sql.Date((new java.util.Date()).getTime()));
			fi_payfor.setPayforstate(request.getParameter("opinionid"));
			
			fi_payfor.setMoney(new BigDecimal(map.get("money").toString()));
			fi_payfor.setPaytype(request.getParameter("paytype"));
			fi_payfor.setNote(request.getParameter("note"));
			fi_payfor.setBmoney(NumToRmb.toHanStr(Double.parseDouble(map.get("money").toString())));
			
			dataBaseControl.updateByBean(fi_payfor);
			
			dataBaseControl.endTransaction();
			request.setAttribute("operationSign", "closeDG_refreshW();");
			
			///////////////////////分配付款后的短信提醒(财务主管)
			String  num=null;
			String infor=null;
			List slist = dataBaseControl.getOutResultSet("select t.* from message t where t.rolename = 2 ", null);
			if(slist!=null&&!slist.isEmpty())
			{
				Map smap = (Map)slist.get(0);
				num = smap.get("num").toString();
				infor = "您有一条款项支付申请待审批";
			}
			PHPRPC_Client client = new PHPRPC_Client(Constant.HTTPDRESS);
			Mas m = (Mas) client.useService(Mas.class);
			m.sendGFDZ(num,infor);
			
		}
		
		return "/fi/payfor/fi_payforpayDtl.jsp";
	}
Example #3
0
	/*
	 * 保存新增款项支付
	 */
	public String save(HttpServletRequest request,HttpServletResponse response) throws Exception {
		Map user = (Map)request.getSession().getAttribute("user");
	    Object[] checkbox = request.getParameterValues("checkbox");
	    String[] danju = request.getParameterValues("danju");
	    String  mapro=null;
		if(checkbox.length!=0)
		{
			Long id = dataBaseControl.getSeq(Fi_payfor.class);
			dataBaseControl.beginTransaction();
			for(int i = 0 ; i < checkbox.length;i++)
			{
				float money = 0;
				
				Map iomap = (Map)dataBaseControl.getOneResultSet("select * from gm_materiel_inout t where t.id = ?", new Object[]{checkbox[i]});
				Gm_materiel_inout inout = new Gm_materiel_inout();
				BeanUtils.populate(inout, iomap);
				
				if(request.getParameter("opinionid").equals("1"))
				{
					inout.setIspay("1");
					dataBaseControl.updateByBean(inout);
				}
				
				
				Map map = dataBaseControl.getOneResultSet("select * from gm_purchase_item t where t.id = ?", new Object[]{iomap.get("purchase_item_id")});
				Fi_payfor_item fi_payfor_item = new Fi_payfor_item();
				Gm_purchase_item purchase_item = new Gm_purchase_item();
				BeanUtils.populate(purchase_item, map);
				mapro=map.get("prj_id").toString();
				fi_payfor_item.setInout_id(new Integer(checkbox[i].toString()));
				fi_payfor_item.setPro_id(Integer.parseInt(map.get("prj_id").toString()));
				fi_payfor_item.setPurchase_item_id(new Integer(purchase_item.getId()+""));
				fi_payfor_item.setOdate(new java.sql.Date((new java.util.Date()).getTime()));
				fi_payfor_item.setMateriel_id(purchase_item.getMateriel_id());
				fi_payfor_item.setNum(new Integer(iomap.get("num").toString()));
				fi_payfor_item.setPrice(new BigDecimal(iomap.get("price").toString()));
				
				money =Float.valueOf(fi_payfor_item.getNum())*Float.valueOf(fi_payfor_item.getPrice().toString());
				  
				fi_payfor_item.setMoney(new BigDecimal(money));
				fi_payfor_item.setPerson(new Integer(user.get("base_info_id").toString()));
				fi_payfor_item.setGongys(purchase_item.getGongys());
				fi_payfor_item.setF_id(new Integer(id+""));
				fi_payfor_item.setFujnum(danju[i]);
				
				dataBaseControl.insertByBean(fi_payfor_item);
				
				int hasnum = purchase_item.getYfsl();
				hasnum = hasnum + new Integer(iomap.get("num").toString());
				purchase_item.setYfsl(hasnum);
				dataBaseControl.updateByBean(purchase_item);
			}
			
			Fi_payfor fi_payfor = new Fi_payfor();
			fi_payfor.setP_id(new BigDecimal(user.get("base_info_id").toString()));
			fi_payfor.setDept_id(new BigDecimal(user.get("branchid").toString()));
			fi_payfor.setOdate(new java.sql.Date((new java.util.Date()).getTime()));
			fi_payfor.setPayforstate(request.getParameter("opinionid"));
			fi_payfor.setMoney(new BigDecimal(request.getParameter("editTotal")));
			fi_payfor.setPaytype(request.getParameter("paytype"));
			fi_payfor.setNote(request.getParameter("note"));
			fi_payfor.setBmoney(NumToRmb.toHanStr(Double.parseDouble(request.getParameter("editTotal"))));
			fi_payfor.setSk_id(new BigDecimal(sk_id));
			fi_payfor.setPro_id(Integer.parseInt(mapro));
			dataBaseControl.insertByBean(fi_payfor, id);
			dataBaseControl.endTransaction();
			
			String num = "";
			String infor = "您有一条款项支付申请待审批";
			List slist = dataBaseControl.getOutResultSet("select t.* from message t where t.rolename = 1 and t.dept = 3 ", null);
			if(slist!=null&&!slist.isEmpty())
			{
				Map smap = (Map)slist.get(0);
				num = smap.get("num").toString();
			}
			
			PHPRPC_Client client = new PHPRPC_Client(Constant.HTTPDRESS);
			Mas m = (Mas) client.useService(Mas.class);
			m.sendGFDZ(num,infor);
			
			request.setAttribute("operationSign", "closeDG_refreshW();");
			
		}else{
			Long id = dataBaseControl.getSeq(Fi_payfor.class);
			request.setAttribute("accid", id);
			
			
		}
		
		return "/fi/payfor/fi_payforDtl.jsp";
	}