Commit c0997a81 authored by 赵啸非's avatar 赵啸非

添加材料数量统计

parent 8032cb29
package com.mortals.xhx.feign.site;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SiteMatterPdu;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 站点事项 Feign接口
* @author zxfei
* @date 2023-02-17
*/
@FeignClient(name = "", path = "", fallbackFactory = SiteMatterFeignFallbackFactory.class)
public interface ISiteMatterFeign extends IFeign {
/**
* 查看站点事项列表
*
* @param siteMatterPdu
* @return
*/
@PostMapping(value = "/site/matter/list")
Rest<RespData<List<SiteMatterPdu>>> list(@RequestBody SiteMatterPdu siteMatterPdu);
/**
* 查看站点事项
*
* @param id
* @return
*/
@GetMapping(value = "/site/matter/info")
Rest<SiteMatterPdu> info(@RequestParam(value = "id") Long id);
/**
* 删除站点事项
*
* @param ids
* @return
*/
@GetMapping(value = "/site/matter/delete")
Rest<Void> delete(Long[] ids,@RequestHeader("Authorization") String authorization);
/**
* 站点事项保存更新
*
* @param siteMatterPdu
* @return
*/
@PostMapping(value = "/site/matter/save")
Rest<RespData<SiteMatterPdu>> save(@RequestBody SiteMatterPdu siteMatterPdu,@RequestHeader("Authorization") String authorization);
}
@Slf4j
@Component
class SiteMatterFeignFallbackFactory implements FallbackFactory<ISiteMatterFeign> {
@Override
public ISiteMatterFeign create(Throwable t) {
return new ISiteMatterFeign() {
@Override
public Rest<RespData<List<SiteMatterPdu>>> list(SiteMatterPdu siteMatterPdu) {
return Rest.fail("暂时无法获取站点事项列表,请稍后再试!");
}
@Override
public Rest<SiteMatterPdu> info(Long id) {
return Rest.fail("暂时无法获取站点事项详细,请稍后再试!");
}
@Override
public Rest<Void> delete(Long[] ids, String authorization) {
return Rest.fail("暂时无法删除站点事项,请稍后再试!");
}
@Override
public Rest<RespData<SiteMatterPdu>> save(SiteMatterPdu siteMatterPdu, String authorization) {
return Rest.fail("暂时无法保存站点事项,请稍后再试!");
}
};
}
}
package com.mortals.xhx.daemon.task;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SiteMatterPdu;
import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.feign.site.ISiteMatterFeign;
import com.mortals.xhx.module.sheet.model.SheetMatterEntity;
import com.mortals.xhx.module.sheet.service.SheetMatterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.List;
import java.util.stream.Collectors;
/**
* 同步事项列表
*/
@Slf4j
@Service("SyncSiteMatterTask")
public class SyncSiteMatterTaskImpl implements ITaskExcuteService {
@Autowired
private ISiteFeign siteFeign;
@Autowired
private ISiteMatterFeign siteMatterFeign;
@Autowired
private SheetMatterService sheetMatterService;
@Override
public void excuteTask(ITask task) throws AppException {
SitePdu sitePdu = new SitePdu();
sitePdu.setId(1L);
Rest<List<SitePdu>> siteRest = siteFeign.getFlatSitesBySiteId(sitePdu);
if (siteRest.getCode() == YesNoEnum.YES.getValue()) {
siteRest.getData().forEach(site -> {
SiteMatterPdu siteMatterPdu = new SiteMatterPdu();
siteMatterPdu.setPage(1);
siteMatterPdu.setSize(-1);
Rest<RespData<List<SiteMatterPdu>>> siteMatterRest = siteMatterFeign.list(siteMatterPdu);
if (siteMatterRest.getCode() == YesNoEnum.YES.getValue()) {
//删除后新增
List<SheetMatterEntity> sheetMatterEntities = siteMatterRest.getData().getData().stream().map(siteMatter -> {
SheetMatterEntity sheetMatterEntity = new SheetMatterEntity();
sheetMatterEntity.initAttrValue();
sheetMatterEntity.setSiteId(siteMatter.getSiteId());
sheetMatterEntity.setMatterName(siteMatter.getMatterName());
sheetMatterEntity.setMatterNo(siteMatter.getMatterCode());
sheetMatterEntity.setDeptCode(siteMatter.getDeptCode());
sheetMatterEntity.setDeptName(siteMatter.getDeptName());
sheetMatterEntity.setAreaCode(siteMatter.getAreaCode());
return sheetMatterEntity;
}).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(sheetMatterEntities)) {
sheetMatterService.save(sheetMatterEntities);
}
}
});
}
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
...@@ -22,9 +22,6 @@ ...@@ -22,9 +22,6 @@
<if test="condition.matterName != null and condition.matterName != ''"> <if test="condition.matterName != null and condition.matterName != ''">
and a.matterName like #{condition.matterName} and a.matterName like #{condition.matterName}
</if> </if>
<if test="condition.matterFullName != null and condition.matterFullName != ''">
and a.matterFullName like #{condition.matterFullName}
</if>
</trim> </trim>
</trim> </trim>
</select> </select>
...@@ -48,9 +45,6 @@ ...@@ -48,9 +45,6 @@
<if test="condition.matterName != null and condition.matterName != ''"> <if test="condition.matterName != null and condition.matterName != ''">
and a.matterName like #{condition.matterName} and a.matterName like #{condition.matterName}
</if> </if>
<if test="condition.matterFullName != null and condition.matterFullName != ''">
and a.matterFullName like #{condition.matterFullName}
</if>
</trim> </trim>
</trim> </trim>
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment