|
|
|
@ -1,11 +1,14 @@
|
|
|
|
|
package com.dsic.gj_erp.jszb.control;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.dsic.gj_erp.bean.ResultBean;
|
|
|
|
|
import com.dsic.gj_erp.bean.jhgk.YdjhImportNew;
|
|
|
|
|
import com.dsic.gj_erp.exception.CustomException;
|
|
|
|
|
import com.dsic.gj_erp.exception.ServiceException;
|
|
|
|
|
import com.dsic.gj_erp.jszb.entity.PartFlowInfo;
|
|
|
|
|
import com.dsic.gj_erp.jszb.excel.ExcelFlowInfoListener;
|
|
|
|
|
import com.dsic.gj_erp.jszb.service.FlowInfoService;
|
|
|
|
@ -17,6 +20,7 @@ import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("jszb")
|
|
|
|
@ -34,8 +38,9 @@ public class JszbController {
|
|
|
|
|
public ResultBean<?> getFlowInfoList(String ch,String begin,String end) {
|
|
|
|
|
List<PartFlowInfo> list = flowInfoService.list(Wrappers.<PartFlowInfo>lambdaQuery()
|
|
|
|
|
.eq(PartFlowInfo::getCh, ch)
|
|
|
|
|
.eq(StrUtil.isEmpty(end) && StrUtil.isNotEmpty(begin), PartFlowInfo::getFd, begin)
|
|
|
|
|
.between(StrUtil.isAllNotEmpty(begin, end), PartFlowInfo::getFd, begin, end)
|
|
|
|
|
.eq(StrUtil.isEmpty(end) && StrUtil.isNotEmpty(begin), PartFlowInfo::getPl, begin)
|
|
|
|
|
.between(StrUtil.isAllNotEmpty(begin, end), PartFlowInfo::getPl, begin, end)
|
|
|
|
|
.orderByAsc(PartFlowInfo::getPl,PartFlowInfo::getFd)
|
|
|
|
|
);
|
|
|
|
|
return new ResultBean<>(list);
|
|
|
|
|
}
|
|
|
|
@ -44,42 +49,34 @@ public class JszbController {
|
|
|
|
|
public ResultBean<?> importFLowInfo(@RequestParam("file") MultipartFile file) throws IOException {
|
|
|
|
|
ExcelFlowInfoListener objectListener = new ExcelFlowInfoListener();
|
|
|
|
|
EasyExcel.read(file.getInputStream(), PartFlowInfo.class, objectListener).sheet(0).headRowNumber(1).doRead();
|
|
|
|
|
|
|
|
|
|
List<PartFlowInfo> objList = objectListener.getObjectList();
|
|
|
|
|
List<String> errors = objectListener.getErrors();
|
|
|
|
|
List<PartFlowInfo> updateList=new ArrayList<>();
|
|
|
|
|
objList.forEach(item->{
|
|
|
|
|
PartFlowInfo one=null;
|
|
|
|
|
if (StrUtil.isNotEmpty(item.getCh())){
|
|
|
|
|
one = flowInfoService.getOne(Wrappers.<PartFlowInfo>lambdaQuery()
|
|
|
|
|
.and(it->it.eq(PartFlowInfo::getCh, item.getCh())
|
|
|
|
|
.or(it0->it0.eq(PartFlowInfo::getCh, item.getProject())))
|
|
|
|
|
.and(it->it.eq(PartFlowInfo::getPartName, item.getPartName())
|
|
|
|
|
.or(it0->it0.eq(PartFlowInfo::getPartName, item.getPartName0()))
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
PartFlowInfo one = flowInfoService.getOne(Wrappers.<PartFlowInfo>lambdaQuery()
|
|
|
|
|
.eq(StrUtil.isNotEmpty(item.getCh()),PartFlowInfo::getCh, item.getCh())
|
|
|
|
|
.eq(StrUtil.isNotEmpty(item.getCh()),PartFlowInfo::getPartName,item.getPartName())
|
|
|
|
|
.eq(StrUtil.isNotEmpty(item.getProject()),PartFlowInfo::getCh,item.getProject())
|
|
|
|
|
.eq(StrUtil.isNotEmpty(item.getProject()),PartFlowInfo::getPartName,item.getPartName0())
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isNotEmpty(item.getProject())){
|
|
|
|
|
one = flowInfoService.getOne(Wrappers.<PartFlowInfo>lambdaQuery()
|
|
|
|
|
.eq(PartFlowInfo::getCh, item.getCh())
|
|
|
|
|
.eq(PartFlowInfo::getPartName, item.getPartName())
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (one==null){
|
|
|
|
|
if (ObjUtil.isEmpty(one)){
|
|
|
|
|
one = new PartFlowInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BeanUtil.copyProperties(item,one);
|
|
|
|
|
BeanUtil.copyProperties(item,one,"id");
|
|
|
|
|
|
|
|
|
|
if(item.getProject()!=null){
|
|
|
|
|
one.setCh(item.getProject());
|
|
|
|
|
one.setFd(item.getBlock());
|
|
|
|
|
one.setPartName(item.getPartName0());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateList.add(one);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
flowInfoService.saveOrUpdateBatch(updateList);
|
|
|
|
|
return new ResultBean<>();
|
|
|
|
|
return new ResultBean<>(errors);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|