Browse Source

技术员奖金统计

limin 7 years ago
parent
commit
77dc4a2889

+ 6 - 0
src/main/java/com/goafanti/common/dao/TOrderBonusMapper.java

@@ -2,7 +2,10 @@ package com.goafanti.common.dao;
 
 import com.goafanti.common.model.TOrderBonus;
 import com.goafanti.common.model.TOrderBonusExample;
+import com.goafanti.order.bo.TOrderBonusBo;
+
 import java.util.List;
+
 import org.apache.ibatis.annotations.Param;
 
 public interface TOrderBonusMapper {
@@ -74,4 +77,7 @@ public interface TOrderBonusMapper {
 	 * @mbggenerated  Fri Nov 23 16:33:27 CST 2018
 	 */
 	int updateByPrimaryKey(TOrderBonus record);
+	
+	List<TOrderBonusBo> getDeptBySome(TOrderBonusBo bonusBo);
+	List<TOrderBonusBo> getBonusData(TOrderBonusBo bonusBo);
 }

+ 186 - 0
src/main/java/com/goafanti/common/mapper/TOrderBonusMapper.xml

@@ -330,4 +330,190 @@
       grant_time = #{grantTime,jdbcType=DATE}
     where id = #{id,jdbcType=VARCHAR}
   </update>
+  <!-- 财务专员统计技术员的奖金 -->
+  <select id="technicianBonusList" parameterType="Map" resultType="com.goafanti.order.bo.TOrderBonusBo">
+   select b.id, t.id as tid, b.order_no as orderNo, t.task_receiver as taskReceiver, t.task_status as taskStatus,  
+  		t.commodity_quantity as commodityQuantity, t.project_status as projectStatus,
+  		accept_time as acceptTime, review_time as reviewTime, licence_time as licenceTime,
+  		o.liquidation_status as liquidationStatus, ga.name as byName,
+  		bonus_subject as bonusSubject, grant_status as grantStatus, a.name as targetName
+  		from t_order_bonus b
+  		left join t_order_new o on o.order_no = b.order_no
+  		left join t_order_task t on t.order_no = b.order_no and t.main=1
+  		left join admin a on a.id = t.task_receiver 
+  		left join admin oa on oa.id = o.salesman_id
+  		left join admin ga on ga.id = b.grant_by 
+  		where b.bonus_subject &gt;= 20
+  		<if test="b.grantBy != null">
+  		and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
+  		</if>
+  		<if test='b.targetName != null and b.targetName != ""'>
+  		<bind name="tn" value="'%' + b.targetName + '%'"/>
+  		and a.name like #{tn,jdbcType=VARCHAR}
+  		</if>
+  		<if test='b.salesName != null and b.salesName != ""'>
+  		<bind name="sn" value="'%' + b.salesName + '%'"/>
+  		and oa.name like #{sn,jdbcType=VARCHAR}
+  		</if>
+  		<if test='b.departmentId != null and b.departmentId !=""'>
+  		and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
+  		</if>
+  		<if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
+  		<bind name="a" value="b.startTime + ' 00:00:00'"/>
+  		<bind name="e" value="b.endTime + ' 23:59:59'"/>
+  		and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
+  		</if>
+  		order by b.grant_status ,b.create_time 
+  		<if test="page_sql != null">
+			${page_sql}
+		</if>
+  </select>
+  <select id="technicianBonusCount" parameterType="Map" resultType="java.lang.Integer">
+  select count(*)
+  from t_order_bonus b
+  		left join t_order_new o on o.order_no = b.order_no
+  		left join t_order_task t on t.order_no = b.order_no and t.main=1
+  		left join admin a on a.id = t.task_receiver 
+  		left join admin oa on oa.id = o.salesman_id
+  		where b.bonus_subject &gt;= 20
+  		<if test="b.grantBy != null">
+  		and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
+  		</if>
+  		<if test='b.targetName != null and b.targetName != ""'>
+  		<bind name="tn" value="'%' + b.targetName + '%'"/>
+  		and a.name like #{tn,jdbcType=VARCHAR}
+  		</if>
+  		<if test='b.salesName != null and b.salesName != ""'>
+  		<bind name="sn" value="'%' + b.salesName + '%'"/>
+  		and oa.name like #{sn,jdbcType=VARCHAR}
+  		</if>
+  		<if test='b.departmentId != null and b.departmentId !=""'>
+  		and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
+  		</if>
+  		<if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
+  		<bind name="a" value="b.startTime + ' 00:00:00'"/>
+  		<bind name="e" value="b.endTime + ' 23:59:59'"/>
+  		and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
+  		</if>
+  </select>
+  <!-- 财务专员统计营销员奖金 -->
+  <select id="saleBonusList" parameterType="Map" resultType="com.goafanti.order.bo.TOrderBonusBo">
+  select b.id, o.order_no as orderNo, o.salesman_id as salesmanId, o.sign_time as signTime,
+	o.buyer_id as buyerId, u.nickname as buyName, o.total_amount as totalAmount, 
+	o.first_amount as firstAmount, o.settlement_amount as settlementAmount, o.refund_amount as refundAmount,
+	o.order_status as orderStatus, o.project_status as projectStatus, b.bonus_subject as bonusSubject,
+	o.proof_count as proofCount, b.grant_status as grant_status, a.name as salesName
+	
+	from t_order_bonus b
+	left join t_order_new o on o.order_no = b.order_no
+	left join admin a on o.salesman_id = a.id
+	left join `user` u on o.buyer_id = u.id
+	where b.bonus_subject &lt;20
+	
+	<if test="b.grantBy != null">
+	and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
+	</if>
+	<if test='b.salesName != null and b.salesName != ""'>
+	<bind name="sn" value="'%' + b.salesName + '%'"/>
+	and a.name like #{sn,jdbcType=VARCHAR}
+	</if>
+	<if test='b.departmentId != null and b.departmentId !=""'>
+	and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
+	</if>
+	<if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
+	<bind name="a" value="b.startTime + ' 00:00:00'"/>
+	<bind name="e" value="b.endTime + ' 23:59:59'"/>
+	and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
+	</if>
+	order by b.grant_status , b.create_time
+	<if test="page_sql != null">
+		${page_sql}
+	</if>
+  </select>
+  <select id="saleBonusCount" parameterType="Map" resultType="java.lang.Integer">
+  select count(*)
+	
+	from t_order_bonus b
+	left join t_order_new o on o.order_no = b.order_no
+	left join admin a on o.salesman_id = a.id
+	left join `user` u on o.buyer_id = u.id
+	where b.bonus_subject &lt;20
+	<if test="b.grantBy != null">
+	and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
+	</if>
+	<if test='b.salesName != null and b.salesName != ""'>
+	<bind name="sn" value="'%' + b.salesName + '%'"/>
+	and a.name like #{sn,jdbcType=VARCHAR}
+	</if>
+	<if test='b.departmentId != null and b.departmentId !=""'>
+	and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
+	</if>
+	<if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
+	<bind name="a" value="b.startTime + ' 00:00:00'"/>
+	<bind name="e" value="b.endTime + ' 23:59:59'"/>
+	and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
+	</if>
+  </select>
+  <!-- 获得技术员有奖金数据的部门 -->
+  <select id="getDeptBySome" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
+    select distinct
+	  	d.id as departmentId, d.name as departmentName
+	  	from t_order_bonus b
+	left join t_order_new o on o.order_no = b.order_no
+	left join admin a on b.grant_target = a.id
+	left join `user` u on o.buyer_id = u.id
+	left join department d on d.id = a.department_id
+	where b.bonus_subject &lt;20
+	<if test="grantBy != null">
+	and b.grant_by = #{grantBy,jdbcType=VARCHAR}
+	</if>
+	<if test='salesName != null and salesName != ""'>
+	<bind name="sn" value="'%' + salesName + '%'"/>
+	and a.name like #{sn,jdbcType=VARCHAR}
+	</if>
+	<if test='departmentId != null and departmentId !=""'>
+	and a.department_id = #{departmentId,jdbcType=VARCHAR}
+	</if>
+	<if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
+	<bind name="a" value="startTime + ' 00:00:00'"/>
+	<bind name="e" value="endTime + ' 23:59:59'"/>
+	and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
+	</if>
+  </select>
+  <!-- 获得及技术员奖金数据 -->
+  <select id="getBonusData" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
+  select b.id, t.id as tid, b.order_no as orderNo, t.task_receiver as taskReceiver, t.task_status as taskStatus,  
+  		t.commodity_quantity as commodityQuantity, t.project_status as projectStatus,
+  		accept_time as acceptTime, review_time as reviewTime, licence_time as licenceTime,
+  		o.liquidation_status as liquidationStatus, ga.name as byName,
+  		bonus_subject as bonusSubject, grant_status as grantStatus, a.name as targetName
+  		from t_order_bonus b
+  		left join t_order_new o on o.order_no = b.order_no
+  		left join t_order_task t on t.order_no = b.order_no and t.main=1
+  		left join admin a on a.id = t.task_receiver 
+  		left join admin oa on oa.id = o.salesman_id
+  		left join admin ga on ga.id = b.grant_by 
+  		where b.bonus_subject &gt;= 20
+  		<if test="grantBy != null">
+  		and b.grant_by = #{grantBy,jdbcType=VARCHAR}
+  		</if>
+  		<if test='targetName != null and targetName != ""'>
+  		<bind name="tn" value="'%' + targetName + '%'"/>
+  		and a.name like #{tn,jdbcType=VARCHAR}
+  		</if>
+  		<if test='salesName != null and salesName != ""'>
+  		<bind name="sn" value="'%' + salesName + '%'"/>
+  		and oa.name like #{sn,jdbcType=VARCHAR}
+  		</if>
+  		<if test='departmentId != null and departmentId !=""'>
+  		and a.department_id = #{departmentId,jdbcType=VARCHAR}
+  		</if>
+  		<if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
+  		<bind name="a" value="b.startTime + ' 00:00:00'"/>
+  		<bind name="e" value="b.endTime + ' 23:59:59'"/>
+  		and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
+  		</if>
+  		order by b.grant_status ,b.create_time 
+  </select>
+  
 </mapper>

+ 6 - 0
src/main/java/com/goafanti/common/mapper/TOrderNewMapper.xml

@@ -729,6 +729,12 @@
       <if test="proofAid != null">
         proof_aid = #{proofAid,jdbcType=VARCHAR},
       </if>
+      <if test="proofTime != null">
+        proof_time = #{proofTime,jdbcType=DATE},
+      </if>
+      <if test="proofStatus != null">
+        proof_status = #{proofStatus,jdbcType=INTEGER},
+      </if>
       <if test="contractPictureUrl != null">
         contract_picture_url = #{contractPictureUrl,jdbcType=LONGVARCHAR},
       </if>

+ 20 - 0
src/main/java/com/goafanti/common/model/TOrderNew.java

@@ -183,6 +183,10 @@ public class TOrderNew {
 	 * @mbggenerated  Fri Nov 23 15:27:45 CST 2018
 	 */
 	private String proofAid;
+	
+	private Date proofTime;
+	
+	private Integer proofStatus;
 
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_new.contract_picture_url
@@ -748,4 +752,20 @@ public class TOrderNew {
 		this.contractPictureUrl = contractPictureUrl;
 	}
 
+	public Date getProofTime() {
+		return proofTime;
+	}
+
+	public void setProofTime(Date proofTime) {
+		this.proofTime = proofTime;
+	}
+
+	public Integer getProofStatus() {
+		return proofStatus;
+	}
+
+	public void setProofStatus(Integer proofStatus) {
+		this.proofStatus = proofStatus;
+	}
+
 }

+ 96 - 0
src/main/java/com/goafanti/common/utils/ExportExcelUtil.java

@@ -22,6 +22,11 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.util.CellRangeAddress;
 
 import com.goafanti.common.model.TOrderBillNew;
+import com.goafanti.order.bo.TOrderBonusBo;
+import com.goafanti.order.enums.BonusSubject;
+import com.goafanti.order.enums.LiquidationNewState;
+import com.goafanti.order.enums.ProjectNewStage;
+import com.goafanti.order.enums.TaskState;
 
 public class ExportExcelUtil {
 	
@@ -205,6 +210,97 @@ public class ExportExcelUtil {
 			e.printStackTrace();
 		}*/
 	}
+	/**
+	 * 导出技术员奖金统计
+	 * @param map
+	 * @param deptnames
+	 * @param comment
+	 * @return
+	 */
+	public static HSSFWorkbook exportDeptBonusInfoT(Map<String,List<TOrderBonusBo>> map,String[] deptnames,String[] comment){
+		//map 数据 ,deptnames 部门名称,comment表头 (列名称)
+		//1,创建一个workbook,对应的是一个excel文件
+		HSSFWorkbook wb = new HSSFWorkbook();
+		int count = 0;
+		//遍历map
+		for (Map.Entry<String,List<TOrderBonusBo>> entry : map.entrySet()) {
+			//2.创建一个sheet
+			HSSFSheet sheet = wb.createSheet(entry.getKey());
+			//3。创建一个row
+			HSSFRow row = sheet.createRow(0);
+			//4.创建一个cell
+			HSSFCell cell = row.createCell(0);
+			cell.setCellValue(deptnames[count]+" 奖金记录");
+			count ++;
+			HSSFCellStyle style1 = setCellStyle1(wb);
+			cell.setCellStyle(style1);
+			//合并列
+			sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, comment.length-1));//合并单元格
+			//创建表头
+			HSSFRow row2 = sheet.createRow(1);
+			for(int i = 0; i < comment.length; i++){
+				sheet.setColumnWidth(i, 3000);//设置列宽
+				HSSFCell c = row2.createCell(i);
+				c.setCellValue(comment[i]);
+				c.setCellStyle(style1);
+			}
+			//填充表格数据
+			//int rowmnum = sheet.getLastRowNum();//获得当前行数据
+			List<TOrderBonusBo> list = entry.getValue();
+			if(list == null){
+				continue;
+			}
+			for (TOrderBonusBo ob : list) {
+				//新增一行
+				HSSFRow r = sheet.createRow(sheet.getLastRowNum()+1);
+				for (int i = 0; i < comment.length; i++) {
+					//当前列的只
+					String o = "";
+					switch (comment[i]) {
+					case "任务编号": o = ob.getTid().toString(); break;
+					case "订单编号": o = ob.getOrderNo(); break;
+					case "任务负责人": o = ob.getSalesName(); break;
+					case "任务状态": o = TaskState.getValueByCode(ob.getTaskStatus()); break;
+					case "任务数量": o = ob.getCommodityQuantity().toString(); break;
+					case "项目状态": o = ProjectNewStage.getValueByCode(ob.getProjectStatus()); break;
+					case "受理日期": o = ob.getAcceptTime(); break;
+					case "评审日期": o = ob.getReviewTime(); break;
+					case "下证日期": o = ob.getLicenceTime();break;
+					case "订单结算状态": o = LiquidationNewState.getValueByCode(ob.getLiquidationStatus()); break;
+					case "发放类型": o = BonusSubject.getValueByCode(ob.getBonusSubject()); break;
+					case "发放状态": 
+						if(0 == ob.getGrantStatus()){
+							o = "未发放";
+						}else if(1 == ob.getGrantStatus()){
+							o = "已发放";
+						}
+					break;
+					default: o = ""; break;
+					}
+					HSSFCell c = r.createCell(i);
+					c.setCellValue(o);
+				}
+			}
+		}
+		return wb;
+		/*OutputStream os = new ByteArrayOutputStream();
+		try {
+			wb.write(os);
+		} catch (IOException e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		}
+		//将表格数据放入文件中
+		try {
+			FileOutputStream fos = new FileOutputStream(filePath);
+			wb.write(fos);
+			fos.close();
+			System.out.println("已经创建文件");
+		} catch (Exception e) {
+			System.out.println("发生了异常");
+			e.printStackTrace();
+		}*/
+	}
 	
 	
 }

