Browse Source

顽症同步

zhuang 1 year ago
parent
commit
6bb4cb545f

+ 63 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxPersistentManageServiceImpl.java

@@ -4,12 +4,20 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.aspose.words.*;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bscommon.sys.dao.ZhcxPersistentManageDao;
 import com.rongwei.bscommon.sys.service.ZhcxPersistentManageService;
+import com.rongwei.bsentity.domain.ZhcxItpProjectNodesDo;
 import com.rongwei.bsentity.domain.ZhcxPersistentManageDo;
+import com.rongwei.bsentity.dto.ZhcxPersistentManageDto;
 import com.rongwei.bsentity.vo.FormDataVO;
 import com.rongwei.bsentity.vo.ZhcxPersistentWordVO;
+import com.rongwei.rwadmincommon.system.domain.SysOrganizationDo;
+import com.rongwei.rwadmincommon.system.service.SysOrganizationService;
+import com.rongwei.rwcommon.base.exception.CustomException;
 import com.rongwei.rwcommon.utils.StringUtils;
 import com.rongwei.rwcommoncomponent.excel.aspose.ExcelExportUtil;
 import com.rongwei.rwcommoncomponent.excel.utils.WordHelpUtils;
@@ -17,9 +25,12 @@ import com.rongwei.rwcommoncomponent.excel.vo.FormData;
 import com.rongwei.rwcommoncomponent.file.service.SysFileItemService;
 import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.*;
 import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.BufferedInputStream;
@@ -46,6 +57,8 @@ public class ZhcxPersistentManageServiceImpl extends ServiceImpl<ZhcxPersistentM
     private ZhcxPersistentManageDao zhcxPersistentManageDao;
     @Autowired
     private SysFileItemService sysFileItemService;
+    @Autowired
+    private SysOrganizationService sysOrganizationService;
 
     @Value("${wz-provider.syncWzDataUrl}")
     private String syncWzDataUrl;
