Bladeren bron

列表修改

anderx 2 jaren geleden
bovenliggende
commit
a7536d932a

+ 45 - 3
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectStaffRecordServiceImpl.java

@@ -9,7 +9,6 @@ import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.bean.BeanValidators;
 import com.ruoyi.project.bo.ProjectStaffRecordInput;
 import com.ruoyi.project.bo.ProjectStaffRecordOut;
-import com.ruoyi.project.bo.ProjectTaskListOut;
 import com.ruoyi.project.domain.ProjectStaffRecord;
 import com.ruoyi.project.domain.ProjectStaffRecordLog;
 import com.ruoyi.project.domain.ProjectTask;
@@ -19,6 +18,7 @@ import com.ruoyi.project.mapper.ProjectTaskMapper;
 import com.ruoyi.project.service.ProjectStaffRecordService;
 import com.ruoyi.system.mapper.SysUserMapper;
 import com.ruoyi.system.service.ISysDeptService;
+import com.ruoyi.system.service.ISysUserService;
 import com.ruoyi.weChat.service.WeChatService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -26,8 +26,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.validation.Validator;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
 
 @Service
 public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService {
@@ -47,6 +49,8 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
     private WeChatService weChatService;
     @Autowired
     private ISysDeptService deptService;
+    @Autowired
+    private SysUserMapper userMapper;
 
     @Override
     public AjaxResult add(ProjectStaffRecord in) {
@@ -55,18 +59,43 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         in.setAid(userId);
         in.setName(username);
         if(in.getProcessStatus()>1)in.setProcessStatus(1);
+        boolean flag=false;
         if (SecurityUtils.hashRoles(UserRolesType.INSPECTORS.getCode())){
             in.setProcessStatus(2);
             sysUserMapper.userAddDuration(userId,in.getDuration());
             projectTaskMapper.projectAddDuration(in.getPid(),in.getDuration());
         }else {
-//            weChatService.addNotice();
+            flag=true;
         }
         addRecordLog(in);
         projectStaffRecordMapper.insertSelective(in);
+        if (flag){
+            addWechatAppSend(in, String.format("[%s]发起研发打卡,请及时审核!", username));
+        }
         return AjaxResult.success();
     }
 
+    private void addWechatAppSend(ProjectStaffRecord in, String remarks) {
+        //获取当事人
+        String openId=null;
+        if (in.getProcessStatus()==1){
+            SysUser sysUser = userMapper.selectSuperUserByUid(in.getAid());
+            openId=sysUser.getOpenId();
+            if (StringUtils.isNull(openId)){
+                log.debug(String.format("查询上级openId为空,%s",remarks));
+            }
+        }else if(in.getProcessStatus()==2||in.getProcessStatus()==3){
+            SysUser sysUser = userMapper.selectUserById(in.getAid());
+            openId=sysUser.getOpenId();
+            if (StringUtils.isNull(openId)){
+                log.debug(String.format("查询发起人openId,%s",remarks));
+            }
+        }
+        if (StringUtils.isNotNull(openId)){
+            weChatService.addNotice(openId, in.getId(),new Date(),remarks);
+        }
+    }
+
     private void addRecordLog(ProjectStaffRecord in) {
         ProjectStaffRecordLog log = new ProjectStaffRecordLog();
         log.setPsrId(in.getId());
@@ -96,11 +125,18 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
     @Override
     public AjaxResult update(ProjectStaffRecord in) {
         Long userId = SecurityUtils.getUserId();
+        ProjectStaffRecord projectStaffRecord = projectStaffRecordMapper.selectByPrimaryKey(in.getId());
+        if (projectStaffRecord.getProcessStatus()!=0&&projectStaffRecord.getProcessStatus()!=3){
+            AjaxResult.success("打卡只有草稿和驳回状态才可以修改!");
+        }
         String username = SecurityUtils.getLoginUser().getUser().getNickName();
         in.setAid(userId);
         in.setName(username);
         if(in.getProcessStatus()>1)in.setProcessStatus(1);
         projectStaffRecordMapper.updateByPrimaryKeySelective(in);
+        if (in.getProcessStatus()==1){
+            addWechatAppSend(in, String.format("[%s]发起研发打卡,及时是审核!", username));
+        }
         addRecordLog(in);
         return AjaxResult.success();
     }
@@ -110,6 +146,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         ProjectStaffRecord newP = new ProjectStaffRecord();
         newP.setId(in.getId());
         newP.setProcessStatus(in.getProcessStatus());
+        String username=SecurityUtils.getLoginUser().getUser().getNickName();
         if (in.getProcessStatus()==2){
             ProjectStaffRecord use = projectStaffRecordMapper.selectByPrimaryKey(in.getId());
             if (use.getProcessStatus()!=1){
@@ -117,11 +154,16 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
             }
             sysUserMapper.userAddDuration(use.getAid(),use.getDuration());
             projectTaskMapper.projectAddDuration(use.getPid(),use.getDuration());
-            newP.setExamineName(SecurityUtils.getLoginUser().getUser().getNickName());
+            newP.setExamineName(username);
             newP.setExamineId(SecurityUtils.getUserId());
             newP.setExamineTime(new Date());
         }
         projectStaffRecordMapper.updateByPrimaryKeySelective(newP);
+        if (in.getProcessStatus()==2){
+            addWechatAppSend(in, String.format("[%s]已审核[%s]您的研发打卡.", username,"同意"));
+        }else if (in.getProcessStatus()==3){
+            addWechatAppSend(in, String.format("[%s]已审核[%s]您的研发打卡.", username,"驳回"));
+        }
         addRecordLog(in);
         return AjaxResult.success();
     }

+ 4 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java

@@ -128,4 +128,8 @@ public interface SysUserMapper
     List<SysUser> selectName(@Param("name") String name,@Param("roleId") Long roleId);
 
     void userAddDuration(@Param("userId") Long userId, @Param("duration") Double duration);
+
+
+
+    SysUser selectSuperUserByUid(Long aid);
 }

