diff --git a/ym-gateway/src/main/resources/application-dev.yml b/ym-gateway/src/main/resources/application-dev.yml index da8f64c..cc956c6 100644 --- a/ym-gateway/src/main/resources/application-dev.yml +++ b/ym-gateway/src/main/resources/application-dev.yml @@ -2,14 +2,14 @@ spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver #MySQL-local - url: jdbc:mysql://10.0.1.249:3306/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true - username: cigs4 - password: 1qazxsw2 +# url: jdbc:mysql://10.0.1.249:3306/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true +# username: cigs4 +# password: 1qazxsw2 #MySQL-remote -# url: jdbc:mysql://mysql.picaiba.com:30307/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true -# username: root -# password: 1qaz@WSX3edc$RFV + url: jdbc:mysql://mysql.picaiba.com:30307/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true + username: root + password: 1qaz@WSX3edc$RFV # #Oracle # driver-class-name: oracle.jdbc.OracleDriver # url: jdbc:oracle:thin:@192.168.10.10:1521:xe @@ -66,15 +66,15 @@ dynamic: # username: root # password: 1qaz@WSX3edc$RFV ## camline系统 - remote -# camline: -# driver-class-name: com.mysql.cj.jdbc.Driver -# url: jdbc:mysql://mysql.picaiba.com:30307/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true -# username: root -# password: 1qaz@WSX3edc$RFV -# - #camline系统 - local camline: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://10.0.1.23:3306/synapse?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true - username: offline_data - password: tpvmfab4 \ No newline at end of file + url: jdbc:mysql://mysql.picaiba.com:30307/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true + username: root + password: 1qaz@WSX3edc$RFV +# + #camline系统 - local +# camline: +# driver-class-name: com.mysql.cj.jdbc.Driver +# url: jdbc:mysql://10.0.1.23:3306/synapse?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true +# username: offline_data +# password: tpvmfab4 \ No newline at end of file diff --git a/ym-gateway/src/main/resources/application-test.yml b/ym-gateway/src/main/resources/application-test.yml index b443abc..790a254 100644 --- a/ym-gateway/src/main/resources/application-test.yml +++ b/ym-gateway/src/main/resources/application-test.yml @@ -2,7 +2,7 @@ spring: datasource: #MySQL driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://mysql.picaiba.com:30307/ym_pass?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true + url: jdbc:mysql://mysql.picaiba.com:30307/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true username: root password: 1qaz@WSX3edc$RFV # #Oracle diff --git a/ym-gateway/src/main/resources/application.yml b/ym-gateway/src/main/resources/application.yml index 209f3fc..bb0ed3e 100644 --- a/ym-gateway/src/main/resources/application.yml +++ b/ym-gateway/src/main/resources/application.yml @@ -33,8 +33,8 @@ spring: enabled: true redis: database: 6 - #host: 127.0.0.1 - host: 10.0.1.249 + host: 127.0.0.1 + #host: 10.0.1.249 #host: 192.168.0.102 port: 6379 password: '' # 密码(默认为空) diff --git a/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java b/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java index a5dcabc..7a5d922 100644 --- a/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java +++ b/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java @@ -19,7 +19,7 @@ public class CodeGenerator { @Test public void test(){ - mybatisPlusGenerator(new String[]{"t_wo_power_level"}); + mybatisPlusGenerator(new String[]{"t_working_time"}); } public static void mybatisPlusGenerator(String[] include){ diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/controller/WorkingTimeController.java b/ym-generator/src/main/java/com/cnbm/generator/code/controller/WorkingTimeController.java new file mode 100644 index 0000000..3f686d5 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/controller/WorkingTimeController.java @@ -0,0 +1,116 @@ +package com.cnbm.generator.code.controller; + +import com.cnbm.admin.annotation.LogOperation; +import com.cnbm.common.constant.Constant; +import com.cnbm.common.page.PageData; +import com.cnbm.common.utils.ExcelUtils; +import com.cnbm.common.utils.Result; +import com.cnbm.common.validator.AssertUtils; +import com.cnbm.common.validator.ValidatorUtils; +import com.cnbm.common.validator.group.AddGroup; +import com.cnbm.common.validator.group.DefaultGroup; +import com.cnbm.common.validator.group.UpdateGroup; +import com.cnbm.generator.code.dto.WorkingTimeDTO; +import com.cnbm.generator.code.excel.WorkingTimeExcel; +import com.cnbm.generator.code.service.WorkingTimeServiceBiz; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 班次时间段 表 前端控制器 + * + * @author codeGenerator + * @since 2023-12-20 + */ +@RestController +@RequestMapping("/code/workingTime") +@Api(tags="班次时间段 表") +public class WorkingTimeController { + @Autowired + private WorkingTimeServiceBiz workingTimeService; + + @GetMapping("page") + @ApiOperation("分页") + @ApiImplicitParams({ + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) + }) + @PreAuthorize("@ex.hasAuthority('code:workingTime:page')") + public Result> page(@ApiIgnore @RequestParam Map params){ + PageData page = workingTimeService.page(params); + + return new Result>().ok(page); + } + + @GetMapping("{id}") + @ApiOperation("信息") + @PreAuthorize("@ex.hasAuthority('code:workingTime:info')") + public Result get(@PathVariable("id") Long id){ + WorkingTimeDTO data = workingTimeService.get(id); + + return new Result().ok(data); + } + + @PostMapping + @ApiOperation("保存") + @LogOperation("保存") + @PreAuthorize("@ex.hasAuthority('code:workingTime:save')") + public Result save(@RequestBody WorkingTimeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + + workingTimeService.save(dto); + + return new Result().ok(dto.getId()); + } + + @PutMapping + @ApiOperation("修改") + @LogOperation("修改") + @PreAuthorize("@ex.hasAuthority('code:workingTime:update')") + public Result update(@RequestBody WorkingTimeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + + workingTimeService.update(dto); + + return new Result().ok(dto.getId()); + } + + @DeleteMapping + @ApiOperation("删除") + @LogOperation("删除") + @PreAuthorize("@ex.hasAuthority('code:workingTime:delete')") + public Result delete(@RequestBody Long[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + + workingTimeService.delete(ids); + + return new Result(); + } + + @GetMapping("export") + @ApiOperation("导出") + @LogOperation("导出") + @PreAuthorize("@ex.hasAuthority('code:workingTime:export')") + public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { + List list = workingTimeService.list(params); + + ExcelUtils.exportExcelToTarget(response, null, list, WorkingTimeExcel.class); + } + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/dto/WorkingTimeDTO.java b/ym-generator/src/main/java/com/cnbm/generator/code/dto/WorkingTimeDTO.java new file mode 100644 index 0000000..1186829 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/dto/WorkingTimeDTO.java @@ -0,0 +1,65 @@ +package com.cnbm.generator.code.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import java.math.BigDecimal; + + +/** + * 班次时间段 表 + * + * @author codeGenerator + * @since 2023-12-20 + */ +@Data +@ApiModel(value = "班次时间段 表DTO对象") +public class WorkingTimeDTO implements Serializable { + private static final long serialVersionUID = 1L; + + + + @ApiModelProperty(value = "ID") + private Long id; + + @ApiModelProperty(value = "班次名 ,A/B/C...") + private String orderName; + + @ApiModelProperty(value = "班次开始时间, 0点 - 24点") + private LocalDateTime beginTime; + + @ApiModelProperty(value = "班次结束时间, 0点 - 24点") + private LocalDateTime endTime; + + @ApiModelProperty(value = "备注") + private String remark; + + @ApiModelProperty(value = "删除标志,是否有效:1 可用 0不可用") + private Integer valid; + + @ApiModelProperty(value = "创建人") + private Long creatorId; + + @ApiModelProperty(value = "创建人姓名") + private String creatorName; + + @ApiModelProperty(value = "创建时间") + private LocalDateTime createTime; + + @ApiModelProperty(value = "更新人") + private Long updaterId; + + @ApiModelProperty(value = "更新人姓名") + private String updaterName; + + @ApiModelProperty(value = "更新时间") + private LocalDateTime updateTime; + + @ApiModelProperty(value = "版本号") + private Integer version; + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/entity/WorkingTime.java b/ym-generator/src/main/java/com/cnbm/generator/code/entity/WorkingTime.java new file mode 100644 index 0000000..e6f74bf --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/entity/WorkingTime.java @@ -0,0 +1,93 @@ +package com.cnbm.generator.code.entity; + +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.time.LocalDateTime; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * 班次时间段 表 + *