@@ -291,6 +304,56 @@ public class ZhcxPersistentManageServiceImpl extends ServiceImpl<ZhcxPersistentM
     @Override
     public void syncWzPlatform(List<String> ids) {
         //zhcxPersistentManageDao.syncWzDataUrl
+        LambdaQueryWrapper<ZhcxPersistentManageDo> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.in(ZhcxPersistentManageDo::getId,ids);
+        List<ZhcxPersistentManageDo> list = this.list(queryWrapper);
+        List<ZhcxPersistentManageDto> dtoList = new ArrayList<>();
+        if(ObjectUtil.isEmpty(list)) {
+            return ;
+        }
+        List<ZhcxPersistentManageDo> updateList = new ArrayList<>();
+        ZhcxPersistentManageDo manageDo;
+        ZhcxPersistentManageDto manageDto;
+        for(ZhcxPersistentManageDo persistentManageDo : list){
+            manageDo = new ZhcxPersistentManageDo();
+            manageDto = new ZhcxPersistentManageDto();
+            manageDo.setId(persistentManageDo.getId());
+            manageDo.setSyncstate("3");
+            updateList.add(manageDo);
+            BeanUtils.copyProperties(persistentManageDo, manageDto);
+            String rectifystatus = manageDto.getRectifystatus();
+            String period = manageDto.getPeriod();
+            String fill = manageDto.getFill();
+            Date checkdate = manageDto.getCheckdate();
+            SysOrganizationDo curOrgTopParent = sysOrganizationService.getCurOrgTopParent(persistentManageDo.getFirstorgid());
+            manageDto.setBaseorgname(curOrgTopParent.getFullname());
+            manageDto.setFineNo(fill + "("+(checkdate.getYear()+1900)+")" +period);
+            if (rectifystatus.equals("未整改")) {
+                manageDto.setRectifystatus("0");
+            }else if (rectifystatus.equals("已整改")) {
+                manageDto.setRectifystatus("1");
+            }
+            dtoList.add(manageDto);
+        }
+
+        RestTemplate restTemplate = new RestTemplate();
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.APPLICATION_JSON);
+        HttpEntity<List<ZhcxPersistentManageDto>> requestEntity = new HttpEntity<>(dtoList, headers);
+        ResponseEntity<String> response = restTemplate.exchange(
+                syncWzDataUrl, HttpMethod.POST, requestEntity, String.class);
+        int statusCodeValue = response.getStatusCodeValue();
+        System.out.println("Response status code: " + statusCodeValue);
+        if(200 != statusCodeValue) {
+            log.error("请求结果:{}", statusCodeValue);
+            throw new CustomException("同步失败,请联系管理员!");
+        }
+        //修改同步状态
+        if(updateList.size()>0){
+            this.updateBatchById(updateList);
+        }
+
+
     }
 
     private void initWeekWord(Document[] doc, List<ZhcxPersistentManageDo> rewardListData, String tempId) {

+ 5 - 0
business-entity/src/main/java/com/rongwei/bsentity/domain/ZhcxPersistentManageDo.java

@@ -253,4 +253,9 @@ public class ZhcxPersistentManageDo extends BaseDo {
      */
     @TableField("PUNISHCONFIRMDATE")
     private Date punishconfirmdate;
+    /**
+     * 同步状态
+     */
+    @TableField("SYNCSTATE")
+    private String syncstate;
 }

+ 199 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/ZhcxPersistentManageDto.java

@@ -0,0 +1,199 @@
+package com.rongwei.bsentity.dto;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.*;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class ZhcxPersistentManageDto {
+    /**
+     * 主键
+     */
+    @TableField("ID")
+    @JSONField(serialize = false)
+    @JsonIgnore
+    private String id;
+
+    /**
+     * 顽症编号
+     */
+    @TableField("CODE")
+    @JSONField(name = "serialnum")
+    @JsonProperty(value = "serialnum")
+    private String code;
+
+    /**
+     * 现场图片
+     */
+    @TableField("SITEPIC")
+    @JSONField(serialize = false)
+    @JsonIgnore
+    private String sitepic;
+    /**
+     * 项目工号
+     */
+    @TableField("PROJECTCODE")
+    @JSONField(name = "projectCode")
+    @JsonProperty(value = "projectCode")
+    private String projectcode;
+    /**
+     * 项目简称
+     */
+    @TableField("PROJECTENAME")
+    @JSONField(name = "projectName")
+    @JsonProperty(value = "projectName")
+    private String projectename;
+    /**
+     * 顽症内容
+     */
+    @TableField("CONTENT")
+    @JSONField(name = "content")
+    @JsonProperty(value = "content")
+    private String content;
+
+    /**
+     * 顽症类型
+     */
+    @TableField("BASEINFONUM")
+
+    private String baseinfonum;
+
+    /**
+     * 一级部门
+     */
+    @TableField("FIRSTORGNAME")
+    @JSONField(name = "secondUnity")
+    @JsonProperty(value = "secondUnity")
+    private String firstorgname;
+
+    /**
+     * 二级部门
+     */
+    @TableField("SECONDORGNAME")
+    @JSONField(name = "thirdUnity")
+    @JsonProperty(value = "thirdUnity")
+    private String secondorgname;
+
+    /**
+     * 分包商简称
+     */
+    @TableField("SUBCONTRACTENAME")
+    @JSONField(name = "subAbbreviation")
+    @JsonProperty(value = "subAbbreviation")
+    private String subcontractename;
+    /**
+     * 分包商编号
+     */
+    @TableField("SUBCONTRACTCODE")
+    @JSONField(name = "subNum")
+    @JsonProperty(value = "subNum")
+    private String subcontractcode;
+    /**
+     * 分包商全称
+     */
+    @TableField("SUBCONTRACTNAME")
+    @JSONField(name = "subcontractors")
+    @JsonProperty(value = "subcontractors")
+    private String subcontractname;
+    /**
+     * 姓名
+     */
+    @TableField("USERNAME")
+    @JSONField(name = "name")
+    @JsonProperty(value = "name")
+    private String username;
+
+    /**
+     * 检查日期
+     */
+    @TableField("CHECKDATE")
+    @JSONField(name = "proposeDate")
+    @JsonProperty(value = "proposeDate")
+    private Date checkdate;
+
+    /**
+     * 抬头
+     */
+    @TableField("FILL")
+    @JsonIgnore
+    private String fill;
+
+    /**
+     * 检查人
+     */
+    @TableField("CHECKUSERNAME")
+    @JSONField(name = "proposeUserName")
+    @JsonProperty(value = "proposeUserName")
+    private String checkusername;
+    /**
+     * 周期
+     */
+    @TableField("PERIOD")
+    @JsonIgnore
+    @JSONField(serialize = false)
+    private String period;
+
+    /**
+     * 质量奖惩表-奖惩依据
+     */
+    @TableField("QUALITYAWARDNAME")
+    @JsonIgnore
+    @JSONField(serialize = false)
+    private String qualityawardname;
+    /**
+     * 参考金额
+     */
+    @TableField("REFERAMOUNT")
+    @JSONField(name = "fineRange")
+    @JsonProperty(value = "fineRange")
+    private String referamount;
+
+    /**
+     * 参考金额
+     */
+    @TableField("PUNISHCONFIRMAMOUNT")
+    @JSONField(name = "fineActurl")
+    @JsonProperty(value = "fineActurl")
+    private String punishconfirmamount;
+
+    /**
+     * 创建日期
+     */
+    @TableField(value = "CREATEDATE")
+    @JSONField(name = "inputDate")
+    @JsonProperty(value = "inputDate")
+    private Date createdate;
+    /**
+     * 分公司
+     */
+    @TableField(value = "BASEORGNAME")
+    @JSONField(name = "firstUnity")
+    @JsonProperty(value = "firstUnity")
+    private String baseorgname;
+
+    /**
+     * 依据拼接周期
+     */
+    @JSONField(name = "fineNo")
+    @JsonProperty(value = "fineNo")
+    private String fineNo;
+
+    /**
+     * 整改情况
+     */
+    @TableField("RECTIFYSTATUS")
+    @JSONField(name = "rectification")
+    @JsonProperty(value = "rectification")
+    private String rectifystatus;
+
+}

+ 15 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxPersistentController.java

@@ -2,6 +2,7 @@ package com.rongwei.bsserver.controller;
 
 import com.rongwei.bscommon.sys.service.ZhcxPersistentManageService;
 import com.rongwei.bscommon.sys.service.ZhcxPersistentService;
+import com.rongwei.bsentity.dto.OutsideInspactionSyncReqquest;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.base.exception.CustomException;
 import io.swagger.annotations.Api;
@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -37,4 +39,17 @@ public class ZhcxPersistentController {
         }
     }
 
+    /**
+     * 顽症数据推送到顽症平台
+     *
+     * @param ids
+     * @return
+     */
+    //@ApiOperation("推送到顽症平台")
+    @PostMapping("/syncWzPlatform")
+    public R syncWzPlatform(@RequestBody List<String> ids){
+        zhcxPersistentManageService.syncWzPlatform(ids);
+        return R.ok();
+    }
+
 }