You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1653 lines
60 KiB
Plaintext

<%@ page import="weaver.general.*" %>
<%@page import="weaver.conn.RecordSet"%>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="org.apache.commons.lang.StringUtils" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="java.util.*" %>
<%@ page import="java.math.BigDecimal" %>
<%@ page import="java.math.RoundingMode" %>
<%@ page import="com.api.develop.service.growup.GrowUpListService" %>
<%@ page import="weaver.formmode.customjavacode.customsearch.contractSearchService.GetTotalService" %>
<%@ page import="weaver.formmode.customjavacode.customsearch.contractSearchService.TotalMoneyDTO" %>
<%@ page import="weaver.formmode.customjavacode.customsearch.contractSearchService.TotalRequestDTO" %>
<%@ page import="weaver.mobile.webservices.workflow.WorkflowServiceImpl" %>
<%@ page import="com.api.doc.search.util.DocShareUtil" %>
<%@ page import="com.api.doc.center.util.DocNumUtil" %>
<%@ page import="com.api.doc.search.util.DocListUtil" %>
<%@ page import="java.text.DecimalFormat" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
BaseBean bb = new BaseBean();
String begindate = "" ;
String enddate = "" ;
int year = 0 ;
User user = null;
String type = Util.null2String(request.getParameter("type"));
if("0".equals(type)){
begindate = Util.null2String(request.getParameter("begindate"));
enddate = Util.null2String(request.getParameter("enddate"));
year = Util.getIntValue(request.getParameter("year"));
int userid = Util.getIntValue(request.getParameter("userid"));
user = new User(userid);
}else{
begindate = TimeUtil.getFirstDayOfTheYear();
enddate = TimeUtil.getCurrentDateString();
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
year = calendar.get(Calendar.YEAR);
user = HrmUserVarify.getUser(request , response) ;
}
RecordSet rs = new RecordSet();
int userid = user.getUID();
String field69 = "";
try {
String sql = " select field69 from cus_fielddata where id= ? and len(field69) > 0 " ;
rs.executeQuery(sql,new Object[]{userid});
while (rs.next()){
String value = Util.null2String(rs.getString("field69"));
if(StringUtils.isNotEmpty(value)){
field69 = value;
}
}
}catch (Exception e){
}
if(StringUtils.isEmpty(field69))
{
String posttype = Util.null2String(request.getParameter("posttype"));
field69 = posttype;
}
String posttype = "" ;
bb.writeLog("field69:"+field69);
bb.writeLog("begindate:"+begindate);
bb.writeLog("enddate:"+enddate);
bb.writeLog("year:"+year);
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
if(StringUtils.isNotEmpty(field69)){
if("1".equals(field69)){
list = getSalesPerson(user,begindate,enddate,year);
posttype = "0" ;
}else if("2".equals(field69)){
list = getProjectPerson(user,begindate,enddate,year);
posttype = "1" ;
}else if("3".equals(field69)){
list = getDevPerson(userid,begindate,enddate);
posttype = "2" ;
}else{
list = getOtherPerson(user,begindate,enddate);
posttype = "3" ;
}
}else{
list = getOtherPerson(user,begindate,enddate);
posttype = "3" ;
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("data",list);
jsonObject.put("posttype",posttype);
jsonObject.put("userid",user.getUID());
jsonObject.put("lastname",user.getLastname());
%>
<%=jsonObject.toString() %>
<%!
/***
* 销售显示6个签约合同金额、年度指标、指标完成率、合同收款、客户数量、商机数量
*/
public List<Map<String,Object>> getSalesPerson(User user, String begindate, String enddate,int currentYear){
BaseBean bb = new BaseBean();
int userid = user.getUID();
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
Map<String,Object> map = new HashMap<String,Object>();
String unit1 = "" ;
String unit2 = "" ;
String unit3 = "" ;
String unit4 = "" ;
String unit5 = "" ;
String xkhht = "0.00" ;
String lkhht = "0.00" ;
try{
double xkhhtje = 0.00;
Map<String,Double> htmap = getSignContract(user,currentYear,begindate,enddate);
if(htmap.containsKey("xkhht")){
xkhhtje = htmap.get("xkhht");
}
bb.writeLog("xkhhtje:"+xkhhtje);
if(xkhhtje < 10000){
unit2 = "万元";
BigDecimal bd = new BigDecimal(xkhhtje);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xkhht = bd.toString();
}else{
unit2 = "亿元";
BigDecimal bd = new BigDecimal(xkhhtje/10000.00);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xkhht = bd.toString();
}
double lkhhtje = 0.00 ;
if(htmap.containsKey("lkhht")){
lkhhtje = htmap.get("lkhht");
}
bb.writeLog("lkhhtje:"+lkhhtje);
if(lkhhtje < 10000){
unit3 = "万元";
BigDecimal bd = new BigDecimal(lkhhtje);
bd = bd.setScale(2, RoundingMode.HALF_UP);
lkhht = bd.toString();
}else{
unit3 = "亿元";
BigDecimal bd = new BigDecimal(lkhhtje/10000.00);
bd = bd.setScale(2, RoundingMode.HALF_UP);
lkhht = bd.toString();
}
}catch (Exception e){
}
Map<String,String> lkhmap = new HashMap<String,String>();
lkhmap.put("name","lkhhtje");
lkhmap.put("value",lkhht);
lkhmap.put("title","老客户合同额");
lkhmap.put("unit",unit3);
lkhmap.put("url","");
Map<String,String> xkhmap = new HashMap<String,String>();
xkhmap.put("name","xkhhtje");
xkhmap.put("value",xkhht+"");
xkhmap.put("title","新客户合同额");
xkhmap.put("unit",unit2);
xkhmap.put("url","");
String xsqyht = "0.00" ;
double qyhtje = 0.00;
try {
qyhtje = getContractPerformanc(user,currentYear,begindate,enddate);
bb.writeLog("qyhtje:"+qyhtje);
if(qyhtje < 10000){
unit1 = "万元";
BigDecimal bd = new BigDecimal(qyhtje);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xsqyht = bd.toString();
}else{
unit1 = "亿元";
BigDecimal bd = new BigDecimal(qyhtje/10000.00);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xsqyht = bd.toString();
}
}catch (Exception e){
}
bb.writeLog("xsqyht:"+xsqyht);
map = new HashMap<String,Object>();
map.put("name","qyhtje");
map.put("value",xsqyht);
map.put("title","本年签约合同额");
map.put("unit",unit1);
map.put("url","/cm/data/SearchFrame.jsp");
map.put("xkh",xkhmap);
map.put("lkh",lkhmap);
list.add(map);
double ndzb = 0.00;
String xsndzb = "0.00" ;
try{
ndzb = getSalesTarget(userid,currentYear);
if(ndzb < 10000){
unit4 = "万元";
BigDecimal bd = new BigDecimal(ndzb);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xsndzb = bd.toString();
}else{
unit4 = "亿元";
BigDecimal bd = new BigDecimal(ndzb/10000.00);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xsndzb = bd.toString();
}
}catch (Exception e){
}
map = new HashMap<String,Object>();
map.put("name","ndzb");
map.put("value",xsndzb);
map.put("title","本年度指标");
map.put("unit",unit4);
map.put("url","");
list.add(map);
String zbwcl = "0.00";
try{
if(ndzb > 0)
{
BigDecimal bd = new BigDecimal((qyhtje/(ndzb*1.00)*100));
bd = bd.setScale(2, RoundingMode.HALF_UP);
zbwcl = bd.toString()+"";
}
}catch (Exception e){
}
bb.writeLog("zbwcl:"+zbwcl);
map = new HashMap<String,Object>();
map.put("name","zbwcl");
map.put("value",zbwcl);
map.put("title","本年指标完成率");
map.put("unit","%");
map.put("url","");
list.add(map);
String xshtsk = "0.00" ;
try {
double htsk = getContractCollection(user,currentYear,begindate,enddate);
bb.writeLog("htsk:"+htsk);
if(htsk < 10000){
unit5 = "万元";
BigDecimal bd = new BigDecimal(htsk);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xshtsk = bd.toString();
}else{
unit5 = "亿元";
BigDecimal bd = new BigDecimal(htsk/10000.00);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xshtsk = bd.toString();
}
}catch (Exception e){
}
bb.writeLog("xshtsk:"+xshtsk);
map = new HashMap<String,Object>();
map.put("name","htsk");
map.put("value",xshtsk);
map.put("title","本年合同收款");
map.put("unit",unit5);
map.put("url","/cm/data/SearchFrame.jsp?tablename=sk");
list.add(map);
int khsl = 0 ;
try{
khsl = getCustomerCount(user,currentYear,begindate,enddate);
}catch (Exception e){
}
map = new HashMap<String,Object>();
map.put("name","khsl");
map.put("value",khsl+"");
map.put("title","本年客户数量");
map.put("unit","");
map.put("url","/CRM/manage/customer/Main.jsp?maintype=1");
list.add(map);
int sjsl = 0 ;
try{
sjsl = getConnectionsCount(user,currentYear,begindate,enddate);
}catch (Exception e){
}
map = new HashMap<String,Object>();
map.put("name","sjsl");
map.put("value",sjsl+"");
map.put("title","本年商机数量");
map.put("unit","");
map.put("url","/spa/crm/static4crmPro/index.html#/main/crmPro/SellChanceManageIndex");
list.add(map);
return list;
}
/***
* 项目显示6个内容验收指标、验收金额、指标达成率、收款金额、验收项目个数、平均项目周期
*/
public List<Map<String,Object>> getProjectPerson(User user,String begindate, String enddate,int year){
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
int userid = user.getUID();
Map<String,Object> map = null ;
double yszb = 0.00;
try {
yszb = getAcceptanceIndex(userid,year);
}catch (Exception e){
}
if(yszb > 0){
BigDecimal bd = new BigDecimal(yszb/10000.00);
bd = bd.setScale(2, RoundingMode.HALF_UP);
yszb = bd.doubleValue();
}
String unit = "" ;
String xmyszb = "" ;
if(yszb < 10000){
unit = "万元";
BigDecimal bd = new BigDecimal(yszb);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xmyszb = bd.toString();
}else{
unit = "亿元";
BigDecimal bd = new BigDecimal(yszb/10000.00);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xmyszb = bd.toString();
}
map = new HashMap<String,Object>();
map.put("name","yszb");
map.put("value",xmyszb);
map.put("title","本年验收指标");
map.put("unit",unit);
map.put("url","/cm/data/SearchFrame.jsp?tablename=xmzb");
list.add(map);
double ysje = 0.00 ;
// try {
// ysje = getAcceptanceAmount(user,year,begindate,enddate);
//
// }catch (Exception e){
// }
// String bnjhys = "0.00";
// String jhyswcl = "0.00";
try {
Map<String,Object> dataMap = getYsAndJhwcl(userid,begindate,enddate);
ysje = Util.getDoubleValue(Util.null2String(dataMap.get("bnwcys")));
// bnjhys = Util.null2String(dataMap.get("bnjhys"));
// jhyswcl = Util.null2String(dataMap.get("jhyswcl"));
}catch (Exception e){
}
unit = "" ;
String xmysje = "" ;
if(ysje < 10000){
unit = "万元";
BigDecimal bd = new BigDecimal(ysje);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xmysje = bd.toString();
}else{
unit = "亿元";
BigDecimal bd = new BigDecimal(ysje/10000.00);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xmysje = bd.toString();
}
map = new HashMap<String,Object>();
map.put("name","ysje");
map.put("value",xmysje+"");
map.put("title","本年验收金额");
map.put("unit",unit);
map.put("url","/cm/data/SearchFrame.jsp?tablename=xmys");
list.add(map);
String zbdcl = "0.00" ;
try{
if(yszb > 0){
BigDecimal bd = new BigDecimal((ysje/(yszb*1.00))*100.00);
bd = bd.setScale(2, RoundingMode.HALF_UP);
zbdcl = bd.toString()+"";
}
}catch (Exception e){
}
map = new HashMap<String,Object>();
map.put("name","zbdcl");
map.put("value",zbdcl);
map.put("title","本年指标达成率");
map.put("unit","%");
map.put("url","");
list.add(map);
double skje = 0.00 ;
try{
//skje = getPaymentsAmount(user,year,begindate,enddate);
skje = getWCSKDataNew(userid,begindate,enddate);
}catch (Exception e){
}
unit = "" ;
String xmskje = "" ;
if(skje < 10000){
unit = "万元";
BigDecimal bd = new BigDecimal(skje);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xmskje = bd.toString();
}else{
unit = "亿元";
BigDecimal bd = new BigDecimal(skje/10000.00);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xmskje = bd.toString();
}
map = new HashMap<String,Object>();
map.put("name","skje");
map.put("value",xmskje+"");
map.put("title","本年收款金额");
map.put("unit",unit);
map.put("url","/cm/data/SearchFrame.jsp?tablename=sk");
list.add(map);
// String ysxmgs = "0";
// String pjxmzq = "0.00";
// try{
// Map<String,Object> xmMap = getProjectCheckCountAndAveragePeriod(userid,year,begindate,enddate);
// ysxmgs = Util.null2String(xmMap.get("ysxmgs"));
// String pjxmyszq = Util.null2String(xmMap.get("pjxmzq"));
//
// if(StringUtils.isNotEmpty(pjxmyszq)){
// pjxmzq = formatBigDecimal(pjxmyszq);
// }
// }catch (Exception e){
//
// }
// map = new HashMap<String,Object>();
// map.put("name","ysxmgs");
// map.put("value",ysxmgs);
// map.put("title","验收项目个数");
// map.put("unit","");
// map.put("url","");
// list.add(map);
//
// map = new HashMap<String,Object>();
// map.put("name","ysxmgs");
// map.put("value",pjxmzq);
// map.put("title","平均项目周期");
// map.put("unit","天");
// map.put("url","");
// list.add(map);
return list;
}
/***
* 技术显示4个内容问题处理数量、开发人天、协作沟通数、处理流程数
*/
public List<Map<String,Object>> getDevPerson(int userid, String begindate, String enddate){
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
Map<String,Object> map = null;
int wtclgs = 0;
try{
wtclgs = getProblemHandlCount(userid,begindate,enddate);
}catch (Exception e){
}
map = new HashMap<String,Object>();
map.put("name","wtclgs");
map.put("value",wtclgs+"");
map.put("title","本年问题处理数量");
map.put("unit","");
map.put("url","");
list.add(map);
double kfrt = 0.00 ;
try{
kfrt = getDevelopDaysCount(userid,begindate,enddate);
}catch (Exception e){
}
map = new HashMap<String,Object>();
map.put("name","kfrt");
map.put("value",kfrt+"");
map.put("title","本年开发人天");
map.put("unit","");
map.put("url","");
list.add(map);
int xzgtsl = 0;
try{
xzgtsl = getCoworkReplayCount(userid,begindate,enddate);
}catch (Exception e){
}
map = new HashMap<String,Object>();
map.put("name","xzgtsl");
map.put("value",xzgtsl+"");
map.put("title","本年协作沟通数");
map.put("unit","");
map.put("url","/spa/cowork/static/index.html#/main/cowork/mine");
list.add(map);
int cllcsl = 0;
try{
cllcsl = getWorkflowDealCount(userid,begindate,enddate);
}catch (Exception e){
}
map = new HashMap<String,Object>();
map.put("name","cllcsl");
map.put("value",cllcsl+"");
map.put("title","本年处理流程数");
map.put("unit","");
map.put("url","/spa/workflow/static/index.html#/main/workflow/listDone");
list.add(map);
return list;
}
/***
* 其他:处理流程数、文档贡献度、微博填写数、沟通协作数
*
*/
public List<Map<String,Object>> getOtherPerson(User user, String begindate, String enddate){
int userid = user.getUID();
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
Map<String,Object> map = null;
int cllcsl = 0;
try{
cllcsl = getWorkflowDealCount(userid,begindate,enddate);
}catch (Exception e){
}
map = new HashMap<String,Object>();
map.put("name","cllcsl");
map.put("value",cllcsl+"");
map.put("title","本年处理流程数");
map.put("unit","");
map.put("url","/spa/workflow/static/index.html#/main/workflow/listDone");
list.add(map);
int wdgxd = 0;
try{
wdgxd = getDocCreateCount(user,begindate,enddate);
}catch (Exception e){
}
map = new HashMap<String,Object>();
map.put("name","wdgxd");
map.put("value",wdgxd+"");
map.put("title","本年文档贡献度");
map.put("unit","");
map.put("url","/spa/document/static/index.html#/main/document/add");
list.add(map);
int wbtxs = 0;
try {
wbtxs = getBlogWriteCount(userid,begindate,enddate);
}catch (Exception e){
}
map = new HashMap<String,Object>();
map.put("name","wbtxs");
map.put("value",wbtxs+"");
map.put("title","本年微博填写数");
map.put("unit","");
map.put("url","/spa/blog/static/index.html#/main/blog/myBlog");
list.add(map);
int xzgts = 0;
try {
xzgts = getCoworkReplayCount(userid,begindate,enddate);
}catch (Exception e){
}
map = new HashMap<String,Object>();
map.put("name","xzgts");
map.put("value",xzgts+"");
map.put("title","本年沟通协作数");
map.put("unit","");
map.put("url","/spa/cowork/static/index.html#/main/cowork/mine");
list.add(map);
return list;
}
/////##########################销售人员##################################//
/***
* 签约合同金额
* @param user
* @param year
* @param startDate
* @param endDate
* @return
*/
public Map<String,Double> getSignContract(User user,int year,String startDate,String endDate){
BaseBean bb = new BaseBean();
bb.writeLog("getSignContract:");
Map<String,Double> map = new HashMap<String,Double>();
GetTotalService totalService = new GetTotalService();
String contractTableName = "zxyjlxfb";
String searchFlag = "1";
String dateCondition = "5";
String zxyjFlag = "";
try {
TotalRequestDTO requestDTO = new TotalRequestDTO();
requestDTO.setDateValue(dateCondition);
requestDTO.setSearchFlag(searchFlag);
requestDTO.setContractTableName(contractTableName);
requestDTO.setUser(user);
requestDTO.setZxyjFlag(zxyjFlag);
TotalMoneyDTO totalMoneyDTO = totalService.getTotalInfo(requestDTO);
bb.writeLog("totalMoneyDTO:"+totalMoneyDTO.toString());
if(totalMoneyDTO !=null)
{
double lkhht = 0.0;
String oldclientmoney = totalMoneyDTO.getOldClientMoney().replace(",","");
bb.writeLog("oldclientmoney:"+oldclientmoney);
if(StringUtils.isNotEmpty(oldclientmoney)){
double xsje = Double.parseDouble(oldclientmoney);
bb.writeLog("xsje:"+xsje);
BigDecimal bd = new BigDecimal(xsje/10000.00);
bd = bd.setScale(2, RoundingMode.HALF_UP);
lkhht = bd.doubleValue();
bb.writeLog("lkhht:"+lkhht);
}
double xkhht = 0.0;
String newclientmoney = totalMoneyDTO.getTotalMoney().replace(",","");
bb.writeLog("newclientmoney:"+newclientmoney);
if(StringUtils.isNotEmpty(newclientmoney)){
double xsje = Double.parseDouble(newclientmoney);
bb.writeLog("xsje:"+xsje);
BigDecimal bd = new BigDecimal(xsje/10000.00);
bd = bd.setScale(2, RoundingMode.HALF_UP);
xkhht = bd.doubleValue();
bb.writeLog("xkhht:"+xkhht);
}
map.put("lkhht",lkhht);
map.put("xkhht",xkhht);
}
}catch (Exception e) {
bb.writeLog("getSignContract-e:"+e);
}
return map;
}
/**
* 销售验收指标
* @param userid
* @param year
* @return
*/
public double getSalesTarget(int userid,int year){
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
bb.writeLog("getSalesTarget:");
double sales_target = 0.0;
// String formtable = getUfPropValue("salesindextable");
// try{
// if(StringUtils.isEmpty(formtable)){
// formtable = "formtable_main_2055";
// }
//
// String lastname = "" ;
// String sql = " select lastname from hrmresource where id = ?" ;
// rs.executeQuery(sql,new Object[]{userid});
// if(rs.next()){
// lastname = Util.null2String(rs.getString("lastname"));
// }
//
// if(StringUtils.isNotEmpty(lastname)){
// String mainid = "" ;
// sql = " select id from "+formtable+" where sbnd='"+year+"' ";
// rs.execute(sql);
// if(rs.next()){
// mainid = Util.null2String(rs.getString("id"));
// }
// if(StringUtils.isNotEmpty(mainid)){
// sql = " select yxyswy from "+formtable+"_dt1 where mainid="+mainid+" and xmfzr='"+lastname+"'" ;
// bb.writeLog("sql:"+sql);
// rs.execute(sql);
// if(rs.next()){
// sales_target = Util.getDoubleValue(Util.null2String(rs.getString("yxyswy")));
// }
// }
// }
// }catch (Exception e){
// bb.writeLog("getSalesTarget-e:"+e);
// }
try{
String sql = " select isnull(sum(convert(decimal(18,2),mbz))/10000.00,0) as mbz from uf_xssjdr where xsry = "+userid;
rs.execute(sql);
if(rs.next()){
sales_target = Util.getDoubleValue(Util.null2String(rs.getString("mbz")));
}
}catch (Exception e){
bb.writeLog("getSalesTarget-e:"+e);
}
return sales_target;
}
/***
* 合同收款金额
* @param user
* @param year
* @param startDate
* @param endDate
* @return
*/
public double getContractCollection(User user,int year,String startDate,String endDate){
BaseBean bb = new BaseBean();
bb.writeLog("getContractCollection:");
Map<String,Double> map = new HashMap<String,Double>();
// GrowUpListService service = new GrowUpListService();
//https://www.e-cology.com.cn/api/develop/growup/getData?season=&month=&week=&day=&
// year=2022&isDecimal=1&grouptype=&datatype=&type=performances&hrmid=5796
// try {
// Map<String,Object> params = new HashMap<String,Object>();
// params.put("year",year);
// params.put("hrmid",userid);
// params.put("type","validpayments");
// params.put("isDecimal","1");
// params.put("fromdate",startDate);
// params.put("todate",endDate);
//
// Map<String,Object> apidatas = service.getValidPayments(user, params);
// bb.writeLog(JSONObject.toJSONString(apidatas));
//
// if(apidatas.containsKey("status") && apidatas.containsKey("num")){
// String status = Util.null2String(apidatas.get("status"));
// if("1".equals(status)){
// _total = Util.getDoubleValue(Util.null2String(apidatas.get("num")));
// }
// }
// bb.writeLog("_total:"+_total);
// }catch (Exception e) {
// bb.writeLog("getContractCollection-e:"+e);
// }
double htsk = 0.00;
String contractTableName = "zxhtyj";
String searchFlag = "1";
String dateCondition = "5";
String zxyjFlag = "zxhtsknew";
GetTotalService totalService = new GetTotalService();
try {
TotalRequestDTO requestDTO = new TotalRequestDTO();
requestDTO.setDateValue(dateCondition);
requestDTO.setSearchFlag(searchFlag);
requestDTO.setContractTableName(contractTableName);
requestDTO.setUser(user);
requestDTO.setZxyjFlag(zxyjFlag);
TotalMoneyDTO totalMoneyDTO = totalService.getTotalInfo(requestDTO);
bb.writeLog("totalMoneyDTO:"+totalMoneyDTO.toString());
if(totalMoneyDTO !=null)
{
String oldclientmoney = totalMoneyDTO.getOldClientMoney().replace(",","");
bb.writeLog("oldclientmoney:"+oldclientmoney);
if(StringUtils.isNotEmpty(oldclientmoney)){
double xsje = Double.parseDouble(oldclientmoney);
bb.writeLog("xsje:"+xsje);
BigDecimal bd = new BigDecimal(xsje/10000.00);
bd = bd.setScale(2, RoundingMode.HALF_UP);
htsk = bd.doubleValue();
bb.writeLog("htsk:"+htsk);
}
}
}catch (Exception e) {
bb.writeLog("getSignContract-e:"+e);
}
return htsk;
}
/***
*
* @param user
* @param year
* @param startDate
* @param endDate
* @return
*/
public double getContractPerformanc(User user,int year,String startDate,String endDate){
BaseBean bb = new BaseBean();
bb.writeLog("getContractCollection:");
Map<String,Double> map = new HashMap<String,Double>();
String contractTableName = "zxhtyj";
String searchFlag = "1";
String dateCondition = "5";
String zxyjFlag = "";
double qyhtje = 0.00;
GetTotalService totalService = new GetTotalService();
try {
TotalRequestDTO requestDTO = new TotalRequestDTO();
requestDTO.setDateValue(dateCondition);
requestDTO.setSearchFlag(searchFlag);
requestDTO.setContractTableName(contractTableName);
requestDTO.setUser(user);
requestDTO.setZxyjFlag(zxyjFlag);
TotalMoneyDTO totalMoneyDTO = totalService.getTotalInfo(requestDTO);
bb.writeLog("totalMoneyDTO:"+totalMoneyDTO.toString());
if(totalMoneyDTO !=null)
{
String totalmoney = totalMoneyDTO.getTotalMoney().replace(",","");
bb.writeLog("totalmoney:"+totalmoney);
if(StringUtils.isNotEmpty(totalmoney)){
double xsje = Double.parseDouble(totalmoney);
bb.writeLog("xsje:"+xsje);
BigDecimal bd = new BigDecimal(xsje/10000.00);
bd = bd.setScale(2, RoundingMode.HALF_UP);
qyhtje = bd.doubleValue();
bb.writeLog("qyhtje:"+qyhtje);
}
}
}catch (Exception e) {
bb.writeLog("getContractPerformanc-e:"+e);
}
return qyhtje;
}
/***
* 客户总和
* @param user
* @param year
* @param startDate
* @param endDate
* @return
*/
public int getCustomerCount(User user,int year,String startDate,String endDate){
BaseBean bb = new BaseBean();
bb.writeLog("getCustomerCount:");
int _total = 0;//总数
int userid = user.getUID();
GrowUpListService service = new GrowUpListService();
//https://www.e-cology.com.cn/api/develop/growup/getData?season=&month=&week=&day=&
// year=2022&isDecimal=1&grouptype=&datatype=&type=performances&hrmid=5796
try {
Map<String,Object> params = new HashMap<String,Object>();
params.put("year",year);
params.put("hrmid",userid);
params.put("type","customernum");
params.put("isDecimal","1");
params.put("fromdate",startDate);
params.put("todate",endDate);
Map<String,Object> apidatas = service.getCustomerNum(user, params);
bb.writeLog(JSONObject.toJSONString(apidatas));
if(apidatas.containsKey("status") && apidatas.containsKey("num")){
String status = Util.null2String(apidatas.get("status"));
if("1".equals(status)){
_total = Util.getIntValue(Util.null2String(apidatas.get("num")));
}
}
bb.writeLog("_total:"+_total);
}catch (Exception e) {
bb.writeLog("getCustomerCount-e:"+e);
}
return _total;
}
/***
* 商机总和
* @param user
* @param year
* @param startDate
* @param endDate
* @return
*/
public int getConnectionsCount(User user,int year,String startDate,String endDate){
BaseBean bb = new BaseBean();
bb.writeLog("getConnectionsCount:");
int _total = 0;//总数
int userid = user.getUID();
GrowUpListService service = new GrowUpListService();
//https://www.e-cology.com.cn/api/develop/growup/getData?season=&month=&week=&day=&
// year=2022&isDecimal=1&grouptype=&datatype=&type=performances&hrmid=5796
try {
Map<String,Object> params = new HashMap<String,Object>();
params.put("year",year);
params.put("hrmid",userid);
params.put("type","sellchancenum");
params.put("isDecimal","1");
params.put("fromdate",startDate);
params.put("todate",endDate);
Map<String,Object> apidatas = service.getSellchanceNum(user, params);
bb.writeLog(JSONObject.toJSONString(apidatas));
if(apidatas.containsKey("status") && apidatas.containsKey("num")){
String status = Util.null2String(apidatas.get("status"));
if("1".equals(status)){
_total = Util.getIntValue(Util.null2String(apidatas.get("num")));
}
}
bb.writeLog("_total:"+_total);
}catch (Exception e) {
bb.writeLog("getConnectionsCount-e:"+e);
}
return _total;
}
/////##########################销售人员##################################//
/////##########################项目人员##################################//
/**
* 验收指标
* @param cyear
* @param hrmid
* @return
*/
public double getAcceptanceIndex(int hrmid,int cyear){
double yszb = 0.00 ;
BaseBean bb = new BaseBean();
bb.writeLog("getAcceptanceIndex");
RecordSet rs = new RecordSet();
// String userids = "" ;
// String sql = " select * from getallchilds("+hrmid+")" ;
// rs.executeQuery(sql);
// while (rs.next()){
// String userid = rs.getString(1);
// userids += StringUtils.isEmpty(userids) ? userid : ","+userid ;
// }
//
// StringBuffer sqlWhere = new StringBuffer();
// sqlWhere.append(" and t1.hsyjnf like '"+cyear+"%'");
// sqlWhere.append(" and (t1.xmjl in("+userids+") or t1.tdfzr in("+userids+") )");
//
// String tablename = "" ;
// sql = " select bm from uf_cm_right_detail where sign='xmzb' ";
// bb.writeLog("sql:"+sql);
// rs.executeQuery(sql);
// if(rs.next()){
// tablename = Util.null2String(rs.getString("bm"));
// }
// if(StringUtils.isNotEmpty(tablename)){
// sql =" select sum(yszb) as yszb from "+tablename + " t1 where 1=1 "+sqlWhere.toString();
// bb.writeLog("sql:"+sql);
// rs.executeQuery(sql);
// if(rs.next()){
// yszb = Util.getDoubleValue(Util.null2String(rs.getString("yszb")));
// }
// }
try{
String sql = " select isnull(sum(convert(decimal(18,2),target)),0) as target from lf_prjhrminfo where hrmid ="+hrmid;
rs.execute(sql);
if(rs.next()){
yszb = Util.getDoubleValue(Util.null2String(rs.getString("target")));
}
}catch (Exception e){
bb.writeLog("getSalesTarget-e:"+e);
}
bb.writeLog("yszb:"+yszb);
return yszb;
}
/***
* 项目验收金额(本年完成验收)、计划完成率、本年计划验收
* @param userid
* @param startdate
* @param enddate
* @return
*/
public Map<String,Object> getYsAndJhwcl(int userid,String startdate,String enddate)
{
Map<String,Object> map = new HashMap<String, Object>();
RecordSet rs = new RecordSet();
double bnwcys = 0.00;
double bnjhys = 0.00;
double jhyswcl = 0.00;
try {
String sql = queryReportWhereWithDate(userid+"",startdate,enddate);
rs.execute(sql);
if(rs.next())
{
bnwcys = Util.getDoubleValue(Util.null2String(rs.getString("thisyearfinishamount"),"0"),0.00);
bnjhys = Util.getDoubleValue(Util.null2String(rs.getString("thisyearplanamount"),"0"),0.00);
}
if(bnjhys > 0){
jhyswcl = getRate(bnwcys, bnjhys);
}
}catch (Exception e) {
e.printStackTrace();
}
map.put("bnwcys", MathUtil.div(bnwcys,10000.0,2));
map.put("jhyswcl", jhyswcl);
map.put("bnjhys", MathUtil.div(bnjhys,10000.0,2));
return map;
}
/***
*
* @param userids
* @param startdate
* @param enddate
* @return
*/
public String queryReportWhereWithDate(String userids,String startdate,String enddate) {
BaseBean bb = new BaseBean();
String userWhere = " and (t3t.hrmid in("+userids+") or t3t.qyjl in("+userids+") or t3t.dqzj in("+userids+") or t3t.qyzj in("+userids+")) " ;
String starMonth = startdate.substring(0,7);
String endMonth = enddate.substring(0,7) ;
StringBuffer sb = new StringBuffer();
// bnwcys = Util.getDoubleValue(rs.getString("thisyearfinishamount"));
// thismonthfinishamount = Util.getDoubleValue(rs.getString("thismonthfinishamount"));
// thismonthplanamount = Util.getDoubleValue(rs.getString("thismonthplanamount"));
//计划验收
sb.append(" SELECT SUM(cie.sumAmount) AS thisyearplanamount,0 as thisyearfinishamount " +
" FROM proj_CardBaseInfo ci " +
" LEFT JOIN proj_CardBaseInfoExec cie ON cie.cbi_id = ci.id " +
" LEFT JOIN lf_prjhrminfo t3t ON t3t.hrmid = ci.projmanager " +
" where (lastprjstate in ('正常', '预警', '延期') or (lastprjstate in ('验收','结案') and gdrq is not null and gdrq<>'' and substring(gdrq, 0, 8)>='"+starMonth+"' and substring(gdrq, 0, 8)<='"+endMonth+"')) " +
userWhere +
" and exists(select 1 from proj_CardBaseInfoPlan where cbi_id=ci.id " +
" and yearMonth >='"+starMonth+"' and yearMonth<='" + endMonth +"' "+
" and substring(planapprovaldate2, 0, 8)>='"+starMonth+"' and substring(planapprovaldate2, 0, 8)<='"+endMonth+"' ) ");
//本年完成验收
sb.append(" union all " +
" SELECT 0 AS thisyearplanamount,sum(isnull(t.htzje, 0)) as thisyearfinishamount " +
" FROM proj_CardBaseInfo ci " +
" LEFT JOIN proj_CardBaseInfoExec cie ON cie.cbi_id = ci.id " +
" LEFT JOIN lf_prjhrminfo t3t ON t3t.hrmid = ci.projmanager " +
" LEFT JOIN (select t1.id,t1.hth,(case when substring(t1.hth,6,1) in ('2','6') then isnull(t4.htzje,0)-isnull(t4.bgje,0) else isnull(t2.htzje,0)-isnull(t2.bgje,0) end) as htzje from formtable_main_190 t1 left join formtable_main_180 t2 on t1.hth=t2.hth and t2.hth<>'' and t2.hth is not null left join formtable_main_183 t4 on t1.hth=t4.hth and t4.hth<>'' and t4.hth is not null " +
" where t1.hsny>='"+starMonth+"' AND t1.hsny<='"+endMonth+"') t on t.hth=cie.hth " +
" where 1=1 "+ userWhere +
" ");
String sql = " SELECT convert(decimal(18,2),isnull((sum(isnull(p.thisyearplanamount,0))),0)) AS thisyearplanamount,\n" +
" convert(decimal(18,2),isnull((sum(isnull(p.thisyearfinishamount,0))),0)) AS thisyearfinishamount\n " +
" FROM( \n" +
sb.toString()+
" ) p ";
bb.writeLog(sql);
return sql;
}
public static double getRate(double a,double b){
double rate=0.0;
if(b==0.0){
return rate;
}
try{
rate=MathUtil.div(a*100,b,2);
}catch (Exception e) {
e.printStackTrace();
}
return rate;
}
/***
* 项目验收金额
* @param user
* @param year
* @param startDate
* @param endDate
* @return
*/
public double getAcceptanceAmount(User user,int year,String startDate,String endDate){
BaseBean bb = new BaseBean();
bb.writeLog("getAcceptanceAmount");
double _total = 0.00;//总数
int userid = user.getUID();
GrowUpListService service = new GrowUpListService();
//https://www.e-cology.com.cn/api/develop/growup/getData?season=&month=&week=&day=&
// year=2022&isDecimal=1&grouptype=&datatype=&type=performances&hrmid=5796
try {
Map<String,Object> params = new HashMap<String,Object>();
params.put("year",year);
params.put("hrmid",userid);
params.put("type","projacceptance");
params.put("isDecimal","1");
params.put("fromdate",startDate);
params.put("todate",endDate);
Map<String,Object> apidatas = service.getProjacceptance(user, params);
bb.writeLog(JSONObject.toJSONString(apidatas));
if(apidatas.containsKey("status") && apidatas.containsKey("num")){
String status = Util.null2String(apidatas.get("status"));
if("1".equals(status)){
_total = Util.getDoubleValue(Util.null2String(apidatas.get("num")));
}
}
bb.writeLog("_total:"+_total);
}catch (Exception e) {
bb.writeLog("getCustomerCount-e:"+e);
}
return _total;
}
/***
* 项目收款金额
* @param user
* @param year
* @param startDate
* @param endDate
* @return
*/
public double getPaymentsAmount(User user,int year,String startDate,String endDate){
BaseBean bb = new BaseBean();
bb.writeLog("getPaymentsAmount");
double _total = 0.00;//总数
int userid = user.getUID();
GrowUpListService service = new GrowUpListService();
//https://www.e-cology.com.cn/api/develop/growup/getData?season=&month=&week=&day=&
// year=2022&isDecimal=1&grouptype=&datatype=&type=performances&hrmid=5796
try {
Map<String,Object> params = new HashMap<String,Object>();
params.put("year",year);
params.put("hrmid",userid);
params.put("type","projpayments");
params.put("isDecimal","1");
params.put("fromdate",startDate);
params.put("todate",endDate);
Map<String,Object> apidatas = service.getProjpayments(user, params);
bb.writeLog(JSONObject.toJSONString(apidatas));
if(apidatas.containsKey("status") && apidatas.containsKey("num")){
String status = Util.null2String(apidatas.get("status"));
if("1".equals(status)){
_total = Util.getDoubleValue(Util.null2String(apidatas.get("num")));
}
}
bb.writeLog("_total:"+_total);
}catch (Exception e) {
bb.writeLog("getCustomerCount-e:"+e);
}
return _total;
}
/***
*
* @param userid
* @param startdate
* @param enddate
* @return
*/
public double getWCSKDataNew(int userid,String startdate,String enddate)
{
BaseBean bb = new BaseBean();
bb.writeLog("getWCSKDataNew"); // 核算公司 只留 泛微网络 项目经理
RecordSet rs = new RecordSet();
/******************完成收款****************/
double totalInAmt = 0.00 ;
try{
String userWhere = " and exists( select 1 from lf_prjhrminfo t3t where t3t.hrmid = cbi.projManager and (t3t.hrmid in("+userid+") or t3t.qyjl in("+userid+") or t3t.dqzj in("+userid+") or t3t.qyzj in("+userid+"))) " ;
String where = getJHSKwhere(userid);
String datewhere = "" ;
if(StringUtils.isNotEmpty(startdate) && StringUtils.isNotEmpty(enddate))
{
datewhere = " and cbiead.inDate >='"+startdate+"' and cbiead.inDate <='"+enddate+"'";
}
//bb.writeLog("where:"+where);
String sql =" select Convert(decimal(18,2),isnull((sum(isnull(w.inAmt,0))/10000.0),0)) as inAmt \n " +
" from( " +
" select cbiead.inAmt,cbi.projManager \n" +
" from proj_CardBaseInfoExec cbie \n" +
" inner join proj_CardBaseInfoExecDtl cbied on cbied.cbie_id = cbie.id \n" +
" inner join proj_CardBaseInfoExecAmtDtl cbiead on cbiead.cbied2_id = cbied.id \n" +
" inner join proj_CardBaseInfo cbi on cbie.cbi_id = cbi.id \n" +
" where 1=1 " + userWhere + datewhere + where +
" ) w " ;
bb.writeLog("sql:"+sql);
rs.execute(sql);
if(rs.next()){
totalInAmt = Util.getDoubleValue(Util.null2String(rs.getString("inAmt"),"0"),0.00);
}
}catch (Exception e){
}
return totalInAmt;
}
/***
*
* @param userid
* @return
*/
public String getJHSKwhere(int userid)
{
StringBuffer sqlWhere_t = new StringBuffer();
try{
sqlWhere_t.append( " AND ( 1 = 2 "+
" OR ( cbi.projManager IN ( SELECT id "+
" FROM getallchilds("+userid+") ) "+
" OR cbi.projManager = "+userid+
" ) "+
" OR ( EXISTS ( SELECT 1 "+
" FROM proj_CardBaseInfo_members cbim "+
" WHERE cbim.cbi_id = cbi.id "+
" AND cbim.userId = "+userid+" ) ) "+
" OR ( EXISTS ( SELECT 1 "+
" FROM CRM_CustomerInfo ci "+
" WHERE ci.id = cbi.projCustomer "+
" AND ( ci.manager IN ( SELECT "+
" id "+
" FROM "+
" getallchilds("+userid+") ) "+
" OR ci.manager = "+userid+
" ) ) ) "+
" OR ( EXISTS ( SELECT 1 "+
" FROM proj_default_share pds "+
" JOIN HrmResource hr ON pds.shared_deptids = hr.departmentid "+
" WHERE ( pds.share_pid IN ( SELECT "+
" id "+
" FROM getallchilds("+userid+") ) "+
" OR pds.share_pid = "+userid+
" ) "+
" AND hr.id = cbi.projManager ) ) "+
" ) ") ;
}catch (Exception e){
}
return sqlWhere_t.toString();
}
/***
* 项目验收个数,项目验收平均周期
* @param userid
* @param startdate
* @param enddate
* @return
*/
public Map<String,Object> getProjectCheckCountAndAveragePeriod(int userid,int year,String startdate,String enddate)
{
BaseBean bb = new BaseBean();
bb.writeLog("getProjectCheckCountAndAveragePeriod:");
RecordSet rs = new RecordSet();
/******************完成收款****************/
String ysxmgs = "0" ;
String pjxmzq = "0.00" ;
Map<String,Object> map = new HashMap<String,Object>();
try{
// String userids = userid+"";
// String sql =" with tem_table(hrm_id,last_name,manager_id,curlevel) as \n" +
// " (select id,lastname,managerid,1 as level " +
// " from HrmResource " +
// " where id=" + userid +
// " union all\n" +
// " select a.id,a.lastname,a.managerid,b.curlevel+1 " +
// " from HrmResource a " +
// " inner join tem_table b on (a.managerid = b.hrm_id) \n" +
// " )\n" +
// " select * from tem_table" ;
// rs.execute(sql);
// while (rs.next()){
// String hrmid = Util.null2String(rs.getString("hrm_id"));
// userids += userids == "" ? hrmid : ","+hrmid ;
// }
String userWhere = " and (t3t.hrmid in("+userid+") or t3t.qyjl in("+userid+") or t3t.dqzj in("+userid+") or t3t.qyzj in("+userid+")) " ;
String sql =" select convert(decimal(18,2),isnull(sum(datediff(Day,cbi.planstartdate,cbi.gdrq)),0)/(case when count(1)=0 then 1.0 else count(1)*1.0 end)) as pjxmzq,isnull(count(1),0) as ysxmgs " +
" from proj_CardBaseInfo cbi " +
" left join lf_prjhrminfo t3t on t3t.hrmid = cbi.projmanager " +
" where cbi.gdrq >= '"+startdate+"' AND cbi.gdrq <= '"+enddate+"' " +
" and cbi.gdrq IS NOT NULL AND cbi.gdrq <> '' " +
" and cbi.planstartdate is not null and cbi.planstartdate <> '' " +
" and cbi.isYanshou=1 "+userWhere;
bb.writeLog("sql:"+sql);
rs.executeQuery(sql);
if(rs.next()){
pjxmzq = Util.null2String(rs.getString("pjxmzq"));
ysxmgs = Util.null2String(rs.getString("ysxmgs"));
}
}catch (Exception e){
}
bb.writeLog("pjxmzq:"+pjxmzq);
bb.writeLog("ysxmgs:"+ysxmgs);
map.put("ysxmgs",ysxmgs);
map.put("pjxmzq",pjxmzq);
return map;
}
/////##########################项目人员##################################//
/////##########################技术人员##################################//
/***
* 问题处理数量
* @param userid
* @param begindate
* @param enddate
* @return
*/
public int getProblemHandlCount(int userid,String begindate,String enddate){
int problem_handl = 0;
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
bb.writeLog("getProblemHandlCount");
// String khwezcjjlc_billform = getUfPropValue("khwezcjjlc.billformid"); //83
// if(StringUtils.isEmpty(khwezcjjlc_billform)){
// khwezcjjlc_billform = "83";
// }
try{
// String sql =" select sum(case when (t.tzhxgs is null or len(t.tzhxgs)=0) then case when convert(varchar(1000),t.gzlgs) is null then 0 else isnull(cast(t.gzlgs as decimal(10,2)),0) end else isnull(cast(t.tzhxgs as decimal(10,2) ),0) end) as gzlgs " +
// " from workflow_form t\n" +
// " inner join workflow_requestbase h on t.requestid = h.requestid\n" +
// " where t.billformid=? \n" +
// " convert(varchar(1000),t.gzlgs) <> '-' \n" +
// " and charindex(','+convert(varchar(1000),t.mutiresource)+',',',"+userid+",')>0 \n" +
// " and h.createdate >= ? and h.createdate<=? \n" +
// " and h.currentnodetype=3";
String sql =" select isnull(count(1),0) as gzlgs " +
" from workflow_form t\n" +
" inner join workflow_requestbase h on t.requestid = h.requestid\n" +
" where h.workflowid = 232 \n" +
" and charindex(','+convert(varchar(1000),t.mutiresource)+',',',"+userid+",')>0 \n" +
" and h.createdate >= ? and h.createdate<=? \n" +
" and h.currentnodeid <> 1023 " +
" and h.currentnodetype = 3";
bb.writeLog("sql:"+sql);
rs.executeQuery(sql,new Object[]{begindate,enddate});
if(rs.next()){
problem_handl = rs.getInt(1);
}
bb.writeLog("problem_handl:"+problem_handl);
}catch (Exception e){
bb.writeLog("getProblemHandlCount-e:"+e);
}
return problem_handl;
}
/***
* 开发人天
* @param userid
* @param begindate
* @param enddate
* @return
*/
public double getDevelopDaysCount(int userid,String begindate,String enddate){
double develop_day = 0.00;
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
bb.writeLog("getDevelopDaysCount");
try{
String sql =" select isnull(sum(cast(desc1 as decimal(6,2))),0) as desc1 from workflow_form t\n" +
" inner join workflow_requestbase h on t.requestid = h.requestid\n" +
" where h.workflowid = 2582 \n" +
" and len(t.desc1) >0" +
" and charindex(','+convert(varchar(1000),t.multiresource5)+',',',"+userid+",')>0\n" +
" and h.createdate >= ? and h.createdate<=?\n" +
" and h.currentnodetype =3 ";
bb.writeLog("sql:"+sql);
rs.executeQuery(sql,new Object[]{begindate,enddate});
if(rs.next()){
develop_day = Util.getDoubleValue(Util.null2String(rs.getString("desc1")));
}
bb.writeLog("develop_day:"+develop_day);
}catch (Exception e){
bb.writeLog("getDevelopDaysCount-e:"+e);
}
return develop_day;
}
/***
*处理流程数
* @param userid
* @param begindate
* @param enddate
* @return
*/
public int getWorkflowDealCount(int userid,String begindate,String enddate){
int wf_deal = 0;
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
WorkflowServiceImpl ws = new WorkflowServiceImpl();
bb.writeLog("getWorkflowDealCount");
try{
boolean isshowprocessed = true;
boolean belongtoshowFlag = true;
String[] conditions = new String[2];
conditions[0] = " t2.operatedate >='"+begindate+"' " ;
conditions[1] = " t2.operatedate <='"+enddate+"'" ;
wf_deal = ws.getHendledWorkflowRequestCount(userid, isshowprocessed, conditions,belongtoshowFlag);
bb.writeLog("wf_deal:"+wf_deal);
if(wf_deal == 0)
{
String sql =" select count(*) my_count from \n" +
" ( select distinct t1.createdate,t1.createtime,t1.creater,t1.currentnodeid,t1.currentnodetype,t1.lastoperator,\n" +
" t1.creatertype,t1.lastoperatortype,t1.lastoperatedate,t1.lastoperatetime,t1.requestid,t1.requestname,t1.requestlevel,\n" +
" t1.workflowid,t2.receivedate,t2.receivetime,t2.userid,t1.requestnamenew\n" +
" from\n" +
" workflow_requestbase t1, workflow_currentoperator t2\n" +
" where\n" +
" t1.requestid = t2.requestid\n" +
" and (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
" and t2.usertype = 0\n" +
" and (t2.userid = "+userid+")\n" +
" and ( t2.isremark in('2', '4') or ( t2.isremark = '0' and t2.takisremark = '-2' ) )\n" +
" and t2.islasttimes = 1\n" +
" and t1.workflowID in(select id from workflow_base where isvalid in('1', '3') )\n" +
" and t2.operatedate >= '"+begindate+"'\n" +
" and t2.operatedate <= '"+enddate+"'\n" +
" ) tableA" ;
bb.writeLog("sql999:"+sql);
rs.executeQuery(sql);
if(rs.next()){
wf_deal = Util.getIntValue(Util.null2String(rs.getString("my_count")));
}
}
}catch (Exception e){
bb.writeLog("getWorkflowDealCount-e:"+e);
}
return wf_deal;
}
/////##########################技术人员##################################//
/***
* 沟通协作数
* @param userid
* @param begindate
* @param enddate
* @return
*/
public int getCoworkReplayCount(int userid,String begindate,String enddate){
int cwork_replay = 0;
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
bb.writeLog("getCoworkReplayCount");
try {
String sql = " select isnull(count(coworkid),0) as amount from cowork_discuss where discussant=? and createdate>=? and createdate<=?";
bb.writeLog("sql:"+sql);
rs.executeQuery(sql,new Object[]{userid,begindate,enddate});
if(rs.next()){
cwork_replay = rs.getInt(1);
}
bb.writeLog("cwork_replay:"+cwork_replay);
}catch (Exception e){
bb.writeLog("getCoworkReplayCount-e:"+e);
}
return cwork_replay;
}
/***
* 微博填写数
* @param userid
* @param begindate
* @param enddate
* @return
*/
public int getBlogWriteCount(int userid,String begindate,String enddate){
int blog_write = 0;
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
bb.writeLog("getBlogWriteCount");
try{
String sql = " select isnull(count(1),0) as count from blog_discuss where userid=? and createdate>=? and createdate<=? ";
bb.writeLog("sql:"+sql);
rs.executeQuery(sql,new Object[]{userid,begindate,enddate});
if(rs.next()){
blog_write = rs.getInt(1);
}
bb.writeLog("blog_write:"+blog_write);
}catch (Exception e){
bb.writeLog("getBlogWriteCount-e:"+e);
}
return blog_write;
}
/***
*文档贡献度
* @param
* @param begindate
* @param enddate
* @return
*/
public int getDocCreateCount(User user,String begindate,String enddate){
int doc_create = 0;
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
bb.writeLog("getDocCreateCount");
// try{
// String sql = " select isnull(count(1),0) as cou FROM DocDetail" +
// " where isreply<>1 and doccreaterid = ? and doccreatedate >=? and doccreatedate <=? " ;
// bb.writeLog("sql:"+sql);
// rs.executeQuery(sql, new Object[]{userid, begindate, enddate});
// if(rs.next()){
// doc_create = rs.getInt(1);
// }
// bb.writeLog("doc_create:"+doc_create);
// }catch (Exception e){
// e.printStackTrace();
// bb.writeLog("getDocCreateCount-e:"+e);
// }
try {
String sql = "";
//docCountType:0-知识库 1-我的文档 2-多部门文档 3-多分部文档 4-多人力资源文档数
String docCountType = "1" ;
//将参数封装到map中
Map<String,Object> datas =new HashMap<String,Object>();
datas.put("user",user);
datas.put("docCountType",docCountType);
datas.put("depts","");
datas.put("subcompanys","");
datas.put("someones","");
//获取权限Table,即拼装sql的t2
DocShareUtil shareUtil = new DocShareUtil(user);// 封装权限表
String str1 = shareUtil.getSqlShare();
String sqlWhere = DocNumUtil.getSqlCondition(datas);
if("1".equals(docCountType)){
sql = "select count(id) num from DocDetail t1,(" + str1 + ") t2 where t1.id=t2.sourceid and docstatus != 8 and docstatus != 9 " +sqlWhere;
}else
sql = "select count(id) num from DocDetail t1,(" + str1 + ") t2 where t1.id=t2.sourceid" +
" and (t1.docstatus in(1,2,5) or (t1.docstatus=7 and (t2.sharelevel>1 or (t1.doccreaterid="+user.getUID()+" or t1.ownerid="+user.getUID()+"))))" + sqlWhere;
sql += " and (ishistory is null or ishistory = 0) ";
sql += " and (t1.isreply is null or t1.isreply='' or t1.isreply='0') ";
sql += " and t1.doccreatedate >='"+begindate+"' and t1.doccreatedate <='"+enddate+"' " ;
sql += DocListUtil.getSecretSql(user," and t1.secretLevel");
bb.writeLog("sql22222:"+sql);
rs.executeQuery(sql);
if(rs.next()){
doc_create = rs.getInt("num");
}
} catch (Exception e) {
e.printStackTrace();
}
return doc_create;
}
/***
*
* @param pkey
* @return
*/
public String getUfPropValue(String pkey){
if(StringUtils.isEmpty(pkey)){
return "";
}
String value = "" ;
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
String active = bb.getPropValue("developProp","active");
String sql = " select devvalue,prodvalue from uf_hr_prop where pkey = ?" ;
rs.executeQuery(sql,new Object[]{pkey});
if(rs.next()){
value = Util.null2String(rs.getString(active+"value"));
}
return value;
}
/***
*
* @param value
* @return
*/
public String formatBigDecimal(String value){
String formatValue = "" ;
try{
DecimalFormat decimalFormat = new DecimalFormat("0.00");
BigDecimal _decimal = new BigDecimal(value);
formatValue = decimalFormat.format(_decimal);
}catch (Exception e){
}
return formatValue;
}
%>