打印机维护

master
Leon 4 years ago
parent 63e9c0277a
commit 4460a78b77

@ -0,0 +1,93 @@
package com.foreverwin.mesnac.common.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.model.Printer;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.R;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.foreverwin.mesnac.common.service.PrinterService;
import java.time.LocalDateTime;
import java.util.List;
/**
*
* @author Leon.L
* @since 2021-08-11
*/
@RestController
@RequestMapping("/PRINTER")
public class PrinterController {
@Autowired
public PrinterService printerService;
/**
*
*
* @return
*/
@ResponseBody
@GetMapping("")
public R getPrinterList(Printer printer){
List<Printer> result;
try {
String site = CommonMethods.getSite();
printer.setSite(site);
QueryWrapper<Printer> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(printer);
result = printerService.list(queryWrapper);
} catch (Exception e) {
return R.failed(e.getMessage());
}
return R.ok(result);
}
@ResponseBody
@GetMapping("/getPrinter")
public R savePrinter(String printer) {
Printer result = null;
try {
String site = CommonMethods.getSite();
String handle = HandleEnum.PRINT.getHandle(site, printer);
result = printerService.getById(handle);
} catch (Exception e) {
return R.failed(e.getMessage());
}
return R.ok(result);
}
@ResponseBody
@PostMapping("/savePrinter")
public R savePrinter(Printer printer) {
try {
LocalDateTime nowDate = LocalDateTime.now();
String site = CommonMethods.getSite();
String handle = HandleEnum.PRINT.getHandle(site, printer.getPrinter());
Printer printerModel = printerService.getById(handle);
if (printerModel == null) {
printer.setHandle(handle);
printer.setSite(site);
printer.setCreatedDateTime(nowDate);
printer.setModifiedDateTime(nowDate);
printerService.save(printer);
} else {
printerModel.setDescription(printer.getDescription());
printerModel.setModifiedDateTime(nowDate);
printerService.updateById(printerModel);
}
} catch (Exception e) {
return R.failed(e.getMessage());
}
return R.ok();
}
}

