From 59a0cef8f52534466ca96012f92faf8385a4a18c Mon Sep 17 00:00:00 2001 From: loujf Date: Wed, 1 Jun 2022 18:33:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=B4=E6=A0=87=E6=A8=A1=E6=9D=BF=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/nl/acs/config/AcsConfig.java | 4 + .../rest/LabelingTemplateController.java | 87 ++++++++++ .../rest/ProduceshiftorderController.java | 6 + .../service/LabelingTemplateService.java | 82 +++++++++ .../service/ProduceshiftorderService.java | 8 +- .../service/dto/LabelingTemplateDto.java | 46 ++++++ .../impl/LabelingTemplateServiceImpl.java | 156 ++++++++++++++++++ .../impl/ProduceshiftorderServiceImpl.java | 51 ++++-- .../order/service/wql/QPRODUCESHIFTORDER.wql | 21 ++- 9 files changed, 446 insertions(+), 15 deletions(-) create mode 100644 nladmin-system/src/main/java/org/nl/acs/order/rest/LabelingTemplateController.java create mode 100644 nladmin-system/src/main/java/org/nl/acs/order/service/LabelingTemplateService.java create mode 100644 nladmin-system/src/main/java/org/nl/acs/order/service/dto/LabelingTemplateDto.java create mode 100644 nladmin-system/src/main/java/org/nl/acs/order/service/impl/LabelingTemplateServiceImpl.java diff --git a/nladmin-system/src/main/java/org/nl/acs/config/AcsConfig.java b/nladmin-system/src/main/java/org/nl/acs/config/AcsConfig.java index 657e8d5..d52a1ed 100644 --- a/nladmin-system/src/main/java/org/nl/acs/config/AcsConfig.java +++ b/nladmin-system/src/main/java/org/nl/acs/config/AcsConfig.java @@ -22,6 +22,10 @@ public interface AcsConfig { String WMSURL = "wmsurl"; //WCS系统接口地址 String WCSURL = "wcsurl"; + //打印机名称 + String PRINTNAME = "printName"; + //打印机地址 + String PRINTURL = "printurl"; String HASOTHERSYSTEM = "hasOtherSystem"; diff --git a/nladmin-system/src/main/java/org/nl/acs/order/rest/LabelingTemplateController.java b/nladmin-system/src/main/java/org/nl/acs/order/rest/LabelingTemplateController.java new file mode 100644 index 0000000..a7e6b52 --- /dev/null +++ b/nladmin-system/src/main/java/org/nl/acs/order/rest/LabelingTemplateController.java @@ -0,0 +1,87 @@ + +package org.nl.acs.order.rest; + + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.order.service.LabelingTemplateService; +import org.nl.acs.order.service.dto.LabelingTemplateDto; +import org.nl.annotation.Log; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.sql.SQLException; +import java.util.Map; + +/** +* @author loujf +* @date 2022-06-01 +**/ +@RestController +@RequiredArgsConstructor +@Api(tags = "贴标模板管理") +@RequestMapping("/api/labelingTemplate") +@Slf4j +public class LabelingTemplateController { + + private final LabelingTemplateService labelingTemplateService; + + @GetMapping + @Log("查询贴标模板") + @ApiOperation("查询贴标模板") + //@PreAuthorize("@el.check('labelingTemplate:list')") + public ResponseEntity query(@RequestParam Map whereJson, Pageable page){ + return new ResponseEntity<>(labelingTemplateService.queryAll(whereJson,page),HttpStatus.OK); + } + + @PostMapping + @Log("新增贴标模板") + @ApiOperation("新增贴标模板") + //@PreAuthorize("@el.check('labelingTemplate:add')") + public ResponseEntity create(@Validated @RequestBody LabelingTemplateDto dto){ + labelingTemplateService.create(dto); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + @PutMapping + @Log("修改贴标模板") + @ApiOperation("修改贴标模板") + //@PreAuthorize("@el.check('labelingTemplate:edit')") + public ResponseEntity update(@Validated @RequestBody LabelingTemplateDto dto){ + labelingTemplateService.update(dto); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除贴标模板") + @ApiOperation("删除贴标模板") + //@PreAuthorize("@el.check('labelingTemplate:del')") + @DeleteMapping + public ResponseEntity delete(@RequestBody String[] ids) { + labelingTemplateService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } + + @Log("导出贴标模板") + @ApiOperation("导出贴标模板") + @GetMapping(value = "/download") + //@PreAuthorize("@el.check('labelingTemplate:list')") + public void download(HttpServletResponse response, @RequestParam Map whereJson) throws IOException { + labelingTemplateService.download(labelingTemplateService.queryAll(whereJson), response); + } + + @PutMapping("/enabled") + @Log("启用禁用路由路线") + @ApiOperation("启用禁用路由路线") + //@PreAuthorize("@el.check('routeLine:edit')") + public ResponseEntity enabled(@Validated @RequestBody LabelingTemplateDto dto) throws SQLException { + labelingTemplateService.enabled(dto.getTemplate_id(), dto.getIs_used()); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } +} diff --git a/nladmin-system/src/main/java/org/nl/acs/order/rest/ProduceshiftorderController.java b/nladmin-system/src/main/java/org/nl/acs/order/rest/ProduceshiftorderController.java index c6bd986..0fc332f 100644 --- a/nladmin-system/src/main/java/org/nl/acs/order/rest/ProduceshiftorderController.java +++ b/nladmin-system/src/main/java/org/nl/acs/order/rest/ProduceshiftorderController.java @@ -156,6 +156,12 @@ public class ProduceshiftorderController { return new ResponseEntity<>(HttpStatus.OK); } + @Log("查询贴标模板下拉列表") + @ApiOperation("查询贴标模板下拉列表") + @GetMapping("/selectTemplateList") + public ResponseEntity selectTemplateList() { + return new ResponseEntity<>(produceshiftorderService.selectTemplateList(),HttpStatus.OK); + } diff --git a/nladmin-system/src/main/java/org/nl/acs/order/service/LabelingTemplateService.java b/nladmin-system/src/main/java/org/nl/acs/order/service/LabelingTemplateService.java new file mode 100644 index 0000000..ffb051d --- /dev/null +++ b/nladmin-system/src/main/java/org/nl/acs/order/service/LabelingTemplateService.java @@ -0,0 +1,82 @@ + +package org.nl.acs.order.service; + +import org.nl.acs.order.service.dto.LabelingTemplateDto; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.sql.SQLException; +import java.util.List; +import java.util.Map; + +/** +* @description 服务接口 +* @author loujf +* @date 2022-06-01 +**/ +public interface LabelingTemplateService { + + /** + * 查询数据分页 + * @param whereJson 条件 + * @param page 分页参数 + * @return Map + */ + Map queryAll(Map whereJson, Pageable page); + + /** + * 查询所有数据不分页 + * @param whereJson 条件参数 + * @return List + */ + List queryAll(Map whereJson); + + /** + * 根据ID查询 + * @param template_id ID + * @return LabelingTemplate + */ + LabelingTemplateDto findById(String template_id); + + /** + * 根据编码查询 + * @param code code + * @return LabelingTemplate + */ + LabelingTemplateDto findByCode(String code); + + + /** + * 创建 + * @param dto / + */ + void create(LabelingTemplateDto dto); + + /** + * 编辑 + * @param dto / + */ + void update(LabelingTemplateDto dto); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(String[] ids); + + /** + * 导出数据 + * @param dtos 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List dtos, HttpServletResponse response) throws IOException; + + /** + * 启用或停用 + * + * @param is_used 1 启用,0 禁用 + */ + void enabled(String template_id, String is_used) throws SQLException; +} diff --git a/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java b/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java index 01789f9..e9d8e99 100644 --- a/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java +++ b/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java @@ -3,7 +3,6 @@ package org.nl.acs.order.service; import com.alibaba.fastjson.JSONArray; import org.nl.acs.order.service.dto.ProduceshiftorderDto; -import org.nl.acs.order.service.dto.ProduceshiftorderdetailDto; import org.springframework.data.domain.Pageable; import javax.servlet.http.HttpServletResponse; @@ -189,4 +188,11 @@ public interface ProduceshiftorderService { List findOrderByOrderStatusFromCache(String order_status); + /** + * 贴标模板下拉选列表 + * + * @return + */ + JSONArray selectTemplateList(); + } diff --git a/nladmin-system/src/main/java/org/nl/acs/order/service/dto/LabelingTemplateDto.java b/nladmin-system/src/main/java/org/nl/acs/order/service/dto/LabelingTemplateDto.java new file mode 100644 index 0000000..3c45a66 --- /dev/null +++ b/nladmin-system/src/main/java/org/nl/acs/order/service/dto/LabelingTemplateDto.java @@ -0,0 +1,46 @@ +package org.nl.acs.order.service.dto; + +import lombok.Data; +import java.io.Serializable; + +/** +* @description / +* @author loujf +* @date 2022-06-01 +**/ +@Data +public class LabelingTemplateDto implements Serializable { + + /** 模板标识 */ + private String template_id; + + /** 模板编码 */ + private String template_code; + + /** 模板名称 */ + private String template_name; + + /** 模板地址 */ + private String template_address; + + /** 创建者 */ + private String create_by; + + /** 创建时间 */ + private String create_time; + + /** 修改者 */ + private String update_by; + + /** 修改时间 */ + private String update_time; + + /** 启用时间 */ + private String is_used_time; + + /** 是否启用 1-启用 0-禁用 */ + private String is_used; + + /** 是否删除 */ + private String is_delete; +} diff --git a/nladmin-system/src/main/java/org/nl/acs/order/service/impl/LabelingTemplateServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/order/service/impl/LabelingTemplateServiceImpl.java new file mode 100644 index 0000000..dd41927 --- /dev/null +++ b/nladmin-system/src/main/java/org/nl/acs/order/service/impl/LabelingTemplateServiceImpl.java @@ -0,0 +1,156 @@ + +package org.nl.acs.order.service.impl; + + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.order.service.LabelingTemplateService; +import org.nl.acs.order.service.dto.LabelingTemplateDto; +import org.nl.exception.BadRequestException; +import org.nl.utils.FileUtil; +import org.nl.utils.SecurityUtils; +import org.nl.wql.WQL; +import org.nl.wql.core.bean.WQLObject; +import org.nl.wql.util.WqlUtil; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.sql.SQLException; +import java.util.*; + +/** +* @description 服务实现 +* @author loujf +* @date 2022-06-01 +**/ +@Service +@RequiredArgsConstructor +@Slf4j +public class LabelingTemplateServiceImpl implements LabelingTemplateService { + + @Override + public Map queryAll(Map whereJson, Pageable page){ + HashMap map = new HashMap<>(); + map.put("flag", "2"); + String template_code = (String) whereJson.get("template_code"); + String template_address = (String) whereJson.get("template_address"); + if (!StrUtil.isEmpty(template_code)) { + map.put("template_code", template_code); + } + if (!StrUtil.isEmpty(template_address)) { + map.put("template_address", template_address); + } + JSONObject jo = WQL.getWO("QPRODUCESHIFTORDER").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "update_time desc"); + return jo; + } + + @Override + public List queryAll(Map whereJson){ + WQLObject wo = WQLObject.getWQLObject("acs_labeling_template"); + JSONArray arr = wo.query().getResultJSONArray(0); + List list = arr.toJavaList(LabelingTemplateDto.class); + return list; + } + + @Override + public LabelingTemplateDto findById(String template_id) { + WQLObject wo = WQLObject.getWQLObject("acs_labeling_template"); + JSONObject json = wo.query("template_id ='" + template_id + "'").uniqueResult(0); + final LabelingTemplateDto obj = (LabelingTemplateDto) JSONObject.toJavaObject(json, LabelingTemplateDto.class); + return obj; + } + + @Override + public LabelingTemplateDto findByCode(String code) { + WQLObject wo = WQLObject.getWQLObject("acs_labeling_template"); + JSONObject json = wo.query("template_code ='" + code + "'").uniqueResult(0); + final LabelingTemplateDto obj = (LabelingTemplateDto) JSONObject.toJavaObject(json, LabelingTemplateDto.class); + return obj; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void create(LabelingTemplateDto dto) { + String template_code = dto.getTemplate_code(); + LabelingTemplateDto templateDto = this.findByCode(template_code); + if (templateDto != null && templateDto.getIs_delete().equals("0")) { + throw new BadRequestException("存在相同的设备编码"); + } + + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + + dto.setTemplate_id(IdUtil.simpleUUID()); + dto.setCreate_by(currentUsername); + dto.setUpdate_by(currentUsername); + dto.setUpdate_time(now); + dto.setCreate_time(now); + dto.setIs_used("1"); + + WQLObject wo = WQLObject.getWQLObject("acs_labeling_template"); + JSONObject json= (JSONObject) JSONObject.toJSON(dto); + wo.insert(json); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(LabelingTemplateDto dto) { + LabelingTemplateDto entity = this.findById(dto.getTemplate_id()); + if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); + + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + dto.setUpdate_time(now); + dto.setUpdate_by(currentUsername); + + WQLObject wo = WQLObject.getWQLObject("acs_labeling_template"); + JSONObject json= (JSONObject) JSONObject.toJSON(dto); + wo.update(json); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteAll(String[] ids) { + WQLObject wo = WQLObject.getWQLObject("acs_labeling_template"); + for (String template_id: ids) { + wo.delete("template_id = '" + template_id + "'"); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (LabelingTemplateDto labelingTemplate : all) { + Map map = new LinkedHashMap<>(); + map.put("模板编码", labelingTemplate.getTemplate_code()); + map.put("模板名称 ", labelingTemplate.getTemplate_name()); + map.put("模板地址", labelingTemplate.getTemplate_address()); + map.put("创建者", labelingTemplate.getCreate_by()); + map.put("创建时间", labelingTemplate.getCreate_time()); + map.put("修改者", labelingTemplate.getUpdate_by()); + map.put("修改时间", labelingTemplate.getUpdate_time()); + map.put("启用时间", labelingTemplate.getIs_used_time()); + map.put("是否启用", labelingTemplate.getIs_used()); + map.put("是否删除", labelingTemplate.getIs_delete()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + public void enabled(String template_id, String is_used) throws SQLException { + //贴标精度表 + WQLObject.getWQLObject("acs_labeling_template"); + LabelingTemplateDto dto = this.findById(template_id); + dto.setIs_used(is_used); + this.update(dto); + } +} diff --git a/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java index 2b0c89d..06407f9 100644 --- a/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java +++ b/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java @@ -503,29 +503,38 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A for (int i = 0; i < listMap.size(); i++) { Map map = listMap.get(i); - String order_code = String.valueOf(map.get(0)); - String order_status = String.valueOf(map.get(1)); - String material_code = String.valueOf(map.get(2)); - String material_name = String.valueOf(map.get(3)); - String outer_diameter = String.valueOf(map.get(4)); - String wall_thickness = String.valueOf(map.get(5)); - String length = String.valueOf(map.get(6)); - String qty = String.valueOf(map.get(7)); - - //月生产计划接口处理表数据 + String material_code = String.valueOf(map.get(0)); + String material_name = String.valueOf(map.get(1)); + String material_spec = String.valueOf(map.get(2)); + String outer_diameter = String.valueOf(map.get(3)); + String wall_thickness = String.valueOf(map.get(4)); + String length = String.valueOf(map.get(5)); + String qty = String.valueOf(map.get(6)); + ProduceshiftorderDto dto = new ProduceshiftorderDto(); dto.setOrder_id(IdUtil.simpleUUID()); - dto.setOrder_code(order_code); - dto.setOrder_status(order_status); dto.setMaterial_uuid(IdUtil.simpleUUID()); + dto.setOrder_code("022"); dto.setMaterial_code(material_code); dto.setMaterial_name(material_name); + dto.setMaterial_spec(material_spec); dto.setOuter_diameter(outer_diameter); dto.setWall_thickness(wall_thickness); dto.setQty(qty); dto.setLength(length); - orderTab.insert(JSONObject.parseObject(JSON.toJSONString(dto))); + +// Map map2 = new HashMap<>(); +// map2.put("material_id",IdUtil.simpleUUID()); +// map2.put("material_code",material_code); +// map2.put("material_name",material_name); +// map2.put("material_spec",material_spec); +// map2.put("outer_diameter",outer_diameter); +// map2.put("wall_thickness",wall_thickness); +// map2.put("length",length); +// map2.put("qty",qty); +// +// create(map2); } } @@ -649,4 +658,20 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A return json; } + @Override + public JSONArray selectTemplateList() { + //贴标模板表【acs_labeling_template】 + JSONArray arr = WQLObject.getWQLObject("acs_labeling_template").query("is_delete= '0' AND is_used= '1'","template_code asc").getResultJSONArray(0); + JSONArray result = new JSONArray(); + for (int i = 0; i < arr.size(); i++) { + JSONObject obj = arr.getJSONObject(i); + JSONObject json = new JSONObject(); + json.put("template_id", obj.getString("template_id")); + json.put("template_code", obj.getString("template_code")); + json.put("template_name", obj.getString("template_name")); + result.add(json); + } + return result; + } + } \ No newline at end of file diff --git a/nladmin-system/src/main/java/org/nl/acs/order/service/wql/QPRODUCESHIFTORDER.wql b/nladmin-system/src/main/java/org/nl/acs/order/service/wql/QPRODUCESHIFTORDER.wql index cf132f7..f2f6cee 100644 --- a/nladmin-system/src/main/java/org/nl/acs/order/service/wql/QPRODUCESHIFTORDER.wql +++ b/nladmin-system/src/main/java/org/nl/acs/order/service/wql/QPRODUCESHIFTORDER.wql @@ -14,7 +14,8 @@ ## 表字段对应输入参数 ################################################# 输入.flag TYPEAS s_string - + 输入.template_code TYPEAS s_string + 输入.template_address TYPEAS s_string [临时表] --这边列出来的临时表就会在运行期动态创建 @@ -49,4 +50,22 @@ ENDQUERY ENDIF + IF 输入.flag = "2" + PAGEQUERY + SELECT + * + FROM + acs_labeling_template template + WHERE + 1=1 + OPTION 输入.template_code <> "" + template.template_code = 输入.template_code + ENDOPTION + OPTION 输入.template_address <> "" + template.template_address = 输入.template_address + ENDOPTION + ENDSELECT + ENDPAGEQUERY + ENDIF +