+ 309 - 0
src/main/java/com/goafanti/order/bo/TOrderBonusBo.java

@@ -0,0 +1,309 @@
+package com.goafanti.order.bo;
+
+import java.math.BigDecimal;
+
+import com.goafanti.common.model.TOrderBonus;
+
+public class TOrderBonusBo extends TOrderBonus{
+	
+	private String targetName; //发放目标(可以是技术员和营销员)
+	
+	private String byName; //发放人
+	
+	private String salesName;//订单负责人
+	
+	private String commodityName;
+	
+	private Integer tid; //任务数量
+	
+	private Integer commodityQuantity; //任务数量
+	
+	private BigDecimal commodityPrice; //价格
+	
+	private Integer taskStatus; //任务状态
+	
+	private Integer liquidationStatus; //订单结算状态
+	
+	private String taskAllocator; //任务分配人
+	
+	private String taskReceiver; //任务负责人
+	
+	private Integer projectStatus; //项目状态
+	
+	private String acceptTime; //受理时间
+	
+	private String reviewTime; //评审日期
+	
+	private String publicityTime; //公示日期
+	
+	private String licenceTime; // 发证日期
+	
+	private String signTime; // 签单日期
+	
+	private String departmentId; // 部门id
+	private String departmentName; // 部门名称
+	private String startTime;
+	private String endTime;
+	
+	private String buyId;
+	private String saleId;
+	private String buyName;
+	private BigDecimal totalAmount; //签单金额
+	private BigDecimal firstAmount; //首付
+	private BigDecimal settlementAmount; //已收
+	private BigDecimal refundAmount; //已付
+	
+	private Integer orderStatus; //订单状态
+	private Float proofCount; //校对量
+	
+	private Integer main;
+
+	public String getTargetName() {
+		return targetName;
+	}
+
+	public void setTargetName(String targetName) {
+		this.targetName = targetName;
+	}
+
+	public String getByName() {
+		return byName;
+	}
+
+	public Integer getTid() {
+		return tid;
+	}
+
+	public void setTid(Integer tid) {
+		this.tid = tid;
+	}
+
+	public void setByName(String byName) {
+		this.byName = byName;
+	}
+
+	public String getCommodityName() {
+		return commodityName;
+	}
+
+	public void setCommodityName(String commodityName) {
+		this.commodityName = commodityName;
+	}
+
+	public Integer getCommodityQuantity() {
+		return commodityQuantity;
+	}
+
+	public void setCommodityQuantity(Integer commodityQuantity) {
+		this.commodityQuantity = commodityQuantity;
+	}
+
+	public BigDecimal getCommodityPrice() {
+		return commodityPrice;
+	}
+
+	public void setCommodityPrice(BigDecimal commodityPrice) {
+		this.commodityPrice = commodityPrice;
+	}
+
+	public Integer getTaskStatus() {
+		return taskStatus;
+	}
+
+	public void setTaskStatus(Integer taskStatus) {
+		this.taskStatus = taskStatus;
+	}
+
+	public String getTaskAllocator() {
+		return taskAllocator;
+	}
+
+	public void setTaskAllocator(String taskAllocator) {
+		this.taskAllocator = taskAllocator;
+	}
+
+	public String getTaskReceiver() {
+		return taskReceiver;
+	}
+
+	public void setTaskReceiver(String taskReceiver) {
+		this.taskReceiver = taskReceiver;
+	}
+
+	public Integer getProjectStatus() {
+		return projectStatus;
+	}
+
+	public void setProjectStatus(Integer projectStatus) {
+		this.projectStatus = projectStatus;
+	}
+
+	public String getAcceptTime() {
+		return acceptTime;
+	}
+
+	public void setAcceptTime(String acceptTime) {
+		this.acceptTime = acceptTime;
+	}
+
+	public String getReviewTime() {
+		return reviewTime;
+	}
+
+	public void setReviewTime(String reviewTime) {
+		this.reviewTime = reviewTime;
+	}
+
+	public String getPublicityTime() {
+		return publicityTime;
+	}
+
+	public void setPublicityTime(String publicityTime) {
+		this.publicityTime = publicityTime;
+	}
+
+	public String getLicenceTime() {
+		return licenceTime;
+	}
+
+	public void setLicenceTime(String licenceTime) {
+		this.licenceTime = licenceTime;
+	}
+
+	public Integer getMain() {
+		return main;
+	}
+
+	public void setMain(Integer main) {
+		this.main = main;
+	}
+
+	public Integer getLiquidationStatus() {
+		return liquidationStatus;
+	}
+
+	public void setLiquidationStatus(Integer liquidationStatus) {
+		this.liquidationStatus = liquidationStatus;
+	}
+
+	public String getStartTime() {
+		return startTime;
+	}
+
+	public void setStartTime(String startTime) {
+		this.startTime = startTime;
+	}
+
+	public String getEndTime() {
+		return endTime;
+	}
+
+	public void setEndTime(String endTime) {
+		this.endTime = endTime;
+	}
+
+	public String getSalesName() {
+		return salesName;
+	}
+
+	public void setSalesName(String salesName) {
+		this.salesName = salesName;
+	}
+
+	public String getDepartmentId() {
+		return departmentId;
+	}
+
+	public void setDepartmentId(String departmentId) {
+		this.departmentId = departmentId;
+	}
+
+	public String getSignTime() {
+		return signTime;
+	}
+
+	public void setSignTime(String signTime) {
+		this.signTime = signTime;
+	}
+
+	public String getBuyId() {
+		return buyId;
+	}
+
+	public void setBuyId(String buyId) {
+		this.buyId = buyId;
+	}
+
+	public String getSaleId() {
+		return saleId;
+	}
+
+	public void setSaleId(String saleId) {
+		this.saleId = saleId;
+	}
+
+	public String getBuyName() {
+		return buyName;
+	}
+
+	public void setBuyName(String buyName) {
+		this.buyName = buyName;
+	}
+
+	public BigDecimal getTotalAmount() {
+		return totalAmount;
+	}
+
+	public void setTotalAmount(BigDecimal totalAmount) {
+		this.totalAmount = totalAmount;
+	}
+
+	public BigDecimal getFirstAmount() {
+		return firstAmount;
+	}
+
+	public void setFirstAmount(BigDecimal firstAmount) {
+		this.firstAmount = firstAmount;
+	}
+
+	public BigDecimal getSettlementAmount() {
+		return settlementAmount;
+	}
+
+	public void setSettlementAmount(BigDecimal settlementAmount) {
+		this.settlementAmount = settlementAmount;
+	}
+
+	public BigDecimal getRefundAmount() {
+		return refundAmount;
+	}
+
+	public void setRefundAmount(BigDecimal refundAmount) {
+		this.refundAmount = refundAmount;
+	}
+
+	public Integer getOrderStatus() {
+		return orderStatus;
+	}
+
+	public void setOrderStatus(Integer orderStatus) {
+		this.orderStatus = orderStatus;
+	}
+
+	public Float getProofCount() {
+		return proofCount;
+	}
+
+	public void setProofCount(Float proofCount) {
+		this.proofCount = proofCount;
+	}
+
+	public String getDepartmentName() {
+		return departmentName;
+	}
+
+	public void setDepartmentName(String departmentName) {
+		this.departmentName = departmentName;
+	}
+	
+}

