|
@@ -1,70 +1,120 @@
|
|
|
package com.pj.project.tb_business_item;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.pj.api.wx.bo.MsgDataBO;
|
|
|
+import com.pj.api.wx.service.WxService;
|
|
|
+import com.pj.current.config.MyConfig;
|
|
|
+import com.pj.current.config.WxConfig;
|
|
|
+import com.pj.project.tb_business.TbBusiness;
|
|
|
+import com.pj.project.tb_business.TbBusinessService;
|
|
|
+import com.pj.project4sp.admin.SpAdmin;
|
|
|
+import com.pj.project4sp.admin.SpAdminService;
|
|
|
import com.pj.utils.so.SoMap;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.pj.utils.sg.*;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
/**
|
|
|
* Service: tb_business_item -- 业务作业项
|
|
|
- * @author qzy
|
|
|
+ *
|
|
|
+ * @author qzy
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional
|
|
|
-public class TbBusinessItemService extends ServiceImpl<TbBusinessItemMapper,TbBusinessItem> implements IService<TbBusinessItem> {
|
|
|
-
|
|
|
- /** 底层 Mapper 对象 */
|
|
|
- @Autowired
|
|
|
- TbBusinessItemMapper tbBusinessItemMapper;
|
|
|
+public class TbBusinessItemService extends ServiceImpl<TbBusinessItemMapper, TbBusinessItem> implements IService<TbBusinessItem> {
|
|
|
|
|
|
- /** 增 */
|
|
|
- int add(TbBusinessItem t){
|
|
|
- return tbBusinessItemMapper.add(t);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 底层 Mapper 对象
|
|
|
+ */
|
|
|
+ @Autowired
|
|
|
+ TbBusinessItemMapper tbBusinessItemMapper;
|
|
|
+ @Resource
|
|
|
+ @Lazy
|
|
|
+ private TbBusinessService tbBusinessService;
|
|
|
+ @Resource
|
|
|
+ @Lazy
|
|
|
+ private SpAdminService spAdminService;
|
|
|
+ @Resource
|
|
|
+ private WxConfig wxConfig;
|
|
|
+ @Resource
|
|
|
+ private MyConfig myConfig;
|
|
|
+ @Resource
|
|
|
+ @Lazy
|
|
|
+ private WxService wxService;
|
|
|
|
|
|
+ /**
|
|
|
+ * 增
|
|
|
+ */
|
|
|
+ int add(TbBusinessItem t) {
|
|
|
+ return tbBusinessItemMapper.add(t);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- /** 改 */
|
|
|
- int update(TbBusinessItem t){
|
|
|
- return tbBusinessItemMapper.update(t);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 改
|
|
|
+ */
|
|
|
+ int update(TbBusinessItem t) {
|
|
|
+ return tbBusinessItemMapper.update(t);
|
|
|
+ }
|
|
|
|
|
|
- /** 查 */
|
|
|
- TbBusinessItem getById(String id){
|
|
|
- return tbBusinessItemMapper.getById(id);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 查
|
|
|
+ */
|
|
|
+ TbBusinessItem getById(String id) {
|
|
|
+ return tbBusinessItemMapper.getById(id);
|
|
|
+ }
|
|
|
|
|
|
- /** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
|
|
|
- public List<TbBusinessItem> getList(SoMap so) {
|
|
|
- return tbBusinessItemMapper.getList(so);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 查集合 - 根据条件(参数为空时代表忽略指定条件)
|
|
|
+ */
|
|
|
+ public List<TbBusinessItem> getList(SoMap so) {
|
|
|
+ return tbBusinessItemMapper.getList(so);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- public void removeByBusinessId(String businessId) {
|
|
|
- QueryWrapper<TbBusinessItem>ew=new QueryWrapper<>();
|
|
|
- ew.eq("business_id",businessId);
|
|
|
- this.remove(ew);
|
|
|
- }
|
|
|
+ public void removeByBusinessId(String businessId) {
|
|
|
+ QueryWrapper<TbBusinessItem> ew = new QueryWrapper<>();
|
|
|
+ ew.eq("business_id", businessId);
|
|
|
+ this.remove(ew);
|
|
|
+ }
|
|
|
|
|
|
public List<TbBusinessItem> findByBusinessId(String businessId) {
|
|
|
- QueryWrapper<TbBusinessItem>ew=new QueryWrapper<>();
|
|
|
- ew.eq("business_id",businessId);
|
|
|
- ew.orderByDesc("pick");
|
|
|
- ew.orderByAsc("confirm");
|
|
|
- return list(ew);
|
|
|
+ QueryWrapper<TbBusinessItem> ew = new QueryWrapper<>();
|
|
|
+ ew.eq("business_id", businessId);
|
|
|
+ ew.orderByDesc("pick");
|
|
|
+ ew.orderByAsc("confirm");
|
|
|
+ return list(ew);
|
|
|
}
|
|
|
|
|
|
- public TbBusinessItem findByBusinessIdAndTypeName(String businessId, String itemTypeName) {
|
|
|
- QueryWrapper<TbBusinessItem>ew=new QueryWrapper<>();
|
|
|
- ew.eq("business_id",businessId);
|
|
|
- ew.eq("item_type_name",itemTypeName);
|
|
|
- return getOne(ew);
|
|
|
- }
|
|
|
+ public TbBusinessItem findByBusinessIdAndTypeName(String businessId, String itemTypeName) {
|
|
|
+ QueryWrapper<TbBusinessItem> ew = new QueryWrapper<>();
|
|
|
+ ew.eq("business_id", businessId);
|
|
|
+ ew.eq("item_type_name", itemTypeName);
|
|
|
+ return getOne(ew);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void confirmBusinessItem(long id) {
|
|
|
+ TbBusinessItem tbBusinessItem = this.getById(id);
|
|
|
+ tbBusinessItem.setConfirm(1).setConfirmTime(new Date());
|
|
|
+ this.updateById(tbBusinessItem);
|
|
|
+ //todo 通知作业方
|
|
|
+ List<SpAdmin> spAdminList = spAdminService.findByCustomerId(tbBusinessItem.getPickCustomerId());
|
|
|
+ MsgDataBO msgDataBO = new MsgDataBO("业务确认提醒", "系统管理人员", DateUtil.now(), tbBusinessItem.getItemTypeName() + "(" + tbBusinessItem.getItemName() + ")");
|
|
|
+ spAdminList.stream().filter(admin -> StrUtil.isNotEmpty(admin.getOpenid())).forEach(admin -> {
|
|
|
+ String detailUrl = myConfig.getWebDomain() + "/pages/business-item/item-detail?itemId=" + id+"&openid="+admin.getOpenid();
|
|
|
+ wxService.sendTemplateMsg(wxConfig.getBusinessConfirmTemplate(), admin.getOpenid(), msgDataBO, detailUrl);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|