|
@@ -1,19 +1,29 @@
|
|
package org.jeecg.ctop.finance.settlement.service.serviceImpl;
|
|
package org.jeecg.ctop.finance.settlement.service.serviceImpl;
|
|
|
|
|
|
|
|
+import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
|
|
|
+import cn.afterturn.easypoi.excel.entity.ImportParams;
|
|
|
|
+import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
-import org.apache.poi.ss.formula.functions.T;
|
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
|
|
import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
|
|
|
|
+import org.jeecg.ctop.finance.settlement.entity.vo.AccountImportVo;
|
|
import org.jeecg.ctop.finance.settlement.mapper.SettlementInfoMapper;
|
|
import org.jeecg.ctop.finance.settlement.mapper.SettlementInfoMapper;
|
|
import org.jeecg.ctop.finance.settlement.service.ISettlementInfoService;
|
|
import org.jeecg.ctop.finance.settlement.service.ISettlementInfoService;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
+@Slf4j
|
|
@Service
|
|
@Service
|
|
public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper, ctopCwjsSettlementInfo> implements ISettlementInfoService {
|
|
public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper, ctopCwjsSettlementInfo> implements ISettlementInfoService {
|
|
|
|
|
|
@@ -52,9 +62,68 @@ public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper,
|
|
return Result.successMsg("财务结算-修改账户状态成功。.", null);
|
|
return Result.successMsg("财务结算-修改账户状态成功。.", null);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ * @description: 删除
|
|
|
|
+ *
|
|
|
|
+ * @param id
|
|
|
|
+ * @return: org.jeecg.common.api.vo.Result
|
|
|
|
+ * @author: zianY
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
public Result deleteSettlementById(Long id) {
|
|
public Result deleteSettlementById(Long id) {
|
|
settlementInfoMapper.deleteSettlementById(id);
|
|
settlementInfoMapper.deleteSettlementById(id);
|
|
return Result.successMsg("财务结算-删除成功。.", null);
|
|
return Result.successMsg("财务结算-删除成功。.", null);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ * @description:
|
|
|
|
+ *
|
|
|
|
+ * @param settlementInfo
|
|
|
|
+ * @param file
|
|
|
|
+ * @return: org.jeecg.common.api.vo.Result
|
|
|
|
+ * @author: zianY
|
|
|
|
+ * @time: 2021/7/30 16:26
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Result settlementAccountImport(ctopCwjsSettlementInfo settlementInfo, MultipartFile file) {
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
+ //settlementInfo.setCreateUserId(user.getId());
|
|
|
|
+ settlementInfo.setCreateUserId("b161b7d9793942f980dbfe8c931cd1b0");
|
|
|
|
+ ImportParams importParams = new ImportParams();
|
|
|
|
+ //表格标题行数
|
|
|
|
+ importParams.setTitleRows(1);
|
|
|
|
+ //表头行数
|
|
|
|
+ importParams.setHeadRows(1);
|
|
|
|
+ //校验数据
|
|
|
|
+ importParams.setNeedVerfiy(true);
|
|
|
|
+
|
|
|
|
+ //校验表头 头条
|
|
|
|
+ if (StringUtils.equals("1",String.valueOf(settlementInfo.getMediaId()))){
|
|
|
|
+ importParams.setImportFields(new String[]{"账户ID","账户名称"});
|
|
|
|
+ //快手
|
|
|
|
+ }else if (StringUtils.equals("2",String.valueOf(settlementInfo.getMediaId()))){
|
|
|
|
+ importParams.setImportFields(new String[]{"快手ID","账户ID","账户名称"});
|
|
|
|
+ }
|
|
|
|
+ importParams.setNeedCheckOrder(true);
|
|
|
|
+ ExcelImportResult<AccountImportVo> importResult = ExcelImportUtil.importExcelMore(file.getInputStream(), AccountImportVo.class,importParams);
|
|
|
|
+ if (importResult.getList().size() < 1){
|
|
|
|
+ return Result.error("读取Excel失败,数据不能为空,请重新检查数据并导入。");
|
|
|
|
+ }
|
|
|
|
+ importResult.getList().forEach(importVo -> {
|
|
|
|
+ BeanUtils.copyProperties(importVo,settlementInfo);
|
|
|
|
+ settlementInfoMapper.insert(settlementInfo);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return Result.error("账户数据上传失败,请使用正确的模板导入!");
|
|
|
|
+ }
|
|
|
|
+ return Result.successMsg("账户数据上传成功。",null);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|