|
|
@@ -9,6 +9,7 @@ import org.sky.core.log.exception.ServiceException;
|
|
|
import org.sky.core.mp.base.BaseServiceImpl;
|
|
|
import org.sky.core.tool.utils.BeanUtil;
|
|
|
import org.sky.core.tool.utils.CollectionUtil;
|
|
|
+import org.sky.core.tool.utils.DateUtil;
|
|
|
import org.sky.core.tool.utils.StringUtil;
|
|
|
import org.sky.scientific.excel.XmLeaseExcel;
|
|
|
import org.sky.scientific.mapper.XmLeaseMapper;
|
|
|
@@ -19,6 +20,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
@@ -60,6 +62,10 @@ public class XmLeaseServiceImpl extends BaseServiceImpl<XmLeaseMapper, XmLeaseEn
|
|
|
List<XmLeaseEntity> insertList = new ArrayList<>();
|
|
|
for (XmLeaseExcel excel : data) {
|
|
|
XmLeaseEntity entity = Objects.requireNonNull(BeanUtil.copyProperties(excel, XmLeaseEntity.class));
|
|
|
+
|
|
|
+ //租赁日期,必须时当月日期
|
|
|
+ judgeLeaseDate(excel.getLeaseDate(), yearAndMonth);
|
|
|
+
|
|
|
if (!StringUtil.isAllBlank(excel.getXmmc(), excel.getXmbh())) {
|
|
|
//根据项目名称或编号查询xmId
|
|
|
Long xmId = xmMapper.getXmIdByXmmcOrXmbh(yearAndMonth, excel.getXmmc(), excel.getXmbh());
|
|
|
@@ -67,8 +73,8 @@ public class XmLeaseServiceImpl extends BaseServiceImpl<XmLeaseMapper, XmLeaseEn
|
|
|
throw new ServiceException("研发项目[" + (StringUtil.isNotBlank(excel.getXmmc()) ? excel.getXmmc() + "," : "") + (StringUtil.isNotBlank(excel.getXmbh()) ? excel.getXmbh() : "") + "]不存在,请检查模板数据");
|
|
|
}
|
|
|
entity.setXmId(xmId);
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
entity.setYearAndMonth(yearAndMonth);
|
|
|
insertList.add(entity);
|
|
|
}
|
|
|
@@ -85,7 +91,19 @@ public class XmLeaseServiceImpl extends BaseServiceImpl<XmLeaseMapper, XmLeaseEn
|
|
|
if (StringUtil.isBlank(xmLease.getYearAndMonth())) {
|
|
|
throw new ServiceException("参数yearAndMonth不能为空");
|
|
|
}
|
|
|
+ judgeLeaseDate(xmLease.getLeaseDate(), xmLease.getYearAndMonth());
|
|
|
return this.saveOrUpdate(xmLease);
|
|
|
}
|
|
|
|
|
|
+ private void judgeLeaseDate(Date date, String yearAndMonth) {
|
|
|
+ //租赁日期,必须时当月日期
|
|
|
+ if (date != null) {
|
|
|
+ String format = DateUtil.format(date, DateUtil.PATTERN_YYYYMM);
|
|
|
+ boolean equals = StringUtil.equals(format, yearAndMonth);
|
|
|
+ if (!equals) {
|
|
|
+ throw new ServiceException("租赁日期" + format + "必须是" + yearAndMonth + "月的一天");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|