+ 75 - 9
src/main/java/com/goafanti/order/controller/OrderBonusStatisticsApiController.java

@@ -1,9 +1,17 @@
 package com.goafanti.order.controller;
 
-import java.math.BigDecimal;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
@@ -11,7 +19,8 @@ import org.springframework.web.bind.annotation.RestController;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.controller.CertifyApiController;
 import com.goafanti.common.model.TOrderNew;
-import com.goafanti.order.bo.TOrderNewBo;
+import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.order.bo.TOrderBonusBo;
 import com.goafanti.order.service.FundManageOrderService;
 import com.goafanti.order.service.OrderBonusService;
 
@@ -41,15 +50,14 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 	  * @return
 	  */
 	 @RequestMapping(value="/saleBonusStatistics", method = RequestMethod.GET)
-	 public Result saleBonusStatistics(TOrderNewBo orderNewBo){
+	 public Result saleBonusStatistics(TOrderBonusBo bonusBo, Integer pageNo, Integer pageSize){
 		 Result res = new Result();
-		 System.out.println(orderNewBo.getFirstAmount().add(new BigDecimal("-3")));
-		 //res.setData(fundManageOrderServiceImpl.updateProofreading(orderNew));
+		 res.setData(orderBonusServiceImpl.saleBonusStatistics(bonusBo, pageNo, pageSize));
 		 return res;
 	 }
 	 
 	 /**
-	  * 财务专员发放奖金
+	  * 财务专员发放营销员奖金
 	  * @param id
 	  * @return
 	  */
@@ -66,14 +74,72 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 	 }
 	 
 	 /**
-	  * 
-	  * @param orderNewBo
+	  * 财务专员查看技术员奖金数据
+	  * @param bonusBo
+	  * @param pageNo
+	  * @param pageSize
 	  * @return
 	  */
 	 @RequestMapping(value="/technicianBonusStatistics", method = RequestMethod.GET)
