|
|
|
@ -1,17 +1,28 @@
|
|
|
|
|
package jnpf.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import jnpf.entity.*;
|
|
|
|
|
import jnpf.mapper.YysMonthlyProductionMapper;
|
|
|
|
|
import jnpf.service.*;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import jnpf.model.yysmonthlyproduction.*;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import jnpf.permission.model.authorize.AuthorizeConditionModel;
|
|
|
|
|
import jnpf.util.GeneraterSwapUtil;
|
|
|
|
|
import jnpf.database.model.superQuery.SuperQueryJsonModel;
|
|
|
|
|
import jnpf.database.model.superQuery.ConditionJsonModel;
|
|
|
|
|
import jnpf.database.model.superQuery.SuperQueryConditionModel;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
|
|
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
import jnpf.model.QueryModel;
|
|
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -25,6 +36,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
|
|
import jnpf.util.*;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
@ -49,17 +63,7 @@ public class YysMonthlyProductionServiceImpl extends ServiceImpl<YysMonthlyProdu
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<YysMonthlyProductionEntity> getList(YysMonthlyProductionPagination yysMonthlyProductionPagination) {
|
|
|
|
|
// QueryWrapper<YysMonthlyProductionEntity> wrapper = new QueryWrapper<>();
|
|
|
|
|
// if (ObjectUtil.isNotEmpty(yysMonthlyProductionPagination.getYears())) {
|
|
|
|
|
// wrapper.lambda().eq(YysMonthlyProductionEntity::getYears, yysMonthlyProductionPagination.getYears().toString());
|
|
|
|
|
// }
|
|
|
|
|
// wrapper.lambda().isNull(YysMonthlyProductionEntity::getDeleteMark);
|
|
|
|
|
// wrapper.last("ORDER BY CAST(day AS UNSIGNED)");
|
|
|
|
|
// Page<YysMonthlyProductionEntity> page = new Page<>(yysMonthlyProductionPagination.getCurrentPage(), yysMonthlyProductionPagination.getPageSize());
|
|
|
|
|
// IPage<YysMonthlyProductionEntity> userIPage = this.page(page, wrapper);
|
|
|
|
|
// return yysMonthlyProductionPagination.setData(userIPage.getRecords(), userIPage.getTotal());
|
|
|
|
|
return getTypeList(yysMonthlyProductionPagination, yysMonthlyProductionPagination.getDataType());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -161,10 +165,13 @@ public class YysMonthlyProductionServiceImpl extends ServiceImpl<YysMonthlyProdu
|
|
|
|
|
if (ObjectUtil.isNotEmpty(yysMonthlyProductionPagination.getYears())) {
|
|
|
|
|
yysMonthlyProductionNum++;
|
|
|
|
|
|
|
|
|
|
String value = yysMonthlyProductionPagination.getYears() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(yysMonthlyProductionPagination.getYears()) :
|
|
|
|
|
String.valueOf(yysMonthlyProductionPagination.getYears());
|
|
|
|
|
yysMonthlyProductionQueryWrapper.lambda().eq(YysMonthlyProductionEntity::getYears, value);
|
|
|
|
|
List YearsList = JsonUtil.getJsonToList(yysMonthlyProductionPagination.getYears(), String.class);
|
|
|
|
|
Long fir = Long.valueOf(String.valueOf(YearsList.get(0)));
|
|
|
|
|
Long sec = Long.valueOf(String.valueOf(YearsList.get(1)));
|
|
|
|
|
|
|
|
|
|
yysMonthlyProductionQueryWrapper.lambda().ge(YysMonthlyProductionEntity::getYears, new Date(fir))
|
|
|
|
|
.le(YysMonthlyProductionEntity::getYears, DateUtil.stringToDate(DateUtil.daFormatYmd(sec) + " 23:59:59"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -202,6 +209,8 @@ public class YysMonthlyProductionServiceImpl extends ServiceImpl<YysMonthlyProdu
|
|
|
|
|
List<String> finalAllRuleIDlist = allRuleIDlist;
|
|
|
|
|
yysMonthlyProductionQueryWrapper.lambda().and(t -> t.in(YysMonthlyProductionEntity::getId, finalAllRuleIDlist));
|
|
|
|
|
}
|
|
|
|
|
//假删除标志
|
|
|
|
|
yysMonthlyProductionQueryWrapper.lambda().isNull(YysMonthlyProductionEntity::getDeleteMark);
|
|
|
|
|
|
|
|
|
|
//排序
|
|
|
|
|
if (StringUtil.isEmpty(yysMonthlyProductionPagination.getSidx())) {
|
|
|
|
@ -270,21 +279,31 @@ public class YysMonthlyProductionServiceImpl extends ServiceImpl<YysMonthlyProdu
|
|
|
|
|
id = form.getId();
|
|
|
|
|
}
|
|
|
|
|
//主表字段验证
|
|
|
|
|
if (StringUtil.isEmpty(form.getYears())) {
|
|
|
|
|
return "年月不能为空";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isEmpty(form.getProductId())) {
|
|
|
|
|
return "产品编码不能为空";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isEmpty(form.getProductName())) {
|
|
|
|
|
return "产品名称不能为空";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isEmpty(form.getModel())) {
|
|
|
|
|
return "规格型号不能为空";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isEmpty(form.getMeasurementUnit())) {
|
|
|
|
|
return "计量单位不能为空";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isNotEmpty(form.getMeasurementNumber())) {
|
|
|
|
|
if (!Pattern.compile("^\\d+$").matcher(String.valueOf(form.getMeasurementNumber())).matches()) {
|
|
|
|
|
return "请输入正确的数字";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isEmpty(form.getCurrentInventory())) {
|
|
|
|
|
return "当前库存不能为空";
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isNotEmpty(form.getCurrentInventory())) {
|
|
|
|
|
if (!Pattern.compile("^\\d+$").matcher(String.valueOf(form.getCurrentInventory())).matches()) {
|
|
|
|
|
return "请输入正确的数字";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return countRecover;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -299,31 +318,33 @@ public class YysMonthlyProductionServiceImpl extends ServiceImpl<YysMonthlyProdu
|
|
|
|
|
@Transactional
|
|
|
|
|
public String saveOrUpdate(YysMonthlyProductionForm yysMonthlyProductionForm, String id, boolean isSave) {
|
|
|
|
|
UserInfo userInfo = userProvider.get();
|
|
|
|
|
LambdaQueryWrapper<YysMonthlyProductionEntity> wrapper = new LambdaQueryWrapper<>(YysMonthlyProductionEntity.class);
|
|
|
|
|
|
|
|
|
|
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
|
|
|
|
|
yysMonthlyProductionForm = JsonUtil.getJsonToBean(
|
|
|
|
|
generaterSwapUtil.swapDatetime(YysMonthlyProductionConstant.getFormData(), yysMonthlyProductionForm), YysMonthlyProductionForm.class);
|
|
|
|
|
YysMonthlyProductionEntity entity = JsonUtil.getJsonToBean(yysMonthlyProductionForm, YysMonthlyProductionEntity.class);
|
|
|
|
|
|
|
|
|
|
if (isSave) {
|
|
|
|
|
wrapper.eq(YysMonthlyProductionEntity::getYears, yysMonthlyProductionForm.getYears());
|
|
|
|
|
java.sql.Date sqlDate = new java.sql.Date(Long.parseLong(yysMonthlyProductionForm.getYears()));
|
|
|
|
|
LambdaQueryWrapper<YysMonthlyProductionEntity> wrapper = new LambdaQueryWrapper<>(YysMonthlyProductionEntity.class);
|
|
|
|
|
wrapper.eq(YysMonthlyProductionEntity::getProductName, yysMonthlyProductionForm.getProductName());
|
|
|
|
|
wrapper.eq(YysMonthlyProductionEntity::getProductId, yysMonthlyProductionForm.getProductId());
|
|
|
|
|
wrapper.eq(YysMonthlyProductionEntity::getYears, sqlDate);
|
|
|
|
|
if (isSave) {
|
|
|
|
|
if (CollectionUtils.isNotEmpty(this.list(wrapper))) {
|
|
|
|
|
return "所选年月与产品已被创建";
|
|
|
|
|
return "所选年月及产品名称已经创建";
|
|
|
|
|
}
|
|
|
|
|
String mainId = RandomUtil.uuId();
|
|
|
|
|
entity.setCreatorTime(DateUtil.getNowDate());
|
|
|
|
|
entity.setCreatorUserId(userInfo.getUserId());
|
|
|
|
|
entity.setId(mainId);
|
|
|
|
|
|
|
|
|
|
entity.setVersion(0);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
wrapper.ne(YysMonthlyProductionEntity::getYears, yysMonthlyProductionForm.getYears());
|
|
|
|
|
wrapper.ne(YysMonthlyProductionEntity::getProductName, yysMonthlyProductionForm.getProductName());
|
|
|
|
|
|
|
|
|
|
YysMonthlyProductionEntity byId = this.getById(yysMonthlyProductionForm.getId());
|
|
|
|
|
boolean isProductNameChanged = !byId.getProductName().equals(yysMonthlyProductionForm.getProductName());
|
|
|
|
|
boolean isProductCodeChanged = !byId.getProductId().equals(yysMonthlyProductionForm.getProductId());
|
|
|
|
|
boolean isYearsChanged = !byId.getYears().equals(sqlDate);
|
|
|
|
|
if (isProductNameChanged || isProductCodeChanged || isYearsChanged) {
|
|
|
|
|
if (CollectionUtils.isNotEmpty(this.list(wrapper))) {
|
|
|
|
|
return "所选年月与产品已被创建";
|
|
|
|
|
return "所选年月及产品名称已经存在,无法修改";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
entity.setLastModifyTime(DateUtil.getNowDate());
|
|
|
|
|
entity.setLastModifyUserId(userInfo.getUserId());
|
|
|
|
@ -333,6 +354,5 @@ public class YysMonthlyProductionServiceImpl extends ServiceImpl<YysMonthlyProdu
|
|
|
|
|
return "操作成功";
|
|
|
|
|
}
|
|
|
|
|
return "操作失败";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|