|
|
@@ -0,0 +1,93 @@
|
|
|
+package com.mokamrp.privates.service.pangu.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.mokamrp.privates.entity.VoltaHandle;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.*;
|
|
|
+import com.mokamrp.privates.mapper.pangu.FosterwxStationPayMapper;
|
|
|
+import com.mokamrp.privates.mapper.pojo.Corp;
|
|
|
+import com.mokamrp.privates.mapper.pojo.User;
|
|
|
+import com.mokamrp.privates.service.pangu.FosterwxStationPayService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.mokamrp.privates.service.pangu.FosterwxStationService;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import com.mokamrp.privates.entity.PostBasePageHandle;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import com.mokamrp.privates.entity.ResHandle;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 盘古养号站点支出 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author leon
|
|
|
+ * @since 2021-12-01
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class FosterwxStationPayServiceImpl extends ServiceImpl<FosterwxStationPayMapper, FosterwxStationPay> implements FosterwxStationPayService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public FosterwxStationPayMapper fosterwxStationPayMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public FosterwxStationService fosterwxStationService;
|
|
|
+ /**
|
|
|
+ * 获取数据列表 支持分页
|
|
|
+ * @param handle
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResHandle<List<FosterwxStationPay>> getList(PostBasePageHandle handle) {
|
|
|
+ Integer pagesize = handle.getPagesize();
|
|
|
+ Integer page = handle.getPage();
|
|
|
+ Page<FosterwxStationPay> pageObj = new Page<FosterwxStationPay>(page, pagesize);
|
|
|
+ List<FosterwxStationPay> list = fosterwxStationPayMapper.getList(pageObj,handle);
|
|
|
+ ResHandle<List<FosterwxStationPay>> res = new ResHandle<>();
|
|
|
+ res.setList(list);
|
|
|
+ res.setTotal(pageObj.getTotal());
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入数据
|
|
|
+ *
|
|
|
+ * @param row
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public VoltaHandle<Boolean> importData(List<Map<String, String>> row, User authUser) throws Exception {
|
|
|
+ VoltaHandle<Boolean> res = new VoltaHandle<>();
|
|
|
+ if (row.size() <= 0) {
|
|
|
+ throw new Exception("表格读取完成后,没有获取到任何数据");
|
|
|
+ }
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ for (int i = 0; i < row.size(); i++) {
|
|
|
+ LocalDateTime nowDate = LocalDateTime.now();
|
|
|
+ Map<String, String> cell = row.get(i);
|
|
|
+ FosterwxStationPay fosterwxStationPay = new FosterwxStationPay();
|
|
|
+ FosterwxStation stationInfo = fosterwxStationService.getOne(new QueryWrapper<FosterwxStation>()
|
|
|
+ .eq("station_name", row.get(i).get("stationName")));
|
|
|
+ if (stationInfo == null) {
|
|
|
+ throw new Exception("站点编号不存在");
|
|
|
+ }
|
|
|
+ fosterwxStationPay.setStationId(stationInfo.getId());
|
|
|
+ fosterwxStationPay.setPayType(Integer.parseInt(row.get(i).get("payType")));
|
|
|
+ fosterwxStationPay.setAmtType(Integer.parseInt(row.get(i).get("amtType")));
|
|
|
+ fosterwxStationPay.setAmt(Double.valueOf(row.get(i).get("amt")));
|
|
|
+ fosterwxStationPay.setPayAt(LocalDateTime.parse(row.get(i).get("payAt") + " 00:00:00", df));
|
|
|
+ fosterwxStationPay.setRemark(row.get(i).get("remark"));
|
|
|
+ fosterwxStationPay.setCreateAt(nowDate);
|
|
|
+ fosterwxStationPay.setUpdateAt(nowDate);
|
|
|
+ fosterwxStationPay.setCreateUid(authUser.getId());
|
|
|
+ this.save(fosterwxStationPay);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+}
|