+ * + * @author codeGenerator + * @since 2023-12-20 + */ +@Data +@TableName("t_working_time") +@ApiModel(value = "WorkingTime对象", description = "班次时间段 表") +public class WorkingTime implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("ID") + private Long id; + + @ApiModelProperty("班次名 ,A/B/C...") + private String orderName; + + @ApiModelProperty("班次开始时间, 0点 - 24点") + private LocalDateTime beginTime; + + @ApiModelProperty("班次结束时间, 0点 - 24点") + private LocalDateTime endTime; + + @ApiModelProperty("备注") + private String remark; + + @ApiModelProperty("删除标志,是否有效:1 可用 0不可用") + @TableLogic + private Integer valid; + + @ApiModelProperty("创建人") + private Long creatorId; + + @ApiModelProperty("创建人姓名") + private String creatorName; + + @ApiModelProperty("创建时间") + private LocalDateTime createTime; + + @ApiModelProperty("更新人") + private Long updaterId; + + @ApiModelProperty("更新人姓名") + private String updaterName; + + @ApiModelProperty("更新时间") + private LocalDateTime updateTime; + + @ApiModelProperty("版本号") + private Integer version; + + + public static final String ID = "id"; + + public static final String ORDER_NAME = "order_name"; + + public static final String BEGIN_TIME = "begin_time"; + + public static final String END_TIME = "end_time"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR_ID = "creator_id"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER_ID = "updater_id"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + +} diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/excel/WorkingTimeExcel.java b/ym-generator/src/main/java/com/cnbm/generator/code/excel/WorkingTimeExcel.java new file mode 100644 index 0000000..8aaba12 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/excel/WorkingTimeExcel.java @@ -0,0 +1,46 @@ +package com.cnbm.generator.code.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.time.LocalDateTime; +import java.math.BigDecimal; + +import java.util.Date; + +/** + * 班次时间段 表 + * + * @author codeGenerator + * @since 2023-12-20 + */ +@Data +public class WorkingTimeExcel { + @Excel(name = "ID") + private Long id; + @Excel(name = "班次名 ,A/B/C...") + private String orderName; + @Excel(name = "班次开始时间, 0点 - 24点") + private LocalDateTime beginTime; + @Excel(name = "班次结束时间, 0点 - 24点") + private LocalDateTime endTime; + @Excel(name = "备注") + private String remark; + @Excel(name = "删除标志,是否有效:1 可用 0不可用") + private Integer valid; + @Excel(name = "创建人") + private Long creatorId; + @Excel(name = "创建人姓名") + private String creatorName; + @Excel(name = "创建时间") + private LocalDateTime createTime; + @Excel(name = "更新人") + private Long updaterId; + @Excel(name = "更新人姓名") + private String updaterName; + @Excel(name = "更新时间") + private LocalDateTime updateTime; + @Excel(name = "版本号") + private Integer version; + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/mapper/WorkingTimeMapper.java b/ym-generator/src/main/java/com/cnbm/generator/code/mapper/WorkingTimeMapper.java new file mode 100644 index 0000000..e0b908b --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/mapper/WorkingTimeMapper.java @@ -0,0 +1,16 @@ +package com.cnbm.generator.code.mapper; + +import com.cnbm.common.dao.BaseDao; +import com.cnbm.generator.code.entity.WorkingTime; +import org.apache.ibatis.annotations.Mapper; + +/** + * 班次时间段 表 + * + * @author codeGenerator + * @since 2023-12-20 + */ +@Mapper +public interface WorkingTimeMapper extends BaseDao { + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/mapper/WorkingTimeMapper.xml b/ym-generator/src/main/java/com/cnbm/generator/code/mapper/WorkingTimeMapper.xml new file mode 100644 index 0000000..e4a0e4c --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/mapper/WorkingTimeMapper.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/mysql/WorkingTimemysql.sql b/ym-generator/src/main/java/com/cnbm/generator/code/mysql/WorkingTimemysql.sql new file mode 100644 index 0000000..4aa356d --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/mysql/WorkingTimemysql.sql @@ -0,0 +1,7 @@ +-- 菜单初始SQL +INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date)VALUES (1737360876993064962, 1067246875800000035, '班次时间段 表', 'code/workingTime', NULL, 0, 'icon-desktop', 0, 1067246875800000001, now(), 1067246875800000001, now()); +INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1737360876993064963, 1737360876993064962, '查看', NULL, 'code:workingTime:page,code:workingTime:info', 1, NULL, 0, 1067246875800000001, now(), 1067246875800000001, now()); +INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1737360876993064964, 1737360876993064962, '新增', NULL, 'code:workingTime:save', 1, NULL, 1, 1067246875800000001, now(), 1067246875800000001, now()); +INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1737360876993064965, 1737360876993064962, '修改', NULL, 'code:workingTime:update', 1, NULL, 2, 1067246875800000001, now(), 1067246875800000001, now()); +INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1737360876993064966, 1737360876993064962, '删除', NULL, 'code:workingTime:delete', 1, NULL, 3, 1067246875800000001, now(), 1067246875800000001, now()); +INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1737360876993064967, 1737360876993064962, '导出', NULL, 'code:workingTime:export', 1, NULL, 4, 1067246875800000001, now(), 1067246875800000001, now()); diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/service/WorkingTimeServiceBiz.java b/ym-generator/src/main/java/com/cnbm/generator/code/service/WorkingTimeServiceBiz.java new file mode 100644 index 0000000..7acc6d9 --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/service/WorkingTimeServiceBiz.java @@ -0,0 +1,15 @@ +package com.cnbm.generator.code.service; + +import com.cnbm.common.service.CrudService; +import com.cnbm.generator.code.dto.WorkingTimeDTO; +import com.cnbm.generator.code.entity.WorkingTime; + +/** + * 班次时间段 表 + * + * @author codeGenerator + * @since 2023-12-20 + */ +public interface WorkingTimeServiceBiz extends CrudService { + +} \ No newline at end of file diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/service/impl/WorkingTimeServiceBizImpl.java b/ym-generator/src/main/java/com/cnbm/generator/code/service/impl/WorkingTimeServiceBizImpl.java new file mode 100644 index 0000000..782020c --- /dev/null +++ b/ym-generator/src/main/java/com/cnbm/generator/code/service/impl/WorkingTimeServiceBizImpl.java @@ -0,0 +1,34 @@ +package com.cnbm.generator.code.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.cnbm.common.service.impl.CrudServiceImpl; +import com.cnbm.generator.code.dto.WorkingTimeDTO; +import com.cnbm.generator.code.mapper.WorkingTimeMapper; +import com.cnbm.generator.code.entity.WorkingTime; +import com.cnbm.generator.code.service.WorkingTimeServiceBiz; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 班次时间段 表 + * + * @author codeGenerator + * @since 2023-12-20 + */ +@Service +public class WorkingTimeServiceBizImpl extends CrudServiceImpl implements WorkingTimeServiceBiz { + + @Override + public QueryWrapper getWrapper(Map params){ + String id = (String)params.get("id"); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), "id", id); + + return wrapper; + } + + +} \ No newline at end of file diff --git a/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java b/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java index a77342f..d498bf1 100644 --- a/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java +++ b/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java @@ -1,539 +1,539 @@ -package com.cnbm.dispatch; - -import cn.hutool.core.date.DateUtil; -import com.cnbm.dispatch.enums.kuka.step1.Step1Mes2PlcVar; -import com.cnbm.dispatch.enums.kuka.step1.Step1Plc2MesVar; -import com.cnbm.dispatch.enums.kuka.step2.Step2Mes2PlcVar; -import com.cnbm.dispatch.enums.kuka.step2.Step2Plc2MesVar; -import com.cnbm.dispatch.enums.kuka.step3.Step3Mes2PlcVar; -import com.cnbm.dispatch.enums.kuka.step3.Step3Plc2MesVar; -import com.cnbm.packing.dto.CamlineExtendArgDTO; -import com.cnbm.packing.dto.CamlineSubIdDTO; -import com.cnbm.packing.entity.WoPackagingBox; -import com.cnbm.packing.entity.WoPackagingBoxSubstrate; -import com.cnbm.packing.entity.WoPowerLevel; -import com.cnbm.packing.service.*; -import com.cnbm.s7.s7connector.enmuc.S7Client; -import com.cnbm.s7.s7connector.type.PlcVar; -import io.swagger.models.auth.In; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import java.text.DecimalFormat; -import java.text.Format; -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.Date; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -/** - * @Desc: "" - * @Author: caixiang - * @DATE: 2022/12/23 12:33 - */ -@Component -@Order(value = 1) -public class KukaJoinThread implements ApplicationRunner { - private static final Logger logger = LoggerFactory.getLogger(KukaJoinThread.class); - - @Autowired - DynamicDataSourceService service; - @Autowired - WoPowerLevelServiceBiz levelServiceBiz; - - @Autowired - WoCompensationPowerServiceBiz compensationPowerServiceBiz; - - @Autowired - WoPackagingBoxSubstrateServiceBiz substrateServiceBiz; - - @Autowired - WoPackagingBoxServiceBiz boxServiceBiz; - - public KukaJoinThread(){ - this.kukaStep1 = Executors.newScheduledThreadPool(1); - this.kukaStep2 = Executors.newScheduledThreadPool(1); - this.kukaStep3 = Executors.newScheduledThreadPool(1); - } - - private ScheduledExecutorService kukaStep1; - private ScheduledExecutorService kukaStep2; - private ScheduledExecutorService kukaStep3; - - - - - /** - * return - * 成功: 返回相应的object对象 - * 失败: 返回null - * */ - private Object read(S7Client s7Client,Step1Plc2MesVar var) { - try { - return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); - }catch (Exception e){ - logger.error("host:"+s7Client.getHost()+" ; read 操作出现问题: "+e.getMessage()); - e.printStackTrace(); - return null; - } - } - private void write(S7Client s7Client, Step1Mes2PlcVar var, Object newValue) { - if(var.getType().equals(PlcVar.STRING_Array)){ - String[] s = (String[])newValue; - String[] ss = (String[])newValue; - if(s.length > var.getLength() ){ - ss = new String[var.getLength()]; - for(int i=0;i< var.getLength();i++){ - ss[i] = s[i]; - } - } - s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),ss); - }else { - s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),newValue); - } - } - - private Object read(S7Client s7Client, Step2Plc2MesVar var) { - try { - return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); - }catch (Exception e){ - logger.error("host:"+s7Client.getHost()+" ; read 操作出现问题: "+e.getMessage()); - e.printStackTrace(); - return null; - } - } - private void write(S7Client s7Client, Step2Mes2PlcVar var, Object newValue) { - if(var.getType().equals(PlcVar.STRING_Array)){ - String[] s = (String[])newValue; - String[] ss = (String[])newValue; - if(s.length > var.getLength() ){ - ss = new String[var.getLength()]; - for(int i=0;i< var.getLength();i++){ - ss[i] = s[i]; - } - } - s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),ss); - }else { - s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),newValue); - } - } - - private Object read(S7Client s7Client, Step3Plc2MesVar var) { - try { - return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); - }catch (Exception e){ - logger.error("host:"+s7Client.getHost()+" ; read 操作出现问题: "+e.getMessage()); - e.printStackTrace(); - return null; - } - } - private void write(S7Client s7Client, Step3Mes2PlcVar var, Object newValue) { - if(var.getType().equals(PlcVar.STRING_Array)){ - String[] s = (String[])newValue; - String[] ss = (String[])newValue; - if(s.length > var.getLength() ){ - ss = new String[var.getLength()]; - for(int i=0;i< var.getLength();i++){ - ss[i] = s[i]; - } - } - s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),ss); - }else { - s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),newValue); - } - } - - - public String getBoxId(String sapMaterial){ - Integer todayBoxNum = service.getTodayBoxNum()+1; - String nowTime = DateUtil.format(new Date(), "yyMMdd"); - - todayBoxNum+=500; - String res = "301"+sapMaterial+nowTime+formateString(todayBoxNum); - return res; - } - - - public String getErrorBoxId(String sapMaterial){ - - String nowTime = DateUtil.format(new Date(), "yyMMdd"); - String mixBoxError = "001"; - String res = "Err"+sapMaterial+nowTime+mixBoxError; - return res; - } - - public String removeKG(String str){ - return str.substring(0,17); - } - - public static void main(String[] args) { - Integer a = 102; - Format f1 = new DecimalFormat("000"); - System.out.println(f1.format(a)); - } - public String formateString(Integer a){ - Format f1 = new DecimalFormat("000"); - return f1.format(a); - } - - //return true 出现混档了,return false 没有出现混档 - private boolean isMixLevel(String[] subIds,Integer size){ - String correctLevel = substrateServiceBiz.getBySubId(subIds[0]).getPowerLevel(); - String errMsg = "以下基板ID出现混档:"; - boolean res = false; - for(int i=0;i var.getLength() ){ +// ss = new String[var.getLength()]; +// for(int i=0;i< var.getLength();i++){ +// ss[i] = s[i]; +// } +// } +// s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),ss); +// }else { +// s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),newValue); +// } +// } +// +// private Object read(S7Client s7Client, Step2Plc2MesVar var) { +// try { +// return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); +// }catch (Exception e){ +// logger.error("host:"+s7Client.getHost()+" ; read 操作出现问题: "+e.getMessage()); +// e.printStackTrace(); +// return null; +// } +// } +// private void write(S7Client s7Client, Step2Mes2PlcVar var, Object newValue) { +// if(var.getType().equals(PlcVar.STRING_Array)){ +// String[] s = (String[])newValue; +// String[] ss = (String[])newValue; +// if(s.length > var.getLength() ){ +// ss = new String[var.getLength()]; +// for(int i=0;i< var.getLength();i++){ +// ss[i] = s[i]; +// } +// } +// s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),ss); +// }else { +// s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),newValue); +// } +// } +// +// private Object read(S7Client s7Client, Step3Plc2MesVar var) { +// try { +// return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); +// }catch (Exception e){ +// logger.error("host:"+s7Client.getHost()+" ; read 操作出现问题: "+e.getMessage()); +// e.printStackTrace(); +// return null; +// } +// } +// private void write(S7Client s7Client, Step3Mes2PlcVar var, Object newValue) { +// if(var.getType().equals(PlcVar.STRING_Array)){ +// String[] s = (String[])newValue; +// String[] ss = (String[])newValue; +// if(s.length > var.getLength() ){ +// ss = new String[var.getLength()]; +// for(int i=0;i< var.getLength();i++){ +// ss[i] = s[i]; +// } +// } +// s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),ss); +// }else { +// s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),newValue); +// } +// } +// +// +// public String getBoxId(String sapMaterial){ +// Integer todayBoxNum = service.getTodayBoxNum()+1; +// String nowTime = DateUtil.format(new Date(), "yyMMdd"); +// +// todayBoxNum+=500; +// String res = "301"+sapMaterial+nowTime+formateString(todayBoxNum); +// return res; +// } +// +// +// public String getErrorBoxId(String sapMaterial){ +// +// String nowTime = DateUtil.format(new Date(), "yyMMdd"); +// String mixBoxError = "001"; +// String res = "Err"+sapMaterial+nowTime+mixBoxError; +// return res; +// } +// +// public String removeKG(String str){ +// return str.substring(0,17); +// } +// +// public static void main(String[] args) { +// Integer a = 102; +// Format f1 = new DecimalFormat("000"); +// System.out.println(f1.format(a)); +// } +// public String formateString(Integer a){ +// Format f1 = new DecimalFormat("000"); +// return f1.format(a); +// } +// +// //return true 出现混档了,return false 没有出现混档 +// private boolean isMixLevel(String[] subIds,Integer size){ +// String correctLevel = substrateServiceBiz.getBySubId(subIds[0]).getPowerLevel(); +// String errMsg = "以下基板ID出现混档:"; +// boolean res = false; +// for(int i=0;i().ok(code); } + @GetMapping("getByLineBody/{lineBody}") + @ApiOperation("依据line_body 查询,is_enable==1 && type==2 limit 1的数据") + public Result getByLineBody(@PathVariable("lineBody") Integer lineBody){ + PrintModelDTO dto = printModelService.getByLineBody(lineBody); + return new Result().ok(dto); + } + } \ No newline at end of file diff --git a/ym-packing/src/main/java/com/cnbm/packing/controller/WorkingTimeController.java b/ym-packing/src/main/java/com/cnbm/packing/controller/WorkingTimeController.java new file mode 100644 index 0000000..3af148d --- /dev/null +++ b/ym-packing/src/main/java/com/cnbm/packing/controller/WorkingTimeController.java @@ -0,0 +1,125 @@ +package com.cnbm.packing.controller; + +import com.cnbm.admin.annotation.LogOperation; +import com.cnbm.common.constant.Constant; +import com.cnbm.common.page.PageData; +import com.cnbm.common.utils.ExcelUtils; +import com.cnbm.common.utils.Result; +import com.cnbm.common.validator.AssertUtils; +import com.cnbm.common.validator.ValidatorUtils; +import com.cnbm.common.validator.group.AddGroup; +import com.cnbm.common.validator.group.DefaultGroup; +import com.cnbm.common.validator.group.UpdateGroup; +import com.cnbm.packing.dto.WorkingTimeDTO; +import com.cnbm.packing.excel.WorkingTimeExcel; +import com.cnbm.packing.service.WorkingTimeServiceBiz; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletResponse; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; + + +/** + * 班次时间段 表 前端控制器 + * + * @author packingGenerator + * @since 2023-12-19 + */ +@RestController +@RequestMapping("/packing/workingTime") +@Api(tags="班次时间段 表") +public class WorkingTimeController { + @Autowired + private WorkingTimeServiceBiz workingTimeService; + + @GetMapping("page") + @ApiOperation("分页") + @ApiImplicitParams({ + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) + }) + @PreAuthorize("@ex.hasAuthority('packing:workingTime:page')") + public Result> page(@ApiIgnore @RequestParam Map params){ + PageData page = workingTimeService.page(params); + + return new Result>().ok(page); + } + + @GetMapping("{id}") + @ApiOperation("信息") + @PreAuthorize("@ex.hasAuthority('packing:workingTime:info')") + public Result get(@PathVariable("id") Long id){ + WorkingTimeDTO data = workingTimeService.get(id); + + return new Result().ok(data); + } + + @PostMapping + @ApiOperation("保存") + @LogOperation("保存") + @PreAuthorize("@ex.hasAuthority('packing:workingTime:save')") + public Result save(@RequestBody WorkingTimeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + + workingTimeService.save(dto); + + return new Result().ok(dto.getId()); + } + + @PutMapping + @ApiOperation("修改") + @LogOperation("修改") + @PreAuthorize("@ex.hasAuthority('packing:workingTime:update')") + public Result update(@RequestBody WorkingTimeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + + workingTimeService.update(dto); + + return new Result().ok(dto.getId()); + } + + @DeleteMapping + @ApiOperation("删除") + @LogOperation("删除") + @PreAuthorize("@ex.hasAuthority('packing:workingTime:delete')") + public Result delete(@RequestBody Long[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + + workingTimeService.delete(ids); + + return new Result(); + } + + @GetMapping("export") + @ApiOperation("导出") + @LogOperation("导出") + @PreAuthorize("@ex.hasAuthority('packing:workingTime:export')") + public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { + List list = workingTimeService.list(params); + + ExcelUtils.exportExcelToTarget(response, null, list, WorkingTimeExcel.class); + } + + @GetMapping("getOrderName") + @ApiOperation("查询时间匹配的班次名称") + public Result getOrderName(@RequestBody LocalDateTime time){ + String orderName = workingTimeService.getOrderName(time); + + return new Result().ok(orderName); + } + +} \ No newline at end of file diff --git a/ym-packing/src/main/java/com/cnbm/packing/dto/PrintModelDTO.java b/ym-packing/src/main/java/com/cnbm/packing/dto/PrintModelDTO.java index f1ff254..1197b11 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/dto/PrintModelDTO.java +++ b/ym-packing/src/main/java/com/cnbm/packing/dto/PrintModelDTO.java @@ -80,4 +80,10 @@ public class PrintModelDTO implements Serializable { @ApiModelProperty(value = "是否启用,0 停用;1 启用") private Integer isEnable; + @ApiModelProperty(value = "场景,前端传字符串过来,目前固定这几个:DZ BIPV") + private String scenes; + + @ApiModelProperty(value = "产品等级,目前固定这几个 : A1 A2 A3 A4 NK") + private String productGrade; + } \ No newline at end of file diff --git a/ym-packing/src/main/java/com/cnbm/packing/dto/WorkingTimeDTO.java b/ym-packing/src/main/java/com/cnbm/packing/dto/WorkingTimeDTO.java new file mode 100644 index 0000000..23ac5e8 --- /dev/null +++ b/ym-packing/src/main/java/com/cnbm/packing/dto/WorkingTimeDTO.java @@ -0,0 +1,63 @@ +package com.cnbm.packing.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * 班次时间段 表 + * + * @author codeGenerator + * @since 2023-12-19 + */ +@Data +@ApiModel(value = "班次时间段 表DTO对象") +public class WorkingTimeDTO implements Serializable { + private static final long serialVersionUID = 1L; + + + + @ApiModelProperty(value = "ID") + private Long id; + + @ApiModelProperty(value = "班次名 ,A/B/C...") + private String orderName; + + @ApiModelProperty(value = "班次开始时间, 0点 - 24点") + private LocalDateTime beginTime; + + @ApiModelProperty(value = "班次结束时间, 0点 - 24点") + private LocalDateTime endTime; + + @ApiModelProperty(value = "备注") + private String remark; + + @ApiModelProperty(value = "删除标志,是否有效:1 可用 0不可用") + private Integer valid; + + @ApiModelProperty(value = "创建人") + private Long creatorId; + + @ApiModelProperty(value = "创建人姓名") + private String creatorName; + + @ApiModelProperty(value = "创建时间") + private LocalDateTime createTime; + + @ApiModelProperty(value = "更新人") + private Long updaterId; + + @ApiModelProperty(value = "更新人姓名") + private String updaterName; + + @ApiModelProperty(value = "更新时间") + private LocalDateTime updateTime; + + @ApiModelProperty(value = "版本号") + private Integer version; + +} \ No newline at end of file diff --git a/ym-packing/src/main/java/com/cnbm/packing/entity/PrintModel.java b/ym-packing/src/main/java/com/cnbm/packing/entity/PrintModel.java index 94fdec2..223f022 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/entity/PrintModel.java +++ b/ym-packing/src/main/java/com/cnbm/packing/entity/PrintModel.java @@ -81,6 +81,12 @@ public class PrintModel implements Serializable { @ApiModelProperty("是否启用,0 停用;1 启用") private Integer isEnable; + @ApiModelProperty("场景,前端传字符串过来,目前固定这几个:DZ BIPV") + private String scenes; + + @ApiModelProperty("产品等级,目前固定这几个 : A1 A2 A3 A4 NK") + private String productGrade; + public static final String ID = "ID"; @@ -120,4 +126,8 @@ public class PrintModel implements Serializable { public static final String IS_ENABLE = "is_enable"; + public static final String SCENES = "scenes"; + + public static final String PRODUCT_GRADE = "product_grade"; + } diff --git a/ym-packing/src/main/java/com/cnbm/packing/entity/WorkingTime.java b/ym-packing/src/main/java/com/cnbm/packing/entity/WorkingTime.java new file mode 100644 index 0000000..216027c --- /dev/null +++ b/ym-packing/src/main/java/com/cnbm/packing/entity/WorkingTime.java @@ -0,0 +1,94 @@ +package com.cnbm.packing.entity; + +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * 班次时间段 表 + *

