瀏覽代碼

1.新增项目人力成本

WoNiu 4 年之前
父節點
當前提交
6209cd5ab3

+ 10 - 0
src/main/java/com/galaxis/manatee/dao/ChuanyunMonthLaborCostDao.java

@@ -0,0 +1,10 @@
+package com.galaxis.manatee.dao;
+
+import com.galaxis.capsule.util.GalaxisRepository;
+import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunMonthLaborCostDO;
+import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunPayrollDO;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface ChuanyunMonthLaborCostDao extends GalaxisRepository<ChuanyunMonthLaborCostDO,String> {
+}

+ 45 - 0
src/main/java/com/galaxis/manatee/entity/chuanyun/data/object/ChuanyunMonthLaborCostDO.java

@@ -0,0 +1,45 @@
+package com.galaxis.manatee.entity.chuanyun.data.object;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+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.manatee.util.ChuanyunLocalDateTimeDeserializer;
+import com.galaxis.manatee.util.ChuanyunLocalDateTimeSerializer;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.persistence.Entity;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+@Slf4j
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Entity(name = "CHUANYUN_MONTH_LABORCOST")
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ChuanyunMonthLaborCostDO extends BasicDO{
+
+    /**
+     * 表名
+     */
+    public static final String SCHEMA_CODE ="D001789c42dc40d56a84e84b09609bf44a77205";
+
+    @JsonProperty("F0000005")
+    private String projectCode;
+
+    @JsonProperty("F0000003")
+    private BigDecimal amount;
+
+    @JsonSerialize(using = LocalDateTimeSerializer.class)
+    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
+    @JsonProperty("F0000002")
+    private LocalDateTime logDate;
+
+    @JsonProperty("F0000004")
+    private String dataType;
+}

+ 17 - 0
src/main/java/com/galaxis/manatee/entity/chuanyun/dto/ChuanyunLaborCostDTO.java

@@ -0,0 +1,17 @@
+package com.galaxis.manatee.entity.chuanyun.dto;
+
+
+import lombok.Data;
+
+import javax.persistence.Id;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+@Data
+public class ChuanyunLaborCostDTO {
+
+
+    private ChuanyunLaborCostPrimaryKey chuanyunLaborCostPrimaryKey;
+
+    private BigDecimal costamount;
+}

+ 24 - 0
src/main/java/com/galaxis/manatee/entity/chuanyun/dto/ChuanyunLaborCostPrimaryKey.java

@@ -0,0 +1,24 @@
+package com.galaxis.manatee.entity.chuanyun.dto;
+
+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.manatee.util.ChuanyunLocalDateTimeDeserializer;
+import com.galaxis.manatee.util.ChuanyunLocalDateTimeSerializer;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.persistence.Embeddable;
+import java.time.LocalDateTime;
+
+@Embeddable
+@Data
+public class ChuanyunLaborCostPrimaryKey {
+
+    protected String projectcode;
+
+    @JsonSerialize(using = LocalDateTimeSerializer.class)
+    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
+    protected LocalDateTime period;
+}

+ 9 - 0
src/main/java/com/galaxis/manatee/manager/ClawFeign.java

@@ -4,6 +4,7 @@ import com.galaxis.capsule.dto.*;
 import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunProjectCashFlowDO;
 import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunPurCostDO;
 import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunReimbursementDO;
+import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunLaborCostDTO;
 import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunProjectCashFlowDTO;
 import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunPurCostDTO;
 import org.springframework.cloud.openfeign.FeignClient;
@@ -54,6 +55,14 @@ public interface ClawFeign {
     @GetMapping("/purcost/findAllByParameters")
     PageDTO<ChuanyunPurCostDTO> findChuanyunPurCost(@RequestParam Map<String,String> map);
 
+    /**
+     * 查询人力成本
+     * @param map
+     * @return
+     */
+    @GetMapping("/laborcost/findAllByParameters")
+    PageDTO<ChuanyunLaborCostDTO> findChuanyunLaborCost(@RequestParam Map<String,String> map);
+
 
     /**
      * 测试

+ 98 - 0
src/main/java/com/galaxis/manatee/task/ChuanyunBasicDataScheduledTask.java

@@ -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();
+                }
+            }
+        }
+    }
+
+
+
     /**
      * 用于刷新项目经理权限的对象
      */

File diff suppressed because it is too large
+ 43 - 1
src/main/java/com/galaxis/manatee/task/ChuanyunProjectScheduledTask.java