Commit e84ed4af authored by 李苏's avatar 李苏 💬

Merge branch 'master' of gitlab.gavelinfo.com:gavelinfo/kwell-mes

parents 7c36683a 58c2bca0
package com.gavel.kwell.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONObject;
import com.gavel.common.BaseURL;
import com.gavel.common.annotation.ResourcePermissions;
import com.gavel.common.base.controller.BaseController;
import com.gavel.common.converter.DataConvert;
import com.gavel.common.utils.ThreadContext;
import com.gavel.jcsj.vo.WlxxCondition;
import com.gavel.kwell.service.GyssnszService;
import com.gavel.kwell.vo.GyssnWlxxVO;
import com.gavel.persistence.sql.RecordSet;
@Controller
@RequestMapping("kmes/gyssnsz")
public class GyssnszController extends BaseController {
@Autowired
private GyssnszService gyssnszService;
@ResourcePermissions()
@RequestMapping("/index")
public String index() {
return "kmes/gyssnsz/index";
}
@RequestMapping("/snsz")
public String edit() {
return "kmes/gyssnsz/snsz";
}
@RequestMapping(value = BaseURL.GET, method = RequestMethod.POST)
@ResponseBody
public Object get(@RequestBody JSONObject param) {
WlxxCondition condition = DataConvert.getCondition(param, WlxxCondition.class);
RecordSet<GyssnWlxxVO> records = gyssnszService.query(condition);
return buildReturnData(records, GyssnWlxxVO.class);
}
@RequestMapping(value = BaseURL.QUERY, method = RequestMethod.POST)
@ResponseBody
public Object query(@RequestBody JSONObject param) {
WlxxCondition condition = DataConvert.getCondition(param, WlxxCondition.class);
RecordSet<GyssnWlxxVO> records = gyssnszService.query(condition);
return buildReturnData(records, GyssnWlxxVO.class);
}
@RequestMapping(value ="queryNotSnruleid", method = RequestMethod.POST)
@ResponseBody
public Object queryNotSnruleid(@RequestBody JSONObject param) {
WlxxCondition condition = DataConvert.getCondition(param, WlxxCondition.class);
RecordSet<GyssnWlxxVO> records = gyssnszService.queryNotSnruleid(condition);
return buildReturnData(records, GyssnWlxxVO.class);
}
@RequestMapping(value = "snsz", method = RequestMethod.POST)
@ResponseBody
public Object changeJldw(@RequestBody JSONObject param) {
WlxxCondition condition = DataConvert.getCondition(param, WlxxCondition.class);
gyssnszService.snsz(condition);
return ThreadContext.getReturnData();
}
}
package com.gavel.kwell.controller;
import com.alibaba.fastjson.JSONObject;
import com.gavel.common.BaseURL;
import com.gavel.common.SystemOperation;
import com.gavel.common.annotation.ResourcePermissions;
import com.gavel.common.base.BaseEditJSON;
import com.gavel.common.base.controller.BaseController;
import com.gavel.common.converter.DataConvert;
import com.gavel.common.utils.ThreadContext;
import com.gavel.kwell.service.UpointService;
import com.gavel.kwell.utils.PointTypeEnum;
import com.gavel.kwell.vo.DataPointItem;
import com.gavel.kwell.vo.UpointCondition;
import com.gavel.kwell.vo.UpointVO;
import com.gavel.persistence.sql.RecordSet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@Controller
@RequestMapping("kmes/point")
public class UpointController extends BaseController {
@Autowired
private UpointService upointService;
@ResourcePermissions()
@RequestMapping("/index")
public String index() {
return "kmes/point/index";
}
@ResourcePermissions({SystemOperation.BottonResource.ADD})
@RequestMapping("/add")
public String add() {
return "kmes/point/edit";
}
@ResourcePermissions({SystemOperation.BottonResource.EDIT})
@RequestMapping("/edit")
public String edit() {
return "kmes/point/edit";
}
@RequestMapping(value = BaseURL.GET, method = RequestMethod.POST)
@ResponseBody
public Object get(@RequestBody JSONObject param) {
UpointCondition condition = DataConvert.getCondition(param, UpointCondition.class);
RecordSet<UpointVO> records = upointService.query(condition);
if ( records.getRecords()!=null && records.getRecords().size()>=1 ){
return buildReturnData(UpointVO.class, records.getRecords().get(0));
}
return buildReturnData(UpointVO.class, null);
}
@RequestMapping(value = BaseURL.QUERY, method = RequestMethod.POST)
@ResponseBody
public Object query(@RequestBody JSONObject param) {
UpointCondition condition = DataConvert.getCondition(param, UpointCondition.class);
RecordSet<UpointVO> records = upointService.query(condition);
return buildReturnData(records, UpointVO.class);
}
@ResourcePermissions(SystemOperation.BottonResource.ADD)
@RequestMapping(value = BaseURL.ADD, method = RequestMethod.POST)
@ResponseBody
public Object insert(@RequestBody JSONObject param) {
BaseEditJSON editJson = BaseEditJSON.parseJSON(param);
upointService.insert(editJson);
return ThreadContext.getReturnData();
}
@ResourcePermissions(SystemOperation.BottonResource.EDIT)
@RequestMapping(value = BaseURL.UPDATE, method = RequestMethod.POST)
@ResponseBody
public Object update(@RequestBody JSONObject param) {
BaseEditJSON editJson = BaseEditJSON.parseJSON(param);
upointService.update(editJson);
return ThreadContext.getReturnData();
}
@ResourcePermissions(SystemOperation.BottonResource.DELETE)
@RequestMapping(value = BaseURL.DELETE, method = RequestMethod.POST)
@ResponseBody
public Object delete(@RequestBody JSONObject param) {
BaseEditJSON editJson = BaseEditJSON.parseJSON(param);
upointService.delete(editJson);
return ThreadContext.getReturnData();
}
/**
* 获取温度,湿度,手环 点位值
* @param param
* @return
*/
@RequestMapping(value = "queryringpoint", method = RequestMethod.POST)
@ResponseBody
public Object queryringpoint(@RequestBody JSONObject param) {
List<DataPointItem> records = upointService.queryringpoint();
return buildReturnData(records, DataPointItem.class);
}
@ResourcePermissions(SystemOperation.BottonResource.EXPORT)
@RequestMapping(value = BaseURL.EXPORT, method = RequestMethod.POST)
@ResponseBody
public void export(HttpServletRequest request,HttpServletResponse response, @RequestBody JSONObject param) throws Exception {
UpointCondition condition = DataConvert.getCondition(param, UpointCondition.class);
RecordSet<UpointVO> records = upointService.query(condition);
doExport(request, response, param, records.getRecords());
}
@RequestMapping(value = "/init/type", method = RequestMethod.POST)
@ResponseBody
public Object initType() {
return buildReturnData(PointTypeEnum.toList());
}
}
package com.gavel.kwell.dao;
import com.gavel.common.base.dao.BaseDao;
import com.gavel.jcsj.vo.WlxxCondition;
import com.gavel.kwell.vo.GyssnWlxxVO;
import com.gavel.persistence.sql.RecordSet;
public interface GyssnszWlxxDao extends BaseDao{
public RecordSet<GyssnWlxxVO> query(WlxxCondition condition);
public RecordSet<GyssnWlxxVO> queryNotSnruleid(WlxxCondition condition);
}
package com.gavel.kwell.dao;
import com.gavel.common.base.dao.BaseDao;
import com.gavel.kwell.persistent.Upoint;
import com.gavel.kwell.vo.UpointCondition;
import com.gavel.kwell.vo.UpointVO;
import com.gavel.persistence.sql.RecordSet;
import java.util.List;
public interface UpointDao extends BaseDao {
public RecordSet<UpointVO> query(UpointCondition condition);
public Upoint exsitPoint(String key, String type);
public boolean queryByCode(String key);
public List<Upoint> queryList(String type);
}
package com.gavel.kwell.dao.impl;
import org.springframework.stereotype.Repository;
import com.gavel.common.base.dao.impl.BaseDaoImpl;
import com.gavel.common.utils.StringUtils;
import com.gavel.jcsj.vo.WlxxCondition;
import com.gavel.kwell.dao.GyssnszWlxxDao;
import com.gavel.kwell.utils.GyssnGzflEnum;
import com.gavel.kwell.vo.GyssnWlxxVO;
import com.gavel.persistence.sql.RecordSet;
import com.gavel.persistence.sql.SqlMap;
import com.gavel.persistence.sql.SqlUtil;
@Repository("gyssnszWlxxDao")
public class GyssnszWlxxDaoImpl extends BaseDaoImpl implements GyssnszWlxxDao {
public RecordSet<GyssnWlxxVO> query(WlxxCondition condition){
/*---------AutoBegin-----------*/
SqlMap sqlMap = new SqlMap();
sqlMap.setPageNo(condition.getPageNo());
sqlMap.setRowCount(condition.getPageSize());
sqlMap.append("select WLXX_ID, WLXX_CODE, WLXX_NAME, WLXX_GG, WLXX_TH, WLXX_CZ,");
sqlMap.append(" WLXX_SNRULEID,WLXX_FLID,WLXX_JLDW,J.JLDW_NAME as JLDW_NAME,");
sqlMap.append(" WLFL_NAME,SNRULE_CODE,SNRULE_NAME,SNRULE_GZFL,");
sqlMap.append(" SNRULE_GZ,SNRULE_QZ,SNRULE_HZ,SNRULE_CD ");
sqlMap.append("from WLXX ");
sqlMap.append(" left join WLFL on WLFL_ID = WLXX_FLID ");
sqlMap.append(" left join JLDW J on J.JLDW_ID = WLXX_JLDW ");
sqlMap.append(" left join SNRULE on SNRULE_ID = WLXX_SNRULEID");
sqlMap.append("where isnull(WLXX_SNRULEID,' ') <> ' ' and SNRULE_GZFL = :SNRULE_GZFL ");
sqlMap.setParamValue("SNRULE_GZFL", GyssnGzflEnum.GYSSN.getId());
if (StringUtils.isNotEmpty(condition.getId())) {
sqlMap.append(" and " + SqlUtil.getWhereSql("WLXX_ID", condition.getId()));
sqlMap.setParamValue("WLXX_ID", condition.getId());
}
if (StringUtils.isNotEmpty(condition.getWlid())) {
sqlMap.append(" and " + SqlUtil.getWhereSql("WLXX_CODE", condition.getWlid()));
sqlMap.setParamValue("WLXX_CODE", condition.getWlid());
}
if (StringUtils.isNotEmpty(condition.getCondition())) {
sqlMap.append(" and (WLXX_CODE like :condition or WLXX_NAME like :condition )");
sqlMap.setParamValueLike("condition", condition.getCondition());
}
if (StringUtils.isNotEmpty(condition.getSnrulename())) {
sqlMap.append(" and " + SqlUtil.getWhereLikeSql("SNRULE_NAME"));
sqlMap.setParamValueLike("SNRULE_NAME", condition.getSnrulename());
}
sqlMap.append("order by WLXX_CODE ");
return sqlMap.queryRecordset(GyssnWlxxVO.class);
/*---------AutoEnd-------------*/
}
@Override
public RecordSet<GyssnWlxxVO> queryNotSnruleid(WlxxCondition condition) {
SqlMap sqlMap = new SqlMap();
sqlMap.setPageNo(condition.getPageNo());
sqlMap.setRowCount(condition.getPageSize());
sqlMap.append("select WLXX_ID, WLXX_CODE, WLXX_NAME, WLXX_GG, WLXX_TH, WLXX_CZ, WLXX_FLID,WLXX_ZZSL,WLXX_JLDW,");
sqlMap.append(" WLFL_NAME,J.JLDW_NAME as JLDW_NAME ");
sqlMap.append("from WLXX ");
sqlMap.append(" left join WLFL on WLFL_ID = WLXX_FLID ");
sqlMap.append(" left join JLDW J on J.JLDW_ID = WLXX_JLDW ");
sqlMap.append("where isnull(WLXX_SNRULEID,' ') = ' ' and isnull(WLXX_TYBZ,'N') = 'N' ");
if (StringUtils.isNotEmpty(condition.getFlcjid())) {
sqlMap.append(" and WLFL_CJID like :WLFL_CJID");
sqlMap.setParamValuePrefixLike("WLFL_CJID", condition.getFlcjid());
}
if (StringUtils.isNotEmpty(condition.getCondition())) {
sqlMap.append(" and (WLXX_CODE like :condition or WLXX_NAME like :condition )");
sqlMap.setParamValueLike("condition", condition.getCondition());
}
sqlMap.append("order by WLXX_CODE ");
sqlMap.query(GyssnWlxxVO.class);
return sqlMap.getRecordSet();
}
}
package com.gavel.kwell.dao.impl;
import com.gavel.common.base.dao.impl.BaseDaoImpl;
import com.gavel.common.utils.StringUtils;
import com.gavel.kwell.dao.UpointDao;
import com.gavel.kwell.persistent.Upoint;
import com.gavel.kwell.vo.UpointCondition;
import com.gavel.kwell.vo.UpointVO;
import com.gavel.persistence.sql.RecordSet;
import com.gavel.persistence.sql.SqlMap;
import com.gavel.persistence.sql.SqlUtil;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository("upointDao")
public class UpointDaoImpl extends BaseDaoImpl implements UpointDao {
public RecordSet<UpointVO> query(UpointCondition condition){
SqlMap sqlMap = new SqlMap();
sqlMap.setPageNo(condition.getPageNo());
sqlMap.setRowCount(condition.getPageSize());
sqlMap.append("select U_PLCPOINT_ID, U_PLCPOINT_CODE, U_PLCPOINT_NAME, U_PLCPOINT_TYPE, U_PLCPOINT_BZ, ");
sqlMap.append(" U_PLCPOINT_WHRID, U_PLCPOINT_WHR, U_PLCPOINT_WHSJ, U_PLCPOINT_CJRID, U_PLCPOINT_CJR, ");
sqlMap.append(" U_PLCPOINT_CJSJ, U_PLCPOINT_SYSVERSION, U_PLCPOINT_SIGN ");
sqlMap.append("from U_PLCPOINT ");
sqlMap.append("where 1 = 1 ");
if (StringUtils.isNotEmpty(condition.getId())){
sqlMap.append(" and " + SqlUtil.getWhereSql("U_PLCPOINT_ID", condition.getId()));
sqlMap.setParamValue("U_PLCPOINT_ID", condition.getId());
}
if (StringUtils.isNotEmpty(condition.getType())){
sqlMap.append(" and " + SqlUtil.getWhereSql("U_PLCPOINT_TYPE", condition.getType()));
sqlMap.setParamValue("U_PLCPOINT_TYPE", condition.getType());
}
if (StringUtils.isNotEmpty(condition.getCondition())){
sqlMap.append("and (U_PLCPOINT_CODE like :condition or U_PLCPOINT_NAME like :condition)");
sqlMap.setParamValueLike("condition",condition.getCondition());
}
sqlMap.append("order by U_PLCPOINT_TYPE,U_PLCPOINT_CODE ");
sqlMap.query(UpointVO.class);
return sqlMap.getRecordSet();
}
@Override
public Upoint exsitPoint(String code, String type) {
SqlMap sqlMap = new SqlMap();
sqlMap.append("select U_PLCPOINT_ID, U_PLCPOINT_CODE, U_PLCPOINT_NAME, U_PLCPOINT_TYPE, U_PLCPOINT_BZ, ");
sqlMap.append(" U_PLCPOINT_WHRID, U_PLCPOINT_WHR, U_PLCPOINT_WHSJ, U_PLCPOINT_CJRID, U_PLCPOINT_CJR, ");
sqlMap.append(" U_PLCPOINT_CJSJ, U_PLCPOINT_SYSVERSION, U_PLCPOINT_SIGN ");
sqlMap.append("from U_PLCPOINT ");
sqlMap.append("where U_PLCPOINT_CODE = :U_PLCPOINT_CODE and U_PLCPOINT_TYPE = :U_PLCPOINT_TYPE");
sqlMap.setParamValue("U_PLCPOINT_CODE", code);
sqlMap.setParamValue("U_PLCPOINT_TYPE", type);
return sqlMap.queryEntity(Upoint.class);
}
@Override
public boolean queryByCode(String code) {
SqlMap sqlMap = new SqlMap();
sqlMap.append("select U_PLCPOINT_ID, U_PLCPOINT_CODE, U_PLCPOINT_NAME, U_PLCPOINT_TYPE, U_PLCPOINT_BZ, ");
sqlMap.append(" U_PLCPOINT_WHRID, U_PLCPOINT_WHR, U_PLCPOINT_WHSJ, U_PLCPOINT_CJRID, U_PLCPOINT_CJR, ");
sqlMap.append(" U_PLCPOINT_CJSJ, U_PLCPOINT_SYSVERSION, U_PLCPOINT_SIGN ");
sqlMap.append("from U_PLCPOINT ");
sqlMap.append("where U_PLCPOINT_CODE = :U_PLCPOINT_CODE ");
sqlMap.setParamValue("U_PLCPOINT_CODE", code);
return sqlMap.queryEntity(Upoint.class) != null;
}
@Override
public List<Upoint> queryList(String type) {
SqlMap sqlMap = new SqlMap();
sqlMap.append("select U_PLCPOINT_ID, U_PLCPOINT_CODE, U_PLCPOINT_NAME, U_PLCPOINT_TYPE, U_PLCPOINT_BZ, ");
sqlMap.append(" U_PLCPOINT_WHRID, U_PLCPOINT_WHR, U_PLCPOINT_WHSJ, U_PLCPOINT_CJRID, U_PLCPOINT_CJR, ");
sqlMap.append(" U_PLCPOINT_CJSJ, U_PLCPOINT_SYSVERSION, U_PLCPOINT_SIGN ");
sqlMap.append("from U_PLCPOINT ");
sqlMap.append("where U_PLCPOINT_TYPE = :U_PLCPOINT_TYPE ");
sqlMap.setParamValue("U_PLCPOINT_TYPE", type);
sqlMap.append("order by U_PLCPOINT_CODE ");
return sqlMap.query(Upoint.class);
}
}
package com.gavel.kwell.persistent;
import com.gavel.common.base.entity.BaseEntity;
import com.gavel.common.utils.CodeStrategy;
import com.gavel.persistence.annotation.FieldMeta;
import com.gavel.persistence.annotation.TableMeta;
import java.util.Date;
@TableMeta(id = "U_PLCPOINT", name = "U_PLCPOINT")
public class Upoint extends BaseEntity {
private static final long serialVersionUID = 1L;
@FieldMeta(fieldName = "U_PLCPOINT_ID", caption = "ID", primaryKey = true,codeStrategy = CodeStrategy.UUID,notEmpty = true)
private String id;
@FieldMeta(fieldName = "U_PLCPOINT_CODE", caption = "编码",notEmpty = true)
private String code;
@FieldMeta(fieldName = "U_PLCPOINT_NAME", caption = "名称")
private String name;
@FieldMeta(fieldName = "U_PLCPOINT_TYPE", caption = "类型")
private String type;
@FieldMeta(fieldName = "U_PLCPOINT_SIGN", caption = "合格标志")
private String sign;
@FieldMeta(fieldName = "U_PLCPOINT_BZ", caption = "备注")
private String bz;
@FieldMeta(fieldName = "U_PLCPOINT_WHRID", caption = "维护人编码", autoUserId = true)
private String whrid;
@FieldMeta(fieldName = "U_PLCPOINT_WHR", caption = "维护人", autoUserName = true)
private String whr;
@FieldMeta(fieldName = "U_PLCPOINT_WHSJ", caption = "维护时间", autoDateTime = true)
private Date whsj;
@FieldMeta(fieldName = "U_PLCPOINT_CJRID", caption = "创建人编码", autoUserId = true, initial = true)
private String cjrid;
@FieldMeta(fieldName = "U_PLCPOINT_CJR", caption = "创建人", autoUserName = true, initial = true)
private String cjr;
@FieldMeta(fieldName = "U_PLCPOINT_CJSJ", caption = "创建时间", autoDateTime = true, initial = true)
private Date cjsj;
@FieldMeta(fieldName = "U_PLCPOINT_SYSVERSION", caption = "系统版本")
private Integer sysversion;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getBz() {
return bz;
}
public void setBz(String bz) {
this.bz = bz;
}
public String getWhrid() {
return whrid;
}
public void setWhrid(String whrid) {
this.whrid = whrid;
}
public String getWhr() {
return whr;
}
public void setWhr(String whr) {
this.whr = whr;
}
public Date getWhsj() {
return whsj;
}
public void setWhsj(Date whsj) {
this.whsj = whsj;
}
public String getCjrid() {
return cjrid;
}
public void setCjrid(String cjrid) {
this.cjrid = cjrid;
}
public String getCjr() {
return cjr;
}
public void setCjr(String cjr) {
this.cjr = cjr;
}
public Date getCjsj() {
return cjsj;
}
public void setCjsj(Date cjsj) {
this.cjsj = cjsj;
}
public Integer getSysversion() {
return sysversion;
}
public void setSysversion(Integer sysversion) {
this.sysversion = sysversion;
}
}
package com.gavel.kwell.service;
import com.gavel.common.base.service.BaseEditService;
import com.gavel.jcsj.vo.WlxxCondition;
import com.gavel.kwell.vo.GyssnWlxxVO;
import com.gavel.persistence.sql.RecordSet;
public interface GyssnszService extends BaseEditService {
public RecordSet<GyssnWlxxVO> query(WlxxCondition condition);
public RecordSet<GyssnWlxxVO> queryNotSnruleid(WlxxCondition condition);
public void snsz(WlxxCondition condition);
}
package com.gavel.kwell.service;
import com.gavel.common.base.service.BaseEditService;
import com.gavel.kwell.vo.DataPointItem;
import com.gavel.kwell.vo.UpointCondition;
import com.gavel.kwell.vo.UpointVO;
import com.gavel.persistence.sql.RecordSet;
import java.util.List;
public interface UpointService extends BaseEditService {
public RecordSet<UpointVO> query(UpointCondition condition);
public List<DataPointItem> queryringpoint();
}
package com.gavel.kwell.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.gavel.common.Constants;
import com.gavel.common.base.service.impl.BaseEditServiceImpl;
import com.gavel.common.utils.StringUtils;
import com.gavel.common.utils.ThreadContext;
import com.gavel.jcsj.persistent.Wlfl;
import com.gavel.jcsj.persistent.Wlxx;
import com.gavel.jcsj.service.JcsjService;
import com.gavel.jcsj.vo.WlxxCondition;
import com.gavel.kwell.dao.GyssnszWlxxDao;
import com.gavel.kwell.service.GyssnszService;
import com.gavel.kwell.vo.GyssnWlxxVO;
import com.gavel.persistence.sql.RecordSet;
@Service("gyssnszService")
@Transactional
public class GyssnszServiceImpl extends BaseEditServiceImpl implements GyssnszService {
@Autowired
private GyssnszWlxxDao gyssnszWlxxDao;
@Autowired
private JcsjService jcsjService;
@Override
public void initService() {
addMaster(Wlxx.class);
}
@Override
public RecordSet<GyssnWlxxVO> query(WlxxCondition condition){
return gyssnszWlxxDao.query(condition);
}
@Override
public RecordSet<GyssnWlxxVO> queryNotSnruleid(WlxxCondition condition) {
if (StringUtils.equalsIgnoreCase(condition.getFlbm(), Constants.TREE_ROOT)) {
condition.setFlcjid("");
}else {
Wlfl wlfl = gyssnszWlxxDao.queryById(Wlfl.class, condition.getFlbm());
if (wlfl == null)
condition.setFlcjid("");
else
condition.setFlcjid(wlfl.getCjid());
}
return gyssnszWlxxDao.queryNotSnruleid(condition);
}
@Override
public void snsz(WlxxCondition condition) {
if(!jcsjService.validWlxxById(condition.getWlid(),false) ){
throw new RuntimeException(ThreadContext.getReturnData().getMessage());
}
if(StringUtils.isEmpty(condition.getSnruleid()) ){
throw new RuntimeException("序列号规则不能为空!");
}
Wlxx record = gyssnszWlxxDao.queryById(Wlxx.class,condition.getWlid());
if(record == null){
throw new RuntimeException("物料不存在!");
}
record.setSnruleid(condition.getSnruleid());
gyssnszWlxxDao.updateByUser(record);
ThreadContext.getReturnData().add(record);
}
}
package com.gavel.kwell.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.gavel.common.base.entity.BaseEntity;
import com.gavel.common.base.service.impl.BaseEditServiceImpl;
import com.gavel.common.utils.NumberUtils;
import com.gavel.common.utils.RedisConnection;
import com.gavel.common.utils.StringUtils;
import com.gavel.kwell.dao.UpointDao;
import com.gavel.kwell.persistent.Upoint;
import com.gavel.kwell.service.UpointService;
import com.gavel.kwell.utils.PointTypeEnum;
import com.gavel.kwell.vo.DataPointItem;
import com.gavel.kwell.vo.UpointCondition;
import com.gavel.kwell.vo.UpointVO;
import com.gavel.persistence.sql.RecordSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("upointService")
@Transactional
public class UpointServiceImpl extends BaseEditServiceImpl implements UpointService {
private Logger logger = LoggerFactory.getLogger(UpointServiceImpl.class);
@Autowired
private UpointDao upointDao;
@Autowired
private RedisConnection redisConnection;
@Override
public void initService() {
addMaster( Upoint.class);
}
@Override
public RecordSet<UpointVO> query(UpointCondition condition) {
return upointDao.query(condition);
}
@Override
public boolean postValid(BaseEntity entity) {
if(entity!=null && entity instanceof Upoint) {
Upoint uplcpoint = (Upoint) entity;
if(StringUtils.equals(uplcpoint.getType(), PointTypeEnum.WORK.getId())){
if(StringUtils.isEmpty(uplcpoint.getSign())){
throwReturnMessage("当选择类型为生产点位,合格标志不能为空!");
return false;
}
}
}
return true;
}
@Override
public void beforePost(BaseEntity entity) {
if(entity!=null && entity instanceof Upoint) {
Upoint uplcpoint = (Upoint) entity;
if(!StringUtils.equals(uplcpoint.getType(), PointTypeEnum.WORK.getId())){
uplcpoint.setSign("");
}
}
}
@Override
public List<DataPointItem> queryringpoint() {
try {
List<Upoint> ponitList = upointDao.queryList(PointTypeEnum.RIGN.getId());
if(ponitList==null || ponitList.size()==0){
logger.error("点位信息未配置,请检查!");
return Collections.EMPTY_LIST;
}
List<String> tagList=ponitList.stream().map(Upoint::getCode).collect(Collectors.toList());
Map<String, Object> valueMap = null;
valueMap = redisConnection.multiGet(tagList);
if (valueMap == null || valueMap.size()==0 ) {
logger.error("读取采集点信息失败!");
return ponitList.stream().map( p -> new DataPointItem(p.getCode(),p.getName())).collect(Collectors.toList());
}
List<DataPointItem> dataPointItems = new ArrayList<DataPointItem>();
for(Upoint uplcpoint : ponitList){
DataPointItem item = new DataPointItem(uplcpoint.getCode(),uplcpoint.getName());
if(valueMap.containsKey(uplcpoint.getCode())){
String jsonStr = (String)valueMap.get(uplcpoint.getCode());
try {
JSONObject json = JSONObject.parseObject(jsonStr);
item.setTimestamp(json.getLong("time"));
int quality = json.getInteger("quality");
Integer value = json.getInteger("value");
if(NumberUtils.isZero(quality)){
value=-1;
}
item.setValue(value);
} catch (Exception e) {
logger.error(e.getMessage() + ": " + jsonStr);
}
}
dataPointItems.add(item);
}
return dataPointItems;
} catch (Exception e) {
logger.error("数据点采集出错!", e);
}
return Collections.EMPTY_LIST;
}
}
package com.gavel.kwell.utils;
import com.gavel.common.utils.DateUtils;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* 切割时间段
*/
public class DateCalculateUtil {
public static List<Date> findDates(String dateType, Date dBegin, Date dEnd){
List<Date> listDate = new ArrayList<>();
Calendar calBegin = Calendar.getInstance();
calBegin.setTime(dBegin);
Calendar calEnd = Calendar.getInstance();
calEnd.setTime(dEnd);
listDate.add(dBegin);
while (calEnd.after(calBegin)) {
switch (dateType) {
case "M":
calBegin.add(Calendar.MONTH, 1);
break;
case "D":
calBegin.add(Calendar.DAY_OF_YEAR, 1);
break;
case "H":
calBegin.add(Calendar.HOUR, 1);
break;
case "N":
calBegin.add(Calendar.SECOND, 1);
break;
}
if (calEnd.after(calBegin))
listDate.add(calBegin.getTime());
else
listDate.add(calBegin.getTime());
}
return listDate;
}
public static void main(String[] args) {
Date start = DateUtils.parseDate("2021-05-29 08:30:00");
Date end = DateUtils.parseDate("2021-05-29 21:00:00");
List<Date> list = findDates("H", start, end);
for (Date date :list){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.format(date));
}
}
}
package com.gavel.kwell.utils;
import com.gavel.kzzx.model.GavelEnumModel;
import java.util.ArrayList;
import java.util.List;
public enum PointTypeEnum {
RIGN("RIGN", "手环点位"),
WEATHER("WEATHER","温湿度点位"),
WORK("WORK","生产点位");
private String id;
private String name;
PointTypeEnum(String id, String name) {
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static List<GavelEnumModel> toList() {
List<GavelEnumModel> list = new ArrayList<>();
for (PointTypeEnum e : PointTypeEnum.values()) {
GavelEnumModel gavelEnumModel = new GavelEnumModel();
gavelEnumModel.setId(e.getId());
gavelEnumModel.setName(e.getName());
list.add(gavelEnumModel);
}
return list;
}
}
package com.gavel.kwell.vo;
import com.alibaba.fastjson.JSONArray;
import com.gavel.common.utils.NumberUtils;
import com.google.common.base.MoreObjects;
import java.io.Serializable;
public class DataPointItem implements Serializable {
private static final long serialVersionUID = 123L;
private String itemId;
private long timestamp;
private Integer quality;
private String name;
private Object value;
public DataPointItem() {
}
public DataPointItem(String itemId, String name) {
this.itemId = itemId;
this.name = name;
this.timestamp =System.currentTimeMillis();
}
public DataPointItem(String itemId, long timestamp, Object value) {
this.itemId = itemId;
this.timestamp = timestamp;
this.value = value;
}
public DataPointItem(String itemId, long timestamp, Integer quality, Object value) {
this.itemId = itemId;
this.timestamp = timestamp;
this.quality = quality;
if(NumberUtils.isZero(quality)){
this.value= -1;
}else {
this.value = value;
}
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
public Integer getQuality() {
return quality;
}
public void setQuality(Integer quality) {
this.quality = quality;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("itemId", itemId)
.add("timestamp", timestamp)
.add("quality",quality)
.add("value", value)
.toString();
}
public static void main(String[] args) {
JSONArray.parseArray("[{\"itemId\":\"sin.demo\",\"timestamp\":1568970213576,\"value\":-0.24192189559966787},{\"itemId\":\"cos.demo\",\"timestamp\":1568970213576,\"value\":0.9702957262759965},{\"itemId\":\"tan.demo\",\"timestamp\":1568970213576,\"value\":-0.24932800284318082}]", DataPointItem.class);
}
}
package com.gavel.kwell.vo;
import com.gavel.common.base.entity.BaseEntity;
public class UpointCondition extends BaseEntity {
private static final long serialVersionUID = 1L;
private String id;
private String condition;
private String type;//类型
private String sign;//合格标志
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCondition() {
return condition;
}
public void setCondition(String condition) {
this.condition = condition;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
}
package com.gavel.kwell.vo;
import com.gavel.kwell.persistent.Upoint;
public class UpointVO extends Upoint {
private static final long serialVersionUID = 1L;
/*---------AutoBegin-----------*/
/*---------AutoEnd-------------*/
}
......@@ -7,25 +7,31 @@
<menu mkid="901000000" mkmc = "科威尔MES">
<menu mkid="901000200" mkmc="装配反馈" url="kmes/gphy/index">
<print entity="com.gavel.kwell.vo.GpfkVO"/>
<mkcz czid = "21" czmc = "取消装配" value="Y"/>
</menu>
<menu mkid="901000400" mkmc="检验反馈" url="kmes/gpjy/index">
<print entity="com.gavel.kwell.vo.GpfkVO"/>
<mkcz czid = "21" czmc = "取消检验" value="Y"/>
</menu>
<menu mkid="901000600" mkmc="维修反馈" url="kmes/gpwx/index" >
<print entity="com.gavel.kwell.vo.GpfkVO"/>
<mkcz czid = "21" czmc = "取消维修" value="Y"/>
</menu>
<menu mkid="901000800" mkmc="产品条码跟踪" url="kmes/wosngz/index" >
<print entity="com.gavel.hzgd.vo.HzWoVO"/>
</menu>
<menu mkid="901001000" mkmc="工票记录查询" url="kmes/gpfkcx/index">
<print entity="com.gavel.hzgd.vo.GpfkcxVO"/>
</menu>
<menu mkid="901001200" mkmc="车间看板" url="kmes/dashboard/index">
</menu>
<menu mkid="901001400" mkmc="点位配置" url="kmes/point/index">
<print entity="com.gavel.kwell.vo.UpointVO"/>
</menu>
</menu>
......
<div id="kmesUplcpointEdit" class="e-dialog-container" data-options="width:560,height:280">
<div class="e-dialog-body">
<input type="hidden" name="flag">
<input type="hidden" name="id" >
<div class="gui-row" >
<div class="gui-col-sm12">
<label class="gui-form-label">编码:</label>
<div class="gui-input-block">
<input type="text" name="code" data-toggle="gui-textbox" data-options="required:true" >
</div>
</div>
</div>
<div class="gui-row" >
<div class="gui-col-sm12">
<label class="gui-form-label">名称:</label>
<div class="gui-input-block">
<input type="text" name="name" data-toggle="gui-textbox" data-options="required:true" >
</div>
</div>
</div>
<div class="gui-row" >
<div class="gui-col-sm12">
<label class="gui-form-label">类型:</label>
<div class="gui-input-block">
<input type="text" name="type" data-toggle="gui-textbox" data-options="" readonly>
</div>
</div>
</div>
<!-- <div class="gui-row" >
<div class="gui-col-sm12">
<label class="gui-form-label">合格标志:</label>
<div class="gui-input-block">
<input type="text" name="sign" data-toggle="gui-textbox" data-options="" >
</div>
</div>
</div>-->
<div class="gui-row" >
<div class="gui-col-sm12">
<label class="gui-form-label">备注:</label>
<div class="gui-input-block">
<input type="text" name="bz" data-toggle="gui-textbox" data-options="" >
</div>
</div>
</div>
</div>
<div class="e-dialog-footer">
<a href="javascript:void(0);" class="e-dialog-ok"></a>
<a href="javascript:void(0);" class="e-dialog-cancel"></a>
</div>
</div>
<script>
$(function () {
var $div=$('#kmesUplcpointEdit');
var $cbxType = $div.find('input[name="type"]');
var $cbxHgbz = $div.find('input[name="sign"]');
gas.load(pageInit, dataInit);
function pageInit(ops){
$cbxType.iCombobox({valueField:'id',textField:'name',allowNull:false,allowEdit:true});
$cbxHgbz.iCombobox({valueField:'id',textField:'name',allowNull:true,allowEdit:true});
}
function dataInit(ops){
gas.post('kmes/point/init/type', {}, function(res){
if (res.success && res.data.records)
$cbxType.iCombobox('loadData', res.data.records);
}, ops);
gas.post('kmes/point/init/hgbz', {}, function(res){
if (res.success && res.data.records)
$cbxHgbz.iCombobox('loadData', res.data.records);
}, ops);
}
})
</script>
\ No newline at end of file
<div id="kmesUplcpoint" class="gui-div">
<table class="toolbar-table" data-options="id: 'kmesUplcpointTable',herf:'kzzx/gridset/query'"></table>
<!-- 表格工具栏开始 -->
<div id="kmesUplcpointTable-toolbar" class="gui-toolbar" data-options="grid:{type:'datagrid',id:'kmesUplcpointTable'}">
<div class="navbar-toolbar">
<!-- <a class="toolbar-print toolbar" href="javascript:void(0)"></a>
<a class="toolbar-export toolbar" href="javascript:void(0)"></a>-->
<a class="toolbar-review toolbar" href="javascript:void(0)"></a>
<a class="toolbar-add toolbar" href="javascript:void(0)"></a>
<a class="toolbar-copy toolbar" href="javascript:void(0)"></a>
<a class="toolbar-edit toolbar" href="javascript:void(0)"></a>
<a class="toolbar-delete toolbar" href="javascript:void(0)"></a>
</div>
<div class="form-sub">
<form class="query-criteria">
<ul>
<li class="gui-form-row" >
<div class="gui-col-sm3">
<label class="gui-form-label">名称:</label>
<div class="gui-input-block">
<input type="text" name="condition" class="gui-textbox" style="width: 100%">
</div>
</div>
</li>
</ul>
<span class="toolbar-search-span"><a class="toolbar-search" href="javascript:void(0)"></a></span>
</form>
</div>
</div>
</div>
<!-- 表格工具栏结束 -->
<script>
$(function () {
/*js初始化*/
var $div=$('#kmesUplcpoint');
var $datagrid=$div.find(".toolbar-table");
var $cbxType = $div.find('input[name="type"]');
var $typeMap = {},$signMap = {};
function paramInit(ops){
gas.post("kmes/point/init/type", {}, function(res){
if (res.success && res.data.records){
var records = res['data']['records'];
$.each(records,function(i, data){
$typeMap[data.id] = data.name;
});
}
}, ops);
/* gas.post("kmes/point/init/hgbz", {}, function(res){
if (res.success && res.data.records){
var records = res['data']['records'];
$.each(records,function(i, data){
$signMap[data.id] = data.name;
});
}
}, ops);*/
}
function pageInit() {
var options = {
url: 'kmes/point',
noRequest: true,
columns: [[
{title: "编码", field: "code", fieldType: "ftString",width:140},
{title: "名称", field: "name", fieldType: "ftString",width:220},
{title: "类型", field: "type", fieldType: "ftString",width:100,formatter: function (value, index, row) {
return $typeMap[value] || "";
}
},
/* {title: "合格标志", field: "sign", fieldType: "ftString",width:100,formatter: function (value, index, row) {
return $signMap[value] || "";
}
},*/
{title: "备注", field: "bz", fieldType: "ftString",width:180},
{title: "维护人", field: "whr", fieldType: "ftString"},
{title: "维护时间", field: "whsj", fieldType: "ftDateTime"}
]],
dialog: {
footerIn: true,
href: 'kmes/point/edit'
}
};
$div.Holder(options);
$cbxType.iCombobox({valueField: "id", textField: "name", allowNull:true, allowEdit:false});
}
/*数据初始化*/
function dataInit(ops){
gas.postHTTP("kmes/point/init/type",{},function (result){
if(result['success']&&result['data']['records']){
$cbxType.iCombobox("loadData",result.data.records)
}
},
ops);
}
/*用户操作*/
function run(ops){
$datagrid.datagrid("options").url="kmes/point/query";
$datagrid.datagrid("load",DataBind.collectData($div))
}
gas.load(paramInit,pageInit,dataInit,run);
})
</script>
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