| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- package com.goafanti.order.service.impl;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.UUID;
- import org.apache.poi.xssf.usermodel.XSSFWorkbook;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.goafanti.common.dao.TOrderBonusMapper;
- import com.goafanti.common.dao.TOrderMonthReportMapper;
- 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.OrderReportBo;
- import com.goafanti.order.bo.TOrderBonusBo;
- import com.goafanti.order.service.OrderBonusService;
- @Service
- public class OrderBonusServiceImpl extends BaseMybatisDao<TOrderBonusMapper> implements OrderBonusService {
-
- @Autowired
- private TOrderBonusMapper bonusMapper;
- @Autowired
- private TOrderNewMapper orderNewMapper;
- @Autowired
- private TOrderMonthReportMapper orderMonthReportMapper;
-
- @Override
- public Integer addOrderBouns(TOrderBonus bonus) {
- // 生成id
- bonus.setId(UUID.randomUUID().toString());
- return bonusMapper.insertSelective(bonus);
- }
- @Override
- public Integer updateBounsPaymnetStatus(String id,String orderNo) {
- //先确定订单有没有校对信息
- TOrderNew o = orderNewMapper.selectByPrimaryKey(orderNo);
- if(null == o || StringUtils.isBlank(o.getProofAid())){//不存在或者没有校对
- return -1;
- }
- TOrderBonus bonus = new TOrderBonus();
- bonus.setId(id);
- bonus.setGrantStatus(1);
- //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<TOrderBonusBo> saleBonusStatistics(TOrderBonusBo newBo, Integer pageNo, Integer pageSize) {
- Map<String, Object> params = new HashMap<String, Object>();
- params.put("b", newBo);
- Pagination<TOrderBonusBo> data = (Pagination<TOrderBonusBo>)findPage("saleBonusList", "saleBonusCount", params, pageNo, pageSize);
-
- innerData((List<TOrderBonusBo>) data.getList(), newBo);
- return data;
- }
-
- private void innerData(List<TOrderBonusBo> list, TOrderBonusBo newBo){
- Integer m = null;
- Integer m1 = null;
- Integer y = null;
- Integer y1 = null;
- if(StringUtils.isNotEmpty(newBo.getStartTime()) && StringUtils.isNotEmpty(newBo.getEndTime())){
- m = Integer.valueOf(newBo.getStartTime().replaceAll("-", ""));
- m1 = Integer.valueOf(newBo.getEndTime().replaceAll("-", ""));
- y = Integer.valueOf(newBo.getStartTime().substring(0, newBo.getStartTime().indexOf("-")));
- y1 = Integer.valueOf(newBo.getEndTime().substring(0, newBo.getEndTime().indexOf("-")));
- }
- for (TOrderBonusBo orderListBo : list) {
- //处理月度数据
- OrderReportBo r = new OrderReportBo();
- r.setSalemansId(orderListBo.getGrantTarget());
- r.setMonth(m);
- r.setMonth1(m1);
- List<OrderReportBo> l = orderMonthReportMapper.getMonthReportByMonth(r);
- if(l.size() == 1){
- OrderReportBo o = l.get(0);
- orderListBo.setKejim(o.getKejim());
- orderListBo.setRenzm(o.getRenzm());
- }
-
- r.setMonth(y);
- r.setMonth1(y1);
- //处理年度数据
- List<OrderReportBo> ll = orderMonthReportMapper.getYearReportByYear(r);
- if(l.size() == 1){
- OrderReportBo o = ll.get(0);
- orderListBo.setKejiy(o.getKejiy());
- orderListBo.setRenzy(o.getRenzy());
- }
- }
- }
- @Override
- public Integer updateChangeBonus(String id) {
- TOrderBonus bonus = new TOrderBonus();
- bonus.setId(id);
- bonus.setGrantStatus(1);
- return bonusMapper.updateByPrimaryKeySelective(bonus);
- }
- @Override
- public XSSFWorkbook exportTechnicianBonusData(TOrderBonusBo bonusBo) {
- // 判断导出是否有部门
- String deptid = bonusBo.getDepartmentId();
- Map<String, List<TOrderBonusBo>> map = new HashMap<String, List<TOrderBonusBo>>();
- String[] deptnames = null;
- if(StringUtils.isBlank(deptid)){
- //获得所有有数据的部门
- bonusBo.setGrantType(1);
- 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];
- deptnames[0] = bonusBo.getDepartmentName();
- map.put(bonusBo.getDepartmentName(), bonusMapper.getBonusData(bonusBo));
- }
- String[] comment = {"任务编号","订单编号","任务负责人","任务状态","任务数量","项目状态","受理日期","评审日期","下证日期","订单结算状态","发放类型","发放状态"};
- XSSFWorkbook wb = ExportExcelUtil.exportDeptBonusInfoT(map, deptnames, comment);
- return wb;
- }
- @Override
- public XSSFWorkbook exportSaleBonusData(TOrderBonusBo bonusBo) {
- String deptid = bonusBo.getDepartmentId();
- Map<String, List<TOrderBonusBo>> map = new HashMap<String, List<TOrderBonusBo>>();
- String[] deptnames = null;
- if(StringUtils.isBlank(deptid)){
- //获得所有有数据的部门
- bonusBo.setGrantType(0);
- 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());
- List<TOrderBonusBo> l = bonusMapper.getSaleBounsList(bonusBo);
- innerData(l, bonusBo);
- map.put(ob.getDepartmentName(), l);
- }
- }else{
- List<TOrderBonusBo> l = bonusMapper.getSaleBounsList(bonusBo);
- innerData(l, bonusBo);
- deptnames = new String[1];
- deptnames[0] = bonusBo.getDepartmentName();
- map.put(bonusBo.getDepartmentName(), l);
- }
- XSSFWorkbook wb = ExportExcelUtil.exportDeptBonusInfoS(map, deptnames);
- return wb;
- }
- }
|