-	 public Result technicianBonusStatistics(TOrderNewBo orderNewBo){
+	 public Result technicianBonusStatistics(TOrderBonusBo bonusBo,Integer pageNo, Integer pageSize){
+		 Result res = new Result();
+		 bonusBo.setSalesName(TokenManager.getAdminId());
+		 res.setData(orderBonusServiceImpl.technicianBonusStatistics(bonusBo, pageNo, pageSize));
+		 return res;
+	 }
+	 
+	 /**
+	  * 财务专员发放技术员的奖金操作
+	  * @param id
+	  * @return
+	  */
+	 @RequestMapping(value="/changeBonus", method = RequestMethod.POST)
+	 public Result changeBonus(String id){
+		 Result res = new Result();
+		 res.setData(orderBonusServiceImpl.updateChangeBonus(id));
+		 return res;
+	 }
+	 
+	 @RequestMapping(value="/exportSaleBonusData", method = RequestMethod.GET)
+	 public Result exportSaleBonusData(TOrderBonusBo bonusBo,HttpServletResponse response) throws IOException{
+		Result res = new Result();
+		return res;
+	 }
+	 
+	/**
+	 * 导出技术员(咨询师)的奖金数据
+	 * @param bonusBo
+	 * @param response
+	 * @return
+	 * @throws IOException
+	 */
+	 @RequestMapping(value="/exportTechnicianBonusData", method = RequestMethod.GET)
+	 public Result exportTechnicianBonusData(TOrderBonusBo bonusBo,HttpServletResponse response) throws IOException{
+		 OutputStream out = response.getOutputStream();
 		 Result res = new Result();
+		 bonusBo.setGrantBy(TokenManager.getAdminId());
+		 HSSFWorkbook wb = orderBonusServiceImpl.exportTechnicianBonusData(bonusBo);
+		 if(null == wb){
+			 wb = new HSSFWorkbook();
+			 HSSFSheet sheet = wb.createSheet("没有技术员奖金记录");
+			 HSSFRow row = sheet.createRow(0);
+			 HSSFCell cell = row.createCell(0);
+			 cell.setCellValue("没有技术员奖金记录");
+		 }
+		 String fileName = "技术员奖金统计" + new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()) + ".xls";
+		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));  
+		 response.setContentType("application/octet-stream;charset=utf-8");  
+		 try {
+			 // 返回数据流
+			 wb.write(out); 
+			 out.flush();
+			 out.close();
+		 } finally {
+			 out.flush(); 
+			 out.close(); 
+		 }
 		 return res;
 	 }
 	 
