Merge remote-tracking branch 'origin/master'

highway
Yangwl 2 years ago
commit a165813130

@ -0,0 +1,53 @@
package com.op.device.config;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
import com.op.common.core.domain.R;
import com.op.common.datasource.creator.DynamicDatasourceCreator;
import com.op.system.api.RemoteUserService;
import com.op.system.api.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
*
*
* @ClassName: DynamicDatasource
* @Description: TODO
* @author shichangzhou
* @date 2023419 1:01:30
*/
@Component
public class DynamicDatasource {
@Resource
private DynamicDatasourceCreator dynamicDatasourceCreator;
@Autowired
private RemoteUserService remoteUserService;
@PostConstruct
public void init() {
// 加载sf-cloud库的sys_datasource
SysUser sysUser = new SysUser();
sysUser.setUserId(1L);
R<List<Map<String, String>>> dateSources0 = remoteUserService.getPoolNameList(sysUser);
List<Map<String, String>> dateSources = dateSources0.getData();
for (Map<String, String> dateSource : dateSources) {
DataSourceProperty sdp = new DataSourceProperty();
sdp.setUrl(dateSource.get("url"));
sdp.setUsername(dateSource.get("userName"));
sdp.setPassword(dateSource.get("password"));
sdp.setDriverClassName(dateSource.get("driveClassName"));
sdp.setPoolName(dateSource.get("poolName"));// 这是数据源的key
sdp.setLazy(false);
dynamicDatasourceCreator.createDynamicDataSource(sdp);
}
}
}