@ -20,6 +20,8 @@ public enum HandleEnum {
/**物料清单**/ /**物料清单**/
BOM("BOMBO:","BOMBO:{0},{1},{2},{3}"), BOM("BOMBO:","BOMBO:{0},{1},{2},{3}"),
PRINT("PrintBO:", "StatusBO:{0},{1}"),
/**叫料**/ /**叫料**/
CALL_ITEM("CallItemBO:", "CallItemBO:{0},{1}"), CALL_ITEM("CallItemBO:", "CallItemBO:{0},{1}"),

@ -1,6 +1,6 @@
package com.foreverwin.mesnac.meapi.mapper; package com.foreverwin.mesnac.common.mapper;
import com.foreverwin.mesnac.meapi.model.Printer; import com.foreverwin.mesnac.common.model.Printer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -10,7 +10,7 @@ import org.springframework.stereotype.Repository;
* </p> * </p>
* *
* @author Leon.L * @author Leon.L
* @since 2021-07-22 * @since 2021-08-11
*/ */
@Repository @Repository
public interface PrinterMapper extends BaseMapper<Printer> { public interface PrinterMapper extends BaseMapper<Printer> {

@ -1,7 +1,8 @@
package com.foreverwin.mesnac.meapi.model; package com.foreverwin.mesnac.common.model;
import java.io.Serializable; import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model; import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -15,15 +16,15 @@ import com.baomidou.mybatisplus.annotation.IdType;
* </p> * </p>
* *
* @author Leon.L * @author Leon.L
* @since 2021-07-22 * @since 2021-08-11
*/ */
@TableName("PRINTER") @TableName("Z_PRINTER")
public class Printer extends Model<Printer> { public class Printer extends Model<Printer> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableField("HANDLE") @TableId(value = "HANDLE", type = IdType.INPUT)
private String handle; private String handle;
@TableField("SITE") @TableField("SITE")
private String site; private String site;

@ -1,7 +1,7 @@
package com.foreverwin.mesnac.meapi.service; package com.foreverwin.mesnac.common.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.meapi.model.Printer; import com.foreverwin.mesnac.common.model.Printer;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.modular.core.util.FrontPage; import com.foreverwin.modular.core.util.FrontPage;
@ -13,7 +13,7 @@ import java.util.List;
* </p> * </p>
* *
* @author Leon.L * @author Leon.L
* @since 2021-07-22 * @since 2021-08-11
*/ */
public interface PrinterService extends IService<Printer> { public interface PrinterService extends IService<Printer> {

@ -1,11 +1,11 @@
package com.foreverwin.mesnac.meapi.service.impl; package com.foreverwin.mesnac.common.service.impl;
import com.foreverwin.modular.core.util.FrontPage; import com.foreverwin.modular.core.util.FrontPage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.meapi.model.Printer; import com.foreverwin.mesnac.common.model.Printer;
import com.foreverwin.mesnac.meapi.mapper.PrinterMapper; import com.foreverwin.mesnac.common.mapper.PrinterMapper;
import com.foreverwin.mesnac.meapi.service.PrinterService; import com.foreverwin.mesnac.common.service.PrinterService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -18,7 +18,7 @@ import java.util.List;
* </p> * </p>
* *
* @author Leon.L * @author Leon.L
* @since 2021-07-22 * @since 2021-08-11
*/ */
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.foreverwin.mesnac.meapi.mapper.PrinterMapper"> <mapper namespace="com.foreverwin.mesnac.common.mapper.PrinterMapper">
<!-- 通用查询映射结果 --> <!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.foreverwin.mesnac.meapi.model.Printer"> <resultMap id="BaseResultMap" type="com.foreverwin.mesnac.common.model.Printer">
<result column="HANDLE" property="handle" /> <result column="HANDLE" property="handle" />
<result column="SITE" property="site" /> <result column="SITE" property="site" />
<result column="PRINTER" property="printer" /> <result column="PRINTER" property="printer" />
@ -22,7 +22,7 @@
<select id="selectByMap" resultMap="BaseResultMap"> <select id="selectByMap" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include> SELECT <include refid="Base_Column_List"></include>
FROM PRINTER FROM Z_PRINTER
<if test="cm!=null and !cm.isEmpty"> <if test="cm!=null and !cm.isEmpty">
<where> <where>
<foreach collection="cm.keys" item="k" separator="AND"> <foreach collection="cm.keys" item="k" separator="AND">
@ -36,7 +36,7 @@
<select id="selectOne" resultMap="BaseResultMap"> <select id="selectOne" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include> FROM PRINTER SELECT <include refid="Base_Column_List"></include> FROM Z_PRINTER
<where> <where>
<if test="ew.entity.handle!=null"> <if test="ew.entity.handle!=null">
HANDLE=#{ew.handle} HANDLE=#{ew.handle}
@ -51,7 +51,7 @@
</select> </select>
<select id="selectCount" resultType="Integer"> <select id="selectCount" resultType="Integer">
SELECT COUNT(1) FROM PRINTER SELECT COUNT(1) FROM Z_PRINTER
<where> <where>
<if test="ew!=null"> <if test="ew!=null">
<if test="ew.entity!=null"> <if test="ew.entity!=null">
@ -76,7 +76,7 @@
</select> </select>
<select id="selectList" resultMap="BaseResultMap"> <select id="selectList" resultMap="BaseResultMap">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM PRINTER SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_PRINTER
<where> <where>
<if test="ew!=null"> <if test="ew!=null">
<if test="ew.entity!=null"> <if test="ew.entity!=null">
@ -101,7 +101,7 @@
</select> </select>
<select id="selectMaps" resultType="HashMap"> <select id="selectMaps" resultType="HashMap">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM PRINTER SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_PRINTER
<where> <where>
<if test="ew!=null"> <if test="ew!=null">
<if test="ew.entity!=null"> <if test="ew.entity!=null">
@ -126,7 +126,7 @@
</select> </select>
<select id="selectObjs" resultType="Object"> <select id="selectObjs" resultType="Object">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM PRINTER SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_PRINTER
<where> <where>
<if test="ew!=null"> <if test="ew!=null">
<if test="ew.entity!=null"> <if test="ew.entity!=null">
@ -151,7 +151,7 @@
</select> </select>
<select id="selectPage" resultMap="BaseResultMap"> <select id="selectPage" resultMap="BaseResultMap">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM PRINTER SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_PRINTER
<where> <where>
<if test="ew!=null"> <if test="ew!=null">
<if test="ew.entity!=null"> <if test="ew.entity!=null">
@ -176,7 +176,7 @@
</select> </select>
<select id="selectMapsPage" resultType="HashMap"> <select id="selectMapsPage" resultType="HashMap">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM PRINTER SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_PRINTER
<where> <where>
<if test="ew!=null"> <if test="ew!=null">
<if test="ew.entity!=null"> <if test="ew.entity!=null">
@ -200,8 +200,8 @@
</if> </if>
</select> </select>
<insert id="insert" parameterType="com.foreverwin.mesnac.meapi.model.Printer"> <insert id="insert" parameterType="com.foreverwin.mesnac.common.model.Printer">
INSERT INTO PRINTER INSERT INTO Z_PRINTER
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
HANDLE, HANDLE,
<if test="site!=null">SITE,</if> <if test="site!=null">SITE,</if>
@ -222,8 +222,8 @@
</trim> </trim>
</insert> </insert>
<insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.meapi.model.Printer"> <insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.common.model.Printer">
INSERT INTO PRINTER INSERT INTO Z_PRINTER
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<include refid="Base_Column_List"></include> <include refid="Base_Column_List"></include>
</trim> VALUES </trim> VALUES
@ -244,7 +244,7 @@
<update id="update"> <update id="update">
UPDATE PRINTER <trim prefix="SET" suffixOverrides=","> UPDATE Z_PRINTER <trim prefix="SET" suffixOverrides=",">
<if test="et.handle!=null">HANDLE=#{et.handle},</if> <if test="et.handle!=null">HANDLE=#{et.handle},</if>
<if test="et.site!=null">SITE=#{et.site},</if> <if test="et.site!=null">SITE=#{et.site},</if>
<if test="et.printer!=null">PRINTER=#{et.printer},</if> <if test="et.printer!=null">PRINTER=#{et.printer},</if>
@ -276,7 +276,7 @@
<delete id="deleteByMap"> <delete id="deleteByMap">
DELETE FROM PRINTER DELETE FROM Z_PRINTER
<if test="cm!=null and !cm.isEmpty"> <if test="cm!=null and !cm.isEmpty">
<where> <where>
<foreach collection="cm.keys" item="k" separator="AND"> <foreach collection="cm.keys" item="k" separator="AND">
@ -289,7 +289,7 @@
</delete> </delete>
<delete id="delete"> <delete id="delete">
DELETE FROM PRINTER DELETE FROM Z_PRINTER
<where> <where>
<if test="ew!=null"> <if test="ew!=null">
<if test="ew.entity!=null"> <if test="ew.entity!=null">

@ -36,11 +36,11 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.foreverwin.mesnac</groupId> <groupId>com.foreverwin.mesnac</groupId>
<artifactId>dispatch</artifactId> <artifactId>common</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.foreverwin.mesnac</groupId> <groupId>com.foreverwin.mesnac</groupId>
<artifactId>common</artifactId> <artifactId>dispatch</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

@ -1,130 +0,0 @@
package com.foreverwin.mesnac.meapi.controller;
import com.foreverwin.modular.core.util.R;
import com.foreverwin.modular.core.util.FrontPage;
import com.foreverwin.modular.core.util.CommonMethods;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.foreverwin.mesnac.meapi.service.PrinterService;
import com.foreverwin.mesnac.meapi.model.Printer;
import java.util.List;
/**
*
* @author Leon.L
* @since 2021-07-22
*/
@RestController
@RequestMapping("/PRINTER")
public class PrinterController {
@Autowired
public PrinterService printerService;
/**
* id
*
* @param id
* @return
*/
@ResponseBody
@GetMapping("/{id:.+}")
public R getPrinterById(@PathVariable String id) {
return R.ok( printerService.getById(id));
}
/**
*
*
* @return
*/
@ResponseBody
@GetMapping("")
public R getPrinterList(Printer printer){
List<Printer> result;
try {
String site = CommonMethods.getSite();
printer.setSite(site);
QueryWrapper<Printer> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(printer);
result = printerService.list(queryWrapper);
} catch (Exception e) {
return R.failed(e.getMessage());
}
return R.ok(result);
}
/**
*
*
* @param frontPage
* @return
*/
@ResponseBody
@GetMapping("/page")
public R page(FrontPage<Printer> frontPage, Printer printer){
IPage result;
QueryWrapper<Printer> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(printer);
if (frontPage.getGlobalQuery() != null && !"".equals(frontPage.getGlobalQuery().trim())) {
//TODO modify global query
queryWrapper.lambda().and(wrapper -> wrapper
.like(Printer::getHandle, frontPage.getGlobalQuery())
.or().like(Printer::getSite, frontPage.getGlobalQuery())
.or().like(Printer::getPrinter, frontPage.getGlobalQuery())
.or().like(Printer::getDescription, frontPage.getGlobalQuery())
.or().like(Printer::getEnabled, frontPage.getGlobalQuery())
);
}
result = printerService.page(frontPage.getPagePlus(), queryWrapper);
return R.ok(result);
}
/**
*
* @param printer
* @return null
*/
@PostMapping
public R save(@RequestBody Printer printer) {
return R.ok(printerService.save(printer));
}
/**
*
* @param printer
* @return null
*/
@PutMapping
public R updateById(@RequestBody Printer printer) {
return R.ok(printerService.updateById(printer));
}
/**
* id
* @param id ID
* @return 0 1
*/
@ResponseBody
@RequestMapping(method = RequestMethod.DELETE, value = "/{id:.+}")
public R removeById(@PathVariable("id") String id){
return R.ok(printerService.removeById(id));
}
/**
*
* @param ids ID
* @return 0 1
*/
@ResponseBody
@RequestMapping(method = RequestMethod.POST, value = "/delete-batch")
public R removeByIds(List<String> ids){
return R.ok(printerService.removeByIds(ids));
}
}
Loading…
Cancel
Save