+	 
 }

+ 68 - 0
src/main/java/com/goafanti/order/enums/BonusSubject.java

@@ -0,0 +1,68 @@
+package com.goafanti.order.enums;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 奖金科目
+ * @author Administrator
+ *
+ */
+public enum BonusSubject {
+	SF(11,"首款付清"),
+	WK(12,"尾款结清"),
+	TK(16,"退款"),
+	// TODO
+	YTJ(1,"申报奖"),
+	PS(2,"认证奖"),
+	DGS(3,"结算奖"),
+	
+	/** 无效 **/
+	INVALID(10, "INVALID");
+	
+	private BonusSubject(Integer code, String desc) {
+		this.code = code;
+		this.desc = desc;
+	}
+
+	private static Map<Integer, BonusSubject> status = new HashMap<Integer, BonusSubject>();
+
+	static {
+		for (BonusSubject value : BonusSubject.values()) {
+			status.put(value.getCode(), value);
+		}
+	}
+	public static BonusSubject getStatus(Integer code) {
+		if (containsType(code)) {
+			return status.get(code);
+		}
+		return INVALID;
+	}
+	public static boolean containsType(Integer code) {
+		return status.containsKey(code);
+	}
+	
+	public static String getValueByCode(Integer code){
+        for(BonusSubject bonusSubject:BonusSubject.values()){
+            if(code.equals(bonusSubject.getCode())){
+                return bonusSubject.getDesc();
+            }
+        }
+        return  null;
+    }
+	
+	private Integer	code;
+	private String	desc;
+	public Integer getCode() {
+		return code;
+	}
+	public void setCode(Integer code) {
+		this.code = code;
+	}
+	public String getDesc() {
+		return desc;
+	}
+	public void setDesc(String desc) {
+		this.desc = desc;
+	}
+}

