|
|
|
|
package com.glxp.api.controller.system;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.ReflectUtil;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
|
|
|
import com.glxp.api.dao.schedule.ScheduledDao;
|
|
|
|
|
import com.glxp.api.entity.system.ProductRemarkSetEntity;
|
|
|
|
|
import com.glxp.api.entity.system.ScheduledEntity;
|
|
|
|
|
import com.glxp.api.entity.system.SystemParamConfigEntity;
|
|
|
|
|
import com.glxp.api.req.system.FilterParamConfigRequest;
|
|
|
|
|
import com.glxp.api.req.system.SysParamConfigSaveRequest;
|
|
|
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
|
|
|
import com.glxp.api.res.system.SystemParamConfigResponse;
|
|
|
|
|
import com.glxp.api.service.system.SystemParamConfigService;
|
|
|
|
|
import com.glxp.api.util.CronUtils;
|
|
|
|
|
import com.glxp.api.common.enums.ResultEnum;
|
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
public class SysParamConfigController {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private SystemParamConfigService systemParamConfigService;
|
|
|
|
|
@Resource
|
|
|
|
|
ScheduledDao scheduledDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("system/param/config/list")
|
|
|
|
|
@GetMapping("/system/param/config/list")
|
|
|
|
|
public BaseResponse list(@Valid FilterParamConfigRequest filterParamConfigRequest,
|
|
|
|
|
BindingResult bindingResult) {
|
|
|
|
|
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
filterParamConfigRequest.setParamStatus(1);
|
|
|
|
|
List<SystemParamConfigEntity> systemParamConfigEntityList = systemParamConfigService.queryPage(filterParamConfigRequest);
|
|
|
|
|
List<SystemParamConfigResponse> systemParamConfigResponseList = systemParamConfigEntityList.stream().map(item -> {
|
|
|
|
|
SystemParamConfigResponse systemParamConfigResponse = new SystemParamConfigResponse();
|
|
|
|
|
BeanUtils.copyProperties(item, systemParamConfigResponse);
|
|
|
|
|
return systemParamConfigResponse;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
PageInfo<SystemParamConfigEntity> pageInfo = new PageInfo<>(systemParamConfigEntityList);
|
|
|
|
|
PageSimpleResponse<SystemParamConfigResponse> pageSimpleResponse = new PageSimpleResponse<>();
|
|
|
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
|
|
|
pageSimpleResponse.setList(systemParamConfigResponseList);
|
|
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("system/param/config/save")
|
|
|
|
|
@PostMapping("/system/param/config/save")
|
|
|
|
|
public BaseResponse save(@RequestBody @Valid SysParamConfigSaveRequest sysParamConfigSaveRequest,
|
|
|
|
|
BindingResult bindingResult) {
|
|
|
|
|
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SystemParamConfigEntity systemParamConfigEntity = new SystemParamConfigEntity();
|
|
|
|
|
BeanUtils.copyProperties(sysParamConfigSaveRequest, systemParamConfigEntity);
|
|
|
|
|
|
|
|
|
|
boolean b = systemParamConfigService.insert(systemParamConfigEntity);
|
|
|
|
|
if (!b) {
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("system/param/config/update")
|
|
|
|
|
@PostMapping("/system/param/config/update")
|
|
|
|
|
public BaseResponse update(@RequestBody SysParamConfigSaveRequest sysParamConfigSaveRequest) {
|
|
|
|
|
// systemParamConfigSaveRequest.setId(1);
|
|
|
|
|
systemParamConfigService.updateById(sysParamConfigSaveRequest);
|
|
|
|
|
if (sysParamConfigSaveRequest.getParentId() == 0) {
|
|
|
|
|
SysParamConfigSaveRequest sysParamConfigSaveRequest1 = new SysParamConfigSaveRequest();
|
|
|
|
|
sysParamConfigSaveRequest1.setParentId(sysParamConfigSaveRequest.getId());
|
|
|
|
|
if (sysParamConfigSaveRequest.getParamValue().equals("1")) {
|
|
|
|
|
sysParamConfigSaveRequest1.setParamStatus(1);
|
|
|
|
|
} else {
|
|
|
|
|
sysParamConfigSaveRequest1.setParamStatus(0);
|
|
|
|
|
}
|
|
|
|
|
systemParamConfigService.updateParentId(sysParamConfigSaveRequest1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//出入库新增单据校验
|
|
|
|
|
if (sysParamConfigSaveRequest.getParamKey().equals("io_transInout_interval")) {
|
|
|
|
|
try {
|
|
|
|
|
int time = 5;
|
|
|
|
|
if (!"0".equals(sysParamConfigSaveRequest.getParamValue())) {
|
|
|
|
|
time = Integer.parseInt(sysParamConfigSaveRequest.getParamValue());
|
|
|
|
|
}
|
|
|
|
|
String cronStr = CronUtils.parseMinuteIntervel(time);
|
|
|
|
|
ScheduledEntity scheduledEntity = new ScheduledEntity();
|
|
|
|
|
scheduledEntity.setCron(cronStr);
|
|
|
|
|
scheduledEntity.setCronName("transInout");
|
|
|
|
|
scheduledDao.modifyScheduled(scheduledEntity);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ResultVOUtils.error(500, "格式错误!");
|
|
|
|
|
}
|
|
|
|
|
} else if (sysParamConfigSaveRequest.getParamKey().equals("io_erpcheck_interval")) {
|
|
|
|
|
try {
|
|
|
|
|
int time = 5;
|
|
|
|
|
if (!"0".equals(sysParamConfigSaveRequest.getParamValue())) {
|
|
|
|
|
time = Integer.parseInt(sysParamConfigSaveRequest.getParamValue());
|
|
|
|
|
}
|
|
|
|
|
String cronStr = CronUtils.parseMinuteIntervel(time);
|
|
|
|
|
ScheduledEntity scheduledEntity = new ScheduledEntity();
|
|
|
|
|
scheduledEntity.setCron(cronStr);
|
|
|
|
|
scheduledEntity.setCronName("erpCheck");
|
|
|
|
|
scheduledDao.modifyScheduled(scheduledEntity);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ResultVOUtils.error(500, "格式错误!");
|
|
|
|
|
}
|
|
|
|
|
} else if (sysParamConfigSaveRequest.getParamKey().equals("supplement_order_interval")) {
|
|
|
|
|
try {
|
|
|
|
|
int time = 5;
|
|
|
|
|
if (!"0".equals(sysParamConfigSaveRequest.getParamValue())) {
|
|
|
|
|
time = Integer.parseInt(sysParamConfigSaveRequest.getParamValue());
|
|
|
|
|
}
|
|
|
|
|
String cornStr = CronUtils.parseMinuteIntervel(time);
|
|
|
|
|
ScheduledEntity scheduledEntity = new ScheduledEntity();
|
|
|
|
|
scheduledEntity.setCron(cornStr);
|
|
|
|
|
scheduledEntity.setCronName("supplementOrderTask");
|
|
|
|
|
scheduledDao.modifyScheduled(scheduledEntity);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ResultVOUtils.error(500, "格式错误!");
|
|
|
|
|
}
|
|
|
|
|
} else if (sysParamConfigSaveRequest.getParamKey().equals("auto_download_thirdSys_data")) {
|
|
|
|
|
try {
|
|
|
|
|
int time = 1;
|
|
|
|
|
if (!"0".equals(sysParamConfigSaveRequest.getParamValue())) {
|
|
|
|
|
time = Integer.parseInt(sysParamConfigSaveRequest.getParamValue());
|
|
|
|
|
}
|
|
|
|
|
if (time > 28) {
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "参数错误,大于28天会导致部分2月份无法更新数据");
|
|
|
|
|
}
|
|
|
|
|
String cornStr = CronUtils.parseDayIntervel(time);
|
|
|
|
|
ScheduledEntity scheduledEntity = new ScheduledEntity();
|
|
|
|
|
scheduledEntity.setCron(cornStr);
|
|
|
|
|
scheduledEntity.setCronName("downThirdSysDataTask");
|
|
|
|
|
scheduledDao.modifyScheduled(scheduledEntity);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ResultVOUtils.error(500, "格式错误!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.success("修改成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//key搜索
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
|
@GetMapping("/udiwms/sys/config/selectByKey")
|
|
|
|
|
public BaseResponse selectByKey(FilterParamConfigRequest filterParamConfigRequest,
|
|
|
|
|
BindingResult bindingResult) {
|
|
|
|
|
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
|
}
|
|
|
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey(filterParamConfigRequest.getParamKey());
|
|
|
|
|
return ResultVOUtils.success(systemParamConfigEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取耗材字典备用字段设置
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
|
@GetMapping("/udiwms/sys/config/selectByBasic")
|
|
|
|
|
public BaseResponse selectByBasic() {
|
|
|
|
|
FilterParamConfigRequest filterParamConfigRequest = new FilterParamConfigRequest();
|
|
|
|
|
filterParamConfigRequest.setParamType(2);
|
|
|
|
|
filterParamConfigRequest.setParamStatus(1);
|
|
|
|
|
List<SystemParamConfigEntity> systemParamConfigEntities = systemParamConfigService.queryPage(filterParamConfigRequest);
|
|
|
|
|
systemParamConfigEntities = systemParamConfigEntities.stream().sorted(Comparator.comparing(SystemParamConfigEntity::getParamKey))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
ProductRemarkSetEntity productRemarkSetEntity = new ProductRemarkSetEntity();
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(systemParamConfigEntities) && systemParamConfigEntities.size() == 8) {
|
|
|
|
|
for (int i = 0; i < systemParamConfigEntities.size(); i++) {
|
|
|
|
|
|
|
|
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigEntities.get(i);
|
|
|
|
|
ReflectUtil.setFieldValue(productRemarkSetEntity, "remarkKey" + (i + 1), systemParamConfigEntity.getParamKey());
|
|
|
|
|
|
|
|
|
|
if (!systemParamConfigEntity.getParamValue().equals("0")) {
|
|
|
|
|
ReflectUtil.setFieldValue(productRemarkSetEntity, "remarkTitle" + (i + 1), systemParamConfigEntity.getParamValue());
|
|
|
|
|
ReflectUtil.setFieldValue(productRemarkSetEntity, "remarkEnable" + (i + 1), true);
|
|
|
|
|
} else {
|
|
|
|
|
ReflectUtil.setFieldValue(productRemarkSetEntity, "remarkEnable" + (i + 1), false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.success(productRemarkSetEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|