@ -2,6 +2,7 @@ package com.op.device.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -23,75 +24,75 @@ import com.op.common.core.web.page.TableDataInfo;
/**
* Controller
*
*
* @author wws
* @date 2023-10-12
*/
@RestController
@RequestMapping("/faultType")
public class EquFaultTypeController extends BaseController {
@Autowired
private IEquFaultTypeService equFaultTypeService;
@Autowired
private IEquFaultTypeService equFaultTypeService;
/**
*
*/
@RequiresPermissions("device:faultType:list")
@GetMapping("/list")
public TableDataInfo list(EquFaultType equFaultType) {
startPage();
List<EquFaultType> list = equFaultTypeService.selectEquFaultTypeList(equFaultType);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("device:faultType:list")
@GetMapping("/list")
public TableDataInfo list(EquFaultType equFaultType) {
startPage();
List<EquFaultType> list = equFaultTypeService.selectEquFaultTypeList(equFaultType);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("device:faultType:export")
@Log(title = "故障类型维护", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, EquFaultType equFaultType) {
List<EquFaultType> list = equFaultTypeService.selectEquFaultTypeList(equFaultType);
ExcelUtil<EquFaultType> util = new ExcelUtil<EquFaultType>(EquFaultType.class);
util.exportExcel(response, list, "故障类型维护数据");
}
/**
*
*/
@RequiresPermissions("device:faultType:export")
@Log(title = "故障类型维护", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, EquFaultType equFaultType) {
List<EquFaultType> list = equFaultTypeService.selectEquFaultTypeList(equFaultType);
ExcelUtil<EquFaultType> util = new ExcelUtil<EquFaultType>(EquFaultType.class);
util.exportExcel(response, list, "故障类型维护数据");
}
/**
*
*/
@RequiresPermissions("device:faultType:query")
@GetMapping(value = "/{faultId}")
public AjaxResult getInfo(@PathVariable("faultId") String faultId) {
return success(equFaultTypeService.selectEquFaultTypeByFaultId(faultId));
}
/**
*
*/
@RequiresPermissions("device:faultType:query")
@GetMapping(value = "/{faultId}")
public AjaxResult getInfo(@PathVariable("faultId") String faultId) {
return success(equFaultTypeService.selectEquFaultTypeByFaultId(faultId));
}
/**
*
*/
@RequiresPermissions("device:faultType:add")
@Log(title = "故障类型维护", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EquFaultType equFaultType) {
return toAjax(equFaultTypeService.insertEquFaultType(equFaultType));
}
/**
*
*/
@RequiresPermissions("device:faultType:add")
@Log(title = "故障类型维护", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EquFaultType equFaultType) {
return equFaultTypeService.insertEquFaultType(equFaultType);
}
/**
*
*/
@RequiresPermissions("device:faultType:edit")
@Log(title = "故障类型维护", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EquFaultType equFaultType) {
return toAjax(equFaultTypeService.updateEquFaultType(equFaultType));
}
/**
*
*/
@RequiresPermissions("device:faultType:edit")
@Log(title = "故障类型维护", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EquFaultType equFaultType) {
return equFaultTypeService.updateEquFaultType(equFaultType);
}
/**
*
*/
@RequiresPermissions("device:faultType:remove")
@Log(title = "故障类型维护", businessType = BusinessType.DELETE)
@DeleteMapping("/{faultIds}")
public AjaxResult remove(@PathVariable String[] faultIds) {
return toAjax(equFaultTypeService.deleteEquFaultTypeByFaultIds(faultIds));
}
/**
*
*/
@RequiresPermissions("device:faultType:remove")
@Log(title = "故障类型维护", businessType = BusinessType.DELETE)
@DeleteMapping("/{faultIds}")
public AjaxResult remove(@PathVariable String[] faultIds) {
return toAjax(equFaultTypeService.deleteEquFaultTypeByFaultIds(faultIds));
}
}

@ -68,23 +68,23 @@ public class EquCheckItem extends BaseEntity {
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdTime;
private Date createTime;
/** 创建人 */
@Excel(name = "创建人")
private String createdBy;
private String createBy;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedTime;
private Date updateTime;
/** 更新人 */
@Excel(name = "更新人")
private String updatedBy;
private String updateBy;
// 创建日期范围list
private List<Date> createdTimeArray;
private List<Date> createTimeArray;
// 更新日期范围list
private List<Date> updateTimeArray;
@ -141,12 +141,12 @@ public class EquCheckItem extends BaseEntity {
this.createTimeEnd = createTimeEnd;
}
public List<Date> getCreatedTimeArray() {
return createdTimeArray;
public List<Date> getCreateTimeArray() {
return createTimeArray;
}
public void setCreatedTimeArray(List<Date> createdTimeArray) {
this.createdTimeArray = createdTimeArray;
public void setCreateTimeArray(List<Date> createTimeArray) {
this.createTimeArray = createTimeArray;
}
public void setItemId(String itemId) {
@ -233,33 +233,33 @@ public class EquCheckItem extends BaseEntity {
public String getDelFlag() {
return delFlag;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getCreatedTime() {
return createdTime;
public Date getCreateTime() {
return createTime;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public String getCreatedBy() {
return createdBy;
public String getCreateBy() {
return createBy;
}
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Date getUpdatedTime() {
return updatedTime;
public Date getUpdateTime() {
return updateTime;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public String getUpdatedBy() {
return updatedBy;
public String getUpdateBy() {
return updateBy;
}
@Override
@ -277,11 +277,11 @@ public class EquCheckItem extends BaseEntity {
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("delFlag", getDelFlag())
.append("createdTime", getCreatedTime())
.append("createdBy", getCreatedBy())
.append("updatedTime", getUpdatedTime())
.append("updatedBy", getUpdatedBy())
.append("createdTimeArray",getCreatedTimeArray())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateTime", getUpdateTime())
.append("updateBy", getUpdateBy())
.append("createTimeArray",getCreateTimeArray())
.toString();
}
}

@ -66,20 +66,20 @@ public class EquCheckItemDetail extends BaseEntity {
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdTime;
private Date createTime;
/** 创建人 */
@Excel(name = "创建人")
private String createdBy;
private String createBy;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedTime;
private Date updateTime;
/** 更新人 */
@Excel(name = "更新人")
private String updatedBy;
private String updateBy;
/** 详情编码 */
@Excel(name = "详情编码")
@ -177,33 +177,33 @@ public class EquCheckItemDetail extends BaseEntity {
public String getDelFlag() {
return delFlag;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getCreatedTime() {
return createdTime;
public Date getCreateTime() {
return createTime;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public String getCreatedBy() {
return createdBy;
public String getCreateBy() {
return createBy;
}
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Date getUpdatedTime() {
return updatedTime;
public Date getUpdateTime() {
return updateTime;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public String getUpdatedBy() {
return updatedBy;
public String getUpdateBy() {
return updateBy;
}
@Override
@ -221,10 +221,10 @@ public class EquCheckItemDetail extends BaseEntity {
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("delFlag", getDelFlag())
.append("createdTime", getCreatedTime())
.append("createdBy", getCreatedBy())
.append("updatedTime", getUpdatedTime())
.append("updatedBy", getUpdatedBy())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateTime", getUpdateTime())
.append("updateBy", getUpdateBy())
.append("detailCode", getDetailCode())
.toString();
}

@ -52,21 +52,21 @@ public class EquItemEquipment extends BaseEntity {
/** 创建人 */
@Excel(name = "创建人")
private String createdBy;
private String createBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdTime;
private Date createTime;
/** 更新人 */
@Excel(name = "更新人")
private String updatedBy;
private String updateBy;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedTime;
private Date updateTime;
public void setId(String id) {
this.id = id;
@ -131,33 +131,33 @@ public class EquItemEquipment extends BaseEntity {
public String getDelFlag() {
return delFlag;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public String getCreatedBy() {
return createdBy;
public String getCreateBy() {
return createBy;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getCreatedTime() {
return createdTime;
public Date getCreateTime() {
return createTime;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public String getUpdatedBy() {
return updatedBy;
public String getUpdateBy() {
return updateBy;
}
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Date getUpdatedTime() {
return updatedTime;
public Date getUpdateTime() {
return updateTime;
}
@Override
@ -172,10 +172,10 @@ public class EquItemEquipment extends BaseEntity {
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("delFlag", getDelFlag())
.append("createdBy", getCreatedBy())
.append("createdTime", getCreatedTime())
.append("updatedBy", getUpdatedBy())
.append("updatedTime", getUpdatedTime())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

@ -32,17 +32,17 @@ public class EquCheckItemDTO {
/** 删除标识 */
private String delFlag ;
/** 创建时间 */
private Date createdTime ;
private Date createTime ;
/** 创建人 */
private String createdBy ;
private String createBy ;
/** 更新时间 */
private Date updatedTime ;
private Date updateTime ;
/** 更新人 */
private String updatedBy ;
private String updateBy ;
// 标准列表
private List<EquCheckItemDetail> formStandard;
// 创建日期范围list
private List<Date> createdTimeArray;
private List<Date> createTimeArray;
// 更新日期范围list
private List<Date> updateTimeArray;
@ -70,12 +70,12 @@ public class EquCheckItemDTO {
this.equipmentCodeList = equipmentCodeList;
}
public List<Date> getCreatedTimeArray() {
return createdTimeArray;
public List<Date> getCreateTimeArray() {
return createTimeArray;
}
public void setCreatedTimeArray(List<Date> createdTimeArray) {
this.createdTimeArray = createdTimeArray;
public void setCreateTimeArray(List<Date> createTimeArray) {
this.createTimeArray = createTimeArray;
}
public List<Date> getUpdateTimeArray() {
@ -214,36 +214,36 @@ public class EquCheckItemDTO {
this.delFlag = delFlag;
}
public Date getCreatedTime() {
return createdTime;
public Date getCreateTime() {
return createTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getCreatedBy() {
return createdBy;
public String getCreateBy() {
return createBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getUpdatedTime() {
return updatedTime;
public Date getUpdateTime() {
return updateTime;
}
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getUpdatedBy() {
return updatedBy;
public String getUpdateBy() {
return updateBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public List<EquCheckItemDetail> getFormStandard() {

@ -32,13 +32,13 @@ public class EquCheckItemVO {
/** 删除标识 */
private String delFlag ;
/** 创建时间 */
private Date createdTime ;
private Date createTime ;
/** 创建人 */
private String createdBy ;
private String createBy ;
/** 更新时间 */
private Date updatedTime ;
private Date updateTime ;
/** 更新人 */
private String updatedBy ;
private String updateBy ;
// 标准列表
private List<EquCheckItemDetail> formStandard;
// 设备名称
@ -158,36 +158,36 @@ public class EquCheckItemVO {
this.delFlag = delFlag;
}
public Date getCreatedTime() {
return createdTime;
public Date getCreateTime() {
return createTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getCreatedBy() {
return createdBy;
public String getCreateBy() {
return createBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getUpdatedTime() {
return updatedTime;
public Date getUpdateTime() {
return updateTime;
}
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getUpdatedBy() {
return updatedBy;
public String getUpdateBy() {
return updateBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public List<EquCheckItemDetail> getFormStandard() {

@ -44,7 +44,7 @@ public interface EquFaultTypeMapper {
public int updateEquFaultType(EquFaultType equFaultType);
/**
*
* -
*
* @param faultId
* @return
@ -52,10 +52,16 @@ public interface EquFaultTypeMapper {
public int deleteEquFaultTypeByFaultId(String faultId);
/**
*
* -
*
* @param faultIds
* @return
*/
public int deleteEquFaultTypeByFaultIds(String[] faultIds);
/**
*
* @return
*/
int selectSerialNumber();
}

@ -1,6 +1,8 @@
package com.op.device.service;
import java.util.List;
import com.op.common.core.web.domain.AjaxResult;
import com.op.device.domain.EquFaultType;
/**
@ -32,7 +34,7 @@ public interface IEquFaultTypeService {
* @param equFaultType
* @return
*/
public int insertEquFaultType(EquFaultType equFaultType);
public AjaxResult insertEquFaultType(EquFaultType equFaultType);
/**
*
@ -40,7 +42,7 @@ public interface IEquFaultTypeService {
* @param equFaultType
* @return
*/
public int updateEquFaultType(EquFaultType equFaultType);
public AjaxResult updateEquFaultType(EquFaultType equFaultType);
/**
*

@ -4,13 +4,11 @@ import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.List;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.context.SecurityContextHolder;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.log.annotation.Log;
import com.op.device.domain.EquCheckItemDetail;
import com.op.device.domain.EquItemEquipment;
import com.op.device.domain.dto.EquCheckItemDTO;
@ -76,12 +74,12 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
@Override
@DS("#header.poolName")
public List<EquCheckItem> selectEquCheckItemList(EquCheckItem equCheckItem) {
if (equCheckItem.getCreatedTimeArray() != null) {
if (equCheckItem.getCreateTimeArray() != null) {
// 设置创建日期开始和结束值
if (equCheckItem.getCreatedTimeArray().size() == 2) {
if (equCheckItem.getCreateTimeArray().size() == 2) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
equCheckItem.setCreateTimeStart(formatter.format(equCheckItem.getCreatedTimeArray().get(0)));
equCheckItem.setCreateTimeEnd(formatter.format(equCheckItem.getCreatedTimeArray().get(1)));
equCheckItem.setCreateTimeStart(formatter.format(equCheckItem.getCreateTimeArray().get(0)));
equCheckItem.setCreateTimeEnd(formatter.format(equCheckItem.getCreateTimeArray().get(1)));
}
}
if (equCheckItem.getUpdateTimeArray() != null) {
@ -106,10 +104,14 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
@Transactional
public AjaxResult insertEquCheckItem(EquCheckItemDTO equCheckItemDTO) {
// 检验重复
EquCheckItem checkItem = equCheckItemMapper.selectEquCheckItemByItemName(equCheckItemDTO.getItemName());
if (checkItem != null) {
return error("检查项已存在!新增失败!");
EquCheckItem checkItem = new EquCheckItem();
checkItem.setItemType(equCheckItemDTO.getItemType());
checkItem.setItemName(equCheckItemDTO.getItemName());
List<EquCheckItem> check = equCheckItemMapper.selectEquCheckItemList(checkItem);
if (check.size() > 0) {
return error(500,"检查项已存在!新增失败!");
}
// 创建检查项对象
EquCheckItem equCheckItem = new EquCheckItem();
BeanUtils.copyProperties(equCheckItemDTO, equCheckItem);
@ -128,10 +130,10 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
equCheckItem.setItemId(IdUtils.fastSimpleUUID());
equCheckItem.setFactoryCode(factory);
equCheckItem.setItemCode(DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + serialNum);
equCheckItem.setCreatedBy(SecurityContextHolder.getUserName());
equCheckItem.setCreatedTime(DateUtils.getNowDate());
equCheckItem.setUpdatedBy(SecurityContextHolder.getUserName());
equCheckItem.setUpdatedTime(DateUtils.getNowDate());
equCheckItem.setCreateBy(SecurityContextHolder.getUserName());
equCheckItem.setCreateTime(DateUtils.getNowDate());
equCheckItem.setUpdateBy(SecurityContextHolder.getUserName());
equCheckItem.setUpdateTime(DateUtils.getNowDate());
if (equCheckItem.getItemType().equals("spotInspection")) {
equCheckItem.setItemTypeName("点检");
}
@ -154,10 +156,10 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
detail.setParentCode(equCheckItem.getItemCode());
detail.setFactoryCode(factory);
detail.setDetailCode(equCheckItem.getItemCode() + detailSerialNum);
detail.setCreatedBy(SecurityContextHolder.getUserName());
detail.setCreatedTime(DateUtils.getNowDate());
detail.setUpdatedBy(SecurityContextHolder.getUserName());
detail.setUpdatedTime(DateUtils.getNowDate());
detail.setCreateBy(SecurityContextHolder.getUserName());
detail.setCreateTime(DateUtils.getNowDate());
detail.setUpdateBy(SecurityContextHolder.getUserName());
detail.setUpdateTime(DateUtils.getNowDate());
// 插入到数据库
equCheckItemDetailMapper.insertEquCheckItemDetail(detail);
@ -175,10 +177,10 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
equItemEquipment.setItemCode(equCheckItem.getItemCode());
equItemEquipment.setEquipmentCode(code);
equItemEquipment.setFactoryCode(factory);
equItemEquipment.setCreatedBy(SecurityContextHolder.getUserName());
equItemEquipment.setCreatedTime(DateUtils.getNowDate());
equItemEquipment.setUpdatedBy(SecurityContextHolder.getUserName());
equItemEquipment.setUpdatedTime(DateUtils.getNowDate());
equItemEquipment.setCreateBy(SecurityContextHolder.getUserName());
equItemEquipment.setCreateTime(DateUtils.getNowDate());
equItemEquipment.setUpdateBy(SecurityContextHolder.getUserName());
equItemEquipment.setUpdateTime(DateUtils.getNowDate());
// 插入数据库
equItemEquipmentMapper.insertEquItemEquipment(equItemEquipment);
@ -197,12 +199,24 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
@DS("#header.poolName")
@Transactional
public AjaxResult updateEquCheckItem(EquCheckItemDTO equCheckItemDTO) {
// 检验
EquCheckItem checkQuery = new EquCheckItem();
checkQuery.setItemType(equCheckItemDTO.getItemType());
checkQuery.setItemName(equCheckItemDTO.getItemName());
List<EquCheckItem> check = equCheckItemMapper.selectEquCheckItemList(checkQuery);
if (check.size()>0) {
if (!check.get(0).getItemCode().equals(equCheckItemDTO.getItemCode())) {
return error(500,"检查项已存在!不可修改!");
}
}
EquCheckItem equCheckItem = new EquCheckItem();
BeanUtils.copyProperties(equCheckItemDTO, equCheckItem);
// 处理检查项信息
equCheckItem.setUpdatedBy(SecurityContextHolder.getUserName());
equCheckItem.setUpdatedTime(DateUtils.getNowDate());
equCheckItem.setUpdateBy(SecurityContextHolder.getUserName());
equCheckItem.setUpdateTime(DateUtils.getNowDate());
if (equCheckItem.getItemType().equals("spotInspection")) {
equCheckItem.setItemTypeName("点检");
}
@ -227,10 +241,10 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
detail.setParentCode(equCheckItem.getItemCode());
detail.setFactoryCode(equCheckItem.getFactoryCode());
detail.setDetailCode(equCheckItem.getItemCode() + detailSerialNum);
detail.setCreatedBy(SecurityContextHolder.getUserName());
detail.setCreatedTime(DateUtils.getNowDate());
detail.setUpdatedBy(SecurityContextHolder.getUserName());
detail.setUpdatedTime(DateUtils.getNowDate());
detail.setCreateBy(SecurityContextHolder.getUserName());
detail.setCreateTime(DateUtils.getNowDate());
detail.setUpdateBy(SecurityContextHolder.getUserName());
detail.setUpdateTime(DateUtils.getNowDate());
// 插入到数据库
equCheckItemDetailMapper.insertEquCheckItemDetail(detail);
@ -251,10 +265,10 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
equItemEquipment.setItemCode(equCheckItem.getItemCode());
equItemEquipment.setEquipmentCode(code);
equItemEquipment.setFactoryCode(equCheckItemDTO.getFactoryCode());
equItemEquipment.setCreatedBy(SecurityContextHolder.getUserName());
equItemEquipment.setCreatedTime(DateUtils.getNowDate());
equItemEquipment.setUpdatedBy(SecurityContextHolder.getUserName());
equItemEquipment.setUpdatedTime(DateUtils.getNowDate());
equItemEquipment.setCreateBy(SecurityContextHolder.getUserName());
equItemEquipment.setCreateTime(DateUtils.getNowDate());
equItemEquipment.setUpdateBy(SecurityContextHolder.getUserName());
equItemEquipment.setUpdateTime(DateUtils.getNowDate());
// 插入数据库
equItemEquipmentMapper.insertEquItemEquipment(equItemEquipment);
@ -313,6 +327,7 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
* @return
*/
@Override
@DS("#header.poolName")
public AjaxResult getEquipmentCodeListByItemCode(String itemCode) {
List<String> equipmentCodeList = equItemEquipmentMapper.selectEquipmentCodeList(itemCode);
return success(equipmentCodeList);

@ -1,89 +1,153 @@
package com.op.device.service.impl;
import java.util.List;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.context.SecurityContextHolder;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.device.mapper.EquFaultTypeMapper;
import com.op.device.domain.EquFaultType;
import com.op.device.service.IEquFaultTypeService;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import static com.op.common.core.web.domain.AjaxResult.error;
import static com.op.common.core.web.domain.AjaxResult.success;
/**
* Service
*
*
* @author wws
* @date 2023-10-12
*/
@Service
public class EquFaultTypeServiceImpl implements IEquFaultTypeService {
@Autowired
private EquFaultTypeMapper equFaultTypeMapper;
/**
*
*
* @param faultId
* @return
*/
@Override
public EquFaultType selectEquFaultTypeByFaultId(String faultId) {
return equFaultTypeMapper.selectEquFaultTypeByFaultId(faultId);
}
/**
*
*
* @param equFaultType
* @return
*/
@Override
public List<EquFaultType> selectEquFaultTypeList(EquFaultType equFaultType) {
return equFaultTypeMapper.selectEquFaultTypeList(equFaultType);
}
/**
*
*
* @param equFaultType
* @return
*/
@Override
public int insertEquFaultType(EquFaultType equFaultType) {
equFaultType.setCreateTime(DateUtils.getNowDate());
return equFaultTypeMapper.insertEquFaultType(equFaultType);
}
/**
*
*
* @param equFaultType
* @return
*/
@Override
public int updateEquFaultType(EquFaultType equFaultType) {
equFaultType.setUpdateTime(DateUtils.getNowDate());
return equFaultTypeMapper.updateEquFaultType(equFaultType);
}
/**
*
*
* @param faultIds
* @return
*/
@Override
public int deleteEquFaultTypeByFaultIds(String[] faultIds) {
return equFaultTypeMapper.deleteEquFaultTypeByFaultIds(faultIds);
}
/**
*
*
* @param faultId
* @return
*/
@Override
public int deleteEquFaultTypeByFaultId(String faultId) {
return equFaultTypeMapper.deleteEquFaultTypeByFaultId(faultId);
}
@Autowired
private EquFaultTypeMapper equFaultTypeMapper;
/**
*
*
* @param faultId
* @return
*/
@Override
@DS("#header.poolName")
public EquFaultType selectEquFaultTypeByFaultId(String faultId) {
return equFaultTypeMapper.selectEquFaultTypeByFaultId(faultId);
}
/**
*
*
* @param equFaultType
* @return
*/
@Override
@DS("#header.poolName")
public List<EquFaultType> selectEquFaultTypeList(EquFaultType equFaultType) {
return equFaultTypeMapper.selectEquFaultTypeList(equFaultType);
}
/**
*
*
* @param equFaultType
* @return
*/
@Override
@DS("#header.poolName")
public AjaxResult insertEquFaultType(EquFaultType equFaultType) {
// 检验
EquFaultType checkQuery = new EquFaultType();
checkQuery.setFaultType(equFaultType.getFaultType());
checkQuery.setFaultSubclass(equFaultType.getFaultSubclass());
List<EquFaultType> check = equFaultTypeMapper.selectEquFaultTypeList(checkQuery);
if (check.size() > 0) {
return error(500,"故障子类已存在!不可添加!");
}
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
int index = str.indexOf("_");
String factory = str.substring(index + 1);
// 获取检查项流水号
String serialNum = String.format("%03d", equFaultTypeMapper.selectSerialNumber());
// 处理故障信息
equFaultType.setFaultId(IdUtils.fastSimpleUUID());
equFaultType.setFaultCode(DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + serialNum);
equFaultType.setFactoryCode(factory);
equFaultType.setCreateBy(SecurityContextHolder.getUserName());
equFaultType.setCreateTime(DateUtils.getNowDate());
equFaultType.setUpdateBy(SecurityContextHolder.getUserName());
equFaultType.setUpdateTime(DateUtils.getNowDate());
// 插入数据库
equFaultTypeMapper.insertEquFaultType(equFaultType);
return success();
}
/**
*
*
* @param equFaultType
* @return
*/
@Override
@DS("#header.poolName")
public AjaxResult updateEquFaultType(EquFaultType equFaultType) {
// 检验
EquFaultType checkQuery = new EquFaultType();
checkQuery.setFaultType(equFaultType.getFaultType());
checkQuery.setFaultSubclass(equFaultType.getFaultSubclass());
List<EquFaultType> check = equFaultTypeMapper.selectEquFaultTypeList(checkQuery);
if (check.size() > 0) {
if (!check.get(0).equals(equFaultType.getFaultCode())) {
return error(500,"故障子类已存在!修改失败!");
}
}
equFaultType.setUpdateBy(SecurityContextHolder.getUserName());
equFaultType.setUpdateTime(DateUtils.getNowDate());
// 插入数据库
equFaultTypeMapper.updateEquFaultType(equFaultType);
return success("修改成功");
}
/**
*
*
* @param faultIds
* @return
*/
@Override
@DS("#header.poolName")
public int deleteEquFaultTypeByFaultIds(String[] faultIds) {
return equFaultTypeMapper.deleteEquFaultTypeByFaultIds(faultIds);
}
/**
*
*
* @param faultId
* @return
*/
@Override
@DS("#header.poolName")
public int deleteEquFaultTypeByFaultId(String faultId) {
return equFaultTypeMapper.deleteEquFaultTypeByFaultId(faultId);
}
}

@ -17,15 +17,15 @@
<result property="attr2" column="attr2" />
<result property="attr3" column="attr3" />
<result property="delFlag" column="del_flag" />
<result property="createdTime" column="created_time" />
<result property="createdBy" column="created_by" />
<result property="updatedTime" column="updated_time" />
<result property="updatedBy" column="updated_by" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="detailCode" column="detail_code" />
</resultMap>
<sql id="selectEquCheckItemDetailVo">
select detail_id, parent_code, standard_type, standard_name, factory_code, detail_up_limit, detail_down_limit, detail_unit, attr1, attr2, attr3, del_flag, created_time, created_by, updated_time, updated_by, detail_code from equ_check_item_detail
select detail_id, parent_code, standard_type, standard_name, factory_code, detail_up_limit, detail_down_limit, detail_unit, attr1, attr2, attr3, del_flag, create_time, create_by, update_time, update_by, detail_code from equ_check_item_detail
</sql>
<select id="selectEquCheckItemDetailList" parameterType="EquCheckItemDetail" resultMap="EquCheckItemDetailResult">
@ -41,10 +41,10 @@
<if test="attr1 != null and attr1 != ''"> and attr1 = #{attr1}</if>
<if test="attr2 != null and attr2 != ''"> and attr2 = #{attr2}</if>
<if test="attr3 != null and attr3 != ''"> and attr3 = #{attr3}</if>
<if test="createdTime != null "> and created_time = #{createdTime}</if>
<if test="createdBy != null and createdBy != ''"> and created_by = #{createdBy}</if>
<if test="updatedTime != null "> and updated_time = #{updatedTime}</if>
<if test="updatedBy != null and updatedBy != ''"> and updated_by = #{updatedBy}</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by = #{updateBy}</if>
<if test="detailCode != null and detailCode != ''"> and detail_code = #{detailCode}</if>
</where>
and del_flag = '0'
@ -58,13 +58,13 @@
<select id="selectSerialNumber" resultType="java.lang.Integer">
SELECT COUNT(detail_id)+1 AS serialNum
FROM equ_check_item_detail
WHERE CONVERT(date, GETDATE()) = CONVERT(date,created_time) and parent_code = #{itemCode} and del_flag = '0'
WHERE CONVERT(date, GETDATE()) = CONVERT(date,create_time) and parent_code = #{itemCode} and del_flag = '0'
</select>
<select id="selectEquCheckItemDetailByParentCode" parameterType="String" resultMap="EquCheckItemDetailResult">
<include refid="selectEquCheckItemDetailVo"/>
where parent_code = #{parentCode} and del_flag = '0'
ORDER BY created_time
ORDER BY create_time
</select>
<insert id="insertEquCheckItemDetail" parameterType="EquCheckItemDetail">
@ -82,10 +82,10 @@
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createdTime != null">created_time,</if>
<if test="createdBy != null and createdBy != ''">created_by,</if>
<if test="updatedTime != null">updated_time,</if>
<if test="updatedBy != null and updatedBy != ''">updated_by,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="detailCode != null and detailCode != ''">detail_code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -101,10 +101,10 @@
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="createdBy != null and createdBy != ''">#{createdBy},</if>
<if test="updatedTime != null">#{updatedTime},</if>
<if test="updatedBy != null and updatedBy != ''">#{updatedBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="detailCode != null and detailCode != ''">#{detailCode},</if>
</trim>
</insert>
@ -123,10 +123,10 @@
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="createdBy != null and createdBy != ''">created_by = #{createdBy},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
<if test="updatedBy != null and updatedBy != ''">updated_by = #{updatedBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="detailCode != null and detailCode != ''">detail_code = #{detailCode},</if>
</trim>
where detail_id = #{detailId} and del_flag = '0'

@ -17,14 +17,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="attr2" column="attr2" />
<result property="attr3" column="attr3" />
<result property="delFlag" column="del_flag" />
<result property="createdTime" column="created_time" />
<result property="createdBy" column="created_by" />
<result property="updatedTime" column="updated_time" />
<result property="updatedBy" column="updated_by" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectEquCheckItemVo">
select item_id, item_code, item_name, item_method, item_type, item_type_name, item_remark, factory_code, attr1, attr2, attr3, del_flag, created_time, created_by, updated_time, updated_by from equ_check_item
select item_id, item_code, item_name, item_method, item_type, item_type_name, item_remark, factory_code, attr1, attr2, attr3, del_flag, create_time, create_by, update_time, update_by from equ_check_item
</sql>
<select id="selectEquCheckItemList" parameterType="EquCheckItem" resultMap="EquCheckItemResult">
@ -41,14 +41,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="attr2 != null and attr2 != ''"> and attr2 = #{attr2}</if>
<if test="attr3 != null and attr3 != ''"> and attr3 = #{attr3}</if>
<if test="delFlag != null and delFlag != ''"> and del_flag = #{delFlag}</if>
<if test="createTimeStart != null "> and CONVERT(date,created_time) >= #{createTimeStart}</if>
<if test="createTimeEnd != null "> and #{createTimeEnd} >= CONVERT(date,created_time)</if>
<if test="createdBy != null and createdBy != ''"> and created_by like concat('%', #{createdBy}, '%')</if>
<if test="updateTimeStart != null "> and CONVERT(date,updated_time) >= #{updateTimeStart}</if>
<if test="updateTimeEnd != null "> and #{updateTimeEnd} >= CONVERT(date,updated_time)</if>
<if test="updatedBy != null and updatedBy != ''"> and updated_by like concat('%', #{updatedBy}, '%')</if>
<if test="createTimeStart != null "> and CONVERT(date,create_time) >= #{createTimeStart}</if>
<if test="createTimeEnd != null "> and #{createTimeEnd} >= CONVERT(date,create_time)</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="updateTimeStart != null "> and CONVERT(date,update_time) >= #{updateTimeStart}</if>
<if test="updateTimeEnd != null "> and #{updateTimeEnd} >= CONVERT(date,update_time)</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
and del_flag = '0'
ORDER BY created_time DESC
ORDER BY create_time DESC
</where>
</select>
@ -65,7 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSerialNumber" resultType="java.lang.Integer">
SELECT COUNT(item_id)+1 AS serialNum
FROM equ_check_item
WHERE CONVERT(date, GETDATE()) = CONVERT(date,created_time) and del_flag = '0'
WHERE CONVERT(date, GETDATE()) = CONVERT(date,create_time) and del_flag = '0'
</select>
<select id="selectAllEquipmentList" resultType="com.op.device.domain.vo.EquCheckItemVO">
@ -87,10 +87,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createdTime != null">created_time,</if>
<if test="createdBy != null and createdBy != ''">created_by,</if>
<if test="updatedTime != null">updated_time,</if>
<if test="updatedBy != null and updatedBy != ''">updated_by,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="itemId != null">#{itemId},</if>
@ -105,10 +105,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="createdBy != null and createdBy != ''">#{createdBy},</if>
<if test="updatedTime != null">#{updatedTime},</if>
<if test="updatedBy != null and updatedBy != ''">#{updatedBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
</trim>
</insert>
@ -126,10 +126,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="createdBy != null and createdBy != ''">created_by = #{createdBy},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
<if test="updatedBy != null and updatedBy != ''">updated_by = #{updatedBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
</trim>
where item_id = #{itemId} and del_flag = '0'
</update>

@ -41,15 +41,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by = #{updateBy}</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
and del_flag = '0'
</where>
</select>
<select id="selectEquFaultTypeByFaultId" parameterType="String" resultMap="EquFaultTypeResult">
<include refid="selectEquFaultTypeVo"/>
where fault_id = #{faultId}
where fault_id = #{faultId} and del_flag = '0'
</select>
<insert id="insertEquFaultType" parameterType="EquFaultType">
<select id="selectSerialNumber" resultType="java.lang.Integer">
SELECT COUNT(fault_id)+1 AS serialNum
FROM equ_fault_type
WHERE CONVERT(date, GETDATE()) = CONVERT(date,create_time) and del_flag = '0'
</select>
<insert id="insertEquFaultType" parameterType="EquFaultType">
insert into equ_fault_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="faultId != null">fault_id,</if>
@ -102,15 +109,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where fault_id = #{faultId}
where fault_id = #{faultId} and del_flag = '0'
</update>
<delete id="deleteEquFaultTypeByFaultId" parameterType="String">
delete from equ_fault_type where fault_id = #{faultId}
delete equ_fault_type set del_flag = '1' where fault_id = #{faultId}
</delete>
<delete id="deleteEquFaultTypeByFaultIds" parameterType="String">
delete from equ_fault_type where fault_id in
update equ_fault_type set del_flag = '1' where fault_id in
<foreach item="faultId" collection="array" open="(" separator="," close=")">
#{faultId}
</foreach>

@ -14,14 +14,14 @@
<result property="attr2" column="attr2" />
<result property="attr3" column="attr3" />
<result property="delFlag" column="del_flag" />
<result property="createdBy" column="created_by" />
<result property="createdTime" column="created_time" />
<result property="updatedBy" column="updated_by" />
<result property="updatedTime" column="updated_time" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectEquItemEquipmentVo">
select id, conn_code, item_code, equipment_code, factory_code, attr1, attr2, attr3, del_flag, created_by, created_time, updated_by, updated_time from equ_item_equipment
select id, conn_code, item_code, equipment_code, factory_code, attr1, attr2, attr3, del_flag, create_by, create_time, update_by, update_time from equ_item_equipment
</sql>
<select id="selectEquItemEquipmentList" parameterType="EquItemEquipment" resultMap="EquItemEquipmentResult">
@ -34,10 +34,10 @@
<if test="attr1 != null and attr1 != ''"> and attr1 = #{attr1}</if>
<if test="attr2 != null and attr2 != ''"> and attr2 = #{attr2}</if>
<if test="attr3 != null and attr3 != ''"> and attr3 = #{attr3}</if>
<if test="createdBy != null and createdBy != ''"> and created_by = #{createdBy}</if>
<if test="createdTime != null "> and created_time = #{createdTime}</if>
<if test="updatedBy != null and updatedBy != ''"> and updated_by = #{updatedBy}</if>
<if test="updatedTime != null "> and updated_time = #{updatedTime}</if>
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by = #{updateBy}</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
</where>
and del_flag = '0'
</select>
@ -50,7 +50,7 @@
<select id="selectSerialNumber" resultType="java.lang.Integer">
SELECT COUNT(id)+1 AS serialNum
FROM equ_item_equipment
WHERE CONVERT(date, GETDATE()) = CONVERT(date,created_time) and del_flag = '0'
WHERE CONVERT(date, GETDATE()) = CONVERT(date,create_time) and del_flag = '0'
</select>
<select id="selectEquipmentCodeList" resultType="java.lang.String">
@ -69,10 +69,10 @@
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createdBy != null and createdBy != ''">created_by,</if>
<if test="createdTime != null">created_time,</if>
<if test="updatedBy != null and updatedBy != ''">updated_by,</if>
<if test="updatedTime != null">updated_time,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@ -84,10 +84,10 @@
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createdBy != null and createdBy != ''">#{createdBy},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updatedBy != null and updatedBy != ''">#{updatedBy},</if>
<if test="updatedTime != null">#{updatedTime},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
@ -102,10 +102,10 @@
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createdBy != null and createdBy != ''">created_by = #{createdBy},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="updatedBy != null and updatedBy != ''">updated_by = #{updatedBy},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id} and del_flag = '0'
</update>

@ -1,13 +1,17 @@
package com.op.mes.controller;
import java.util.List;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import javax.servlet.http.HttpServletResponse;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.domain.MesProcessReport;
import com.op.mes.domain.MesReportProduction;
import com.op.mes.domain.*;
import com.op.mes.domain.dto.LineChartDto;
import com.op.mes.domain.dto.SysFactoryDto;
import com.op.mes.mapper.MesReportWorkMapper;
@ -24,7 +28,6 @@ import org.springframework.web.bind.annotation.RestController;
import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.mes.domain.MesReportWork;
import com.op.mes.service.IMesReportWorkService;
import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
@ -42,8 +45,6 @@ import com.op.common.core.utils.poi.ExcelUtilDailyReport;
public class MesReportWorkController extends BaseController {
@Autowired
private IMesReportWorkService mesReportWorkService;
@Autowired
private MesReportWorkMapper mesReportWorkMapper;
/**
*
*/
@ -189,6 +190,76 @@ public class MesReportWorkController extends BaseController {
return mesReportWorkService.getLineChartData(mesReportProduction);
}
/**
*
*/
@RequiresPermissions("mes:hourProduction:list")
@GetMapping("/getHourProductionTitle")
public List<String> getProcessFinishList(MesHourReport mesHourReport) {
//默认时间范围T 00:00:00~T+1 00:00:00
if(StringUtils.isEmpty(mesHourReport.getProductDateStart())){
mesHourReport.setProductDateStart(DateUtils.getDate()+" 00:00:00");//start
LocalDate date = LocalDate.now();
LocalDate dateEnd = date.plusDays(1);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String dateEndStr = dtf.format(dateEnd)+" 00:00:00";
mesHourReport.setProductDateEnd(dateEndStr);//end
}
// 返回的日期集合
List<String> dayHours = new ArrayList<String>();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH");
try {
Date start = dateFormat.parse(mesHourReport.getProductDateStart());
Date end = dateFormat.parse(mesHourReport.getProductDateEnd());
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(start);
Calendar tempEnd = Calendar.getInstance();
tempEnd.setTime(end);
while (tempStart.before(tempEnd)) {
dayHours.add(dateFormat.format(tempStart.getTime()));
tempStart.add(Calendar.HOUR_OF_DAY, 1);
}
} catch (ParseException e) {
e.printStackTrace();
}
return dayHours;
}
/**
*
*/
@RequiresPermissions("mes:hourProduction:list")
@GetMapping("/getHourProductionList")
public List<HashMap> getHourProductionList(MesHourReport mesHourReport) {
List<String> hourNames = this.getProcessFinishList(mesHourReport);
mesHourReport.setHourNames(hourNames);
List<HashMap> list = mesReportWorkService.getHourProductionList(mesHourReport);
return list;
}
public static void main(String args[]){
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
try {
Date start = dateFormat.parse("2023-10-12 09:00:00");
Date end = dateFormat.parse("2023-10-13 18:00:00");
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(start);
Calendar tempEnd = Calendar.getInstance();
tempEnd.setTime(end);
while (tempStart.before(tempEnd)) {
System.out.println(dateFormat.format(tempStart.getTime()));
tempStart.add(Calendar.HOUR_OF_DAY, 1);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,143 @@
package com.op.mes.domain;
import com.op.common.core.web.domain.BaseEntity;
import java.util.Date;
import java.util.List;
/**
*
*
* @author Open Platform
* @date 2023-08-24
*/
public class MesHourReport extends BaseEntity {
private static final long serialVersionUID = 1L;
private String productCode;//产品编码
private String productName;//产品名称
private String quantity;//数量
private String unit;//单位
private String hourName;
private String productDateStart;
private String productDateEnd;
private String ymdh;
private String equCode;
private String equName;
private String orderCode;
private String workorderCode;
private List<String> hourNames;
private String equCodeHour;
public String getEquCodeHour() {
return equCodeHour;
}
public void setEquCodeHour(String equCodeHour) {
this.equCodeHour = equCodeHour;
}
public List<String> getHourNames() {
return hourNames;
}
public void setHourNames(List<String> hourNames) {
this.hourNames = hourNames;
}
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode;
}
public String getWorkorderCode() {
return workorderCode;
}
public void setWorkorderCode(String workorderCode) {
this.workorderCode = workorderCode;
}
public String getYmdh() {
return ymdh;
}
public void setYmdh(String ymdh) {
this.ymdh = ymdh;
}
public String getEquCode() {
return equCode;
}
public void setEquCode(String equCode) {
this.equCode = equCode;
}
public String getEquName() {
return equName;
}
public void setEquName(String equName) {
this.equName = equName;
}
public String getProductDateStart() {
return productDateStart;
}
public void setProductDateStart(String productDateStart) {
this.productDateStart = productDateStart;
}
public String getProductDateEnd() {
return productDateEnd;
}
public void setProductDateEnd(String productDateEnd) {
this.productDateEnd = productDateEnd;
}
public String getProductCode() {
return productCode;
}
public void setProductCode(String productCode) {
this.productCode = productCode;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getQuantity() {
return quantity;
}
public void setQuantity(String quantity) {
this.quantity = quantity;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getHourName() {
return hourName;
}
public void setHourName(String hourName) {
this.hourName = hourName;
}
}

@ -3,10 +3,7 @@ package com.op.mes.mapper;
import java.util.List;
import java.util.Map;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.domain.MesProcessReport;
import com.op.mes.domain.MesReportProduction;
import com.op.mes.domain.MesReportWork;
import com.op.mes.domain.*;
import com.op.mes.domain.dto.SysFactoryDto;
import org.apache.ibatis.annotations.MapKey;
@ -84,4 +81,8 @@ public interface MesReportWorkMapper {
Map<String,MesReportProduction> getLineChartsDatas(MesReportProduction mesReportProduction);
List<String> getLineChartsNames(MesReportProduction mesReportProduction);
@MapKey("equCodeHour")
Map<String,MesHourReport> getHourProductionList(MesHourReport mesHourReport);
List<MesHourReport> getEquNames(MesHourReport mesHourReport);
}

@ -1,11 +1,9 @@
package com.op.mes.service;
import java.util.HashMap;
import java.util.List;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.domain.MesProcessReport;
import com.op.mes.domain.MesReportProduction;
import com.op.mes.domain.MesReportWork;
import com.op.mes.domain.*;
import com.op.mes.domain.dto.LineChartDto;
import com.op.mes.domain.dto.SysFactoryDto;
@ -75,4 +73,6 @@ public interface IMesReportWorkService {
List<SysFactoryDto> getWorkcenterList(MesDailyReport mesDailyReport);
LineChartDto getLineChartData(MesReportProduction mesReportProduction);
List<HashMap> getHourProductionList(MesHourReport mesHourReport);
}

@ -8,16 +8,13 @@ import java.util.*;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.domain.MesProcessReport;
import com.op.mes.domain.MesReportProduction;
import com.op.mes.domain.*;
import com.op.mes.domain.dto.LineChartDto;
import com.op.mes.domain.dto.LineChartSeriesDto;
import com.op.mes.domain.dto.SysFactoryDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.mes.mapper.MesReportWorkMapper;
import com.op.mes.domain.MesReportWork;
import com.op.mes.service.IMesReportWorkService;
import org.springframework.util.CollectionUtils;
@ -191,7 +188,7 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
* data: [120, 132, 101, 134, 90, 230, 210,120, 132, 101, 134, 90, 230, 210]
* }
* ]
* @param mesDailyReport
* @param
* @return
*/
@Override
@ -238,6 +235,33 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
lineChartDto.setSeriesDatas(seriesDatas);
return lineChartDto;
}
@DS("#header.poolName")
@Override
public List<HashMap> getHourProductionList(MesHourReport mesHourReport) {
List<HashMap> hourPros = new ArrayList<>();
List<MesHourReport> equs = mesReportWorkMapper.getEquNames(mesHourReport);
List<String> hourNames = mesHourReport.getHourNames();
Map<String,MesHourReport> equProMap = mesReportWorkMapper.getHourProductionList(mesHourReport);
for(MesHourReport equ:equs){
HashMap result = new HashMap();
result.put("equCode",equ.getEquCode());
result.put("equName",equ.getEquName());
for(int n = 0;n < hourNames.size();n++){
String hourName = hourNames.get(n);
String key = equ.getEquCode()+hourName;
MesHourReport hourdto = equProMap.get(key);
if(hourdto!=null){
result.put("hourPro"+n,hourdto.getQuantity());
}else{
result.put("hourPro"+n,"0");
}
}
hourPros.add(result);
}
return hourPros;
}
/**两个日期之间的所有日期**/
public static List<String> getDays(String startTime,String endTime) {

@ -244,6 +244,76 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
CONVERT(varchar(10),mrw.feedback_time, 120) >= #{productDateStart}
and #{productDateEnd} >= CONVERT(varchar(10),mrw.feedback_time, 120)
</select>
<select id="getEquNames" resultType="com.op.mes.domain.MesHourReport">
select
DISTINCT mt.equipmentCode equCode,
equ.equipment_name equName
from mes_material_transfer_result mt
left join base_equipment equ on mt.equipmentCode = equ.equipment_code
left join pro_order_workorder pow on pow.workorder_id = mt.OrderCode
where 1=1
<if test="productDateStart != null "> and CONVERT(varchar(30),mt.update_time, 120) >= #{productDateStart}</if>
<if test="productDateEnd != null "> and #{productDateEnd} > CONVERT(varchar(30),mt.update_time, 120)</if>
<if test="orderCode != null and orderCode != ''">
and pow.order_code like concat('%', #{orderCode}, '%')
</if>
<if test="productCode != null and productCode != ''">
and pow.product_code like concat('%', #{productCode}, '%')
</if>
<if test="productName != null and productName != ''">
and pow.product_name like concat('%', #{productName}, '%')
</if>
<if test="workorderCode != null and workorderCode != ''">
and pow.workorder_code like concat('%', #{workorderCode}, '%')
</if>
<if test="equName != null and equName != ''">
and equ.equipment_name like concat('%', #{equName}, '%')
</if>
order by mt.equipmentCode
</select>
<select id="getHourProductionList" resultType="com.op.mes.domain.MesHourReport">
select
concat(mt.equipmentCode,mt.ymdh) equCodeHour,
mt.ymdh,
mt.equipmentCode equCode,
equ.equipment_name equName,
count(0) quantity,
'车' unit
from
(
select
SUBSTRING(CONVERT(varchar(100),update_time, 20), 0, 14) ymdh,
equipmentCode,
OrderCode
from mes_material_transfer_result
where 1=1
<if test="productDateStart != null "> and CONVERT(varchar(30),update_time, 120) >= #{productDateStart}</if>
<if test="productDateEnd != null "> and #{productDateEnd} > CONVERT(varchar(30),update_time, 120)</if>
)mt
left join base_equipment equ on mt.equipmentCode = equ.equipment_code
left join pro_order_workorder pow on pow.workorder_id = mt.OrderCode
where pow.order_code is not null
<if test="orderCode != null and orderCode != ''">
and pow.order_code like concat('%', #{orderCode}, '%')
</if>
<if test="productCode != null and productCode != ''">
and pow.product_code like concat('%', #{productCode}, '%')
</if>
<if test="productName != null and productName != ''">
and pow.product_name like concat('%', #{productName}, '%')
</if>
<if test="workorderCode != null and workorderCode != ''">
and pow.workorder_code like concat('%', #{workorderCode}, '%')
</if>
<if test="equName != null and equName != ''">
and equ.equipment_name like concat('%', #{equName}, '%')
</if>
group by
mt.ymdh,
mt.equipmentCode,
equ.equipment_name
</select>
<insert id="insertMesReportWork" parameterType="MesReportWork">
insert into mes_report_work

Loading…
Cancel
Save