+ 10 - 0
src/main/java/com/goafanti/order/enums/LiquidationNewState.java

@@ -34,6 +34,16 @@ public enum LiquidationNewState {
 		}
 		return INVALID;
 	}
+	
+	public static String getValueByCode(Integer code){
+        for(LiquidationNewState liquidationNewState:LiquidationNewState.values()){
+            if(code.equals(liquidationNewState.getCode())){
+                return liquidationNewState.getDesc();
+            }
+        }
+        return  null;
+    }
+	
 	public static boolean containsType(Integer code) {
 		return status.containsKey(code);
 	}

+ 10 - 0
src/main/java/com/goafanti/order/enums/ProjectNewStage.java

@@ -43,6 +43,16 @@ public enum ProjectNewStage {
 	public static boolean containsType(Integer code) {
 		return status.containsKey(code);
 	}
+	
+	public static String getValueByCode(Integer code){
+        for(ProjectNewStage projectNewStage:ProjectNewStage.values()){
+            if(code.equals(projectNewStage.getCode())){
+                return projectNewStage.getDesc();
+            }
+        }
+        return  null;
+    }
+	
 	private Integer	code;
 	private String	desc;
 	public Integer getCode() {

+ 8 - 0
src/main/java/com/goafanti/order/enums/TaskState.java

@@ -32,6 +32,14 @@ public enum TaskState {
 	public static boolean containsType(Integer code) {
 		return status.containsKey(code);
 	}
+	public static String getValueByCode(Integer code){
+        for(TaskState taskState:TaskState.values()){
+            if(code.equals(taskState.getCode())){
+                return taskState.getDesc();
+            }
+        }
+        return  null;
+    }
 	private Integer	code;
 	private String	desc;
 	public Integer getCode() {

+ 33 - 1
src/main/java/com/goafanti/order/service/OrderBonusService.java

@@ -1,6 +1,11 @@
 package com.goafanti.order.service;
 
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+
 import com.goafanti.common.model.TOrderBonus;
+import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.order.bo.OrderListBo;
+import com.goafanti.order.bo.TOrderBonusBo;
 
 public interface OrderBonusService {
 	/**
@@ -11,9 +16,36 @@ public interface OrderBonusService {
 	Integer addOrderBouns(TOrderBonus bonus);
 	
 	/**
-	 * 更改发放奖金状态
+	 * 更改营销员发放奖金状态
 	 * @param id
 	 * @return
 	 */
 	Integer updateBounsPaymnetStatus(String id,String orderNo);
+	
+	/**
+	 * 财务专员查看技术员的奖金统计
+	 * @param newBo
+	 * @return
+	 */
+	Pagination<OrderListBo> technicianBonusStatistics(TOrderBonusBo bonusBo , Integer pageNo, Integer pageSize);
+	
+	/**
+	 * 财务专员查看营销员的奖金统计
+	 * @param newBo
+	 * @return
+	 */
+	Pagination<OrderListBo> saleBonusStatistics(TOrderBonusBo bonusBo, Integer pageNo, Integer pageSize);
+	/**
+	 * 财务专员更改技术员(咨询师)奖金发放状态
+	 * @param id
+	 * @return
+	 */
+	Integer updateChangeBonus(String id);
+	
+	/**
+	 * 财务专员导出技术员奖金数据
+	 * @param bonusBo
+	 * @return
+	 */
+	HSSFWorkbook exportTechnicianBonusData(TOrderBonusBo bonusBo);
 }

+ 5 - 0
src/main/java/com/goafanti/order/service/impl/FundManagerOrderServiceImpl.java

@@ -2,6 +2,7 @@ package com.goafanti.order.service.impl;
 
 import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -306,6 +307,10 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 	public Integer updateProofreading(TOrderNew orderNew) {
 		// 创建人
 		orderNew.setProofAid(TokenManager.getAdminId());
+		//校对状态
+		orderNew.setProofStatus(1);
+		//校对时间
+		orderNew.setProofTime(new Date());
 		return tOrderNewMapper.updateByPrimaryKeySelective(orderNew);
 	}
 	

+ 62 - 1
src/main/java/com/goafanti/order/service/impl/OrderBonusServiceImpl.java

@@ -1,8 +1,11 @@
 package com.goafanti.order.service.impl;
 
-import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -10,8 +13,12 @@ import com.goafanti.common.dao.TOrderBonusMapper;
 import com.goafanti.common.dao.TOrderNewMapper;
 import com.goafanti.common.model.TOrderBonus;
 import com.goafanti.common.model.TOrderNew;
+import com.goafanti.common.utils.ExportExcelUtil;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.order.bo.OrderListBo;
+import com.goafanti.order.bo.TOrderBonusBo;
 import com.goafanti.order.service.OrderBonusService;
 
 @Service
@@ -42,4 +49,58 @@ public class OrderBonusServiceImpl extends BaseMybatisDao<TOrderBonusMapper> imp
 		//bonus.setGrantTime(new Date());发放时间预留
 		return bonusMapper.updateByPrimaryKeySelective(bonus);
 	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public Pagination<OrderListBo> technicianBonusStatistics(TOrderBonusBo newBo,Integer pageNo, Integer pageSize) {
+		Map<String, Object> params = new HashMap<String, Object>();
+		params.put("b", newBo);
+		Pagination<OrderListBo> data = (Pagination<OrderListBo>)findPage("technicianBonusList", "technicianBonusCount", params, pageNo, pageSize);
+		return data;
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public Pagination<OrderListBo> saleBonusStatistics(TOrderBonusBo newBo, Integer pageNo, Integer pageSize) {
+		Map<String, Object> params = new HashMap<String, Object>();
+		params.put("b", newBo);
+		Pagination<OrderListBo> data = (Pagination<OrderListBo>)findPage("saleBonusList", "saleBonusCount", params, pageNo, pageSize);
+		return data;
+	}
+
+	@Override
+	public Integer updateChangeBonus(String id) {
+		TOrderBonus bonus = new TOrderBonus();
+		bonus.setId(id);
+		bonus.setGrantStatus(1);
+		return bonusMapper.updateByPrimaryKeySelective(bonus);
+	}
+
+	@Override
+	public HSSFWorkbook exportTechnicianBonusData(TOrderBonusBo bonusBo) {
+		// 判断导出是否有部门
+		String deptid = bonusBo.getDepartmentId();
+		Map<String, List<TOrderBonusBo>> map = new HashMap<String, List<TOrderBonusBo>>();
+		String[] deptnames = null; 
+		if(StringUtils.isBlank(deptid)){
+			//获得所有有数据的部门
+			List<TOrderBonusBo> dlist = bonusMapper.getDeptBySome(bonusBo);
+			if(null == dlist || dlist.size() == 0){
+				return null;
+			}
+			deptnames = new String[dlist.size()];
+			for (int i = 0; i < dlist.size(); i++) {
+				TOrderBonusBo ob = dlist.get(i);
+				deptnames[i] = ob.getDepartmentName();
+				bonusBo.setDepartmentId(ob.getDepartmentId());
+				map.put(ob.getDepartmentName(), bonusMapper.getBonusData(bonusBo));
+			}
+		}else{
+			deptnames = new String[1];
+			map.put(bonusBo.getDepartmentName(), bonusMapper.getBonusData(bonusBo));
+		}
+		String[] comment = {"任务编号","订单编号","任务负责人","任务状态","任务数量","项目状态","受理日期","评审日期","下证日期","订单结算状态","发放类型","发放状态"};
+		HSSFWorkbook wb = ExportExcelUtil.exportDeptBonusInfoT(map, deptnames, comment);
+		return wb;
+	}
 }