Jelajahi Sumber

提交更新

9060 6 bulan lalu
induk
melakukan
0406c6ce51

+ 13 - 9
app/workSheetSystem/src/main/java/com/qy/worksheetsystem/controller/PersonWorkController.java

@@ -66,11 +66,11 @@ public class PersonWorkController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
     })
-    public MessageResult insertWork(@RequestHeader("token") String token, @RequestBody WorkHoursReport jobWork) {
+    public MessageResultV2 insertWork(@RequestHeader("token") String token, @RequestBody WorkHoursReport jobWork) {
         try {
             String number = JWTUtil.getCacheNumber(token);
             if (StringUtils.isEmpty(number)) {
-                return MessageResult.error("token异常");
+                return MessageResultV2.error("token异常");
             }
             Map<String, Object> map = new HashMap<>();
             SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
@@ -83,12 +83,14 @@ public class PersonWorkController {
             Date endDate = format.parse(endTime);
             Date enterDate = format.parse(person.get("enterDate"));
             if (enterDate.compareTo(beginDate) > 0) {
-                return MessageResult.error("不能填报,入职日期之前的日期!");
+                return MessageResultV2.error("不能填报,入职日期之前的日期!");
             }
             map.put("jobWork",jobWork);
             map.put("person",person);
             map.put("beginDate",beginDate);
             map.put("endDate",endDate);
+            map.put("beginDateStr",beginTime);
+            map.put("endDateStr",endTime);
             //校验报工日期是否超过8小时
             List<Map<String,Object>> availableList = personWorkService.getAvailableDateInfo(number,beginTime,endTime);
             Map<String,Map<String,Object>> availableMap = Maps.newHashMap();
@@ -114,7 +116,7 @@ public class PersonWorkController {
                 Hours += Hour.intValue();
                 String projectId = jobWorkEntry.getProjectId();
                 if (StringUtils.isBlank(projectId)) {
-                    return MessageResult.error("项目id为空");
+                    return MessageResultV2.error("项目id为空");
                 }
                 for (int i = begin; i <= end; i++) {
                     String iday = "01";
@@ -134,20 +136,22 @@ public class PersonWorkController {
                 }
             }
             if (Hours > 8) {
-                return MessageResult.error("报工小时数不能大于8小时");
+                return MessageResultV2.error("报工小时数不能大于8小时");
             }
             if (errMsg.length() > 0) {
-                MessageResult result = new MessageResult();
+                MessageResultV2 result = new MessageResultV2();
                 result.setCode(400);
                 result.setMsg(errMsg.toString());
                 return result;
             }
-
+            Map<String,Object> objectMap = personWorkService.insertWork(map);
+            MessageResultV2 resultV2 = MessageResultV2.success();
+            resultV2.setData(objectMap);
+            return resultV2;
         }catch (Exception e){
             log.error(e.getMessage(),e);
-            return MessageResult.error(e.getMessage());
+            return MessageResultV2.error(e.getMessage());
         }
-        return MessageResult.success().add("jobWork","jobWork");
     }
 
     @ApiOperation(value = "获取员工报工列表", notes = "获取员工报工列表")

+ 13 - 4
app/workSheetSystem/src/main/java/com/qy/worksheetsystem/model/mapper/PersonMapper.xml

@@ -5,34 +5,43 @@
     <select id="getPersonByUserId" resultType="java.util.Map" parameterType="String">
         select p.fid id,p.fnumber number,p.fname_l2 name,
         CONVERT(varchar(10) ,isnull(pp2.FEnterDate,''),120) enterDate,
-        btype.fname_l2 btypeName,btype.fid btypeId
+        btype.fname_l2 btypeName,btype.fid btypeId,
+        pp.fid userID,pp2.FControlUnitID controlUnitID,pp2.FHrOrgUnitID hrOrgUnitID,
+        pop.FPersonDep adminOrgID
         from t_bd_person p
         left join t_pm_user pp on pp.fpersonid=p.fid
         left join T_HR_EMPLABORRELATION pp2 on pp2.FPersonID=p.fid
         left join T_HR_BDEmployeeType btype on btype.fid=pp2.FLaborRelationStateID
+        left join T_HR_PersonPosition pop on pop.fpersonid=p.fid
         where pp.fid=#{userid}
     </select>
 
     <select id="getPersonByOpenId" resultType="java.util.Map" parameterType="String">
         select p.fid id,p.fnumber number,p.fname_l2 name,
         CONVERT(varchar(10) ,isnull(pp2.FEnterDate,''),120) enterDate,
-        btype.fname_l2 btypeName,btype.fid btypeId
-
+        btype.fname_l2 btypeName,btype.fid btypeId,
+        pp.fid userID,pp2.FControlUnitID controlUnitID,pp2.FHrOrgUnitID hrOrgUnitID,
+        pop.FPersonDep adminOrgID
         from t_bd_person p
         left join t_pm_user pp on pp.fpersonid=p.fid
         left join T_HR_EMPLABORRELATION pp2 on pp2.FPersonID=p.fid
         left join T_HR_BDEmployeeType btype on btype.fid=pp2.FLaborRelationStateID
+        left join T_HR_PersonPosition pop on pop.fpersonid=p.fid
         where pp.fopenid=#{openid}
     </select>
 
     <select id="getPersonByJobNo" resultType="java.util.Map" parameterType="String">
         select p.fid id,p.fnumber number,p.fname_l2 name,
         CONVERT(varchar(10) ,isnull(pp2.FEnterDate,''),120) enterDate,
-        btype.fname_l2 btypeName,btype.fid btypeId
+
+        btype.fname_l2 btypeName,btype.fid btypeId,
+        pp.fid userID,pp2.FControlUnitID controlUnitID,pp2.FHrOrgUnitID hrOrgUnitID,
+        pop.FPersonDep adminOrgID
         from t_bd_person p
         left join t_pm_user pp on pp.fpersonid=p.fid
         left join T_HR_EMPLABORRELATION pp2 on pp2.FPersonID=p.fid
         left join T_HR_BDEmployeeType btype on btype.fid=pp2.FLaborRelationStateID
+        left join T_HR_PersonPosition pop on pop.fpersonid=p.fid
         where p.fnumber=#{jobNo}
     </select>
 </mapper>

+ 6 - 0
app/workSheetSystem/src/main/java/com/qy/worksheetsystem/model/mapper/PersonWorkMapper.java

@@ -9,6 +9,12 @@ import java.util.Map;
 
 @Repository
 public interface PersonWorkMapper {
+        String selectBillKey();
+        String selectKeyByBosTyoe(@Param("employeeID") String employeeID);
 
         List<Map<String,Object>> getAvailableDateInfo(@Param("employeeID") String employeeID, @Param("startDate")String startDate,  @Param("endDate")String endDate);
+
+        int insertBill(@Param("billList")List<Map<String, Object>> billList);
+
+        int insertWork(@Param("workList")List<Map<String, Object>> workList);
 }

+ 44 - 4
app/workSheetSystem/src/main/java/com/qy/worksheetsystem/model/mapper/PersonWorkMapper.xml

@@ -1,9 +1,12 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qy.worksheetsystem.model.mapper.PersonWorkMapper">
-    <select id="selectKey" resultType="String">
+    <select id="selectBillKey" resultType="String">
         select dbo.newbosid('CF9DCEB1') as id
     </select>
+    <select id="selectKeyByBosTyoe" resultType="String">
+        select dbo.newbosid(#{bosTyoe}) as id
+    </select>
     <select id="getAvailableDateInfo" resultType="java.util.Map">
         SELECT
         item.fid as "id",
@@ -25,7 +28,44 @@
         AND w.FISDEFAULT=1
         order by item.FDate
     </select>
-    <!--22DCD041-->
-
-
+    <!---->
+    <select id="getPersonWorkList" resultType="java.util.Map">
+        select * from CT_PRO_WorkHoursReportEntry
+    </select>
+    <insert id="insertBill" parameterType="java.util.List" >
+        insert
+        into CT_PRO_WorkHoursReport(
+        CFAffiliatedProjec,FAdminOrgUnitId,FHROrgUnitID,
+        FBillState,FNumber,FBizDate,
+        FCreatorID,FCreateTime,FLastUpdateUserID,
+        FLastUpdateTime, FControlUnitID,FID,
+        CFDataSource,CFFillingStartDate,CFFillingEndDate
+        )
+        values
+        <foreach collection="billList" item="item" index="index" separator=",">
+        (
+            #{item.affiliatedProject}, #{item.adminOrg}, #{item.hrOrgUnit},
+            #{item.billState}, #{item.number}, #{item.bizDate},
+            #{item.creator}, getDate(), #{item.lastUpdateUser},
+            getDate(), #{item.CU}, #{item.id},
+            'employeeReport', #{item.fillingStartDate}, #{item.fillingEndDate}
+        )
+        </foreach>
+    </insert>
+    <insert id="insertWork" parameterType="java.util.List">
+        INSERT
+        into CT_PRO_WorkHoursReportEntry(FParentID,CFEmployeeID,CFClockTime,
+        CFClockLocation,CFData,CFWorkingHours,
+        CFNotes,FSeq,Fid
+        )
+        values
+        <foreach collection="workList" item="item" index="index" separator=",">
+            (
+            #{item.parent},#{item.employee},
+            #{item.clockTime},#{item.clockLocation},#{item.data},
+            #{item.WorkingHours},#{item.notes},
+            #{item.seq},dbo.newbosid('22DCD041')
+            )
+        </foreach>
+    </insert>
 </mapper>

+ 1 - 0
app/workSheetSystem/src/main/java/com/qy/worksheetsystem/model/mapper/ProjectMapper.xml

@@ -68,4 +68,5 @@
         </if>
         #{dateTime}
     </select>
+
 </mapper>

+ 1 - 0
app/workSheetSystem/src/main/java/com/qy/worksheetsystem/service/PersonWorkService.java

@@ -16,4 +16,5 @@ public interface PersonWorkService {
     public Map<String,Object> insertWork(Map<String,Object> param);
 
     public List<Map<String, Object>> getAvailableDateInfo(String number, String startDate, String endDate);
+
 }

+ 92 - 15
app/workSheetSystem/src/main/java/com/qy/worksheetsystem/service/impl/PersonWorkServiceImpl.java

@@ -1,17 +1,31 @@
 package com.qy.worksheetsystem.service.impl;
 
+
+import cn.hutool.core.lang.Snowflake;
+import cn.hutool.core.util.IdUtil;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.qy.worksheetsystem.model.MessageResult;
 import com.qy.worksheetsystem.model.mapper.PersonMapper;
 import com.qy.worksheetsystem.model.mapper.PersonWorkMapper;
 
+import com.qy.worksheetsystem.model.mapper.ProjectMapper;
 import com.qy.worksheetsystem.service.PersonService;
 import com.qy.worksheetsystem.service.PersonWorkService;
+import com.qy.worksheetsystem.util.SnowflakeUtils;
 import com.qy.worksheetsystem.vo.InsertJobWorkingVO;
+import com.qy.worksheetsystem.vo.WorkHoursReport;
+import com.qy.worksheetsystem.vo.WorkHoursReportEntry;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.RequestHeader;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -28,34 +42,93 @@ import java.util.Map;
 @Service
 public class PersonWorkServiceImpl implements PersonWorkService {
     private static final BigDecimal h8 = new BigDecimal(8);
+
     @Resource
     private PersonWorkMapper personWorkMapper;
     @Resource
     private PersonService personService;
 
+    @Resource
+    private ProjectMapper projectMapper;
+
     @Override
     @Transactional
     public Map<String,Object> insertWork(Map<String,Object> param){
+        try {
+            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+            int begin = (int) param.get("begin");
+            int end = (int) param.get("end");
+            String yearMonth = (String) param.get("yearMonth");
+            WorkHoursReport jobWork = (WorkHoursReport) param.get("jobWork");
+            Map<String, String> person = (Map<String, String>) param.get("person");
+            Date beginDate = (Date) param.get("beginDate");
+            Date endDate = (Date) param.get("endDate");
+            Map<String, Map<String, Object>> availableMap = (Map<String, Map<String, Object>>) param.get("availableMap");
+
+            List<Map<String, Object>> billList = Lists.newArrayList();
+            List<Map<String, Object>> workList = Lists.newArrayList();
+            Integer Hours = 0;
+            for (WorkHoursReportEntry jobWorkEntry : jobWork.getEntries()) {
+                String workingHours = jobWorkEntry.getWorkingHours();
+                BigDecimal Hour = new BigDecimal(workingHours);
+                Hours += Hour.intValue();
+                String projectId = jobWorkEntry.getProjectId();
 
+                String number = SnowflakeUtils.getInstance().getSnowflake().nextIdStr();
 
-        Map<String, String> billMap = new HashMap<>();
-        billMap.put("affiliatedProject","");
-        billMap.put("fillingStartDate","");
-        billMap.put("fillingEndDate","");
-        billMap.put("adminOrg","");
-        billMap.put("hrOrgUnit","");
-        billMap.put("billState","");
-        billMap.put("number","");
-        billMap.put("CU","");
-        billMap.put("bizDate","");
-        billMap.put("creator","");
-        billMap.put("createTime","");
-        billMap.put("lastUpdateUser","");
-        billMap.put("lastUpdateTime","");
-        
+                Map<String, Object> billMap = new HashMap<>();
 
+                String billID = personWorkMapper.selectBillKey();
+                billMap.put("id", billID);
+                billMap.put("affiliatedProject", projectId);
+                billMap.put("fillingStartDate", beginDate);
+                billMap.put("fillingEndDate", endDate);
+                billMap.put("adminOrg", person.get("adminOrgID"));
+                billMap.put("hrOrgUnit", person.get("hrOrgUnitID"));
+                billMap.put("billState", jobWork.getState());
+                billMap.put("number", number);
+                billMap.put("CU", person.get("controlUnitID"));
+                Date createTime = new Date();
+                billMap.put("bizDate", createTime);
+                billMap.put("creator", person.get("userID"));
+                billMap.put("createTime", createTime);
+                billMap.put("lastUpdateUser", person.get("userID"));
+                billMap.put("lastUpdateTime", createTime);
+                for (int i = begin; i <= end; i++) {
+                    Map<String, Object> objectMap = Maps.newHashMap();
+                    String iday = "01";
+                    if (i < 10) {
+                        iday = "0" + i;
+                    } else {
+                        iday = i + "";
+                    }
+                    String reportDate = yearMonth + iday;
+                    Map<String, Object> avMap = availableMap.get(reportDate);
+                    BigDecimal availableWorkHous = (BigDecimal) avMap.get("availableWorkHous");
+                    BigDecimal workHours = (BigDecimal) avMap.get("workHours");
+                    objectMap.put("parent", billID);
+                    objectMap.put("employee", person.get("id"));
+                    objectMap.put("clockTime", reportDate);
+                    objectMap.put("clockLocation", "移动端");
+                    objectMap.put("data", format.parse(reportDate));
+                    objectMap.put("WorkingHours", availableWorkHous);
+                    objectMap.put("notes", "");
+                    objectMap.put("seq", i);
+                    workList.add(objectMap);
 
+                }
+                billList.add(billMap);
+            }
 
+            int bInt = personWorkMapper.insertBill(billList);
+            int wInt = personWorkMapper.insertWork(workList);
+            Map<String, Object> reMap = Maps.newHashMap();
+            reMap.put("billList", billList);
+            reMap.put("workList", workList);
+            return reMap;
+        }catch (Exception e){
+            log.error(e.getMessage(),e);
+        }
         return null;
     }
 
@@ -75,5 +148,9 @@ public class PersonWorkServiceImpl implements PersonWorkService {
         return list;
     }
 
+    public MessageResult getPersonWorkList(String number,String beginTime, String endTime, Boolean state) {
+        return null;
+    }
+
 
 }

+ 26 - 0
app/workSheetSystem/src/main/java/com/qy/worksheetsystem/util/SnowflakeUtils.java

@@ -0,0 +1,26 @@
+package com.qy.worksheetsystem.util;
+
+import cn.hutool.core.lang.Snowflake;
+import cn.hutool.core.util.IdUtil;
+
+/**
+ * @BelongsProject: workSheetSystem
+ * @BelongsPackage: com.qy.worksheetsystem.util
+ * @Author: lhbj
+ * @CreateTime: 2024-12-07  14:57
+ * @Description: TODO
+ * @Version: 1.0
+ */
+public class SnowflakeUtils {
+    private static SnowflakeUtils snowflakeUtils =new SnowflakeUtils();
+    private Snowflake snowflake = IdUtil.getSnowflake(0,0);
+    public static SnowflakeUtils getInstance(){
+        return snowflakeUtils;
+    }
+
+    public Snowflake getSnowflake() {
+        return snowflake;
+    }
+
+
+}