+ * + * @author codeGenerator + * @since 2023-12-19 + */ +@Data +@TableName("t_working_time") +@ApiModel(value = "WorkingTime对象", description = "班次时间段 表") +public class WorkingTime implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("ID") + private Long id; + + @ApiModelProperty("班次名 ,A/B/C...") + private String orderName; + + @ApiModelProperty("班次开始时间, 0点 - 24点") + private LocalDateTime beginTime; + + @ApiModelProperty("班次结束时间, 0点 - 24点") + private LocalDateTime endTime; + + @ApiModelProperty("备注") + private String remark; + + @ApiModelProperty("删除标志,是否有效:1 可用 0不可用") + @TableLogic + private Integer valid; + + @ApiModelProperty("创建人") + private Long creatorId; + + @ApiModelProperty("创建人姓名") + private String creatorName; + + @ApiModelProperty("创建时间") + private LocalDateTime createTime; + + @ApiModelProperty("更新人") + private Long updaterId; + + @ApiModelProperty("更新人姓名") + private String updaterName; + + @ApiModelProperty("更新时间") + private LocalDateTime updateTime; + + @ApiModelProperty("版本号") + private Integer version; + + + public static final String ID = "id"; + + public static final String ORDER_NAME = "order_name"; + + public static final String BEGIN_TIME = "begin_time"; + + public static final String END_TIME = "end_time"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR_ID = "creator_id"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER_ID = "updater_id"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + +} diff --git a/ym-packing/src/main/java/com/cnbm/packing/excel/WorkingTimeExcel.java b/ym-packing/src/main/java/com/cnbm/packing/excel/WorkingTimeExcel.java new file mode 100644 index 0000000..42243aa --- /dev/null +++ b/ym-packing/src/main/java/com/cnbm/packing/excel/WorkingTimeExcel.java @@ -0,0 +1,43 @@ +package com.cnbm.packing.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 班次时间段 表 + * + * @author codeGenerator + * @since 2023-12-19 + */ +@Data +public class WorkingTimeExcel { + @Excel(name = "ID") + private Long id; + @Excel(name = "班次名 ,A/B/C...") + private String orderName; + @Excel(name = "班次开始时间, 0点 - 24点") + private LocalDateTime beginTime; + @Excel(name = "班次结束时间, 0点 - 24点") + private LocalDateTime endTime; + @Excel(name = "备注") + private String remark; + @Excel(name = "删除标志,是否有效:1 可用 0不可用") + private Integer valid; + @Excel(name = "创建人") + private Long creatorId; + @Excel(name = "创建人姓名") + private String creatorName; + @Excel(name = "创建时间") + private LocalDateTime createTime; + @Excel(name = "更新人") + private Long updaterId; + @Excel(name = "更新人姓名") + private String updaterName; + @Excel(name = "更新时间") + private LocalDateTime updateTime; + @Excel(name = "版本号") + private Integer version; + +} \ No newline at end of file diff --git a/ym-packing/src/main/java/com/cnbm/packing/mapper/WorkingTimeMapper.java b/ym-packing/src/main/java/com/cnbm/packing/mapper/WorkingTimeMapper.java new file mode 100644 index 0000000..7009991 --- /dev/null +++ b/ym-packing/src/main/java/com/cnbm/packing/mapper/WorkingTimeMapper.java @@ -0,0 +1,23 @@ +package com.cnbm.packing.mapper; + +import com.cnbm.common.dao.BaseDao; +import com.cnbm.packing.dto.WoPowerLevelDTO; +import com.cnbm.packing.dto.WorkingTimeDTO; +import com.cnbm.packing.entity.WorkingTime; +import org.apache.ibatis.annotations.Mapper; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * 打印标签模板表 + * + * @author codeGenerator + * @since 2023-02-15 + */ +@Mapper +public interface WorkingTimeMapper extends BaseDao { + + List list(); + +} \ No newline at end of file diff --git a/ym-packing/src/main/java/com/cnbm/packing/service/PrintModelServiceBiz.java b/ym-packing/src/main/java/com/cnbm/packing/service/PrintModelServiceBiz.java index 441df6c..212b302 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/service/PrintModelServiceBiz.java +++ b/ym-packing/src/main/java/com/cnbm/packing/service/PrintModelServiceBiz.java @@ -30,4 +30,6 @@ public interface PrintModelServiceBiz extends CrudService list(); String getCode(); + + PrintModelDTO getByLineBody(Integer lineBody); } \ No newline at end of file diff --git a/ym-packing/src/main/java/com/cnbm/packing/service/WorkingTimeServiceBiz.java b/ym-packing/src/main/java/com/cnbm/packing/service/WorkingTimeServiceBiz.java new file mode 100644 index 0000000..eac4247 --- /dev/null +++ b/ym-packing/src/main/java/com/cnbm/packing/service/WorkingTimeServiceBiz.java @@ -0,0 +1,34 @@ +package com.cnbm.packing.service; + +import com.cnbm.common.page.PageData; +import com.cnbm.common.service.CrudService; +import com.cnbm.packing.dto.WorkingTimeDTO; +import com.cnbm.packing.dto.WorkingTimeDTO; +import com.cnbm.packing.entity.WorkingTime; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; + +/** + * 班次时间段 表 + * + * @author codeGenerator + * @since 2023-12-19 + */ +public interface WorkingTimeServiceBiz extends CrudService { + + PageData page (Map params); + + WorkingTimeDTO get(Long id); + + void save(WorkingTimeDTO dto); + + void update(WorkingTimeDTO dto); + + void delete(Long[] ids); + + List list(); + + String getOrderName(LocalDateTime time); +} \ No newline at end of file diff --git a/ym-packing/src/main/java/com/cnbm/packing/service/impl/PrintModelServiceBizImpl.java b/ym-packing/src/main/java/com/cnbm/packing/service/impl/PrintModelServiceBizImpl.java index 1d02586..629241e 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/service/impl/PrintModelServiceBizImpl.java +++ b/ym-packing/src/main/java/com/cnbm/packing/service/impl/PrintModelServiceBizImpl.java @@ -107,5 +107,18 @@ public class PrintModelServiceBizImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); + wrapper.eq(ObjectUtils.isNotNull(lineBody), PrintModel.LINE_BODY, lineBody); + wrapper.eq(PrintModel.IS_ENABLE,1); + wrapper.eq(PrintModel.TYPE,2); + List list = mapper.selectList(wrapper); + PrintModel entity = new PrintModel(); + if(list.size()>0){ + entity = list.get(0); + } + return ConvertUtils.sourceToTarget(entity, PrintModelDTO.class); + } } \ No newline at end of file diff --git a/ym-packing/src/main/java/com/cnbm/packing/service/impl/WorkingTimeServiceBizImpl.java b/ym-packing/src/main/java/com/cnbm/packing/service/impl/WorkingTimeServiceBizImpl.java new file mode 100644 index 0000000..389c244 --- /dev/null +++ b/ym-packing/src/main/java/com/cnbm/packing/service/impl/WorkingTimeServiceBizImpl.java @@ -0,0 +1,122 @@ +package com.cnbm.packing.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.cnbm.admin.utils.BaseSupportUtils; +import com.cnbm.common.page.PageData; +import com.cnbm.common.service.impl.CrudServiceImpl; + +import com.cnbm.common.utils.ConvertUtils; +import com.cnbm.packing.dto.WorkingTimeDTO; +import com.cnbm.packing.entity.WorkingTime; +import com.cnbm.packing.mapper.WorkingTimeMapper; +import com.cnbm.packing.service.WorkingTimeServiceBiz; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 班次时间段 表 + * + * @author codeGenerator + * @since 2023-12-19 + */ +@Service +public class WorkingTimeServiceBizImpl extends CrudServiceImpl implements WorkingTimeServiceBiz { + + @Autowired + private WorkingTimeMapper mapper; + + @Override + public QueryWrapper getWrapper(Map params){ + String id = (String)params.get("id"); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), "id", id); + + return wrapper; + } + + @Override + public PageData page (Map params){ + IPage page = baseDao.selectPage( + getPage(params, WorkingTime.CREATE_TIME, false), + getWrapper(params) + ); + return getPageData(page, WorkingTimeDTO.class); + } + + @Override + public WorkingTimeDTO get(Long id) { + WorkingTime entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, WorkingTimeDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(WorkingTimeDTO dto) { + WorkingTime entity = ConvertUtils.sourceToTarget(dto, WorkingTime.class); + BaseSupportUtils.setCommonField(entity); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(WorkingTimeDTO dto) { + WorkingTime entity = ConvertUtils.sourceToTarget(dto, WorkingTime.class); + BaseSupportUtils.setUpdateCommonField(entity); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(Long[] ids) { + //删除 + deleteBatchIds(Arrays.asList(ids)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public List list() { + List list = mapper.list(); + return list; + } + + @Override + public String getOrderName(LocalDateTime time) { + + LocalTime localTime = time.toLocalTime(); + List resultList = new ArrayList<>(); + List listAll = mapper.list(); + for(WorkingTimeDTO dto : listAll){ + LocalTime beginTime = dto.getBeginTime().toLocalTime(); + LocalTime endTime = dto.getEndTime().toLocalTime(); + if(beginTime.isBefore(endTime)) { + if (localTime.isBefore(endTime) && localTime.isAfter(beginTime)) { + resultList.add(dto); + } + } + else if(localTime.isAfter(endTime)||localTime.isBefore(beginTime)){ + resultList.add(dto); + } + } + String orderName = null; + if(resultList.size()>0){ + orderName = resultList.get(0).getOrderName(); + } + return orderName; + } + + + +} \ No newline at end of file diff --git a/ym-packing/src/main/resources/mapper/PrintModleMapper.xml b/ym-packing/src/main/resources/mapper/PrintModleMapper.xml index cb01df3..9573d50 100644 --- a/ym-packing/src/main/resources/mapper/PrintModleMapper.xml +++ b/ym-packing/src/main/resources/mapper/PrintModleMapper.xml @@ -22,6 +22,8 @@ + + + select * from t_working_time + order by id asc + + +