Commit 821302bc authored by 李驰骋's avatar 李驰骋

排产调整

parent 29b72ed0
......@@ -55,7 +55,7 @@ public class BaseController {
}
protected static void startPage(final PageParams pageParams) {
PageUtils.startPage();
PageUtils.startPage(pageParams);
}
/**
......
package com.ximai.common.core.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PageParams {
/**
* 当前记录起始索引
*/
public static Integer pageNum;
@ApiModelProperty("页数")
public Integer pageNum;
/**
* 每页显示记录数
*/
@ApiModelProperty("分页SIZE")
public Integer pageSize;
/**
* 排序列
*/
@ApiModelProperty("排序列")
public String orderByColumn;
/**
* 排序的方向 "desc" 或者 "asc".
*/
@ApiModelProperty("排序方向")
public String isAsc;
/**
* 分页参数合理化
*/
public Boolean reasonable;
public static Integer getPageNum() {
return pageNum;
}
public static void setPageNum(Integer pageNum) {
PageParams.pageNum = pageNum;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public String getOrderByColumn() {
return orderByColumn;
}
public void setOrderByColumn(String orderByColumn) {
this.orderByColumn = orderByColumn;
}
public String getIsAsc() {
return isAsc;
}
public void setIsAsc(String isAsc) {
this.isAsc = isAsc;
}
public Boolean getReasonable() {
return reasonable;
}
public void setReasonable(Boolean reasonable) {
this.reasonable = reasonable;
}
}
package com.ximai.common.utils;
import java.util.Calendar;
import java.util.Collection;
import java.util.List;
import cn.hutool.core.date.DateUtil;
import com.ximai.common.constant.Constants;
import com.ximai.common.core.domain.entity.SysDictData;
import com.ximai.common.core.redis.RedisCache;
......@@ -179,4 +182,5 @@ public class DictUtils
{
return Constants.SYS_DICT_KEY + configKey;
}
}
......@@ -5,15 +5,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="${packageName}.mapper${childPackageName}.${ClassName}Mapper">
<resultMap type="${ClassName}" id="${ClassName}Result">
#foreach ($column in $columns)
<result property="${column.javaField}" column="${column.columnName}" />
#end
#foreach ($column in $columns)
<result property="${column.javaField}" column="${column.columnName}" />
#end
</resultMap>
<resultMap type="${packageName}.dto${childPackageName}.${ClassName}Dto" id="${ClassName}Result2">
#foreach ($column in $columns)
<result property="${column.javaField}" column="${column.columnName}" />
#end
#foreach ($column in $columns)
<result property="${column.javaField}" column="${column.columnName}" />
#end
</resultMap>
#if($table.sub)
......
......@@ -97,10 +97,30 @@ public class ProWorkorderController extends BaseController {
@ApiOperation("工单查询")
@GetMapping("/list")
public TableDataInfo<ProWorkorder> list(ProWorkorderQuery proWorkorder) {
startPage();
List<ProWorkorder> list = proWorkorderService.selectProWorkorderList(proWorkorder);
// List<ProWorkorder> workorderList = list.stream().filter(x -> x.getStatus() != WorkorderStatusEnum.CLOSE.getValue()).collect(Collectors.toList());
return getDataTable(list);
return getManualDataTable(list);
}
/**
* 查询待排产生产工单列表
*/
@ApiOperation("查询待排产生产工单列表")
@GetMapping("/scheduleList")
public TableDataInfo<ProWorkorder> scheduleList(ProWorkorderQuery proWorkorder) {
QueryWrapper<ProWorkorder> query = new QueryWrapper<>();
query.like(StringUtils.isNotEmpty(proWorkorder.getWorkorderCode()), "t1.workorder_code",
proWorkorder.getWorkorderCode());
query.like(StringUtils.isNotEmpty(proWorkorder.getProductCode()), "t1.product_code",
proWorkorder.getProductCode());
query.like(StringUtils.isNotEmpty(proWorkorder.getProductName()), "t1.product_name",
proWorkorder.getProductName());
query.in(StringUtils.isNotEmpty(proWorkorder.getStatusArr()), "t1.status",
proWorkorder.getStatusArr());
query.in(StringUtils.isNotEmpty(proWorkorder.getStatusArr()), "t1.status",
new String[]{WorkorderStatusEnum.PREPARE.getValue(), WorkorderStatusEnum.PUBLISHED.getValue()});
query.gt("t1.quantity-t1.quantity_scheduled", 0);
List<ProWorkorder> list = proWorkorderService.selectListByQw(query);
return getManualDataTable(list);
}
......
......@@ -334,11 +334,7 @@ public class ProTaskController extends BaseController {
@Log(title = "生产任务排产", businessType = BusinessType.OTHER)
@PostMapping("/schedule")
public AjaxResult schedule(@ApiParam(value = "工单属性集合", required = true) @RequestBody List<WorkorderScheduleParams> params) {
List<String> arrangeCodes = params.stream().map(WorkorderScheduleParams::getArrangeCode).collect(Collectors.toList());
QueryWrapper<ProWorkorder> queryWrapper = new QueryWrapper<ProWorkorder>();
queryWrapper.in("arrange_code", arrangeCodes);
List<ProWorkorder> list = proWorkorderService.selectListByQw(queryWrapper);
proTaskService.schedule(list.stream().map(ProWorkorder::getWorkorderId).collect(Collectors.toList()));
proTaskService.schedule(params);
return AjaxResult.success();
}
......
package com.ximai.mes.pro.domain;
import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import com.ximai.common.core.domain.BaseEntity;
import org.apache.commons.lang3.StringUtils;
import java.time.LocalDateTime;
/**
* 产品二维码规则对象 pro_product_qrcode_rule
......@@ -56,5 +60,11 @@ public class ProProductQrcodeRule extends BaseEntity {
private Integer currentSerial;
public String buildQrcode(){
String rst = this.getPrefix() +
DateUtil.format(LocalDateTime.now(), this.getDatePattern()) +
StringUtils.leftPad(currentSerial+"",serialLen, "0");
return rst;
}
}
......@@ -111,21 +111,6 @@ public class ProWorkorder extends TreeEntity {
*/
@Excel(name = "产品名称")
private String productName;
//产品分类
@TableField(exist = false)
private String itemTypeName;
@TableField(exist = false)
private Long itemTypeId;
@TableField(exist = false)
private double processingRatio;
@TableField(exist = false)
private Double feedBackedQuantity;
/**
* 规格型号
*/
......@@ -135,7 +120,7 @@ public class ProWorkorder extends TreeEntity {
/**
* 单位
*/
@Excel(name = "单位")
@ApiModelProperty("单位")
private String unitOfMeasure;
/**
......@@ -160,7 +145,7 @@ public class ProWorkorder extends TreeEntity {
/**
* 已生产数量
*/
@Excel(name = "已生产数量")
@ApiModelProperty("已生产数量")
private BigDecimal quantityProduced;
@ApiModelProperty("合格数量")
......@@ -178,7 +163,7 @@ public class ProWorkorder extends TreeEntity {
/**
* 已排产数量
*/
@Excel(name = "已排产数量")
@ApiModelProperty("已排产数量")
private BigDecimal quantityScheduled;
/**
......@@ -237,25 +222,6 @@ public class ProWorkorder extends TreeEntity {
*/
@Excel(name = "单据状态")
private String status;
@TableField(exist = false)
private Long taskId;
@TableField(exist = false)
private String combinationCode;
@TableField(exist = false)
private String workorderIds;
@TableField(exist = false)
private List<ProTask> tasks;
@TableField(exist = false)
private List<ProTaskVo> taskVos;
@TableField(exist = false)
private List<ProTaskWorkunit> proTaskWorkunits;
/**
* 任务清单组键值
*/
......@@ -364,5 +330,35 @@ public class ProWorkorder extends TreeEntity {
@TableField(exist = false)
private Date combinationStartTime;
//产品分类
@TableField(exist = false)
private String itemTypeName;
@TableField(exist = false)
private Long itemTypeId;
@TableField(exist = false)
private double processingRatio;
@TableField(exist = false)
private Double feedBackedQuantity;
@TableField(exist = false)
private Long taskId;
@TableField(exist = false)
private String combinationCode;
@TableField(exist = false)
private String workorderIds;
@TableField(exist = false)
private List<ProTask> tasks;
@TableField(exist = false)
private List<ProTaskVo> taskVos;
@TableField(exist = false)
private List<ProTaskWorkunit> proTaskWorkunits;
}
......@@ -3,11 +3,15 @@ package com.ximai.mes.pro.domain.task;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class WorkorderScheduleParams {
@ApiModelProperty("工单ID")
Long workorderId;
@ApiModelProperty("编排单号")
String arrangeCode;
@ApiModelProperty("本次排产数量")
BigDecimal scheduleQuantity;
}
......@@ -173,8 +173,6 @@ public class ProWorkorderQuery extends BaseEntity {
@TableField(exist = false)
private String itemTypeName;
/**
* 需求日期
*/
......@@ -226,15 +224,8 @@ public class ProWorkorderQuery extends BaseEntity {
*/
private Long attr4;
private Long taskId;
private Long taskWorkunitId;
private String parentId;
@ApiModelProperty(hidden = true)
@TableField(exist = false)
private List<ProTask> tasks;
@TableField(exist = false)
private List<Long> workorderIds;
......
package com.ximai.mes.pro.schedule;
import com.ximai.mes.pro.domain.task.WorkorderScheduleParams;
import java.time.LocalDateTime;
import java.util.List;
......@@ -14,7 +16,7 @@ public interface AlgorithmDataSource {
* @param orderIds 工单ID
* @return
*/
public List<Resource> getResource(LocalDateTime schedulingStartedDate, List<Long> orderIds);
public List<Resource> getResource(LocalDateTime schedulingStartedDate, List<WorkorderScheduleParams> workorderScheduleParams);
/**
* 获取工单工序作务数据
......@@ -23,7 +25,7 @@ public interface AlgorithmDataSource {
* @param resources 资源ID
* @return
*/
public List<Job> getJob(LocalDateTime schedulingStartedDate, List<Long> orderIds, List<Resource> resources);
public List<Job> getJob(LocalDateTime schedulingStartedDate, List<WorkorderScheduleParams> workorderScheduleParams, List<Resource> resources);
/**
* 获取日历数据
......@@ -32,7 +34,7 @@ public interface AlgorithmDataSource {
* @param resources 资源ID
* @return
*/
public List<Calendar> getCalendar(LocalDateTime schedulingStartedDate, List<Long> orderIds, List<Resource> resources);
public List<Calendar> getCalendar(LocalDateTime schedulingStartedDate, List<WorkorderScheduleParams> workorderScheduleParams, List<Resource> resources);
}
......@@ -15,6 +15,7 @@ import com.ximai.mes.pro.domain.productionSolution.ProProductionSolution;
import com.ximai.mes.pro.domain.productionSolution.ProProductionSolutionProcess;
import com.ximai.mes.pro.domain.productionSolution.ProProductionSolutionSpecificationSheet;
import com.ximai.mes.pro.domain.task.ProTaskWorkunit;
import com.ximai.mes.pro.domain.task.WorkorderScheduleParams;
import com.ximai.mes.pro.schedule.*;
import com.ximai.mes.pro.service.proWorkOrder.IProWorkOrderProcessService;
import com.ximai.mes.pro.service.proWorkOrder.IProWorkorderService;
......@@ -63,7 +64,7 @@ public class AlgorithmDataSourceImpl implements AlgorithmDataSource {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public List<Resource> getResource(LocalDateTime schedulingStartedDate, List<Long> orderIds) {
public List<Resource> getResource(LocalDateTime schedulingStartedDate, List<WorkorderScheduleParams> workorderScheduleParams) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
QueryWrapper<MdWorkunitVo> query = new QueryWrapper<MdWorkunitVo>();
......@@ -98,25 +99,25 @@ public class AlgorithmDataSourceImpl implements AlgorithmDataSource {
}
@Override
public List<Job> getJob(LocalDateTime schedulingStartedDate, List<Long> orderIds, List<Resource> resources) {
public List<Job> getJob(LocalDateTime schedulingStartedDate, List<WorkorderScheduleParams> workorderScheduleParams, List<Resource> resources) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<Job> algJobs = new ArrayList<Job>();
//查询相关工单,工单编排单号也需一并查询出来
QueryWrapper<ProWorkorder> queryWrapper = new QueryWrapper<ProWorkorder>();
queryWrapper.in("workorder_id", orderIds);
queryWrapper.in("workorder_id", workorderScheduleParams.stream().map(s->s.getWorkorderId()).collect(Collectors.toList()));
List<ProWorkorder> workorderList = proWorkorderService.selectListByQw(queryWrapper);
Map<String, List<ProWorkorder>> workorderMap = workorderList.stream().collect(Collectors.groupingBy(s -> s.getArrangeCode()));
Map<Long,WorkorderScheduleParams> workorderScheduleParamsMap= workorderScheduleParams.stream().collect(Collectors.toMap(s->s.getWorkorderId(),s->s));
List<ScheduleJobGroup> scheduleJobGroupList = new ArrayList<ScheduleJobGroup>();
for (String arrangeCode : workorderMap.keySet()) {
List<ProWorkorder> list = workorderMap.get(arrangeCode);
for (ProWorkorder workorder : workorderList) {
ScheduleJobGroup scheduleJobGroup = new ScheduleJobGroup();
List<ProWorkorder> list = new ArrayList<>();
list.add(workorder);
scheduleJobGroup.setWorkorderList(list);
BigDecimal total = list.stream().map(ProWorkorder::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
LocalDateTime recentDate = list.stream().map(s -> DateUtil.toLocalDateTime(s.getRequestDate())).min(Comparator.comparing(LocalDateTime::toLocalDate)).get();
scheduleJobGroup.setQuantity(total);
scheduleJobGroup.setArrangeCode(arrangeCode);
scheduleJobGroup.setQuantity(workorderScheduleParamsMap.get(workorder.getWorkorderId()).getScheduleQuantity());
scheduleJobGroup.setDemandDate(recentDate);
scheduleJobGroup.setWorkorderCode(workorder.getWorkorderCode());
scheduleJobGroupList.add(scheduleJobGroup);
}
//按交期近,数量少排序
......@@ -142,7 +143,7 @@ public class AlgorithmDataSourceImpl implements AlgorithmDataSource {
ProProductionSolutionSpecificationSheet specificationSheet = proProductionSolutionSpecificationSheetService.selectSpecificationSheetByProductionSolutionId(productionSolution.getProductionSolutionId());
// 工序分组 生成Job及Task
Job job = new Job(scheduleJobGroup.getArrangeCode(), Duration.between(schedulingStartedDate, DateUtil.date(scheduleJobGroup.getDemandDate()).toLocalDateTime())) {{
Job job = new Job(scheduleJobGroup.getWorkorderCode(), Duration.between(schedulingStartedDate, DateUtil.date(scheduleJobGroup.getDemandDate()).toLocalDateTime())) {{
setFixed(false);
}};
JobExtent jobExtent = new JobExtent();
......@@ -200,7 +201,7 @@ public class AlgorithmDataSourceImpl implements AlgorithmDataSource {
}
@Override
public List<Calendar> getCalendar(LocalDateTime schedulingStartedDate, List<Long> orderIds, List<Resource> resources) {
public List<Calendar> getCalendar(LocalDateTime schedulingStartedDate, List<WorkorderScheduleParams> workorderScheduleParams, List<Resource> resources) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
Map<Long, Resource> resourceMap = resources.stream().collect(Collectors.toMap(s -> s.getId(), s -> s));
......@@ -254,8 +255,8 @@ public class AlgorithmDataSourceImpl implements AlgorithmDataSource {
LocalDateTime demandDate;
//总数量
BigDecimal quantity;
//编排单号
String arrangeCode;
//工单单号
String workorderCode;
}
}
......@@ -102,6 +102,7 @@ public class AlgorithmResultProcessImpl implements AlgorithmResultProcess {
proWorkorderUpdate.setStatus(WorkorderStatusEnum.ISSUED.getValue());
proWorkorderUpdate.setArrangeCode(workorder.getArrangeCode());
proWorkorderUpdate.setWorkorderId(workorder.getWorkorderId());
proWorkorderUpdate.setQuantityScheduled(proWorkorderUpdate.getQuantityScheduled().add(task.getOrderQuantity()));
proWorkorderService.updateProWorkorder(proWorkorderUpdate);
j++;
}
......
......@@ -2,6 +2,7 @@ package com.ximai.mes.pro.schedule.impl;
import cn.hutool.core.date.StopWatch;
import com.ximai.common.exception.ServiceException;
import com.ximai.mes.pro.domain.task.WorkorderScheduleParams;
import com.ximai.mes.pro.schedule.*;
import com.ximai.mes.pro.schedule.Calendar;
import com.ximai.mes.pro.schedule.strategy.EquipmentSelectionStrategy;
......@@ -27,7 +28,7 @@ public class BaoshenScheduleAlgorithmAdapter implements IScheduleAlgorithmAdapte
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public List<ScheduledResult> schedule(LocalDateTime schedulingStartedDate, List<Long> orderIds) {
public List<ScheduledResult> schedule(LocalDateTime schedulingStartedDate, List<WorkorderScheduleParams> workorderScheduleParams) {
logger.info("----------排产开始----------");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
......@@ -35,9 +36,9 @@ public class BaoshenScheduleAlgorithmAdapter implements IScheduleAlgorithmAdapte
StopWatch stopWatch2 = new StopWatch();
stopWatch2.start();
List<Resource> algResources = algorithmDataSource.getResource(schedulingStartedDate, orderIds);
List<Job> algJobs = algorithmDataSource.getJob(schedulingStartedDate, orderIds, algResources);
List<Calendar> algCalendar = algorithmDataSource.getCalendar(schedulingStartedDate, orderIds, algResources);
List<Resource> algResources = algorithmDataSource.getResource(schedulingStartedDate, workorderScheduleParams);
List<Job> algJobs = algorithmDataSource.getJob(schedulingStartedDate, workorderScheduleParams, algResources);
List<Calendar> algCalendar = algorithmDataSource.getCalendar(schedulingStartedDate, workorderScheduleParams, algResources);
stopWatch2.stop();
logger.info(String.format("排产数据加载总耗时:%s", stopWatch2.getTotalTimeSeconds()));
if(algorithmExtendDataSources!=null){
......@@ -45,7 +46,7 @@ public class BaoshenScheduleAlgorithmAdapter implements IScheduleAlgorithmAdapte
setJobs(algJobs);
setCalendars(algCalendar);
setResources(algResources);
setWorkorderIds(orderIds);
setWorkorderIds(workorderScheduleParams.stream().map(s->s.getWorkorderId()).collect(Collectors.toList()));
}};
algorithmExtendDataSources.forEach(s->{
s.extendData(algorithmDataContext);
......
package com.ximai.mes.pro.schedule.impl;
import com.ximai.mes.pro.domain.task.WorkorderScheduleParams;
import java.time.LocalDateTime;
import java.util.List;
......@@ -11,6 +13,6 @@ public interface IScheduleAlgorithmAdapter {
* @param orderIds 工单集合
* @return
*/
List<ScheduledResult> schedule(LocalDateTime schedulingStartedDate, List<Long> orderIds);
List<ScheduledResult> schedule(LocalDateTime schedulingStartedDate, List<WorkorderScheduleParams> workorderScheduleParams);
}
......@@ -86,4 +86,11 @@ public interface IProProductQrcodeRuleService
* @return 结果
*/
public int deleteProProductQrcodeRuleByRuleId(Long ruleId);
/**
* 获取产品序列编码
* @param rule
* @return
*/
public String buildQrcode(ProProductQrcodeRule rule);
}
package com.ximai.mes.pro.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ximai.common.utils.data.DateUtils;
......@@ -133,4 +134,25 @@ public class ProProductQrcodeRuleServiceImpl implements IProProductQrcodeRuleSer
public int deleteProProductQrcodeRuleByRuleId(Long ruleId) {
return proProductQrcodeRuleMapper.deleteProProductQrcodeRuleByRuleId(ruleId);
}
@Override
public String buildQrcode(ProProductQrcodeRule rule) {
String rst = rule.buildQrcode();
//当前流水+1
rule.setCurrentSerial(rule.getCurrentSerial()+1);
proProductQrcodeRuleMapper.updateById(rule);
return rst;
}
public List<String> buildQrcode(ProProductQrcodeRule rule, Integer quantity) {
List<String> rst = new ArrayList<>();
for(int i=0;i<quantity;i++){
String temp = rule.buildQrcode();
rst.add(temp);
rule.setCurrentSerial(rule.getCurrentSerial()+1);
}
proProductQrcodeRuleMapper.updateById(rule);
return rst;
}
}
......@@ -581,14 +581,6 @@ public class ProWorkorderServiceImpl implements IProWorkorderService {
rst.add(workorderVo);
});
ProProductionSolutionProcessVo processVo = solutionProcessMapper.selectObjByTwIdAndPIdAndWoId(proWorkorder.getTaskWorkunitId(), proWorkorder.getProcessId());
if (processVo != null) {
for (ProWorkorderVo proWorkorderVo : rst) {
proWorkorderVo.setUnitOfConvert(processVo.getUnitConvert() == null || processVo.getUnitConvert().doubleValue() == 0 ? "1" : processVo.getUnitConvert().toString());
}
}
return rst;
}
......
......@@ -1843,7 +1843,7 @@ public class ProTaskServiceImpl implements IProTaskService {
@Transactional
@Override
public void schedule(List<Long> orderIds) {
public void schedule(List<WorkorderScheduleParams> workorderScheduleParams) {
BaoshenScheduleAlgorithmAdapter baoshenScheduleAlgorithmAdapter = new BaoshenScheduleAlgorithmAdapter();
baoshenScheduleAlgorithmAdapter.setAlgorithmDataSource(algorithmDataSource);
baoshenScheduleAlgorithmAdapter.setAlgorithmResultProcess(algorithmResultProcess);
......@@ -1853,18 +1853,16 @@ public class ProTaskServiceImpl implements IProTaskService {
baoshenScheduleAlgorithmAdapter.setEquipmentSelectionStrategy(defaultStrategy);
baoshenScheduleAlgorithmAdapter.setAlgorithmExtendDataSources(new ArrayList<AlgorithmExtendDataSource>() {
private static final long serialVersionUID = -4466020352312471396L;
{
add(equipmentNewestTaskAlgorithmData);
add(scheduleSetupRuleAlgorithmData);
}
});
List<ScheduledResult> scheduledResults = baoshenScheduleAlgorithmAdapter.schedule(LocalDateTime.now(),
orderIds);
baoshenScheduleAlgorithmAdapter.schedule(LocalDateTime.now(),
workorderScheduleParams);
StopWatch stopWatch = new StopWatch();
stopWatch.start();
// closeSapWorkorderUpdate(orderIds);
stopWatch.stop();
logger.info(String.format("排产结果发送SAP耗时:%s", stopWatch.getTotalTimeSeconds()));
......
......@@ -5,6 +5,7 @@ import com.ximai.mes.pro.domain.GanttTask;
import com.ximai.mes.pro.domain.ProFeedback;
import com.ximai.mes.pro.domain.task.ProTask;
import com.ximai.mes.pro.domain.task.ProTaskWorkunit;
import com.ximai.mes.pro.domain.task.WorkorderScheduleParams;
import com.ximai.mes.pro.domain.vo.ProPackagePrintResult;
import com.ximai.mes.pro.domain.vo.ProTaskQuery;
import com.ximai.mes.pro.domain.vo.ProTaskVo;
......@@ -178,7 +179,7 @@ public interface IProTaskService {
/**
* 工单排产
*/
void schedule(List<Long> orderIds);
void schedule(List<WorkorderScheduleParams> workorderScheduleParams);
/**
* 查询设备关联最新任务号
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ximai.mes.pro.mapper.ProProductQrcodeRecordMapper">
<resultMap type="ProProductQrcodeRecord" id="ProProductQrcodeRecordResult">
<result property="recordId" column="record_id" />
<result property="itemId" column="item_id" />
<result property="itemCode" column="item_code" />
<result property="workOrderId" column="work_order_id" />
<result property="workOrderNo" column="work_order_no" />
<result property="printTime" column="print_time" />
<result property="qrcode" column="qrcode" />
<result property="clientCode" column="client_code" />
<result property="clientName" column="client_name" />
<result property="itemDesc" column="item_desc" />
<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>
<resultMap type="com.ximai.mes.pro.dto.ProProductQrcodeRecordDto" id="ProProductQrcodeRecordResult2">
<result property="recordId" column="record_id" />
<result property="itemId" column="item_id" />
<result property="itemCode" column="item_code" />
<result property="workOrderId" column="work_order_id" />
<result property="workOrderNo" column="work_order_no" />
<result property="printTime" column="print_time" />
<result property="qrcode" column="qrcode" />
<result property="clientCode" column="client_code" />
<result property="clientName" column="client_name" />
<result property="itemDesc" column="item_desc" />
<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="selectProProductQrcodeRecordVo">
select record_id, item_id, item_code, work_order_id, work_order_no, print_time, qrcode, client_code, client_name, item_desc, create_by, create_time, update_by, update_time from pro_product_qrcode_record
</sql>
<select id="selectProProductQrcodeRecordList" parameterType="ProProductQrcodeRecord" resultMap="ProProductQrcodeRecordResult2">
<include refid="selectProProductQrcodeRecordVo"/>
<where>
<if test="itemId != null "> and item_id = #{itemId}</if>
<if test="itemCode != null and itemCode != ''"> and item_code = #{itemCode}</if>
<if test="workOrderId != null "> and work_order_id = #{workOrderId}</if>
<if test="workOrderNo != null and workOrderNo != ''"> and work_order_no = #{workOrderNo}</if>
<if test="printTime != null "> and print_time = #{printTime}</if>
<if test="qrcode != null and qrcode != ''"> and qrcode = #{qrcode}</if>
<if test="clientCode != null and clientCode != ''"> and client_code = #{clientCode}</if>
<if test="clientName != null and clientName != ''"> and client_name like concat('%', #{clientName}, '%')</if>
<if test="itemDesc != null and itemDesc != ''"> and item_desc = #{itemDesc}</if>
</where>
</select>
<select id="selectProProductQrcodeRecordByRecordId" parameterType="Long" resultMap="ProProductQrcodeRecordResult2">
<include refid="selectProProductQrcodeRecordVo"/>
where record_id = #{recordId}
</select>
<insert id="insertProProductQrcodeRecord" parameterType="ProProductQrcodeRecord" useGeneratedKeys="true" keyProperty="recordId">
insert into pro_product_qrcode_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="itemId != null">item_id,</if>
<if test="itemCode != null">item_code,</if>
<if test="workOrderId != null">work_order_id,</if>
<if test="workOrderNo != null">work_order_no,</if>
<if test="printTime != null">print_time,</if>
<if test="qrcode != null">qrcode,</if>
<if test="clientCode != null">client_code,</if>
<if test="clientName != null">client_name,</if>
<if test="itemDesc != null">item_desc,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="itemId != null">#{itemId},</if>
<if test="itemCode != null">#{itemCode},</if>
<if test="workOrderId != null">#{workOrderId},</if>
<if test="workOrderNo != null">#{workOrderNo},</if>
<if test="printTime != null">#{printTime},</if>
<if test="qrcode != null">#{qrcode},</if>
<if test="clientCode != null">#{clientCode},</if>
<if test="clientName != null">#{clientName},</if>
<if test="itemDesc != null">#{itemDesc},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateProProductQrcodeRecord" parameterType="ProProductQrcodeRecord">
update pro_product_qrcode_record
<trim prefix="SET" suffixOverrides=",">
<if test="itemId != null">item_id = #{itemId},</if>
<if test="itemCode != null">item_code = #{itemCode},</if>
<if test="workOrderId != null">work_order_id = #{workOrderId},</if>
<if test="workOrderNo != null">work_order_no = #{workOrderNo},</if>
<if test="printTime != null">print_time = #{printTime},</if>
<if test="qrcode != null">qrcode = #{qrcode},</if>
<if test="clientCode != null">client_code = #{clientCode},</if>
<if test="clientName != null">client_name = #{clientName},</if>
<if test="itemDesc != null">item_desc = #{itemDesc},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where record_id = #{recordId}
</update>
<delete id="deleteProProductQrcodeRecordByRecordId" parameterType="Long">
delete from pro_product_qrcode_record where record_id = #{recordId}
</delete>
<delete id="deleteProProductQrcodeRecordByRecordIds" parameterType="String">
delete from pro_product_qrcode_record where record_id in
<foreach item="recordId" collection="array" open="(" separator="," close=")">
#{recordId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
package com.bs.mes.schedule.api;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import java.io.FileOutputStream;
import java.io.IOException;
public class ApiExcetlTest {
@Test
public void test2() {
// 创建一个新的工作簿
Workbook workbook = new XSSFWorkbook();
// 创建一个工作表
Sheet sheet = workbook.createSheet("ExampleSheet");
// 创建行(0基索引)
Row row = sheet.createRow(0);
// 创建单元格并设置值
Cell cell = row.createCell(0);
cell.setCellValue("服务启用");
cell = row.createCell(1);
cell.setCellValue("接口服务描述");
cell = row.createCell(2);
cell.setCellValue("接口地址");
cell = row.createCell(3);
cell.setCellValue("api地址");
// 写入到文件
try (FileOutputStream outputStream = new FileOutputStream("C:\\Users\\1\\Desktop\\example.xlsx")) {
workbook.write(outputStream);
} catch (IOException e) {
e.printStackTrace();
} finally {
// 清理资源
try {
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
\ No newline at end of file
package com.bs.mes.schedule.api;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;
public class CalendarManagerTest {
@Test
public void addOaccupiedCalendar() {
List<Map<String, String>> list = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(new FileReader("C:\\Users\\1\\Desktop\\default.md"))) {
// int row = 0;
String line;
Boolean flag1 = null;
Map<String, String> map = null;
while ((line = reader.readLine()) != null) {
if (flag1 == null || flag1) {
map = new HashMap<>();
flag1 = false;
}
if (line.contains("接口地址")) {
String replace = line.replace("**接口地址**:", "").replace("<p>", "").replace("</p>", "").replace("`", "");
map.put("apiaddr", replace);
}
if (line.contains("**请求方式**:")) {
String replace = line.replace("**请求方式**:", "").replace("<p>", "").replace("</p>", "").replace("`", "");
map.put("apimethod", replace);
}
if (line.contains("**接口描述**:")) {
String replace = line.replace("**接口描述**:", "").replace("<p>", "").replace("<p />", "").replace("</p>", "").replace("`", "");
map.put("apidesc", replace);
}
if (map.size() == 3) {
flag1 = true;
list.add(map);
}
// row++;
}
} catch (IOException e) {
e.printStackTrace();
}
excel(list);
}
public void excel(List<Map<String, String>> list) {
Set<String> objects = new HashSet<>();
List<Map<String, String>> objects1 = new ArrayList<>();
for (Map<String, String> entry : list) {
if (objects.add(entry.get("apiaddr"))) {
objects1.add(entry);
}
}
// 创建一个新的工作簿
Workbook workbook = new XSSFWorkbook();
// 创建一个工作表
Sheet sheet = workbook.createSheet("接口");
// 创建行(0基索引)
Row row = sheet.createRow(0);
// 创建单元格并设置值
Cell cell = row.createCell(0);
cell.setCellValue("服务启用");
cell = row.createCell(3);
cell.setCellValue("接口服务描述");
cell = row.createCell(1);
cell.setCellValue("接口地址");
cell = row.createCell(2);
cell.setCellValue("api地址");
int rowIndex = 1;
for (Map<String, String> dataRow : objects1) {
// 创建行(0基索引)
row = sheet.createRow(rowIndex);
// 创建单元格并设置值
cell = row.createCell(0);
cell.setCellValue("是");
cell = row.createCell(3);
cell.setCellValue(dataRow.get("apidesc"));
cell = row.createCell(1);
cell.setCellValue("http://192.168.3.91:8080");
cell = row.createCell(2);
cell.setCellValue(dataRow.get("apiaddr"));
rowIndex++;
}
// 写入到文件
try (FileOutputStream outputStream = new FileOutputStream("C:\\Users\\1\\Desktop\\对外提供接口地址.xlsx")) {
workbook.write(outputStream);
} catch (IOException e) {
e.printStackTrace();
} finally {
// 清理资源
try {
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment