Procházet zdrojové kódy

研发打卡修改

anderx před 2 roky
rodič
revize
bcf8d008d2

+ 2 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ProjectTaskController.java

@@ -275,8 +275,8 @@ public class ProjectTaskController extends BaseController {
      * @return
      */
     @GetMapping("/myDuration")
-    public AjaxResult myDuration(Long id){
-        return projectStaffRecordService.myDuration(id);
+    public AjaxResult myDuration(Long id,String recordTime){
+        return projectStaffRecordService.myDuration(id,recordTime);
     }
 
 

+ 46 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java

@@ -54,9 +54,55 @@ public class SysDept extends BaseEntity
     /** 最大时长 */
     private Double maxDuration;
 
+    /**
+     * 公司编号
+     */
+    private Long companyId;
+
+    /**
+     * 公司名称
+     */
+    private String companyName;
+
+    private String startTime;
+    private String endTime;
+
+    public String getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(String startTime) {
+        this.startTime = startTime;
+    }
+
+    public String getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(String endTime) {
+        this.endTime = endTime;
+    }
+
     /** 子部门 */
     private List<SysDept> children = new ArrayList<SysDept>();
 
+
+    public Long getCompanyId() {
+        return companyId;
+    }
+
+    public void setCompanyId(Long companyId) {
+        this.companyId = companyId;
+    }
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
     public Double getMaxDuration() {
         return maxDuration;
     }

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/project/domain/ProjectStaffRecord.java

@@ -79,7 +79,7 @@ public class ProjectStaffRecord implements Serializable {
     /**
      * 打卡时间
      */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date recordTime;
 
     private static final long serialVersionUID = 1L;

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/project/service/ProjectStaffRecordService.java

@@ -18,7 +18,7 @@ public interface ProjectStaffRecordService {
 
     String importProject(List<ProjectStaffRecordOut> list, boolean isUpdateSupport, String operName);
 
-    AjaxResult myDuration(Long id);
+    AjaxResult myDuration(Long id,String recordTime);
 
     AjaxResult addCheckMaxDuration(ProjectStaffRecord in);
 

+ 21 - 15
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectStaffRecordServiceImpl.java

@@ -92,11 +92,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         String maxDurationProjectFlag = configService.selectConfigByKey("maxDurationProject");
         Boolean maxflag = Boolean.parseBoolean(maxDurationProjectFlag);
         Double myDuration=0d;
-        if (maxflag){
-            myDuration=getMyDuration(in.getPid(), in.getAid());
-        }else {
-            myDuration=getMyDuration(null, in.getAid());
-        }
+        myDuration=getMyDuration(in,maxflag);
         BigDecimal mySum = new BigDecimal(myDuration).add(new BigDecimal(in.getDuration()));
 
         if (mySum.compareTo(maxDuration)==1){
@@ -393,7 +389,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
     }
 
     @Override
-    public AjaxResult myDuration(Long id) {
+    public AjaxResult myDuration(Long id,String recordTime) {
         String maxDurationProjectFlag = configService.selectConfigByKey("maxDurationProject");
         Boolean flag = Boolean.parseBoolean(maxDurationProjectFlag);
         if (flag){
@@ -404,23 +400,33 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         SysUser user = SecurityUtils.getLoginUser().getUser();
         SysDept dept = user.getDept();
         Double maxDuration=dept.getMaxDuration();
-        Double myDuration=getMyDuration(id,user.getUserId());
+        Double myDuration=getMyDuration(id,user.getUserId(),recordTime);
         BigDecimal res = new BigDecimal(maxDuration).subtract(new BigDecimal(myDuration.toString()));
         return AjaxResult.success(res);
     }
 
 
 
-    public Double getMyDuration(Long pid,Long aid) {
-        AtomicReference<Double> myDuration = new AtomicReference<>(0d);
-        String date=DateUtils.getDate();
+    public Double getMyDuration(ProjectStaffRecord in ,boolean flag) {
+        Double myDuration = 0d;
+        Long pid=in.getPid();
+        Long aid=in.getAid();
+        if (!flag)pid=null;
+        String recordTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, in.getRecordTime());
+        return getMyDuration(pid,aid,recordTime);
+    }
+
+    public Double getMyDuration(Long pid ,Long aid ,String recordTime) {
+        Double myDuration = 0d;
+
+
         List<ProjectStaffRecord> projectStaffRecords = projectStaffRecordMapper.selectByPidAndAid(pid,aid);
-        projectStaffRecords.stream().forEach(e ->{
+        for (ProjectStaffRecord e : projectStaffRecords) {
             String eDate= DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, e.getRecordTime());
-            if (date.equals(eDate)){
-                myDuration.updateAndGet(v -> v + e.getDuration());
+            if (recordTime.equals(eDate)){
+                myDuration+=e.getDuration();
             }
-        });
-        return myDuration.get();
+        }
+        return myDuration;
     }
 }

+ 13 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java

@@ -222,6 +222,12 @@ public class SysDeptServiceImpl implements ISysDeptService
         {
             throw new ServiceException("部门停用,不允许新增");
         }
+        String[] split = info.getAncestors().split(",");
+        if (split.length>2){
+            SysDept sysDept = deptMapper.selectDeptById(Long.valueOf(split[2]));
+            dept.setCompanyId(sysDept.getDeptId());
+            dept.setCompanyName(sysDept.getDeptName());
+        }
         dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
         return deptMapper.insertDept(dept);
     }
@@ -243,7 +249,14 @@ public class SysDeptServiceImpl implements ISysDeptService
             String oldAncestors = oldDept.getAncestors();
             dept.setAncestors(newAncestors);
             updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
+            String[] split = newAncestors.split(",");
+            if (split.length>2){
+                SysDept sysDept = deptMapper.selectDeptById(Long.valueOf(split[2]));
+                dept.setCompanyId(sysDept.getDeptId());
+                dept.setCompanyName(sysDept.getDeptName());
+            }
         }
+
         int result = deptMapper.updateDept(dept);
         if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
                 && !StringUtils.equals("0", dept.getAncestors()))

+ 18 - 1
ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -20,10 +20,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="createTime" column="create_time" />
 		<result property="updateBy"   column="update_by"   />
 		<result property="updateTime" column="update_time" />
+		<result property="companyId" column="company_id" />
+		<result property="companyName" column="company_name" />
+		<result property="maxDuration" column="max_duration" />
 	</resultMap>
 
 	<sql id="selectDeptVo">
-        select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
+        select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,
+               d.del_flag, d.create_by, d.create_time,d.company_id,d.company_name,d.max_duration
         from sys_dept d
     </sql>
 
@@ -42,6 +46,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<if test="status != null and status != ''">
 			AND status = #{status}
 		</if>
+		<if test="companyName != null and companyName != ''">
+			AND company_name like concat('%', #{companyName}, '%')
+		</if>
+
+		<if test="startTime != null and endTime !=null">
+			AND create_time bentween #{startTime} and #{endTime}
+		</if>
 		<if test="ancestors !=null">
 			and (dept_id= #{ancestors} or find_in_set(#{ancestors},ancestors))
 		</if>
@@ -103,6 +114,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="status != null">status,</if>
  			<if test="createBy != null and createBy != ''">create_by,</if>
 			<if test="maxDuration != null ">max_duration,</if>
+			<if test="companyId != null ">company_id,</if>
+			<if test="companyName != null ">company_name,</if>
  			create_time
  		)values(
  			<if test="deptId != null and deptId != 0">#{deptId},</if>
@@ -116,6 +129,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="status != null">#{status},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
 			<if test="maxDuration != null ">#{maxDuration},</if>
+			<if test="companyId != null ">#{companyId},</if>
+			<if test="companyName != null ">#{companyName},</if>
  			sysdate()
  		)
 	</insert>
@@ -133,6 +148,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="status != null and status != ''">status = #{status},</if>
  			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  			<if test="maxDuration != null ">max_duration = #{maxDuration},</if>
+ 			<if test="companyId != null ">company_id = #{companyId},</if>
+ 			<if test="companyName != null ">company_name = #{companyName},</if>
  			update_time = sysdate()
  		</set>
  		where dept_id = #{deptId}