|
@@ -1,18 +1,23 @@
|
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
-import com.management.platform.entity.ActionLog;
|
|
|
-import com.management.platform.entity.BusinessOpportunity;
|
|
|
-import com.management.platform.entity.Clue;
|
|
|
-import com.management.platform.entity.User;
|
|
|
-import com.management.platform.mapper.ActionLogMapper;
|
|
|
-import com.management.platform.mapper.BusinessOpportunityMapper;
|
|
|
+import com.management.platform.entity.*;
|
|
|
+import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.BusinessOpportunityService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.management.platform.service.WxCorpInfoService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -28,10 +33,20 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportunityMapper, BusinessOpportunity> implements BusinessOpportunityService {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ExcelExportServiceImpl excelExportService;
|
|
|
+ @Resource
|
|
|
+ private WxCorpInfoService wxCorpInfoService;
|
|
|
@Resource
|
|
|
private BusinessOpportunityMapper bOMapper;
|
|
|
@Resource
|
|
|
private ActionLogMapper actionLogMapper;
|
|
|
+ @Resource
|
|
|
+ private UserMapper userMapper;
|
|
|
+ @Resource
|
|
|
+ private BusinessItemProductMapper biMapper;
|
|
|
+ @Autowired
|
|
|
+ private SysFormMapper sysFormMapper;
|
|
|
@Override
|
|
|
public List<BusinessOpportunity> getAll(BusinessOpportunity bo) {
|
|
|
return bOMapper.selectAllList(bo);
|
|
@@ -42,6 +57,14 @@ public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportun
|
|
|
return bOMapper.selectAllList1(bo,user.getId());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public BusinessOpportunity getInfo(BusinessOpportunity bo, User user) {
|
|
|
+ BusinessOpportunity businessOpportunity = bOMapper.selectById(bo.getId());
|
|
|
+ businessOpportunity.setBusinessItemProductList(biMapper.selectList(new QueryWrapper<BusinessItemProduct>().eq("business_id",bo.getId())));
|
|
|
+ businessOpportunity.setActionLogList(actionLogMapper.selectList(new QueryWrapper<ActionLog>().eq("item_id",bo.getId()).eq("code","business")));
|
|
|
+ return businessOpportunity;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<BusinessOpportunity> getAll2(BusinessOpportunity bo, User user) {
|
|
|
return bOMapper.selectAllList2(bo,user.getId());
|
|
@@ -63,13 +86,21 @@ public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportun
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void insert(BusinessOpportunity bo) {
|
|
|
+ setNull(bo);
|
|
|
bo.setCreateTime(new Date());
|
|
|
bOMapper.insert(bo);
|
|
|
-
|
|
|
+ ActionLog actionLog = new ActionLog();
|
|
|
+ actionLog.setUserId(bo.getUserId());
|
|
|
+ actionLog.setItemId(bo.getId());
|
|
|
+ actionLog.setCode("business");
|
|
|
+ actionLog.setName("创建了线索");
|
|
|
+ actionLogMapper.insert(actionLog);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void update(BusinessOpportunity bo,String userId) {
|
|
|
setNull(bo);
|
|
|
bOMapper.updateById(bo);
|
|
@@ -83,6 +114,7 @@ public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportun
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void getAndTransfer(BusinessOpportunity bo, User user) {
|
|
|
UpdateWrapper<BusinessOpportunity> updateWrapper = new UpdateWrapper<>();
|
|
|
String ids1 = bo.getIds();
|
|
@@ -119,6 +151,32 @@ public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportun
|
|
|
updateWrapper.set("incharger_id",inchargerId);
|
|
|
bOMapper.update(null, updateWrapper);
|
|
|
}
|
|
|
+
|
|
|
+ @Value(value = "${upload.file}")
|
|
|
+ private String path;
|
|
|
+ @Override
|
|
|
+ public Object exportData(BusinessOpportunity bo, HttpServletRequest request) throws Exception {
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ SysForm sysForm = sysFormMapper.selectOne(new LambdaQueryWrapper<SysForm>().eq(SysForm::getCompanyId, user.getCompanyId()).eq(SysForm::getCode, "Clue").eq(SysForm::getIsCurrent, 1));
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, user.getCompanyId()));
|
|
|
+ String config = sysForm.getConfig();
|
|
|
+ JSONObject configOb = JSON.parseObject(config);
|
|
|
+ JSONArray configObJSONArray = configOb.getJSONArray("list");
|
|
|
+ List<List<String>> dataList = new ArrayList<>();
|
|
|
+ List<String> titleList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < configObJSONArray.size(); i++) {
|
|
|
+ JSONObject item = configObJSONArray.getJSONObject(i);
|
|
|
+ titleList.add(item.getString("label"));
|
|
|
+ }
|
|
|
+ dataList.add(titleList);//设置表头
|
|
|
+
|
|
|
+
|
|
|
+ bo.setCompanyId(user.getCompanyId());
|
|
|
+
|
|
|
+ String fileName = "商机表导出_" + System.currentTimeMillis();
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo, fileName, dataList, path);
|
|
|
+ }
|
|
|
+
|
|
|
private BusinessOpportunity setNull(BusinessOpportunity bo) {
|
|
|
if (bo.getPlate1() == "") {
|
|
|
bo.setPlate1(null);
|