|
|
@@ -20,6 +20,7 @@ import com.qy.worksheetsystem.util.SnowflakeUtils;
|
|
|
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.apache.http.HttpException;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -82,6 +83,96 @@ public class PersonWorkServiceImpl implements PersonWorkService {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public synchronized Map<String, Object> updateWork(Map<String, Object> param) {
|
|
|
+ List<Map<String, Object>> billList = Lists.newArrayList();
|
|
|
+ List<Map<String, Object>> workList = Lists.newArrayList();
|
|
|
+ int begin = (int) param.get("begin");
|
|
|
+ int end = (int) param.get("end");
|
|
|
+ JobBooking jobBooking = (JobBooking) param.get("jobBooking");
|
|
|
+ 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");
|
|
|
+ Map<String, Object> reMap = Maps.newHashMap();
|
|
|
+ try {
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Integer Hours = 0;
|
|
|
+ for (WorkHoursReportEntry jobWorkEntry : jobWork.getEntries()) {
|
|
|
+ String workingHours = jobWorkEntry.getWorkingHours();
|
|
|
+ BigDecimal Hour = new BigDecimal(workingHours);
|
|
|
+ Hours += Hour.intValue();
|
|
|
+ String projectId = jobWorkEntry.getProjectId();
|
|
|
+ Map<String, String> pros = personService.getProjectManagementInfoBYId(projectId, person.get("id"));
|
|
|
+ if (null == pros && pros.isEmpty()) {
|
|
|
+ throw new Exception("没有找到项目,请检查");
|
|
|
+ }
|
|
|
+ String number = SnowflakeUtils.getInstance().getSnowflake().nextIdStr();
|
|
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
|
+ String str = "";
|
|
|
+ Map<String, Object> billMap = new HashMap<>();
|
|
|
+ billMap.put("id", jobWork.getId());
|
|
|
+ billMap.put("isBack", 0);
|
|
|
+ billMap.put("affiliatedProject", projectId);
|
|
|
+ billMap.put("fillingStartDate", jobWork.getBeginTime());
|
|
|
+ billMap.put("fillingEndDate", jobWork.getEndTime());
|
|
|
+ billMap.put("adminOrg", person.get("adminOrgId"));
|
|
|
+ billMap.put("hrOrgUnit", person.get("hrOrgUnitID"));
|
|
|
+ billMap.put("billState", jobBooking.get("state"));
|
|
|
+ billMap.put("personId", person.get("id"));
|
|
|
+ billMap.put("ptypeId", pros.get("ptypeId"));
|
|
|
+ billMap.put("projectRoleId", pros.get("projectRoleId"));
|
|
|
+ billMap.put("number", number);
|
|
|
+ billMap.put("CU", person.get("controlUnitID"));
|
|
|
+ billMap.put("lastUpdateUser", person.get("userID"));
|
|
|
+ billMap.put("jobContent", jobWorkEntry.getJobContent());
|
|
|
+ BigDecimal WorkingHoursSum = BigDecimal.ZERO;
|
|
|
+ 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("availableWorkHours");
|
|
|
+ BigDecimal workHours = (BigDecimal) avMap.get("workHours");
|
|
|
+ objectMap.put("parent", jobWork.getId());
|
|
|
+ objectMap.put("employee", person.get("id"));
|
|
|
+ objectMap.put("clockTime", reportDate);
|
|
|
+ objectMap.put("clockLocation", "移动端");
|
|
|
+ objectMap.put("data", reportDate);
|
|
|
+ objectMap.put("WorkingHours", Hour);
|
|
|
+ objectMap.put("notes", "");
|
|
|
+ objectMap.put("seq", i);
|
|
|
+ workList.add(objectMap);
|
|
|
+ }
|
|
|
+ billMap.put("WorkingHours", Hour);
|
|
|
+ billList.add(billMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ int bInt = personWorkMapper.updateBill(billList);
|
|
|
+ int dwInt = personWorkMapper.deleteWorkEntry(jobWork.getId());
|
|
|
+ int wInt = personWorkMapper.insertWork(workList);
|
|
|
+ reMap.put("billList", billList);
|
|
|
+ reMap.put("workList", workList);
|
|
|
+ reMap.put("code", (billList.size() + workList.size()) == (bInt + wInt));
|
|
|
+ return reMap;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ for (Map<String, Object> bill : billList) {
|
|
|
+ this.deleteWork(person.get("personNumber"), (String) bill.get("id"));
|
|
|
+ }
|
|
|
+ reMap.put("errMsg", e.getMessage());
|
|
|
+ reMap.put("code", false);
|
|
|
+ }
|
|
|
+ return reMap;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
@@ -106,13 +197,12 @@ public class PersonWorkServiceImpl implements PersonWorkService {
|
|
|
Hours += Hour.intValue();
|
|
|
String projectId = jobWorkEntry.getProjectId();
|
|
|
Map<String, String> pros = personService.getProjectManagementInfoBYId(projectId, person.get("id"));
|
|
|
- if (null==pros&&pros.isEmpty()) {
|
|
|
+ if (null == pros && pros.isEmpty()) {
|
|
|
throw new Exception("没有找到项目,请检查");
|
|
|
}
|
|
|
String number = SnowflakeUtils.getInstance().getSnowflake().nextIdStr();
|
|
|
Map<String, Object> map = Maps.newHashMap();
|
|
|
String str = "";
|
|
|
-
|
|
|
Response response = shrClient.executeServiceByLongConnection(url, codingRuleService, map);
|
|
|
str = (String) response.getData();
|
|
|
if (StrUtil.isNotBlank(str)) {
|
|
|
@@ -125,6 +215,7 @@ public class PersonWorkServiceImpl implements PersonWorkService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
Map<String, Object> billMap = new HashMap<>();
|
|
|
String billID = personWorkMapper.selectBillKey(String.valueOf(number));
|
|
|
billMap.put("id", billID);
|
|
|
@@ -141,6 +232,10 @@ public class PersonWorkServiceImpl implements PersonWorkService {
|
|
|
billMap.put("CU", person.get("controlUnitID"));
|
|
|
Date createTime = new Date();
|
|
|
billMap.put("creator", person.get("userID"));
|
|
|
+ if (StringUtils.isNotBlank((String) param.get("createTime"))) {
|
|
|
+ createTime = format.parse((String) param.get("createTime"));
|
|
|
+ }
|
|
|
+ billMap.put("createTime", createTime);
|
|
|
billMap.put("lastUpdateUser", person.get("userID"));
|
|
|
billMap.put("jobContent", jobWorkEntry.getJobContent());
|
|
|
BigDecimal WorkingHoursSum = BigDecimal.ZERO;
|
|
|
@@ -222,6 +317,40 @@ public class PersonWorkServiceImpl implements PersonWorkService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> getAvailableDateInfoByProjectIDAndId(String number, String projectID, String id, String startDate, String endDate) {
|
|
|
+ Map<String, String> person = personService.getPersonByJobNo(number);
|
|
|
+ List<Map<String, Object>> list = personWorkMapper.getAvailableDateInfoById(person.get("id"), id, startDate, endDate);
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+
|
|
|
+ BigDecimal workHours = (BigDecimal) map.get("workHours");
|
|
|
+ if (null != workHours) {
|
|
|
+ map.put("availableWorkHours", h8.subtract(workHours));
|
|
|
+ } else {
|
|
|
+ map.put("workHours", BigDecimal.ZERO);
|
|
|
+ map.put("availableWorkHours", h8);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> getAvailableDateInfoByProjectID(String number, String projectID, String startDate, String endDate) {
|
|
|
+ Map<String, String> person = personService.getPersonByJobNo(number);
|
|
|
+ List<Map<String, Object>> list = personWorkMapper.getAvailableDateInfo(person.get("id"), startDate, endDate);
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+
|
|
|
+ BigDecimal workHours = (BigDecimal) map.get("workHours");
|
|
|
+ if (null != workHours) {
|
|
|
+ map.put("availableWorkHours", h8.subtract(workHours));
|
|
|
+ } else {
|
|
|
+ map.put("workHours", BigDecimal.ZERO);
|
|
|
+ map.put("availableWorkHours", h8);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<Map<String, Object>> getPersonWorkList(String number, String beginTime, String endTime, Boolean state) {
|
|
|
List<Map<String, Object>> list = personWorkMapper.getPersonWorkList(number, beginTime, endTime, state);
|
|
|
@@ -291,19 +420,46 @@ public class PersonWorkServiceImpl implements PersonWorkService {
|
|
|
|
|
|
for (JobBookingEntry jobEntry : (List<JobBookingEntry>) e.get("entries")) {
|
|
|
|
|
|
- workingHours =new BigDecimal(jobEntry.getWorkingHours());
|
|
|
+ workingHours = new BigDecimal(jobEntry.getWorkingHours());
|
|
|
|
|
|
}
|
|
|
e.put("WorkingHours", workingHours.toPlainString());
|
|
|
return e;
|
|
|
}
|
|
|
+ @Override
|
|
|
+ public JobBooking getPersonWorkInfoByIdToBack(String number, String id) {
|
|
|
+ JobBooking e = personWorkMapper.getPersonWorkInfoByIdToBack(number, id);
|
|
|
+ BigDecimal workingHours = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ for (JobBookingEntry jobEntry : (List<JobBookingEntry>) e.get("entries")) {
|
|
|
|
|
|
+ workingHours = new BigDecimal(jobEntry.getWorkingHours());
|
|
|
+
|
|
|
+ }
|
|
|
+ e.put("WorkingHours", workingHours.toPlainString());
|
|
|
+ return e;
|
|
|
+ }
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public int deleteWork(String number, String id) {
|
|
|
- int x = personWorkMapper.deleteWorkEntry(id);
|
|
|
- int i = personWorkMapper.deleteWork(id);
|
|
|
- return i;
|
|
|
+ Map<String,Object> JobBooking = personWorkMapper.getPersonWorkInfoById(number,id);
|
|
|
+ Integer state = (Integer) JobBooking.get("state");
|
|
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
|
+ if(state==0) {
|
|
|
+ int x = personWorkMapper.deleteWorkEntry(id);
|
|
|
+ int i = personWorkMapper.deleteWork(id);
|
|
|
+
|
|
|
+ map.put("code", (i > 0 ? 1 : 0));
|
|
|
+ map.put("work", i);
|
|
|
+ map.put("workEntry", x);
|
|
|
+ }else {
|
|
|
+
|
|
|
+ map.put("code", 0);
|
|
|
+ map.put("work", 0);
|
|
|
+ map.put("workEntry", 0);
|
|
|
+ map.put("msg", "打回状态不能删除");
|
|
|
+ }
|
|
|
+ return state==0?1:state;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -334,10 +490,10 @@ public class PersonWorkServiceImpl implements PersonWorkService {
|
|
|
@Transactional
|
|
|
public int submitWork(String number, String id) {
|
|
|
SHRClient shrClient = null;
|
|
|
- int result =0;
|
|
|
+ int result = 0;
|
|
|
try {
|
|
|
shrClient = new SHRClient(url, number);
|
|
|
- result= this.submitWork(number, id, shrClient);
|
|
|
+ result = this.submitWork(number, id, shrClient);
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
} finally {
|
|
|
@@ -382,10 +538,10 @@ public class PersonWorkServiceImpl implements PersonWorkService {
|
|
|
@Transactional
|
|
|
public int revocaWork(String number, String id) {
|
|
|
SHRClient shrClient = null;
|
|
|
- int result=0;
|
|
|
+ int result = 0;
|
|
|
try {
|
|
|
shrClient = new SHRClient(url, number);
|
|
|
- result= this.revocaWork(number, id, shrClient);
|
|
|
+ result = this.revocaWork(number, id, shrClient);
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
} finally {
|
|
|
@@ -402,14 +558,26 @@ public class PersonWorkServiceImpl implements PersonWorkService {
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Map<String, Object> deleteWorkToMap(String number, String id) {
|
|
|
- int x = personWorkMapper.deleteWorkEntry(id);
|
|
|
- int i = personWorkMapper.deleteWork(id);
|
|
|
+ Map<String,Object> JobBooking = personWorkMapper.getPersonWorkInfoById(number,id);
|
|
|
+ Integer state = (Integer) JobBooking.get("state");
|
|
|
Map<String, Object> map = Maps.newHashMap();
|
|
|
- map.put("code", (i > 0 ? 1 : 0));
|
|
|
- map.put("work", i);
|
|
|
- map.put("workEntry", x);
|
|
|
+ if(state==0) {
|
|
|
+ int x = personWorkMapper.deleteWorkEntry(id);
|
|
|
+ int i = personWorkMapper.deleteWork(id);
|
|
|
+
|
|
|
+ map.put("code", (i > 0 ? 1 : 0));
|
|
|
+ map.put("work", i);
|
|
|
+ map.put("workEntry", x);
|
|
|
+ }else {
|
|
|
+
|
|
|
+ map.put("code", 0);
|
|
|
+ map.put("work", 0);
|
|
|
+ map.put("workEntry", 0);
|
|
|
+ map.put("msg", "打回状态不能删除");
|
|
|
+ }
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Map<String, Object> submitWorkToMap(String number, String id, SHRClient shrClient) {
|
|
|
@@ -417,33 +585,37 @@ public class PersonWorkServiceImpl implements PersonWorkService {
|
|
|
map.put("billId", id);// 单据id
|
|
|
map.put("status", "1");// 单据id
|
|
|
try {
|
|
|
- Response response = shrClient.executeServiceByLongConnection(url, serviceName, map);
|
|
|
- String str = (String) response.getData();
|
|
|
+ //int upInt = personWorkMapper.updateBack("0", id);
|
|
|
map.put("code", 0);
|
|
|
- if (StrUtil.isNotBlank(str)) {
|
|
|
- if (JSONUtil.isTypeJSON(str)) {
|
|
|
- JSONObject j = JSONUtil.parseObj(str);
|
|
|
- String code = j.getStr("code");
|
|
|
- if ("200".equals(code)) {
|
|
|
- map.put("code", 1);
|
|
|
+
|
|
|
+ Response response = shrClient.executeServiceByLongConnection(url, serviceName, map);
|
|
|
+ String str = (String) response.getData();
|
|
|
+ if (StrUtil.isNotBlank(str)) {
|
|
|
+ if (JSONUtil.isTypeJSON(str)) {
|
|
|
+ JSONObject j = JSONUtil.parseObj(str);
|
|
|
+ String code = j.getStr("code");
|
|
|
+ if ("200".equals(code)) {
|
|
|
+ map.put("code", 1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ map.put("msg", str);
|
|
|
}
|
|
|
- } else {
|
|
|
- map.put("msg", str);
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Map<String, Object> submitWorkToMap(String number, String id) {
|
|
|
- Map<String, Object> result=null;
|
|
|
+ Map<String, Object> result = null;
|
|
|
SHRClient shrClient = null;
|
|
|
try {
|
|
|
shrClient = new SHRClient(url, number);
|
|
|
- result= this.submitWorkToMap(number, id, shrClient);
|
|
|
+ result = this.submitWorkToMap(number, id, shrClient);
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
} finally {
|
|
|
@@ -456,6 +628,7 @@ public class PersonWorkServiceImpl implements PersonWorkService {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Map<String, Object> revocaWorkToMap(String number, String id, SHRClient shrClient) {
|
|
|
@@ -491,11 +664,11 @@ public class PersonWorkServiceImpl implements PersonWorkService {
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Map<String, Object> revocaWorkToMap(String number, String id) {
|
|
|
- Map<String, Object> result=null;
|
|
|
+ Map<String, Object> result = null;
|
|
|
SHRClient shrClient = null;
|
|
|
try {
|
|
|
shrClient = new SHRClient(url, number);
|
|
|
- result= this.revocaWorkToMap(number, id, shrClient);
|
|
|
+ result = this.revocaWorkToMap(number, id, shrClient);
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
} finally {
|
|
|
@@ -510,5 +683,4 @@ public class PersonWorkServiceImpl implements PersonWorkService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|