+ 1 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java

@@ -207,4 +207,5 @@ public interface ISysUserService
     Object selectName(String name,Integer type);
 
     String setOpenId(String code);
+
 }

+ 1 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -567,4 +567,5 @@ public class SysUserServiceImpl implements ISysUserService
         userMapper.updateUser(user);
         return openId;
     }
+
 }

+ 4 - 4
ruoyi-system/src/main/java/com/ruoyi/weChat/service/WeChatService.java

@@ -106,9 +106,9 @@ public class WeChatService {
 	}
 
 
-	public Integer addNotice(String openid ,Integer id, Date date, String remarks){
-		String str= DateUtils.parseStrYYYYMMDDHHMMSS(date);
-		return addNotice(openid,id,date,remarks);
+	public Integer addNotice(String openid ,Long id, Date date, String remarks){
+		String dateTime= DateUtils.parseStrYYYYMMDDHHMMSS(date);
+		return addNotice(openid,id,dateTime,remarks);
 	}
 
 
@@ -117,7 +117,7 @@ public class WeChatService {
 	 * @param openid 发送对象微信openid
 	 * @param remarks 发送信息,不能大于十五个字
 	 */
-	public Integer addNotice(String openid ,Integer id, String dateTime, String remarks) {
+	public Integer addNotice(String openid ,Long id, String dateTime, String remarks) {
 		Map<String, Object> map=new HashMap<String, Object>();
 		String accessToken=getAccessToken();
 		String url=send_url.replace("ACCESS_TOKEN", accessToken);

+ 7 - 0
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -279,6 +279,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		and user_id in (select user_id from sys_user_role where role_id = #{roleId})
 	</select>
 
+
+	<select id="selectSuperUserByUid" resultType="com.ruoyi.common.core.domain.entity.SysUser">
+		select b.user_id userId, b.user_name userName,b.nick_name nickName,b.open_id openId
+		from sys_user a left join sys_user b on a.superior_id=b.user_id
+		where a.user_id=#{aid}
+	</select>
+
 	<update id="userAddDuration">
 		update sys_user set duration = duration+#{duration}
 		where user_id = #{userId}