|
@@ -195,7 +195,7 @@ public class MachineManageAction implements IMINAction {
|
|
|
@MINParam(key = "account") String account,
|
|
|
@MINParam(key = "temLine") String temLine,
|
|
|
@MINParam(key = "temRow") String temRow,
|
|
|
- MINSession session) throws MINBusinessException {
|
|
|
+ MINSession session) throws MINBusinessException, IOException {
|
|
|
|
|
|
MINActionResult res = new MINActionResult();
|
|
|
//获取当前时间
|
|
@@ -234,7 +234,49 @@ public class MachineManageAction implements IMINAction {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ //获取当前用户信息
|
|
|
+ User u = session.getUser();
|
|
|
+ //获取用户id
|
|
|
+ String userId = u.getBranchId();
|
|
|
+ //开发环境修改配置
|
|
|
+ String basePath = "/home/images/"+ userId+".jpg"; //与nginx配置相同
|
|
|
+ String os = System.getProperty("os.name");
|
|
|
+ if(os.toLowerCase().startsWith("win")){
|
|
|
+ System.out.println(os + " can't gunzip");
|
|
|
+ basePath = "D:/images/"+ userId+".jpg"; //与nginx配置相同
|
|
|
+ }
|
|
|
String id = Service.lookup(IPublicService.class).getSequence("EQU_MACHINE_NO");
|
|
|
+ File file = new File(basePath);
|
|
|
+ //获取父目录
|
|
|
+ File fileParent = file.getParentFile();
|
|
|
+ //判断是否存在
|
|
|
+ if (!fileParent.exists()) {
|
|
|
+ fileParent.mkdirs();
|
|
|
+ }
|
|
|
+ //获取渠道号
|
|
|
+ String channel = "V01";
|
|
|
+ // 加密客户号
|
|
|
+ OutputStream outputStream = new FileOutputStream(file);
|
|
|
+ String serviceUrl = Service.lookup(IPropertiesService.class)
|
|
|
+ .getSystemProperties().get(channel+"_TO_MACHINE_ERWERMA").getKey();
|
|
|
+ serviceUrl = "http://".concat(serviceUrl.concat("/admin/h5/index.html?equId=").concat(id));
|
|
|
+ //String urlString = URLEncoder.encode(, "GBK");
|
|
|
+
|
|
|
+ // 生成二维码图片到本地
|
|
|
+ try {
|
|
|
+ EquCodeCreateUtil.createQrCode(outputStream,serviceUrl,900,"JPEG");
|
|
|
+ } catch (com.google.zxing.WriterException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ outputStream.close();
|
|
|
+ // 上传图片到服务器
|
|
|
+ InputStream inputSteam = new FileInputStream(file);
|
|
|
+ String url = UpLoadFile.uploadImg(inputSteam,"jpg",channel,"00");
|
|
|
+
|
|
|
+ inputSteam.close();
|
|
|
+ // 删除本地图片
|
|
|
+ file.delete();
|
|
|
VmEquipmentInf pro = new VmEquipmentInf();
|
|
|
pro.setId(id);
|
|
|
pro.setMachineNo(equCode);
|
|
@@ -245,12 +287,31 @@ public class MachineManageAction implements IMINAction {
|
|
|
pro.setCreateTime(nowTime);
|
|
|
pro.setRows(temRow);
|
|
|
pro.setLines(temLine);
|
|
|
+ pro.setUrlCode(url);
|
|
|
pro.setBranchid(user.getBranchid());
|
|
|
Service.lookup(IMINDataBaseService.class)
|
|
|
.getMybatisMapper(VmEquipmentInfMapper.class)
|
|
|
.insertSelective(pro);
|
|
|
for (int i = 1; i < size; i++) {
|
|
|
String ids = Service.lookup(IPublicService.class).getSequence("EQU_MACHINE_NO");
|
|
|
+ serviceUrl = "http://".concat(serviceUrl.concat("/admin/h5/index.html?equId=").concat(ids));
|
|
|
+ //String urlString = URLEncoder.encode(, "GBK");
|
|
|
+ OutputStream outputStreams = new FileOutputStream(file);
|
|
|
+ // 生成二维码图片到本地
|
|
|
+ try {
|
|
|
+ EquCodeCreateUtil.createQrCode(outputStreams,serviceUrl,900,"JPEG");
|
|
|
+ } catch (com.google.zxing.WriterException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ outputStreams.close();
|
|
|
+ // 上传图片到服务器
|
|
|
+ InputStream inputSteams = new FileInputStream(file);
|
|
|
+ url = UpLoadFile.uploadImg(inputSteams,"jpg",channel,"00");
|
|
|
+
|
|
|
+ inputSteams.close();
|
|
|
+ // 删除本地图片
|
|
|
+ file.delete();
|
|
|
VmEquipmentInf pros = new VmEquipmentInf();
|
|
|
pros.setId(ids);
|
|
|
pros.setChannel("V01");
|
|
@@ -261,6 +322,7 @@ public class MachineManageAction implements IMINAction {
|
|
|
pros.setCreateTime(nowTime);
|
|
|
pros.setRows(temRow);
|
|
|
pros.setLines(temLine);
|
|
|
+ pros.setUrlCode(url);
|
|
|
pros.setBranchid(user.getBranchid());
|
|
|
Service.lookup(IMINDataBaseService.class)
|
|
|
.getMybatisMapper(VmEquipmentInfMapper.class)
|
|
@@ -1279,6 +1341,13 @@ public class MachineManageAction implements IMINAction {
|
|
|
// 删除本地图片
|
|
|
file.delete();
|
|
|
res.set("url", url);
|
|
|
+ VmEquipmentInf vmEquipmentInf = Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmEquipmentInfMapper.class).selectByPrimaryKey(equId);
|
|
|
+ if (null != vmEquipmentInf){
|
|
|
+ vmEquipmentInf.setUrlCode(url);
|
|
|
+ Service.lookup(IMINDataBaseService.class)
|
|
|
+ .getMybatisMapper(VmEquipmentInfMapper.class)
|
|
|
+ .updateByPrimaryKeySelective(vmEquipmentInf);
|
|
|
+ }
|
|
|
return res;
|
|
|
}
|
|
|
/**
|