|
@@ -4,6 +4,10 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|
|
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
|
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
|
|
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
|
|
import com.galaxis.capsule.dto.PageDTO;
|
|
|
import com.galaxis.manatee.constant.ChuanYunConstant;
|
|
|
import com.galaxis.manatee.dao.*;
|
|
@@ -12,15 +16,19 @@ import com.galaxis.manatee.entity.chuanyun.dto.*;
|
|
|
import com.galaxis.manatee.exception.BigSizeException;
|
|
|
import com.galaxis.manatee.manager.ChuanYunManager;
|
|
|
import com.galaxis.manatee.manager.ClawFeign;
|
|
|
+import com.galaxis.manatee.util.ChuanyunLocalDateTimeDeserializer;
|
|
|
+import com.galaxis.manatee.util.ChuanyunLocalDateTimeSerializer;
|
|
|
import com.mysql.cj.x.protobuf.MysqlxExpr;
|
|
|
import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.format.annotation.DateTimeFormat;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -97,6 +105,8 @@ public class ChuanyunBasicDataScheduledTask {
|
|
|
*/
|
|
|
@Scheduled(fixedDelay = 3600000L)
|
|
|
private void getDataFromChuanyun() {
|
|
|
+ //项目人力成本
|
|
|
+ saveLaborCost();
|
|
|
// saveAskForLeave();
|
|
|
//专项费用分摊
|
|
|
getSpecialProcedure();
|
|
@@ -474,6 +484,62 @@ public class ChuanyunBasicDataScheduledTask {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 新增人力成本
|
|
|
+ */
|
|
|
+ private void saveLaborCost() {
|
|
|
+ var objectMapper=new ObjectMapper();
|
|
|
+ var page = 1;
|
|
|
+ var size = 20;
|
|
|
+ var flag=true;
|
|
|
+ while (flag) {
|
|
|
+ Map<String,String> map=new HashMap<>(1);
|
|
|
+ map.put("page",String.valueOf(page));
|
|
|
+ map.put("size",String.valueOf(size));
|
|
|
+ //获取物料成本
|
|
|
+ PageDTO<ChuanyunLaborCostDTO> pageInfo = clawFeign.findChuanyunLaborCost(map);
|
|
|
+ if (page<=pageInfo.getTotalPages()){
|
|
|
+ page += 1;
|
|
|
+ }else {
|
|
|
+ flag = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ List<ChuanyunLaborCostDTO> list = pageInfo.getContent();
|
|
|
+ list.forEach(chuanyunLaborCostDTO -> {
|
|
|
+ try {
|
|
|
+ if(chuanyunLaborCostDTO != null) {
|
|
|
+ LaborCostDTO laborCostDTO = new LaborCostDTO(chuanyunLaborCostDTO);
|
|
|
+ laborCostDTO.setDataType("U9");
|
|
|
+ var purcostString=objectMapper.writeValueAsString(laborCostDTO);
|
|
|
+ ChuanyunSaveDTO chuanyunSaveDTO;
|
|
|
+ //根据项目号判断是否存在
|
|
|
+ List<String> macthers = new ArrayList<>();
|
|
|
+ macthers.add("F0000005_2,"+chuanyunLaborCostDTO.getChuanyunLaborCostPrimaryKey().getProjectcode());
|
|
|
+ macthers.add("F0000002_2,"+chuanyunLaborCostDTO.getChuanyunLaborCostPrimaryKey().getPeriod());
|
|
|
+ var filter= Filter.instance(0,1,true,"And",macthers);
|
|
|
+ var chuanyunFindAllResponse=chuanYunManager.findAll(ChuanyunMonthLaborCostDO.SCHEMA_CODE,filter);
|
|
|
+ if (chuanyunFindAllResponse.getReturnData() == null) {
|
|
|
+ //新增
|
|
|
+ chuanyunSaveDTO =chuanYunManager.save(ChuanyunMonthLaborCostDO.SCHEMA_CODE,purcostString,true);
|
|
|
+ }else {
|
|
|
+ List<ChuanyunMonthLaborCostDO> result=objectMapper.convertValue(chuanyunFindAllResponse.getReturnData().getBizObjectArray(), new TypeReference<>(){});
|
|
|
+ ChuanyunMonthLaborCostDO chuanyunMonthLaborCostDO = result.get(0);
|
|
|
+ //更新
|
|
|
+ chuanyunSaveDTO = chuanYunManager.update(ChuanyunMonthLaborCostDO.SCHEMA_CODE,chuanyunMonthLaborCostDO.getObjectId(),purcostString);
|
|
|
+ }
|
|
|
+ if(chuanyunSaveDTO.getSuccessful()){
|
|
|
+ log.info("新增项目人力成本成功");
|
|
|
+ }else{
|
|
|
+ log.warn("新增项目人力成本失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (JsonProcessingException | BigSizeException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取供应商信息
|
|
|
*/
|
|
|
private void getSupplier(){
|
|
@@ -1019,6 +1085,38 @@ public class ChuanyunBasicDataScheduledTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Data
|
|
|
+ class LaborCostDTO {
|
|
|
+
|
|
|
+ @JsonProperty("F0000005")
|
|
|
+ private String projectCode;
|
|
|
+
|
|
|
+ @JsonProperty("F0000003")
|
|
|
+ private BigDecimal amount;
|
|
|
+
|
|
|
+ @JsonProperty("F0000002")
|
|
|
+ private LocalDateTime logDate;
|
|
|
+
|
|
|
+ @JsonProperty("F0000004")
|
|
|
+ private String dataType;
|
|
|
+
|
|
|
+ public LaborCostDTO(ChuanyunLaborCostDTO chuanyunMonthLaborCostDTO) {
|
|
|
+ if (null!=chuanyunMonthLaborCostDTO){
|
|
|
+ if (null!=chuanyunMonthLaborCostDTO.getCostamount()){
|
|
|
+ this.amount=chuanyunMonthLaborCostDTO.getCostamount();
|
|
|
+ }
|
|
|
+ if (null!=chuanyunMonthLaborCostDTO.getChuanyunLaborCostPrimaryKey().getProjectcode()){
|
|
|
+ this.projectCode=chuanyunMonthLaborCostDTO.getChuanyunLaborCostPrimaryKey().getProjectcode();
|
|
|
+ }
|
|
|
+ if (null!=chuanyunMonthLaborCostDTO.getChuanyunLaborCostPrimaryKey().getPeriod()){
|
|
|
+ this.logDate=chuanyunMonthLaborCostDTO.getChuanyunLaborCostPrimaryKey().getPeriod();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 用于刷新项目经理权限的对象
|
|
|
*/
|