|
@@ -18,6 +18,7 @@ import com.management.platform.service.*;
|
|
import com.management.platform.util.ExcelUtil;
|
|
import com.management.platform.util.ExcelUtil;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.MessageUtils;
|
|
import com.management.platform.util.MessageUtils;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.poi.EncryptedDocumentException;
|
|
import org.apache.poi.EncryptedDocumentException;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.ss.usermodel.CellType;
|
|
import org.apache.poi.ss.usermodel.CellType;
|
|
@@ -54,6 +55,7 @@ import java.util.stream.Collectors;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
@Transactional
|
|
@Transactional
|
|
|
|
+@Slf4j
|
|
public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, ExpenseSheet> implements ExpenseSheetService {
|
|
public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, ExpenseSheet> implements ExpenseSheetService {
|
|
@Value(value = "${upload.path}")
|
|
@Value(value = "${upload.path}")
|
|
private String path;
|
|
private String path;
|
|
@@ -325,12 +327,14 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
|
|
if (auditSetting==null||auditSetting.getAuditType() == null || auditSetting.getAuditType() == 0) {
|
|
if (auditSetting==null||auditSetting.getAuditType() == null || auditSetting.getAuditType() == 0) {
|
|
expenseItemService.remove(new QueryWrapper<ExpenseItem>().eq("expense_id", sheet.getId()));
|
|
expenseItemService.remove(new QueryWrapper<ExpenseItem>().eq("expense_id", sheet.getId()));
|
|
expenseItemService.saveBatch(itemList);
|
|
expenseItemService.saveBatch(itemList);
|
|
- } else {
|
|
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
if (isAuditor) {
|
|
if (isAuditor) {
|
|
//有审核权限的人修改,直接修改
|
|
//有审核权限的人修改,直接修改
|
|
expenseItemService.remove(new QueryWrapper<ExpenseItem>().eq("expense_id", sheet.getId()));
|
|
expenseItemService.remove(new QueryWrapper<ExpenseItem>().eq("expense_id", sheet.getId()));
|
|
expenseItemService.saveBatch(itemList);
|
|
expenseItemService.saveBatch(itemList);
|
|
- } else {
|
|
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
//已通过不能删除
|
|
//已通过不能删除
|
|
QueryWrapper<ExpenseItem> queryWrapper = new QueryWrapper<ExpenseItem>().eq("expense_id", sheet.getId());
|
|
QueryWrapper<ExpenseItem> queryWrapper = new QueryWrapper<ExpenseItem>().eq("expense_id", sheet.getId());
|
|
queryWrapper.eq("status", 0);
|
|
queryWrapper.eq("status", 0);
|
|
@@ -459,6 +463,108 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
|
|
}
|
|
}
|
|
informationService.saveBatch(informationList);
|
|
informationService.saveBatch(informationList);
|
|
}
|
|
}
|
|
|
|
+ //柘中下发报销单 给报销人发送信息提醒
|
|
|
|
+ else if (isNew && auditSetting != null && auditSetting.getAuditType() == 2&&org.apache.commons.lang3.StringUtils.isEmpty(sheet.getFirstCheckerId())) {
|
|
|
|
+ //给报销人发送信息提醒
|
|
|
|
+ log.info("柘中给报销人下发报销单");
|
|
|
|
+ List<User> targetUserList = new ArrayList<>();
|
|
|
|
+ User owner = userMapper.selectById(sheet.getOwnerId());
|
|
|
|
+ targetUserList.add(owner);
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
+ if (wxCorpInfo != null) {
|
|
|
|
+ String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
|
|
|
|
+ ExpenseMainType mainType = expenseMainTypeService.getById(sheet.getType());
|
|
|
|
+ //推送到企业微信
|
|
|
|
+ JSONObject json=new JSONObject();
|
|
|
|
+ JSONArray dataJson=new JSONArray();
|
|
|
|
+ JSONObject jsonObj=new JSONObject();
|
|
|
|
+ jsonObj.put("key", "报销人");
|
|
|
|
+ jsonObj.put("value",("$userName="+owner.getCorpwxUserid()+"$"));
|
|
|
|
+ JSONObject jsonObj1=new JSONObject();
|
|
|
|
+ jsonObj1.put("key", "填报日期");
|
|
|
|
+ jsonObj1.put("value",sheet.getCreateDate()==null?"":sheet.getCreateDate());
|
|
|
|
+ JSONObject jsonObj2=new JSONObject();
|
|
|
|
+ jsonObj2.put("key", "票据类型");
|
|
|
|
+ jsonObj2.put("value",mainType.getName());
|
|
|
|
+ JSONObject jsonObj3=new JSONObject();
|
|
|
|
+ jsonObj2.put("key", "提示");
|
|
|
|
+ jsonObj2.put("value","请及时填写报销单信息");
|
|
|
|
+ dataJson.add(jsonObj);
|
|
|
|
+ dataJson.add(jsonObj1);
|
|
|
|
+ dataJson.add(jsonObj2);
|
|
|
|
+ dataJson.add(jsonObj3);
|
|
|
|
+ json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
|
|
|
|
+ json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
|
|
|
|
+ json.put("content_item",dataJson);
|
|
|
|
+ wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Information> informationList=new ArrayList<>();
|
|
|
|
+ for (User item : targetUserList) {
|
|
|
|
+ Information information=new Information();
|
|
|
|
+ information.setUserId(item.getId());
|
|
|
|
+ information.setTime(LocalDateTime.now());
|
|
|
|
+ information.setMsg("机械费用报销待报销人填写信息");
|
|
|
|
+ information.setType(3);
|
|
|
|
+ information.setContent(sheet.getCreateDate()+"");
|
|
|
|
+ informationList.add(information);
|
|
|
|
+ }
|
|
|
|
+ informationService.saveBatch(informationList);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ //柘中报销人填写报销单信息,完善填报金额,第一审核人,第二审核人信息,给第一审核人发送信息
|
|
|
|
+ if (!isNew&& auditSetting != null && auditSetting.getAuditType() == 2&&sheet.getReviewProcess()==0){
|
|
|
|
+ log.info("柘中报销人填写报销单信息,完善填报金额,第一审核人,第二审核人信息,给第一审核人发送信息");
|
|
|
|
+ //发送给第一审核人审核
|
|
|
|
+ List<User> targetUserList = new ArrayList<>();
|
|
|
|
+ User firstChecker = userMapper.selectById(sheet.getFirstCheckerId());
|
|
|
|
+ targetUserList.add(firstChecker);
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
+ if (wxCorpInfo != null) {
|
|
|
|
+ String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
|
|
|
|
+ User targetUser = userMapper.selectById(sheet.getOwnerId());
|
|
|
|
+ ExpenseMainType mainType = expenseMainTypeService.getById(sheet.getType());
|
|
|
|
+ //推送到企业微信
|
|
|
|
+ JSONObject json=new JSONObject();
|
|
|
|
+ JSONArray dataJson=new JSONArray();
|
|
|
|
+ JSONObject jsonObj=new JSONObject();
|
|
|
|
+ jsonObj.put("key", "报销人");
|
|
|
|
+ jsonObj.put("value",("$userName="+targetUser.getCorpwxUserid()+"$"));
|
|
|
|
+ JSONObject jsonObj1=new JSONObject();
|
|
|
|
+ jsonObj1.put("key", "填报日期");
|
|
|
|
+ jsonObj1.put("value",sheet.getCreateDate());
|
|
|
|
+ JSONObject jsonObj2=new JSONObject();
|
|
|
|
+ jsonObj2.put("key", "票据类型");
|
|
|
|
+ jsonObj2.put("value",mainType.getName());
|
|
|
|
+ JSONObject jsonObj3=new JSONObject();
|
|
|
|
+ jsonObj3.put("key", "金额");
|
|
|
|
+ jsonObj3.put("value",sheet.getTotalAmount());
|
|
|
|
+ JSONObject jsonObj4=new JSONObject();
|
|
|
|
+ jsonObj4.put("key", "备注");
|
|
|
|
+ jsonObj4.put("value",sheet.getRemark()==null?"":sheet.getRemark());
|
|
|
|
+ dataJson.add(jsonObj);
|
|
|
|
+ dataJson.add(jsonObj1);
|
|
|
|
+ dataJson.add(jsonObj2);
|
|
|
|
+ dataJson.add(jsonObj3);
|
|
|
|
+ dataJson.add(jsonObj4);
|
|
|
|
+ json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
|
|
|
|
+ json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
|
|
|
|
+ json.put("content_item",dataJson);
|
|
|
|
+ wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Information> informationList=new ArrayList<>();
|
|
|
|
+ for (User item : targetUserList) {
|
|
|
|
+ Information information=new Information();
|
|
|
|
+ information.setUserId(item.getId());
|
|
|
|
+ information.setTime(LocalDateTime.now());
|
|
|
|
+ information.setMsg("费用报销待审核");
|
|
|
|
+ information.setType(3);
|
|
|
|
+ information.setContent(sheet.getCreateDate()+"");
|
|
|
|
+ informationList.add(information);
|
|
|
|
+ }
|
|
|
|
+ informationService.saveBatch(informationList);
|
|
|
|
+ }
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|